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

[iOS] Adding Manage sync settings item in Google services settings

Screenshot: https://screenshot.googleplex.com/7Bp9z54Le5s

Bug: 914059
Change-Id: I12ed57a7b2e456f542c14647b959396617ea61c4
Reviewed-on: https://chromium-review.googlesource.com/c/1416144
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#625790}
parent 200a953f
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
// Opens the account setting view. // Opens the account setting view.
- (void)openAccountSettings; - (void)openAccountSettings;
// Opens the manage sync settings view.
- (void)openManageSyncSettings;
@end @end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_GOOGLE_SERVICES_SETTINGS_COMMAND_HANDLER_H_ #endif // IOS_CHROME_BROWSER_UI_SETTINGS_GOOGLE_SERVICES_SETTINGS_COMMAND_HANDLER_H_
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#import "ios/chrome/browser/ui/settings/google_services_settings_command_handler.h" #import "ios/chrome/browser/ui/settings/google_services_settings_command_handler.h"
#import "ios/chrome/browser/ui/settings/google_services_settings_mediator.h" #import "ios/chrome/browser/ui/settings/google_services_settings_mediator.h"
#import "ios/chrome/browser/ui/settings/google_services_settings_view_controller.h" #import "ios/chrome/browser/ui/settings/google_services_settings_view_controller.h"
#import "ios/chrome/browser/ui/settings/manage_sync_settings_coordinator.h"
#import "ios/chrome/browser/ui/signin_interaction/signin_interaction_coordinator.h" #import "ios/chrome/browser/ui/signin_interaction/signin_interaction_coordinator.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -26,7 +27,8 @@ ...@@ -26,7 +27,8 @@
@interface GoogleServicesSettingsCoordinator () < @interface GoogleServicesSettingsCoordinator () <
GoogleServicesSettingsCommandHandler, GoogleServicesSettingsCommandHandler,
GoogleServicesSettingsViewControllerPresentationDelegate> GoogleServicesSettingsViewControllerPresentationDelegate,
ManageSyncSettingsCoordinatorDelegate>
// Google services settings mediator. // Google services settings mediator.
@property(nonatomic, strong) GoogleServicesSettingsMediator* mediator; @property(nonatomic, strong) GoogleServicesSettingsMediator* mediator;
...@@ -41,6 +43,9 @@ ...@@ -41,6 +43,9 @@
// Settings page. // Settings page.
@property(nonatomic, strong) @property(nonatomic, strong)
SigninInteractionCoordinator* signinInteractionCoordinator; SigninInteractionCoordinator* signinInteractionCoordinator;
// Coordinator to present the manage sync settings.
@property(nonatomic, strong)
ManageSyncSettingsCoordinator* manageSyncSettingsCoordinator;
@end @end
...@@ -162,6 +167,17 @@ ...@@ -162,6 +167,17 @@
[self.navigationController pushViewController:controller animated:YES]; [self.navigationController pushViewController:controller animated:YES];
} }
- (void)openManageSyncSettings {
DCHECK(!self.manageSyncSettingsCoordinator);
self.manageSyncSettingsCoordinator = [[ManageSyncSettingsCoordinator alloc]
initWithBaseViewController:self.viewController
browserState:self.browserState];
self.manageSyncSettingsCoordinator.navigationController =
self.navigationController;
self.manageSyncSettingsCoordinator.delegate = self;
[self.manageSyncSettingsCoordinator start];
}
#pragma mark - GoogleServicesSettingsViewControllerPresentationDelegate #pragma mark - GoogleServicesSettingsViewControllerPresentationDelegate
- (void)googleServicesSettingsViewControllerDidRemove: - (void)googleServicesSettingsViewControllerDidRemove:
...@@ -170,4 +186,12 @@ ...@@ -170,4 +186,12 @@
[self.delegate googleServicesSettingsCoordinatorDidRemove:self]; [self.delegate googleServicesSettingsCoordinatorDidRemove:self];
} }
#pragma mark - ManageSyncSettingsCoordinatorDelegate
- (void)manageSyncSettingsCoordinatorWasPopped:
(ManageSyncSettingsCoordinator*)coordinator {
DCHECK_EQ(self.manageSyncSettingsCoordinator, coordinator);
self.manageSyncSettingsCoordinator = nil;
}
@end @end
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#import "ios/chrome/browser/ui/authentication/resized_avatar_cache.h" #import "ios/chrome/browser/ui/authentication/resized_avatar_cache.h"
#import "ios/chrome/browser/ui/settings/cells/account_sign_in_item.h" #import "ios/chrome/browser/ui/settings/cells/account_sign_in_item.h"
#import "ios/chrome/browser/ui/settings/cells/settings_image_detail_text_item.h" #import "ios/chrome/browser/ui/settings/cells/settings_image_detail_text_item.h"
#import "ios/chrome/browser/ui/settings/cells/settings_multiline_detail_item.h"
#import "ios/chrome/browser/ui/settings/cells/sync_switch_item.h" #import "ios/chrome/browser/ui/settings/cells/sync_switch_item.h"
#import "ios/chrome/browser/ui/settings/google_services_settings_command_handler.h" #import "ios/chrome/browser/ui/settings/google_services_settings_command_handler.h"
#import "ios/chrome/browser/ui/settings/sync_utils/sync_util.h" #import "ios/chrome/browser/ui/settings/sync_utils/sync_util.h"
...@@ -56,6 +57,7 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -56,6 +57,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
RestartAuthenticationFlowErrorItemType, RestartAuthenticationFlowErrorItemType,
ReauthDialogAsSyncIsInAuthErrorItemType, ReauthDialogAsSyncIsInAuthErrorItemType,
ShowPassphraseDialogErrorItemType, ShowPassphraseDialogErrorItemType,
ManageSyncItemType,
// NonPersonalizedSectionIdentifier section. // NonPersonalizedSectionIdentifier section.
AutocompleteSearchesAndURLsItemType, AutocompleteSearchesAndURLsItemType,
PreloadPagesItemType, PreloadPagesItemType,
...@@ -240,8 +242,10 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -240,8 +242,10 @@ typedef NS_ENUM(NSInteger, ItemType) {
- (void)updateSyncSection:(BOOL)notifyConsumer { - (void)updateSyncSection:(BOOL)notifyConsumer {
BOOL needsAccountSigninItemUpdate = [self updateAccountSignInItem]; BOOL needsAccountSigninItemUpdate = [self updateAccountSignInItem];
BOOL needsSyncErrorItemsUpdate = [self updateSyncErrorItems]; BOOL needsSyncErrorItemsUpdate = [self updateSyncErrorItems];
BOOL needsManageSyncItemUpdate = [self updateManageSyncItem];
if (notifyConsumer && if (notifyConsumer &&
(needsAccountSigninItemUpdate || needsSyncErrorItemsUpdate)) { (needsAccountSigninItemUpdate || needsSyncErrorItemsUpdate ||
needsManageSyncItemUpdate)) {
TableViewModel* model = self.consumer.tableViewModel; TableViewModel* model = self.consumer.tableViewModel;
NSUInteger sectionIndex = NSUInteger sectionIndex =
[model sectionForSectionIdentifier:SyncSectionIdentifier]; [model sectionForSectionIdentifier:SyncSectionIdentifier];
...@@ -336,6 +340,29 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -336,6 +340,29 @@ typedef NS_ENUM(NSInteger, ItemType) {
return YES; return YES;
} }
// Reloads the manage sync item, and returns YES if the section should be
// reloaded.
- (BOOL)updateManageSyncItem {
TableViewModel* model = self.consumer.tableViewModel;
BOOL hasManageSyncItem = [model hasItemForItemType:ManageSyncItemType
sectionIdentifier:SyncSectionIdentifier];
if (self.isAuthenticated) {
if (hasManageSyncItem)
return NO;
SettingsMultilineDetailItem* item =
[[SettingsMultilineDetailItem alloc] initWithType:ManageSyncItemType];
item.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
item.text = GetNSString(IDS_IOS_MANAGE_SYNC_SETTINGS_TITLE);
[model addItem:item toSectionWithIdentifier:SyncSectionIdentifier];
return YES;
}
if (!hasManageSyncItem)
return NO;
[model removeItemWithType:ManageSyncItemType
fromSectionWithIdentifier:SyncSectionIdentifier];
return YES;
}
#pragma mark - Load non personalized section #pragma mark - Load non personalized section
// Loads NonPersonalizedSectionIdentifier section. // Loads NonPersonalizedSectionIdentifier section.
...@@ -373,6 +400,7 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -373,6 +400,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
case RestartAuthenticationFlowErrorItemType: case RestartAuthenticationFlowErrorItemType:
case ReauthDialogAsSyncIsInAuthErrorItemType: case ReauthDialogAsSyncIsInAuthErrorItemType:
case ShowPassphraseDialogErrorItemType: case ShowPassphraseDialogErrorItemType:
case ManageSyncItemType:
NOTREACHED(); NOTREACHED();
break; break;
} }
...@@ -503,6 +531,7 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -503,6 +531,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
case RestartAuthenticationFlowErrorItemType: case RestartAuthenticationFlowErrorItemType:
case ReauthDialogAsSyncIsInAuthErrorItemType: case ReauthDialogAsSyncIsInAuthErrorItemType:
case ShowPassphraseDialogErrorItemType: case ShowPassphraseDialogErrorItemType:
case ManageSyncItemType:
NOTREACHED(); NOTREACHED();
break; break;
} }
...@@ -526,6 +555,9 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -526,6 +555,9 @@ typedef NS_ENUM(NSInteger, ItemType) {
case ShowPassphraseDialogErrorItemType: case ShowPassphraseDialogErrorItemType:
[self.commandHandler openPassphraseDialog]; [self.commandHandler openPassphraseDialog];
break; break;
case ManageSyncItemType:
[self.commandHandler openManageSyncSettings];
break;
case AutocompleteSearchesAndURLsItemType: case AutocompleteSearchesAndURLsItemType:
case PreloadPagesItemType: case PreloadPagesItemType:
case ImproveChromeItemType: case ImproveChromeItemType:
......
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