OLD | NEW |
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/privacy_collection_view_controller.h" | 5 #import "ios/chrome/browser/ui/settings/privacy_collection_view_controller.h" |
6 | 6 |
7 #include "base/ios/ios_util.h" | 7 #include "base/ios/ios_util.h" |
8 #import "base/ios/weak_nsobject.h" | 8 #import "base/ios/weak_nsobject.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #import "base/mac/foundation_util.h" | 10 #import "base/mac/foundation_util.h" |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 | 440 |
441 #pragma mark - BooleanObserver | 441 #pragma mark - BooleanObserver |
442 | 442 |
443 - (void)booleanDidChange:(id<ObservableBoolean>)observableBoolean { | 443 - (void)booleanDidChange:(id<ObservableBoolean>)observableBoolean { |
444 DCHECK_EQ(observableBoolean, _suggestionsEnabled.get()); | 444 DCHECK_EQ(observableBoolean, _suggestionsEnabled.get()); |
445 | 445 |
446 // Update the item. | 446 // Update the item. |
447 _showSuggestionsItem.get().on = [_suggestionsEnabled value]; | 447 _showSuggestionsItem.get().on = [_suggestionsEnabled value]; |
448 | 448 |
449 // Update the cell. | 449 // Update the cell. |
450 [self reconfigureCellsForItems:@[ _showSuggestionsItem ] | 450 [self reconfigureCellsForItems:@[ _showSuggestionsItem ]]; |
451 inSectionWithIdentifier:SectionIdentifierWebServices]; | |
452 } | 451 } |
453 | 452 |
454 #pragma mark - Actions | 453 #pragma mark - Actions |
455 | 454 |
456 - (void)showSuggestionsToggled:(UISwitch*)sender { | 455 - (void)showSuggestionsToggled:(UISwitch*)sender { |
457 NSIndexPath* switchPath = [self.collectionViewModel | 456 NSIndexPath* switchPath = [self.collectionViewModel |
458 indexPathForItemType:ItemTypeWebServicesShowSuggestions | 457 indexPathForItemType:ItemTypeWebServicesShowSuggestions |
459 sectionIdentifier:SectionIdentifierWebServices]; | 458 sectionIdentifier:SectionIdentifierWebServices]; |
460 | 459 |
461 CollectionViewSwitchItem* switchItem = | 460 CollectionViewSwitchItem* switchItem = |
(...skipping 11 matching lines...) Expand all Loading... |
473 | 472 |
474 #pragma mark - PrefObserverDelegate | 473 #pragma mark - PrefObserverDelegate |
475 | 474 |
476 - (void)onPreferenceChanged:(const std::string&)preferenceName { | 475 - (void)onPreferenceChanged:(const std::string&)preferenceName { |
477 if (preferenceName == prefs::kIosHandoffToOtherDevices) { | 476 if (preferenceName == prefs::kIosHandoffToOtherDevices) { |
478 NSString* detailText = | 477 NSString* detailText = |
479 _browserState->GetPrefs()->GetBoolean(prefs::kIosHandoffToOtherDevices) | 478 _browserState->GetPrefs()->GetBoolean(prefs::kIosHandoffToOtherDevices) |
480 ? l10n_util::GetNSString(IDS_IOS_SETTING_ON) | 479 ? l10n_util::GetNSString(IDS_IOS_SETTING_ON) |
481 : l10n_util::GetNSString(IDS_IOS_SETTING_OFF); | 480 : l10n_util::GetNSString(IDS_IOS_SETTING_OFF); |
482 _handoffDetailItem.get().detailText = detailText; | 481 _handoffDetailItem.get().detailText = detailText; |
483 [self reconfigureCellsForItems:@[ _handoffDetailItem ] | 482 [self reconfigureCellsForItems:@[ _handoffDetailItem ]]; |
484 inSectionWithIdentifier:SectionIdentifierOtherDevices]; | |
485 return; | 483 return; |
486 } | 484 } |
487 | 485 |
488 if (preferenceName == metrics::prefs::kMetricsReportingEnabled || | 486 if (preferenceName == metrics::prefs::kMetricsReportingEnabled || |
489 preferenceName == prefs::kMetricsReportingWifiOnly) { | 487 preferenceName == prefs::kMetricsReportingWifiOnly) { |
490 NSString* detailText = [DataplanUsageCollectionViewController | 488 NSString* detailText = [DataplanUsageCollectionViewController |
491 currentLabelForPreference:GetApplicationContext()->GetLocalState() | 489 currentLabelForPreference:GetApplicationContext()->GetLocalState() |
492 basePref:metrics::prefs::kMetricsReportingEnabled | 490 basePref:metrics::prefs::kMetricsReportingEnabled |
493 wifiPref:prefs::kMetricsReportingWifiOnly]; | 491 wifiPref:prefs::kMetricsReportingWifiOnly]; |
494 | 492 |
495 _sendUsageDetailItem.get().detailText = detailText; | 493 _sendUsageDetailItem.get().detailText = detailText; |
496 | 494 |
497 [self reconfigureCellsForItems:@[ _sendUsageDetailItem ] | 495 [self reconfigureCellsForItems:@[ _sendUsageDetailItem ]]; |
498 inSectionWithIdentifier:SectionIdentifierWebServices]; | |
499 return; | 496 return; |
500 } | 497 } |
501 } | 498 } |
502 | 499 |
503 @end | 500 @end |
OLD | NEW |