| 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/autofill_collection_view_controller.h" | 5 #import "ios/chrome/browser/ui/settings/autofill_collection_view_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "components/autofill/core/browser/personal_data_manager.h" | 9 #include "components/autofill/core/browser/personal_data_manager.h" |
| 10 #include "components/autofill/core/common/autofill_pref_names.h" | 10 #include "components/autofill/core/common/autofill_pref_names.h" |
| 11 #import "components/autofill/ios/browser/credit_card_util.h" | 11 #import "components/autofill/ios/browser/credit_card_util.h" |
| 12 #import "components/autofill/ios/browser/personal_data_manager_observer_bridge.h
" | 12 #import "components/autofill/ios/browser/personal_data_manager_observer_bridge.h
" |
| 13 #include "components/prefs/pref_service.h" | 13 #include "components/prefs/pref_service.h" |
| 14 #include "ios/chrome/browser/application_context.h" | 14 #include "ios/chrome/browser/application_context.h" |
| 15 #include "ios/chrome/browser/autofill/personal_data_manager_factory.h" | 15 #include "ios/chrome/browser/autofill/personal_data_manager_factory.h" |
| 16 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 16 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 17 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom
e.h" | 17 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom
e.h" |
| 18 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item
.h" | 18 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item
.h" |
| 19 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_cell.h
" |
| 19 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h
" | 20 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h
" |
| 20 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" | 21 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" |
| 21 #import "ios/chrome/browser/ui/settings/autofill_credit_card_edit_collection_vie
w_controller.h" | 22 #import "ios/chrome/browser/ui/settings/autofill_credit_card_edit_collection_vie
w_controller.h" |
| 22 #import "ios/chrome/browser/ui/settings/autofill_profile_edit_collection_view_co
ntroller.h" | 23 #import "ios/chrome/browser/ui/settings/autofill_profile_edit_collection_view_co
ntroller.h" |
| 23 #import "ios/chrome/browser/ui/settings/cells/autofill_data_item.h" | 24 #import "ios/chrome/browser/ui/settings/cells/autofill_data_item.h" |
| 24 #include "ios/chrome/grit/ios_strings.h" | 25 #include "ios/chrome/grit/ios_strings.h" |
| 25 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" | 26 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" |
| 27 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
| 27 | 29 |
| 28 #if !defined(__has_feature) || !__has_feature(objc_arc) | 30 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 29 #error "This file requires ARC support." | 31 #error "This file requires ARC support." |
| 30 #endif | 32 #endif |
| 31 | 33 |
| 32 namespace { | 34 namespace { |
| 33 | 35 |
| 34 typedef NS_ENUM(NSInteger, SectionIdentifier) { | 36 typedef NS_ENUM(NSInteger, SectionIdentifier) { |
| 35 SectionIdentifierSwitches = kSectionIdentifierEnumZero, | 37 SectionIdentifierSwitches = kSectionIdentifierEnumZero, |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 175 |
| 174 - (CollectionViewItem*)cardSectionHeader { | 176 - (CollectionViewItem*)cardSectionHeader { |
| 175 CollectionViewTextItem* header = [self genericHeader]; | 177 CollectionViewTextItem* header = [self genericHeader]; |
| 176 header.text = l10n_util::GetNSString(IDS_IOS_AUTOFILL_CREDITCARDS_GROUP_NAME); | 178 header.text = l10n_util::GetNSString(IDS_IOS_AUTOFILL_CREDITCARDS_GROUP_NAME); |
| 177 return header; | 179 return header; |
| 178 } | 180 } |
| 179 | 181 |
| 180 - (CollectionViewTextItem*)genericHeader { | 182 - (CollectionViewTextItem*)genericHeader { |
| 181 CollectionViewTextItem* header = | 183 CollectionViewTextItem* header = |
| 182 [[CollectionViewTextItem alloc] initWithType:ItemTypeHeader]; | 184 [[CollectionViewTextItem alloc] initWithType:ItemTypeHeader]; |
| 183 header.textColor = [[MDCPalette greyPalette] tint500]; | |
| 184 return header; | 185 return header; |
| 185 } | 186 } |
| 186 | 187 |
| 187 - (CollectionViewItem*)itemForProfile: | 188 - (CollectionViewItem*)itemForProfile: |
| 188 (const autofill::AutofillProfile&)autofillProfile { | 189 (const autofill::AutofillProfile&)autofillProfile { |
| 189 std::string guid(autofillProfile.guid()); | 190 std::string guid(autofillProfile.guid()); |
| 190 NSString* title = base::SysUTF16ToNSString(autofillProfile.GetInfo( | 191 NSString* title = base::SysUTF16ToNSString(autofillProfile.GetInfo( |
| 191 autofill::AutofillType(autofill::NAME_FULL), _locale)); | 192 autofill::AutofillType(autofill::NAME_FULL), _locale)); |
| 192 NSString* subTitle = base::SysUTF16ToNSString(autofillProfile.GetInfo( | 193 NSString* subTitle = base::SysUTF16ToNSString(autofillProfile.GetInfo( |
| 193 autofill::AutofillType(autofill::ADDRESS_HOME_LINE1), _locale)); | 194 autofill::AutofillType(autofill::ADDRESS_HOME_LINE1), _locale)); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 base::mac::ObjCCastStrict<CollectionViewSwitchCell>(cell); | 259 base::mac::ObjCCastStrict<CollectionViewSwitchCell>(cell); |
| 259 [switchCell.switchView addTarget:self | 260 [switchCell.switchView addTarget:self |
| 260 action:@selector(autofillSwitchChanged:) | 261 action:@selector(autofillSwitchChanged:) |
| 261 forControlEvents:UIControlEventValueChanged]; | 262 forControlEvents:UIControlEventValueChanged]; |
| 262 } else if (itemType == ItemTypeWalletSwitch) { | 263 } else if (itemType == ItemTypeWalletSwitch) { |
| 263 CollectionViewSwitchCell* switchCell = | 264 CollectionViewSwitchCell* switchCell = |
| 264 base::mac::ObjCCastStrict<CollectionViewSwitchCell>(cell); | 265 base::mac::ObjCCastStrict<CollectionViewSwitchCell>(cell); |
| 265 [switchCell.switchView addTarget:self | 266 [switchCell.switchView addTarget:self |
| 266 action:@selector(walletSwitchChanged:) | 267 action:@selector(walletSwitchChanged:) |
| 267 forControlEvents:UIControlEventValueChanged]; | 268 forControlEvents:UIControlEventValueChanged]; |
| 269 } else if (itemType == ItemTypeHeader) { |
| 270 CollectionViewTextCell* textCell = |
| 271 base::mac::ObjCCastStrict<CollectionViewTextCell>(cell); |
| 272 textCell.textLabel.font = [MDCTypography body2Font]; |
| 273 textCell.textLabel.textColor = [[MDCPalette greyPalette] tint500]; |
| 274 textCell.detailTextLabel.font = [MDCTypography body1Font]; |
| 275 textCell.detailTextLabel.textColor = [[MDCPalette greyPalette] tint500]; |
| 268 } | 276 } |
| 269 return cell; | 277 return cell; |
| 270 } | 278 } |
| 271 | 279 |
| 272 #pragma mark - Switch Callbacks | 280 #pragma mark - Switch Callbacks |
| 273 | 281 |
| 274 - (void)autofillSwitchChanged:(UISwitch*)switchView { | 282 - (void)autofillSwitchChanged:(UISwitch*)switchView { |
| 275 [self setSwitchItemOn:[switchView isOn] itemType:ItemTypeAutofillSwitch]; | 283 [self setSwitchItemOn:[switchView isOn] itemType:ItemTypeAutofillSwitch]; |
| 276 _userInteractionInProgress = YES; | 284 _userInteractionInProgress = YES; |
| 277 [self setAutofillEnabled:[switchView isOn]]; | 285 [self setAutofillEnabled:[switchView isOn]]; |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 return _browserState->GetPrefs()->GetBoolean( | 611 return _browserState->GetPrefs()->GetBoolean( |
| 604 autofill::prefs::kAutofillWalletImportEnabled); | 612 autofill::prefs::kAutofillWalletImportEnabled); |
| 605 } | 613 } |
| 606 | 614 |
| 607 - (void)setWalletEnabled:(BOOL)isEnabled { | 615 - (void)setWalletEnabled:(BOOL)isEnabled { |
| 608 _browserState->GetPrefs()->SetBoolean( | 616 _browserState->GetPrefs()->SetBoolean( |
| 609 autofill::prefs::kAutofillWalletImportEnabled, isEnabled); | 617 autofill::prefs::kAutofillWalletImportEnabled, isEnabled); |
| 610 } | 618 } |
| 611 | 619 |
| 612 @end | 620 @end |
| OLD | NEW |