Commit 9da24aee authored by Nohemi Fernandez's avatar Nohemi Fernandez Committed by Commit Bot

[iOS][MICE] Split Google Services and Sync options into separate sheets.

UI change that moves all Google Services and Sync options into their
respective categories. Ensures that all Sync status updates are
respected.

Bug: 1125631
Change-Id: I30cc039ca924a856b555b6215c9a25f6bcf07188
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2445513
Commit-Queue: Nohemi Fernandez <fernandex@chromium.org>
Reviewed-by: default avatarJérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814726}
parent abb178f2
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h" #include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/safe_browsing/core/features.h" #include "components/safe_browsing/core/features.h"
#include "components/signin/public/base/account_consistency_method.h"
#import "components/signin/public/identity_manager/objc/identity_manager_observer_bridge.h" #import "components/signin/public/identity_manager/objc/identity_manager_observer_bridge.h"
#include "components/sync/driver/sync_service.h" #include "components/sync/driver/sync_service.h"
#include "components/ukm/ios/features.h" #include "components/ukm/ios/features.h"
...@@ -122,7 +123,7 @@ NSString* kGoogleServicesSyncErrorImage = @"google_services_sync_error"; ...@@ -122,7 +123,7 @@ NSString* kGoogleServicesSyncErrorImage = @"google_services_sync_error";
@property(nonatomic, assign, readonly) BOOL isSyncDisabledByAdministrator; @property(nonatomic, assign, readonly) BOOL isSyncDisabledByAdministrator;
// Returns YES if the user is allowed to turn on sync (even if there is a sync // Returns YES if the user is allowed to turn on sync (even if there is a sync
// error). // error).
@property(nonatomic, assign, readonly) BOOL isSyncCanBeAvailable; @property(nonatomic, assign, readonly) BOOL shouldDisplaySync;
// Sync setup service. // Sync setup service.
@property(nonatomic, assign, readonly) SyncSetupService* syncSetupService; @property(nonatomic, assign, readonly) SyncSetupService* syncSetupService;
// ** Identity section. // ** Identity section.
...@@ -444,7 +445,7 @@ NSString* kGoogleServicesSyncErrorImage = @"google_services_sync_error"; ...@@ -444,7 +445,7 @@ NSString* kGoogleServicesSyncErrorImage = @"google_services_sync_error";
// reloaded. // reloaded.
- (BOOL)updateManageSyncItem { - (BOOL)updateManageSyncItem {
TableViewModel* model = self.consumer.tableViewModel; TableViewModel* model = self.consumer.tableViewModel;
if (self.isSyncCanBeAvailable) { if (self.shouldDisplaySync) {
BOOL needsUpdate = NO; BOOL needsUpdate = NO;
if (!self.manageSyncItem) { if (!self.manageSyncItem) {
self.manageSyncItem = self.manageSyncItem =
...@@ -478,7 +479,7 @@ NSString* kGoogleServicesSyncErrorImage = @"google_services_sync_error"; ...@@ -478,7 +479,7 @@ NSString* kGoogleServicesSyncErrorImage = @"google_services_sync_error";
// updated. // updated.
- (BOOL)updateSyncChromeDataItem { - (BOOL)updateSyncChromeDataItem {
TableViewModel* model = self.consumer.tableViewModel; TableViewModel* model = self.consumer.tableViewModel;
if (self.isSyncCanBeAvailable) { if (self.shouldDisplaySync) {
BOOL needsUpdate = NO; BOOL needsUpdate = NO;
if (!self.syncChromeDataSwitchItem) { if (!self.syncChromeDataSwitchItem) {
self.syncChromeDataSwitchItem = self.syncChromeDataSwitchItem =
...@@ -594,8 +595,13 @@ NSString* kGoogleServicesSyncErrorImage = @"google_services_sync_error"; ...@@ -594,8 +595,13 @@ NSString* kGoogleServicesSyncErrorImage = @"google_services_sync_error";
self.mode == GoogleServicesSettingsModeAdvancedSigninSettings); self.mode == GoogleServicesSettingsModeAdvancedSigninSettings);
} }
- (BOOL)isSyncCanBeAvailable { - (BOOL)shouldDisplaySync {
return self.isAuthenticated && !self.isSyncDisabledByAdministrator; BOOL experimentEnabled =
base::FeatureList::IsEnabled(signin::kMobileIdentityConsistency);
BOOL firstSetupWithExperiment =
!self.syncSetupService->IsFirstSetupComplete() && experimentEnabled;
return (firstSetupWithExperiment || !experimentEnabled) &&
self.isAuthenticated && !self.isSyncDisabledByAdministrator;
} }
- (ItemArray)nonPersonalizedItems { - (ItemArray)nonPersonalizedItems {
......
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
#import "ios/chrome/browser/ui/settings/elements/enterprise_info_popover_view_controller.h" #import "ios/chrome/browser/ui/settings/elements/enterprise_info_popover_view_controller.h"
#import "ios/chrome/browser/ui/settings/google_services/accounts_table_view_controller.h" #import "ios/chrome/browser/ui/settings/google_services/accounts_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/google_services/google_services_settings_coordinator.h" #import "ios/chrome/browser/ui/settings/google_services/google_services_settings_coordinator.h"
#import "ios/chrome/browser/ui/settings/google_services/manage_sync_settings_coordinator.h"
#import "ios/chrome/browser/ui/settings/language/language_settings_mediator.h" #import "ios/chrome/browser/ui/settings/language/language_settings_mediator.h"
#import "ios/chrome/browser/ui/settings/language/language_settings_table_view_controller.h" #import "ios/chrome/browser/ui/settings/language/language_settings_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/password/passwords_coordinator.h" #import "ios/chrome/browser/ui/settings/password/passwords_coordinator.h"
...@@ -150,6 +151,8 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -150,6 +151,8 @@ typedef NS_ENUM(NSInteger, ItemType) {
ItemTypeSigninPromo, ItemTypeSigninPromo,
ItemTypeAccount, ItemTypeAccount,
ItemTypeSyncAndGoogleServices, ItemTypeSyncAndGoogleServices,
ItemTypeGoogleSync,
ItemTypeGoogleServices,
ItemTypeHeader, ItemTypeHeader,
ItemTypeSearchEngine, ItemTypeSearchEngine,
ItemTypeManagedDefaultSearchEngine, ItemTypeManagedDefaultSearchEngine,
...@@ -183,6 +186,7 @@ NSString* kDevViewSourceKey = @"DevViewSource"; ...@@ -183,6 +186,7 @@ NSString* kDevViewSourceKey = @"DevViewSource";
ChromeIdentityServiceObserver, ChromeIdentityServiceObserver,
GoogleServicesSettingsCoordinatorDelegate, GoogleServicesSettingsCoordinatorDelegate,
IdentityManagerObserverBridgeDelegate, IdentityManagerObserverBridgeDelegate,
ManageSyncSettingsCoordinatorDelegate,
PasswordCheckObserver, PasswordCheckObserver,
PasswordsCoordinatorDelegate, PasswordsCoordinatorDelegate,
PopoverLabelViewControllerDelegate, PopoverLabelViewControllerDelegate,
...@@ -225,6 +229,7 @@ NSString* kDevViewSourceKey = @"DevViewSource"; ...@@ -225,6 +229,7 @@ NSString* kDevViewSourceKey = @"DevViewSource";
// identity update notifications. // identity update notifications.
SigninPromoViewMediator* _signinPromoViewMediator; SigninPromoViewMediator* _signinPromoViewMediator;
GoogleServicesSettingsCoordinator* _googleServicesSettingsCoordinator; GoogleServicesSettingsCoordinator* _googleServicesSettingsCoordinator;
ManageSyncSettingsCoordinator* _manageSyncSettingsCoordinator;
// Privacy coordinator. // Privacy coordinator.
PrivacyCoordinator* _privacyCoordinator; PrivacyCoordinator* _privacyCoordinator;
...@@ -437,8 +442,10 @@ NSString* kDevViewSourceKey = @"DevViewSource"; ...@@ -437,8 +442,10 @@ NSString* kDevViewSourceKey = @"DevViewSource";
// Adds experimental Google Services item separate from Sync. // Adds experimental Google Services item separate from Sync.
if (base::FeatureList::IsEnabled(signin::kMobileIdentityConsistency)) { if (base::FeatureList::IsEnabled(signin::kMobileIdentityConsistency)) {
[model addItem:[self syncCellItem] if (authService->IsAuthenticated()) {
toSectionWithIdentifier:SectionIdentifierAccount]; [model addItem:[self googleSyncCellItem]
toSectionWithIdentifier:SectionIdentifierAccount];
}
[model addItem:[self googleServicesCellItem] [model addItem:[self googleServicesCellItem]
toSectionWithIdentifier:SectionIdentifierAccount]; toSectionWithIdentifier:SectionIdentifierAccount];
} else { } else {
...@@ -559,7 +566,7 @@ NSString* kDevViewSourceKey = @"DevViewSource"; ...@@ -559,7 +566,7 @@ NSString* kDevViewSourceKey = @"DevViewSource";
- (TableViewItem*)googleServicesCellItem { - (TableViewItem*)googleServicesCellItem {
TableViewImageItem* googleServicesItem = TableViewImageItem* googleServicesItem =
[[TableViewImageItem alloc] initWithType:ItemTypeSyncAndGoogleServices]; [[TableViewImageItem alloc] initWithType:ItemTypeGoogleServices];
googleServicesItem.accessoryType = googleServicesItem.accessoryType =
UITableViewCellAccessoryDisclosureIndicator; UITableViewCellAccessoryDisclosureIndicator;
googleServicesItem.title = googleServicesItem.title =
...@@ -570,19 +577,18 @@ NSString* kDevViewSourceKey = @"DevViewSource"; ...@@ -570,19 +577,18 @@ NSString* kDevViewSourceKey = @"DevViewSource";
return googleServicesItem; return googleServicesItem;
} }
- (TableViewItem*)syncCellItem { - (TableViewItem*)googleSyncCellItem {
// TODO(crbug.com/805214): This branded icon image needs to come from // TODO(crbug.com/805214): This branded icon image needs to come from
// BrandedImageProvider. // BrandedImageProvider.
TableViewImageItem* googleServicesItem = TableViewDetailIconItem* googleSyncCellItem =
[[TableViewImageItem alloc] initWithType:ItemTypeSyncAndGoogleServices]; [self detailItemWithType:ItemTypeGoogleSync
googleServicesItem.accessoryType = text:l10n_util::GetNSString(
UITableViewCellAccessoryDisclosureIndicator; IDS_IOS_GOOGLE_SYNC_SETTINGS_TITLE)
googleServicesItem.title = detailText:l10n_util::GetNSString(IDS_IOS_SETTING_ON)
l10n_util::GetNSString(IDS_IOS_GOOGLE_SYNC_SETTINGS_TITLE); iconImageName:kSyncAndGoogleServicesSyncOnImageName
googleServicesItem.accessibilityIdentifier = accessibilityIdentifier:kSettingsGoogleSyncAndServicesCellId];
kSettingsGoogleSyncAndServicesCellId; [self updateGoogleSyncCellItem:googleSyncCellItem];
[self updateSyncAndGoogleServicesItem:googleServicesItem]; return googleSyncCellItem;
return googleServicesItem;
} }
- (TableViewItem*)syncAndGoogleServicesCellItem { - (TableViewItem*)syncAndGoogleServicesCellItem {
...@@ -996,8 +1002,13 @@ NSString* kDevViewSourceKey = @"DevViewSource"; ...@@ -996,8 +1002,13 @@ NSString* kDevViewSourceKey = @"DevViewSource";
closeSettingsOnAddAccount:NO]; closeSettingsOnAddAccount:NO];
break; break;
case ItemTypeSyncAndGoogleServices: case ItemTypeSyncAndGoogleServices:
case ItemTypeGoogleServices:
base::RecordAction(base::UserMetricsAction("Settings.GoogleServices")); base::RecordAction(base::UserMetricsAction("Settings.GoogleServices"));
[self showSyncGoogleService]; [self showGoogleServices];
break;
case ItemTypeGoogleSync:
base::RecordAction(base::UserMetricsAction("Settings.Sync"));
[self showGoogleSync];
break; break;
case ItemTypeDefaultBrowser: case ItemTypeDefaultBrowser:
base::RecordAction( base::RecordAction(
...@@ -1156,7 +1167,7 @@ NSString* kDevViewSourceKey = @"DevViewSource"; ...@@ -1156,7 +1167,7 @@ NSString* kDevViewSourceKey = @"DevViewSource";
#pragma mark - Private methods #pragma mark - Private methods
- (void)showSyncGoogleService { - (void)showGoogleServices {
DCHECK(!_googleServicesSettingsCoordinator); DCHECK(!_googleServicesSettingsCoordinator);
_googleServicesSettingsCoordinator = _googleServicesSettingsCoordinator =
[[GoogleServicesSettingsCoordinator alloc] [[GoogleServicesSettingsCoordinator alloc]
...@@ -1168,6 +1179,15 @@ NSString* kDevViewSourceKey = @"DevViewSource"; ...@@ -1168,6 +1179,15 @@ NSString* kDevViewSourceKey = @"DevViewSource";
[_googleServicesSettingsCoordinator start]; [_googleServicesSettingsCoordinator start];
} }
- (void)showGoogleSync {
DCHECK(!_manageSyncSettingsCoordinator);
_manageSyncSettingsCoordinator = [[ManageSyncSettingsCoordinator alloc]
initWithBaseNavigationController:self.navigationController
browser:_browser];
_manageSyncSettingsCoordinator.delegate = self;
[_manageSyncSettingsCoordinator start];
}
- (void)showPasswords { - (void)showPasswords {
DCHECK(!_passwordsCoordinator); DCHECK(!_passwordsCoordinator);
_passwordsCoordinator = [[PasswordsCoordinator alloc] _passwordsCoordinator = [[PasswordsCoordinator alloc]
...@@ -1318,17 +1338,71 @@ NSString* kDevViewSourceKey = @"DevViewSource"; ...@@ -1318,17 +1338,71 @@ NSString* kDevViewSourceKey = @"DevViewSource";
DCHECK(googleServicesItem.image); DCHECK(googleServicesItem.image);
} }
// Updates the Sync item to display the right icon and status message in the
// cell.
- (void)updateGoogleSyncCellItem:(TableViewDetailIconItem*)googleSyncItem {
syncer::SyncService* syncService =
ProfileSyncServiceFactory::GetForBrowserState(_browserState);
SyncSetupService* syncSetupService =
SyncSetupServiceFactory::GetForBrowserState(_browserState);
if (syncService->GetDisableReasons().Has(
syncer::SyncService::DISABLE_REASON_ENTERPRISE_POLICY)) {
googleSyncItem.detailText = l10n_util::GetNSString(
IDS_IOS_GOOGLE_SERVICES_SETTINGS_SYNC_DISABLBED_BY_ADMINISTRATOR_STATUS);
googleSyncItem.iconImageName = kSyncAndGoogleServicesSyncOffImageName;
} else if (!IsTransientSyncError(syncSetupService->GetSyncServiceState())) {
googleSyncItem.detailText =
GetSyncErrorDescriptionForSyncSetupService(syncSetupService);
googleSyncItem.iconImageName = kSyncAndGoogleServicesSyncErrorImageName;
} else if (syncSetupService->IsFirstSetupComplete() &&
syncSetupService->IsSyncEnabled()) {
googleSyncItem.detailText = l10n_util::GetNSString(IDS_IOS_SETTING_ON);
googleSyncItem.iconImageName = kSyncAndGoogleServicesSyncOnImageName;
} else {
googleSyncItem.detailText = l10n_util::GetNSString(IDS_IOS_SETTING_OFF);
googleSyncItem.iconImageName = kSyncAndGoogleServicesSyncOffImageName;
}
}
// Updates and reloads the Google service cell. // Updates and reloads the Google service cell.
- (void)reloadSyncAndGoogleServicesCell { - (void)reloadSyncAndGoogleServicesCell {
NSIndexPath* googleServicesCellIndexPath = if (base::FeatureList::IsEnabled(signin::kMobileIdentityConsistency)) {
[self.tableViewModel indexPathForItemType:ItemTypeSyncAndGoogleServices bool googleSyncCellInitialized =
[self.tableViewModel hasItemForItemType:ItemTypeGoogleSync
sectionIdentifier:SectionIdentifierAccount]; sectionIdentifier:SectionIdentifierAccount];
TableViewImageItem* googleServicesItem = AuthenticationService* authService =
base::mac::ObjCCast<TableViewImageItem>( AuthenticationServiceFactory::GetForBrowserState(_browserState);
[self.tableViewModel itemAtIndexPath:googleServicesCellIndexPath]); if (authService->IsAuthenticated()) {
DCHECK(googleServicesItem); if (!googleSyncCellInitialized) {
[self updateSyncAndGoogleServicesItem:googleServicesItem]; [self.tableViewModel addItem:[self googleSyncCellItem]
[self reconfigureCellsForItems:@[ googleServicesItem ]]; toSectionWithIdentifier:SectionIdentifierAccount];
} else {
NSIndexPath* syncCellIndexPath =
[self.tableViewModel indexPathForItemType:ItemTypeGoogleSync
sectionIdentifier:SectionIdentifierAccount];
TableViewDetailIconItem* detailIconItem =
base::mac::ObjCCast<TableViewDetailIconItem>(
[self.tableViewModel itemAtIndexPath:syncCellIndexPath]);
[self updateGoogleSyncCellItem:detailIconItem];
[self reconfigureCellsForItems:@[ detailIconItem ]];
}
} else {
if (googleSyncCellInitialized) {
[self.tableViewModel removeItemWithType:ItemTypeGoogleSync
fromSectionWithIdentifier:SectionIdentifierAccount];
}
}
} else {
NSIndexPath* googleServicesCellIndexPath =
[self.tableViewModel indexPathForItemType:ItemTypeSyncAndGoogleServices
sectionIdentifier:SectionIdentifierAccount];
TableViewImageItem* googleServicesItem =
base::mac::ObjCCast<TableViewImageItem>(
[self.tableViewModel itemAtIndexPath:googleServicesCellIndexPath]);
DCHECK(googleServicesItem);
[self updateSyncAndGoogleServicesItem:googleServicesItem];
[self reconfigureCellsForItems:@[ googleServicesItem ]];
}
} }
// Check if the default search engine is managed by policy. // Check if the default search engine is managed by policy.
...@@ -1663,4 +1737,13 @@ NSString* kDevViewSourceKey = @"DevViewSource"; ...@@ -1663,4 +1737,13 @@ NSString* kDevViewSourceKey = @"DevViewSource";
[self view:nil didTapLinkURL:convertedURL]; [self view:nil didTapLinkURL:convertedURL];
} }
#pragma mark - ManageSyncSettingsCoordinatorDelegate
- (void)manageSyncSettingsCoordinatorWasRemoved:
(ManageSyncSettingsCoordinator*)coordinator {
DCHECK_EQ(_manageSyncSettingsCoordinator, coordinator);
[_manageSyncSettingsCoordinator stop];
_manageSyncSettingsCoordinator = nil;
}
@end @end
...@@ -20918,6 +20918,14 @@ should be able to be added at any place in this file. ...@@ -20918,6 +20918,14 @@ should be able to be added at any place in this file.
</description> </description>
</action> </action>
<action name="Settings.Sync">
<owner>jlebel@chromium.org</owner>
<owner>fernandex@chromium.org</owner>
<description>
Reported when user navigates to Google Sync Settings. iOS only.
</description>
</action>
<action name="Settings.VoiceSearch"> <action name="Settings.VoiceSearch">
<owner>rohitrao@chromium.org</owner> <owner>rohitrao@chromium.org</owner>
<owner>sczs@chromium.org</owner> <owner>sczs@chromium.org</owner>
......
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