Commit 21818627 authored by Jérôme Lebel's avatar Jérôme Lebel Committed by Commit Bot

[iOS] Need to close Manage sync settings when the user is signed-out

Manage sync settings coordinator should listen to onPrimaryAccountCleared:
notification. When the user is signed out, the Manage sync settings should
be pop out, to come back to Google services settings.

Bug: 914059
Change-Id: If08580a0dfe2cb2d94bad4e0276a5b3e3ef7c31c
Reviewed-on: https://chromium-review.googlesource.com/c/1482952
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635503}
parent ad0f8d00
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "components/google/core/common/google_util.h" #include "components/google/core/common/google_util.h"
#include "ios/chrome/browser/application_context.h" #include "ios/chrome/browser/application_context.h"
#include "ios/chrome/browser/chrome_url_constants.h" #include "ios/chrome/browser/chrome_url_constants.h"
#include "ios/chrome/browser/signin/identity_manager_factory.h"
#include "ios/chrome/browser/sync/profile_sync_service_factory.h" #include "ios/chrome/browser/sync/profile_sync_service_factory.h"
#include "ios/chrome/browser/sync/sync_setup_service_factory.h" #include "ios/chrome/browser/sync/sync_setup_service_factory.h"
#import "ios/chrome/browser/ui/commands/application_commands.h" #import "ios/chrome/browser/ui/commands/application_commands.h"
...@@ -18,14 +19,20 @@ ...@@ -18,14 +19,20 @@
#import "ios/chrome/browser/ui/settings/google_services/manage_sync_settings_table_view_controller.h" #import "ios/chrome/browser/ui/settings/google_services/manage_sync_settings_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/sync/sync_encryption_passphrase_table_view_controller.h" #import "ios/chrome/browser/ui/settings/sync/sync_encryption_passphrase_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/sync/sync_encryption_table_view_controller.h" #import "ios/chrome/browser/ui/settings/sync/sync_encryption_table_view_controller.h"
#import "services/identity/public/objc/identity_manager_observer_bridge.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
@interface ManageSyncSettingsCoordinator () < @interface ManageSyncSettingsCoordinator () <
IdentityManagerObserverBridgeDelegate,
ManageSyncSettingsCommandHandler, ManageSyncSettingsCommandHandler,
ManageSyncSettingsTableViewControllerPresentationDelegate> ManageSyncSettingsTableViewControllerPresentationDelegate> {
// Identity manager observer.
std::unique_ptr<identity::IdentityManagerObserverBridge>
_identityManagerObserverBridge;
}
// View controller. // View controller.
@property(nonatomic, strong) @property(nonatomic, strong)
...@@ -55,6 +62,10 @@ ...@@ -55,6 +62,10 @@
DCHECK(self.navigationController); DCHECK(self.navigationController);
[self.navigationController pushViewController:self.viewController [self.navigationController pushViewController:self.viewController
animated:YES]; animated:YES];
identity::IdentityManager* identityManager =
IdentityManagerFactory::GetForBrowserState(self.browserState);
_identityManagerObserverBridge.reset(
new identity::IdentityManagerObserverBridge(identityManager, self));
} }
#pragma mark - ManageSyncSettingsTableViewControllerPresentationDelegate #pragma mark - ManageSyncSettingsTableViewControllerPresentationDelegate
...@@ -65,6 +76,17 @@ ...@@ -65,6 +76,17 @@
[self.delegate manageSyncSettingsCoordinatorWasPopped:self]; [self.delegate manageSyncSettingsCoordinatorWasPopped:self];
} }
#pragma mark - IdentityManagerObserverBridgeDelegate
- (void)onPrimaryAccountCleared:
(const CoreAccountInfo&)previousPrimaryAccountInfo {
if (self.viewController.navigationController) {
[self.navigationController popToViewController:self.viewController
animated:NO];
[self.navigationController popViewControllerAnimated:YES];
}
}
#pragma mark - ManageSyncSettingsCommandHandler #pragma mark - ManageSyncSettingsCommandHandler
- (void)openPassphraseDialog { - (void)openPassphraseDialog {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment