| 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/do_not_track_collection_view_controller.
h" | 5 #import "ios/chrome/browser/ui/settings/do_not_track_collection_view_controller.
h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #include "components/google/core/browser/google_util.h" | 8 #include "components/google/core/browser/google_util.h" |
| 9 #include "components/prefs/pref_member.h" | 9 #include "components/prefs/pref_member.h" |
| 10 #include "ios/chrome/browser/application_context.h" | 10 #include "ios/chrome/browser/application_context.h" |
| 11 #include "ios/chrome/browser/chrome_url_constants.h" | 11 #include "ios/chrome/browser/chrome_url_constants.h" |
| 12 #include "ios/chrome/browser/pref_names.h" | 12 #include "ios/chrome/browser/pref_names.h" |
| 13 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom
e.h" | 13 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom
e.h" |
| 14 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item
.h" | 14 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item
.h" |
| 15 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item
.h" | 15 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item
.h" |
| 16 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" | 16 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" |
| 17 #include "ios/chrome/grit/ios_strings.h" | 17 #include "ios/chrome/grit/ios_strings.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 20 | 20 |
| 21 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 22 #error "This file requires ARC support." |
| 23 #endif |
| 24 |
| 21 namespace { | 25 namespace { |
| 22 | 26 |
| 23 typedef NS_ENUM(NSInteger, SectionIdentifier) { | 27 typedef NS_ENUM(NSInteger, SectionIdentifier) { |
| 24 SectionIdentifierSwitch = kSectionIdentifierEnumZero, | 28 SectionIdentifierSwitch = kSectionIdentifierEnumZero, |
| 25 SectionIdentifierFooter, | 29 SectionIdentifierFooter, |
| 26 }; | 30 }; |
| 27 | 31 |
| 28 typedef NS_ENUM(NSInteger, ItemType) { | 32 typedef NS_ENUM(NSInteger, ItemType) { |
| 29 ItemTypeSwitch = kItemTypeEnumZero, | 33 ItemTypeSwitch = kItemTypeEnumZero, |
| 30 ItemTypeFooter, | 34 ItemTypeFooter, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 [model addSectionWithIdentifier:SectionIdentifierSwitch]; | 70 [model addSectionWithIdentifier:SectionIdentifierSwitch]; |
| 67 [model addItem:[self switchItem] | 71 [model addItem:[self switchItem] |
| 68 toSectionWithIdentifier:SectionIdentifierSwitch]; | 72 toSectionWithIdentifier:SectionIdentifierSwitch]; |
| 69 | 73 |
| 70 [model addSectionWithIdentifier:SectionIdentifierFooter]; | 74 [model addSectionWithIdentifier:SectionIdentifierFooter]; |
| 71 [model addItem:[self footerItem] | 75 [model addItem:[self footerItem] |
| 72 toSectionWithIdentifier:SectionIdentifierFooter]; | 76 toSectionWithIdentifier:SectionIdentifierFooter]; |
| 73 } | 77 } |
| 74 | 78 |
| 75 - (CollectionViewItem*)switchItem { | 79 - (CollectionViewItem*)switchItem { |
| 76 CollectionViewSwitchItem* item = [[[CollectionViewSwitchItem alloc] | 80 CollectionViewSwitchItem* item = |
| 77 initWithType:ItemTypeSwitch] autorelease]; | 81 [[CollectionViewSwitchItem alloc] initWithType:ItemTypeSwitch]; |
| 78 item.text = l10n_util::GetNSString(IDS_IOS_OPTIONS_DO_NOT_TRACK_MOBILE); | 82 item.text = l10n_util::GetNSString(IDS_IOS_OPTIONS_DO_NOT_TRACK_MOBILE); |
| 79 item.on = _doNotTrackEnabled.GetValue(); | 83 item.on = _doNotTrackEnabled.GetValue(); |
| 80 return item; | 84 return item; |
| 81 } | 85 } |
| 82 | 86 |
| 83 - (CollectionViewItem*)footerItem { | 87 - (CollectionViewItem*)footerItem { |
| 84 NSString* footerText = l10n_util::GetNSString( | 88 NSString* footerText = l10n_util::GetNSString( |
| 85 IDS_IOS_OPTIONS_ENABLE_DO_NOT_TRACK_BUBBLE_TEXT_MOBILE); | 89 IDS_IOS_OPTIONS_ENABLE_DO_NOT_TRACK_BUBBLE_TEXT_MOBILE); |
| 86 GURL learnMoreURL = google_util::AppendGoogleLocaleParam( | 90 GURL learnMoreURL = google_util::AppendGoogleLocaleParam( |
| 87 GURL(kDoNotTrackLearnMoreURL), | 91 GURL(kDoNotTrackLearnMoreURL), |
| 88 GetApplicationContext()->GetApplicationLocale()); | 92 GetApplicationContext()->GetApplicationLocale()); |
| 89 | 93 |
| 90 CollectionViewFooterItem* item = [[[CollectionViewFooterItem alloc] | 94 CollectionViewFooterItem* item = |
| 91 initWithType:ItemTypeFooter] autorelease]; | 95 [[CollectionViewFooterItem alloc] initWithType:ItemTypeFooter]; |
| 92 item.text = footerText; | 96 item.text = footerText; |
| 93 item.linkURL = learnMoreURL; | 97 item.linkURL = learnMoreURL; |
| 94 item.linkDelegate = self; | 98 item.linkDelegate = self; |
| 95 return item; | 99 return item; |
| 96 } | 100 } |
| 97 | 101 |
| 98 #pragma mark - Actions | 102 #pragma mark - Actions |
| 99 | 103 |
| 100 - (void)switchToggled:(id)sender { | 104 - (void)switchToggled:(id)sender { |
| 101 NSIndexPath* switchPath = | 105 NSIndexPath* switchPath = |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 switch (type) { | 191 switch (type) { |
| 188 case ItemTypeFooter: | 192 case ItemTypeFooter: |
| 189 case ItemTypeSwitch: | 193 case ItemTypeSwitch: |
| 190 return YES; | 194 return YES; |
| 191 default: | 195 default: |
| 192 return NO; | 196 return NO; |
| 193 } | 197 } |
| 194 } | 198 } |
| 195 | 199 |
| 196 @end | 200 @end |
| OLD | NEW |