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

[iOS] Hiding old UI when the unified consent is enabled

The settings UI in "Sync and Google services" is hidden from the
previous places.
List of UI hidden:
 + Settings => Bandwidth
 + Settings => Privacy => Search and Site Suggestions
 + Settings => Privacy => Send Usage Data
 + Settings => Account => Sync
 + Settings => Account => Google Activity Controls

Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I59abbc50628e57d50bb99492f92e6fcaddeceb00
Reviewed-on: https://chromium-review.googlesource.com/1188473
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586660}
parent 8e8576e0
......@@ -41,6 +41,7 @@
#import "ios/chrome/browser/ui/settings/sync_settings_collection_view_controller.h"
#import "ios/chrome/browser/ui/settings/sync_utils/sync_util.h"
#import "ios/chrome/browser/ui/signin_interaction/signin_interaction_coordinator.h"
#include "ios/chrome/browser/unified_consent/feature.h"
#include "ios/chrome/grit/ios_chromium_strings.h"
#include "ios/chrome/grit/ios_strings.h"
#import "ios/public/provider/chrome/browser/chrome_browser_provider.h"
......@@ -135,7 +136,11 @@ typedef NS_ENUM(NSInteger, ItemType) {
_closeSettingsOnAddAccount = closeSettingsOnAddAccount;
browser_sync::ProfileSyncService* syncService =
ProfileSyncServiceFactory::GetForBrowserState(_browserState);
_syncObserver.reset(new SyncObserverBridge(self, syncService));
if (!IsUnifiedConsentEnabled()) {
// When unified consent flag is enabled, the sync settings are available
// in the "Google Services and sync" settings.
_syncObserver.reset(new SyncObserverBridge(self, syncService));
}
_tokenServiceObserver.reset(new OAuth2TokenServiceObserverBridge(
ProfileOAuth2TokenServiceFactory::GetForBrowserState(_browserState),
self));
......@@ -232,11 +237,16 @@ typedef NS_ENUM(NSInteger, ItemType) {
[model addItem:[self addAccountItem]
toSectionWithIdentifier:SectionIdentifierAccounts];
// Sync and Google Activity section.
[model addSectionWithIdentifier:SectionIdentifierSync];
[model addItem:[self syncItem] toSectionWithIdentifier:SectionIdentifierSync];
[model addItem:[self googleActivityControlsItem]
toSectionWithIdentifier:SectionIdentifierSync];
if (!IsUnifiedConsentEnabled()) {
// Sync and Google Activity section.
// When unified consent flag is enabled, those settings are available in
// the Google Services and sync settings.
[model addSectionWithIdentifier:SectionIdentifierSync];
[model addItem:[self syncItem]
toSectionWithIdentifier:SectionIdentifierSync];
[model addItem:[self googleActivityControlsItem]
toSectionWithIdentifier:SectionIdentifierSync];
}
// Sign out section.
[model addSectionWithIdentifier:SectionIdentifierSignOut];
......
......@@ -37,6 +37,7 @@
#import "ios/chrome/browser/ui/settings/settings_utils.h"
#import "ios/chrome/browser/ui/settings/utils/pref_backed_boolean.h"
#include "ios/chrome/browser/ui/ui_util.h"
#include "ios/chrome/browser/unified_consent/feature.h"
#include "ios/chrome/grit/ios_chromium_strings.h"
#include "ios/chrome/grit/ios_strings.h"
#import "ios/third_party/material_components_ios/src/components/Palettes/src/MaterialPalettes.h"
......@@ -118,10 +119,14 @@ typedef NS_ENUM(NSInteger, ItemType) {
self.title =
l10n_util::GetNSString(IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY);
self.collectionViewAccessibilityIdentifier = kPrivacyCollectionViewId;
_suggestionsEnabled = [[PrefBackedBoolean alloc]
initWithPrefService:_browserState->GetPrefs()
prefName:prefs::kSearchSuggestEnabled];
[_suggestionsEnabled setObserver:self];
if (!IsUnifiedConsentEnabled()) {
// When unified consent flag is enabled, the suggestion setting is
// available in the "Google Services and sync" settings.
_suggestionsEnabled = [[PrefBackedBoolean alloc]
initWithPrefService:_browserState->GetPrefs()
prefName:prefs::kSearchSuggestEnabled];
[_suggestionsEnabled setObserver:self];
}
PrefService* prefService = _browserState->GetPrefs();
......@@ -166,32 +171,38 @@ typedef NS_ENUM(NSInteger, ItemType) {
[model addItem:[self handoffDetailItem]
toSectionWithIdentifier:SectionIdentifierOtherDevices];
// Web Services Section
[model addSectionWithIdentifier:SectionIdentifierWebServices];
SettingsTextItem* webServicesHeader =
[[SettingsTextItem alloc] initWithType:ItemTypeWebServicesHeader];
webServicesHeader.text =
l10n_util::GetNSString(IDS_IOS_OPTIONS_WEB_SERVICES_LABEL);
webServicesHeader.textColor = [[MDCPalette greyPalette] tint500];
[model setHeader:webServicesHeader
forSectionWithIdentifier:SectionIdentifierWebServices];
_showSuggestionsItem = [self showSuggestionsSwitchItem];
[model addItem:_showSuggestionsItem
toSectionWithIdentifier:SectionIdentifierWebServices];
[model addItem:[self sendUsageDetailItem]
toSectionWithIdentifier:SectionIdentifierWebServices];
if (!IsUnifiedConsentEnabled() || web::IsDoNotTrackSupported()) {
// Add "Web services" section only if "Do not track" feature, metrics
// reporting feature and show suggestions feature are available.
// Web Services Section
[model addSectionWithIdentifier:SectionIdentifierWebServices];
SettingsTextItem* webServicesHeader =
[[SettingsTextItem alloc] initWithType:ItemTypeWebServicesHeader];
webServicesHeader.text =
l10n_util::GetNSString(IDS_IOS_OPTIONS_WEB_SERVICES_LABEL);
webServicesHeader.textColor = [[MDCPalette greyPalette] tint500];
[model setHeader:webServicesHeader
forSectionWithIdentifier:SectionIdentifierWebServices];
// Footer Section
[model addSectionWithIdentifier:SectionIdentifierWebServicesFooter];
[model addItem:[self showSuggestionsFooterItem]
toSectionWithIdentifier:SectionIdentifierWebServicesFooter];
}
if (!IsUnifiedConsentEnabled()) {
// When unified consent flag is enabled, the show suggestions feature and
// metrics reporting feature are available in the "Google Services and sync"
// settings.
_showSuggestionsItem = [self showSuggestionsSwitchItem];
[model addItem:_showSuggestionsItem
toSectionWithIdentifier:SectionIdentifierWebServices];
[model addItem:[self sendUsageDetailItem]
toSectionWithIdentifier:SectionIdentifierWebServices];
}
if (web::IsDoNotTrackSupported()) {
[model addItem:[self doNotTrackDetailItem]
toSectionWithIdentifier:SectionIdentifierWebServices];
}
// Footer Section
[model addSectionWithIdentifier:SectionIdentifierWebServicesFooter];
[model addItem:[self showSuggestionsFooterItem]
toSectionWithIdentifier:SectionIdentifierWebServicesFooter];
// CanMakePayment Section
[model addSectionWithIdentifier:SectionIdentifierCanMakePayment];
[model addItem:[self canMakePaymentItem]
......
......@@ -454,8 +454,12 @@ void SigninObserverBridge::GoogleSignedOut(const std::string& account_id,
toSectionWithIdentifier:SectionIdentifierAdvanced];
[model addItem:[self contentSettingsDetailItem]
toSectionWithIdentifier:SectionIdentifierAdvanced];
[model addItem:[self bandwidthManagementDetailItem]
toSectionWithIdentifier:SectionIdentifierAdvanced];
if (!IsUnifiedConsentEnabled()) {
// When unified consent flag is enabled, the bandwidth settings is available
// under the Google services and sync settings.
[model addItem:[self bandwidthManagementDetailItem]
toSectionWithIdentifier:SectionIdentifierAdvanced];
}
// Info Section
[model addSectionWithIdentifier:SectionIdentifierInfo];
......
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