Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(941)

Side by Side Diff: ios/chrome/browser/ui/settings/settings_collection_view_controller.mm

Issue 2894883004: Removed IsNativeAppLauncherEnabled() experiment (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/chrome/browser/ui/settings/settings_collection_view_controller.h" 5 #import "ios/chrome/browser/ui/settings/settings_collection_view_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #import "base/mac/foundation_util.h" 9 #import "base/mac/foundation_util.h"
10 #include "base/metrics/user_metrics.h" 10 #include "base/metrics/user_metrics.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h " 51 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h "
52 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" 52 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
53 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" 53 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
54 #import "ios/chrome/browser/ui/settings/about_chrome_collection_view_controller. h" 54 #import "ios/chrome/browser/ui/settings/about_chrome_collection_view_controller. h"
55 #import "ios/chrome/browser/ui/settings/accounts_collection_view_controller.h" 55 #import "ios/chrome/browser/ui/settings/accounts_collection_view_controller.h"
56 #import "ios/chrome/browser/ui/settings/autofill_collection_view_controller.h" 56 #import "ios/chrome/browser/ui/settings/autofill_collection_view_controller.h"
57 #import "ios/chrome/browser/ui/settings/bandwidth_management_collection_view_con troller.h" 57 #import "ios/chrome/browser/ui/settings/bandwidth_management_collection_view_con troller.h"
58 #import "ios/chrome/browser/ui/settings/cells/account_signin_item.h" 58 #import "ios/chrome/browser/ui/settings/cells/account_signin_item.h"
59 #import "ios/chrome/browser/ui/settings/content_settings_collection_view_control ler.h" 59 #import "ios/chrome/browser/ui/settings/content_settings_collection_view_control ler.h"
60 #import "ios/chrome/browser/ui/settings/material_cell_catalog_view_controller.h" 60 #import "ios/chrome/browser/ui/settings/material_cell_catalog_view_controller.h"
61 #import "ios/chrome/browser/ui/settings/native_apps_collection_view_controller.h "
62 #import "ios/chrome/browser/ui/settings/privacy_collection_view_controller.h" 61 #import "ios/chrome/browser/ui/settings/privacy_collection_view_controller.h"
63 #import "ios/chrome/browser/ui/settings/save_passwords_collection_view_controlle r.h" 62 #import "ios/chrome/browser/ui/settings/save_passwords_collection_view_controlle r.h"
64 #import "ios/chrome/browser/ui/settings/search_engine_settings_collection_view_c ontroller.h" 63 #import "ios/chrome/browser/ui/settings/search_engine_settings_collection_view_c ontroller.h"
65 #import "ios/chrome/browser/ui/settings/settings_utils.h" 64 #import "ios/chrome/browser/ui/settings/settings_utils.h"
66 #import "ios/chrome/browser/ui/settings/utils/pref_backed_boolean.h" 65 #import "ios/chrome/browser/ui/settings/utils/pref_backed_boolean.h"
67 #import "ios/chrome/browser/ui/settings/voicesearch_collection_view_controller.h " 66 #import "ios/chrome/browser/ui/settings/voicesearch_collection_view_controller.h "
68 #import "ios/chrome/browser/ui/sync/sync_util.h" 67 #import "ios/chrome/browser/ui/sync/sync_util.h"
69 #import "ios/chrome/browser/ui/uikit_ui_util.h" 68 #import "ios/chrome/browser/ui/uikit_ui_util.h"
70 #include "ios/chrome/browser/voice/speech_input_locale_config.h" 69 #include "ios/chrome/browser/voice/speech_input_locale_config.h"
71 #include "ios/chrome/grit/ios_chromium_strings.h" 70 #include "ios/chrome/grit/ios_chromium_strings.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 }; 104 };
106 105
107 typedef NS_ENUM(NSInteger, ItemType) { 106 typedef NS_ENUM(NSInteger, ItemType) {
108 ItemTypeSignInButton = kItemTypeEnumZero, 107 ItemTypeSignInButton = kItemTypeEnumZero,
109 ItemTypeSigninPromo, 108 ItemTypeSigninPromo,
110 ItemTypeAccount, 109 ItemTypeAccount,
111 ItemTypeHeader, 110 ItemTypeHeader,
112 ItemTypeSearchEngine, 111 ItemTypeSearchEngine,
113 ItemTypeSavedPasswords, 112 ItemTypeSavedPasswords,
114 ItemTypeAutofill, 113 ItemTypeAutofill,
115 ItemTypeNativeApps,
116 ItemTypeVoiceSearch, 114 ItemTypeVoiceSearch,
117 ItemTypePrivacy, 115 ItemTypePrivacy,
118 ItemTypeContentSettings, 116 ItemTypeContentSettings,
119 ItemTypeBandwidth, 117 ItemTypeBandwidth,
120 ItemTypeAboutChrome, 118 ItemTypeAboutChrome,
121 ItemTypeMemoryDebugging, 119 ItemTypeMemoryDebugging,
122 ItemTypeViewSource, 120 ItemTypeViewSource,
123 ItemTypeLogJavascript, 121 ItemTypeLogJavascript,
124 ItemTypeShowAutofillTypePredictions, 122 ItemTypeShowAutofillTypePredictions,
125 ItemTypeCellCatalog, 123 ItemTypeCellCatalog,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 ChromeIdentityServiceObserver, 181 ChromeIdentityServiceObserver,
184 BooleanObserver, 182 BooleanObserver,
185 PrefObserverDelegate, 183 PrefObserverDelegate,
186 SigninPromoViewConsumer, 184 SigninPromoViewConsumer,
187 SigninPromoViewDelegate> { 185 SigninPromoViewDelegate> {
188 // The main browser state that hold the settings. Never off the record. 186 // The main browser state that hold the settings. Never off the record.
189 ios::ChromeBrowserState* _mainBrowserState; // weak 187 ios::ChromeBrowserState* _mainBrowserState; // weak
190 188
191 // The current browser state. It is either |_mainBrowserState| 189 // The current browser state. It is either |_mainBrowserState|
192 // or |_mainBrowserState->GetOffTheRecordChromeBrowserState()|. 190 // or |_mainBrowserState->GetOffTheRecordChromeBrowserState()|.
193 ios::ChromeBrowserState* _currentBrowserState; // weak
194 std::unique_ptr<SigninObserverBridge> _notificationBridge; 191 std::unique_ptr<SigninObserverBridge> _notificationBridge;
195 std::unique_ptr<SyncObserverBridge> _syncObserverBridge; 192 std::unique_ptr<SyncObserverBridge> _syncObserverBridge;
196 SigninInteractionController* _signinInteractionController; 193 SigninInteractionController* _signinInteractionController;
197 // Whether the impression of the Signin button has already been recorded. 194 // Whether the impression of the Signin button has already been recorded.
198 BOOL _hasRecordedSigninImpression; 195 BOOL _hasRecordedSigninImpression;
199 // PrefBackedBoolean for ShowMemoryDebugTools switch. 196 // PrefBackedBoolean for ShowMemoryDebugTools switch.
200 PrefBackedBoolean* _showMemoryDebugToolsEnabled; 197 PrefBackedBoolean* _showMemoryDebugToolsEnabled;
201 // The item related to the switch for the show suggestions setting. 198 // The item related to the switch for the show suggestions setting.
202 CollectionViewSwitchItem* _showMemoryDebugToolsItem; 199 CollectionViewSwitchItem* _showMemoryDebugToolsItem;
203 200
(...skipping 28 matching lines...) Expand all
232 // Stops observing browser state services. This is required during the shutdown 229 // Stops observing browser state services. This is required during the shutdown
233 // phase to avoid observing services for a profile that is being killed. 230 // phase to avoid observing services for a profile that is being killed.
234 - (void)stopBrowserStateServiceObservers; 231 - (void)stopBrowserStateServiceObservers;
235 232
236 @end 233 @end
237 234
238 @implementation SettingsCollectionViewController 235 @implementation SettingsCollectionViewController
239 236
240 #pragma mark Initialization 237 #pragma mark Initialization
241 238
242 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)mainBrowserState 239 - (instancetype)initWithBrowserState:
243 currentBrowserState: 240 (ios::ChromeBrowserState*)mainBrowserState {
Eugene But (OOO till 7-30) 2017/05/25 14:47:33 ditto
pkl (ping after 24h if needed) 2017/05/26 17:34:18 Acknowledged.
244 (ios::ChromeBrowserState*)currentBrowserState {
245 DCHECK(mainBrowserState); 241 DCHECK(mainBrowserState);
246 DCHECK(currentBrowserState);
247 DCHECK_EQ(mainBrowserState,
248 currentBrowserState->GetOriginalChromeBrowserState());
249 self = [super initWithStyle:CollectionViewControllerStyleAppBar]; 242 self = [super initWithStyle:CollectionViewControllerStyleAppBar];
250 if (self) { 243 if (self) {
251 _mainBrowserState = mainBrowserState; 244 _mainBrowserState = mainBrowserState;
252 _currentBrowserState = currentBrowserState;
253 self.title = l10n_util::GetNSStringWithFixup(IDS_IOS_SETTINGS_TITLE); 245 self.title = l10n_util::GetNSStringWithFixup(IDS_IOS_SETTINGS_TITLE);
254 self.collectionViewAccessibilityIdentifier = kSettingsCollectionViewId; 246 self.collectionViewAccessibilityIdentifier = kSettingsCollectionViewId;
255 _notificationBridge.reset( 247 _notificationBridge.reset(
256 new SigninObserverBridge(_mainBrowserState, self)); 248 new SigninObserverBridge(_mainBrowserState, self));
257 syncer::SyncService* syncService = 249 syncer::SyncService* syncService =
258 IOSChromeProfileSyncServiceFactory::GetForBrowserState( 250 IOSChromeProfileSyncServiceFactory::GetForBrowserState(
259 _mainBrowserState); 251 _mainBrowserState);
260 _syncObserverBridge.reset(new SyncObserverBridge(self, syncService)); 252 _syncObserverBridge.reset(new SyncObserverBridge(self, syncService));
261 253
262 _showMemoryDebugToolsEnabled = [[PrefBackedBoolean alloc] 254 _showMemoryDebugToolsEnabled = [[PrefBackedBoolean alloc]
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 basicsHeader.text = l10n_util::GetNSString(IDS_IOS_OPTIONS_GENERAL_TAB_LABEL); 346 basicsHeader.text = l10n_util::GetNSString(IDS_IOS_OPTIONS_GENERAL_TAB_LABEL);
355 basicsHeader.textColor = [[MDCPalette greyPalette] tint500]; 347 basicsHeader.textColor = [[MDCPalette greyPalette] tint500];
356 [model setHeader:basicsHeader 348 [model setHeader:basicsHeader
357 forSectionWithIdentifier:SectionIdentifierBasics]; 349 forSectionWithIdentifier:SectionIdentifierBasics];
358 [model addItem:[self searchEngineDetailItem] 350 [model addItem:[self searchEngineDetailItem]
359 toSectionWithIdentifier:SectionIdentifierBasics]; 351 toSectionWithIdentifier:SectionIdentifierBasics];
360 [model addItem:[self savePasswordsDetailItem] 352 [model addItem:[self savePasswordsDetailItem]
361 toSectionWithIdentifier:SectionIdentifierBasics]; 353 toSectionWithIdentifier:SectionIdentifierBasics];
362 [model addItem:[self autoFillDetailItem] 354 [model addItem:[self autoFillDetailItem]
363 toSectionWithIdentifier:SectionIdentifierBasics]; 355 toSectionWithIdentifier:SectionIdentifierBasics];
364 if (experimental_flags::IsNativeAppLauncherEnabled()) {
365 [model addItem:[self nativeAppsDetailItem]
366 toSectionWithIdentifier:SectionIdentifierBasics];
367 }
368 356
369 // Advanced Section 357 // Advanced Section
370 [model addSectionWithIdentifier:SectionIdentifierAdvanced]; 358 [model addSectionWithIdentifier:SectionIdentifierAdvanced];
371 CollectionViewTextItem* advancedHeader = 359 CollectionViewTextItem* advancedHeader =
372 [[CollectionViewTextItem alloc] initWithType:ItemTypeHeader]; 360 [[CollectionViewTextItem alloc] initWithType:ItemTypeHeader];
373 advancedHeader.text = 361 advancedHeader.text =
374 l10n_util::GetNSString(IDS_IOS_OPTIONS_ADVANCED_TAB_LABEL); 362 l10n_util::GetNSString(IDS_IOS_OPTIONS_ADVANCED_TAB_LABEL);
375 advancedHeader.textColor = [[MDCPalette greyPalette] tint500]; 363 advancedHeader.textColor = [[MDCPalette greyPalette] tint500];
376 [model setHeader:advancedHeader 364 [model setHeader:advancedHeader
377 forSectionWithIdentifier:SectionIdentifierAdvanced]; 365 forSectionWithIdentifier:SectionIdentifierAdvanced];
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 ? l10n_util::GetNSString(IDS_IOS_SETTING_ON) 476 ? l10n_util::GetNSString(IDS_IOS_SETTING_ON)
489 : l10n_util::GetNSString(IDS_IOS_SETTING_OFF); 477 : l10n_util::GetNSString(IDS_IOS_SETTING_OFF);
490 _autoFillDetailItem = 478 _autoFillDetailItem =
491 [self detailItemWithType:ItemTypeAutofill 479 [self detailItemWithType:ItemTypeAutofill
492 text:l10n_util::GetNSString(IDS_IOS_AUTOFILL) 480 text:l10n_util::GetNSString(IDS_IOS_AUTOFILL)
493 detailText:autofillDetail]; 481 detailText:autofillDetail];
494 482
495 return _autoFillDetailItem; 483 return _autoFillDetailItem;
496 } 484 }
497 485
498 - (CollectionViewItem*)nativeAppsDetailItem {
499 return [self
500 detailItemWithType:ItemTypeNativeApps
501 text:l10n_util::GetNSString(IDS_IOS_GOOGLE_APPS_SM_SETTINGS)
502 detailText:nil];
503 }
504
505 - (CollectionViewItem*)voiceSearchDetailItem { 486 - (CollectionViewItem*)voiceSearchDetailItem {
506 voice::SpeechInputLocaleConfig* localeConfig = 487 voice::SpeechInputLocaleConfig* localeConfig =
507 voice::SpeechInputLocaleConfig::GetInstance(); 488 voice::SpeechInputLocaleConfig::GetInstance();
508 voice::SpeechInputLocale locale = 489 voice::SpeechInputLocale locale =
509 _voiceLocaleCode.GetValue().length() 490 _voiceLocaleCode.GetValue().length()
510 ? localeConfig->GetLocaleForCode(_voiceLocaleCode.GetValue()) 491 ? localeConfig->GetLocaleForCode(_voiceLocaleCode.GetValue())
511 : localeConfig->GetDefaultLocale(); 492 : localeConfig->GetDefaultLocale();
512 NSString* languageName = base::SysUTF16ToNSString(locale.display_name); 493 NSString* languageName = base::SysUTF16ToNSString(locale.display_name);
513 _voiceSearchDetailItem = 494 _voiceSearchDetailItem =
514 [self detailItemWithType:ItemTypeVoiceSearch 495 [self detailItemWithType:ItemTypeVoiceSearch
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 break; 732 break;
752 case ItemTypeSavedPasswords: { 733 case ItemTypeSavedPasswords: {
753 controller = [[SavePasswordsCollectionViewController alloc] 734 controller = [[SavePasswordsCollectionViewController alloc]
754 initWithBrowserState:_mainBrowserState]; 735 initWithBrowserState:_mainBrowserState];
755 break; 736 break;
756 } 737 }
757 case ItemTypeAutofill: 738 case ItemTypeAutofill:
758 controller = [[AutofillCollectionViewController alloc] 739 controller = [[AutofillCollectionViewController alloc]
759 initWithBrowserState:_mainBrowserState]; 740 initWithBrowserState:_mainBrowserState];
760 break; 741 break;
761 case ItemTypeNativeApps:
762 controller = [[NativeAppsCollectionViewController alloc]
763 initWithURLRequestContextGetter:_currentBrowserState
764 ->GetRequestContext()];
765 break;
766 case ItemTypeVoiceSearch: 742 case ItemTypeVoiceSearch:
767 controller = [[VoicesearchCollectionViewController alloc] 743 controller = [[VoicesearchCollectionViewController alloc]
768 initWithPrefs:_mainBrowserState->GetPrefs()]; 744 initWithPrefs:_mainBrowserState->GetPrefs()];
769 break; 745 break;
770 case ItemTypePrivacy: 746 case ItemTypePrivacy:
771 controller = [[PrivacyCollectionViewController alloc] 747 controller = [[PrivacyCollectionViewController alloc]
772 initWithBrowserState:_mainBrowserState]; 748 initWithBrowserState:_mainBrowserState];
773 break; 749 break;
774 case ItemTypeContentSettings: 750 case ItemTypeContentSettings:
775 controller = [[ContentSettingsCollectionViewController alloc] 751 controller = [[ContentSettingsCollectionViewController alloc]
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 (SigninPromoView*)signinPromoView { 1175 (SigninPromoView*)signinPromoView {
1200 DCHECK(_signinPromoViewMediator.defaultIdentity); 1176 DCHECK(_signinPromoViewMediator.defaultIdentity);
1201 base::RecordAction( 1177 base::RecordAction(
1202 base::UserMetricsAction("Signin_SigninNotDefault_FromSettings")); 1178 base::UserMetricsAction("Signin_SigninNotDefault_FromSettings"));
1203 [self showSignInWithIdentity:nil 1179 [self showSignInWithIdentity:nil
1204 promoAction:signin_metrics::PromoAction:: 1180 promoAction:signin_metrics::PromoAction::
1205 PROMO_ACTION_NOT_DEFAULT]; 1181 PROMO_ACTION_NOT_DEFAULT];
1206 } 1182 }
1207 1183
1208 @end 1184 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698