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

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

Issue 2815513008: [ObjC ARC] Converts ios/chrome/browser/ui/settings:settings_arc to ARC. (Closed)
Patch Set: Removes accidental retain from another CL Created 3 years, 8 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/autofill_profile_edit_collection_view_co ntroller.h" 5 #import "ios/chrome/browser/ui/settings/autofill_profile_edit_collection_view_co ntroller.h"
6 6
7 #import "base/ios/weak_nsobject.h"
8 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
9 #import "base/mac/scoped_nsobject.h"
10 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
11 #include "components/autofill/core/browser/autofill_profile.h" 9 #include "components/autofill/core/browser/autofill_profile.h"
12 #include "components/autofill/core/browser/field_types.h" 10 #include "components/autofill/core/browser/field_types.h"
13 #include "components/autofill/core/browser/payments/payments_service_url.h" 11 #include "components/autofill/core/browser/payments/payments_service_url.h"
14 #include "components/autofill/core/browser/personal_data_manager.h" 12 #include "components/autofill/core/browser/personal_data_manager.h"
15 #include "ios/chrome/browser/application_context.h" 13 #include "ios/chrome/browser/application_context.h"
16 #import "ios/chrome/browser/ui/autofill/autofill_ui_type.h" 14 #import "ios/chrome/browser/ui/autofill/autofill_ui_type.h"
17 #import "ios/chrome/browser/ui/autofill/autofill_ui_type_util.h" 15 #import "ios/chrome/browser/ui/autofill/autofill_ui_type_util.h"
18 #import "ios/chrome/browser/ui/autofill/cells/autofill_edit_item.h" 16 #import "ios/chrome/browser/ui/autofill/cells/autofill_edit_item.h"
19 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" 17 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
20 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" 18 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h"
21 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" 19 #include "ios/chrome/browser/ui/commands/ios_command_ids.h"
22 #import "ios/chrome/browser/ui/commands/open_url_command.h" 20 #import "ios/chrome/browser/ui/commands/open_url_command.h"
23 #include "ios/chrome/grit/ios_strings.h" 21 #include "ios/chrome/grit/ios_strings.h"
24 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
25 #include "url/gurl.h" 23 #include "url/gurl.h"
26 24
25 #if !defined(__has_feature) || !__has_feature(objc_arc)
26 #error "This file requires ARC support."
27 #endif
28
27 NSString* const kAutofillProfileEditCollectionViewId = 29 NSString* const kAutofillProfileEditCollectionViewId =
28 @"kAutofillProfileEditCollectionViewId"; 30 @"kAutofillProfileEditCollectionViewId";
29 31
30 namespace { 32 namespace {
31 using ::AutofillTypeFromAutofillUIType; 33 using ::AutofillTypeFromAutofillUIType;
32 using ::AutofillUITypeFromAutofillType; 34 using ::AutofillUITypeFromAutofillType;
33 35
34 typedef NS_ENUM(NSInteger, SectionIdentifier) { 36 typedef NS_ENUM(NSInteger, SectionIdentifier) {
35 SectionIdentifierFields = kSectionIdentifierEnumZero, 37 SectionIdentifierFields = kSectionIdentifierEnumZero,
36 }; 38 };
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 [self setTitle:l10n_util::GetNSString(IDS_IOS_AUTOFILL_EDIT_ADDRESS)]; 104 [self setTitle:l10n_util::GetNSString(IDS_IOS_AUTOFILL_EDIT_ADDRESS)];
103 [self loadModel]; 105 [self loadModel];
104 } 106 }
105 107
106 return self; 108 return self;
107 } 109 }
108 110
109 + (instancetype)controllerWithProfile:(const autofill::AutofillProfile&)profile 111 + (instancetype)controllerWithProfile:(const autofill::AutofillProfile&)profile
110 personalDataManager: 112 personalDataManager:
111 (autofill::PersonalDataManager*)dataManager { 113 (autofill::PersonalDataManager*)dataManager {
112 return [[[self alloc] initWithProfile:profile personalDataManager:dataManager] 114 return [[self alloc] initWithProfile:profile personalDataManager:dataManager];
113 autorelease];
114 } 115 }
115 116
116 #pragma mark - SettingsRootCollectionViewController 117 #pragma mark - SettingsRootCollectionViewController
117 118
118 - (void)editButtonPressed { 119 - (void)editButtonPressed {
119 // In the case of server profiles, open the Payments editing page instead. 120 // In the case of server profiles, open the Payments editing page instead.
120 if (_autofillProfile.record_type() == 121 if (_autofillProfile.record_type() ==
121 autofill::AutofillProfile::SERVER_PROFILE) { 122 autofill::AutofillProfile::SERVER_PROFILE) {
122 GURL paymentsURL = autofill::payments::GetManageAddressesUrl(0); 123 GURL paymentsURL = autofill::payments::GetManageAddressesUrl(0);
123 base::scoped_nsobject<OpenUrlCommand> command( 124 OpenUrlCommand* command =
124 [[OpenUrlCommand alloc] initWithURLFromChrome:paymentsURL]); 125 [[OpenUrlCommand alloc] initWithURLFromChrome:paymentsURL];
125 [command setTag:IDC_CLOSE_SETTINGS_AND_OPEN_URL]; 126 [command setTag:IDC_CLOSE_SETTINGS_AND_OPEN_URL];
126 [self chromeExecuteCommand:command]; 127 [self chromeExecuteCommand:command];
127 128
128 // Don't call [super editButtonPressed] because edit mode is not actually 129 // Don't call [super editButtonPressed] because edit mode is not actually
129 // entered in this case. 130 // entered in this case.
130 return; 131 return;
131 } 132 }
132 133
133 [super editButtonPressed]; 134 [super editButtonPressed];
134 135
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 175
175 - (void)loadModel { 176 - (void)loadModel {
176 [super loadModel]; 177 [super loadModel];
177 CollectionViewModel* model = self.collectionViewModel; 178 CollectionViewModel* model = self.collectionViewModel;
178 179
179 std::string locale = GetApplicationContext()->GetApplicationLocale(); 180 std::string locale = GetApplicationContext()->GetApplicationLocale();
180 [model addSectionWithIdentifier:SectionIdentifierFields]; 181 [model addSectionWithIdentifier:SectionIdentifierFields];
181 for (size_t i = 0; i < arraysize(kFieldsToDisplay); ++i) { 182 for (size_t i = 0; i < arraysize(kFieldsToDisplay); ++i) {
182 const AutofillFieldDisplayInfo& field = kFieldsToDisplay[i]; 183 const AutofillFieldDisplayInfo& field = kFieldsToDisplay[i];
183 AutofillEditItem* item = 184 AutofillEditItem* item =
184 [[[AutofillEditItem alloc] initWithType:ItemTypeField] autorelease]; 185 [[AutofillEditItem alloc] initWithType:ItemTypeField];
185 item.textFieldName = l10n_util::GetNSString(field.displayStringID); 186 item.textFieldName = l10n_util::GetNSString(field.displayStringID);
186 item.textFieldValue = base::SysUTF16ToNSString(_autofillProfile.GetInfo( 187 item.textFieldValue = base::SysUTF16ToNSString(_autofillProfile.GetInfo(
187 autofill::AutofillType(field.autofillType), locale)); 188 autofill::AutofillType(field.autofillType), locale));
188 item.autofillUIType = AutofillUITypeFromAutofillType(field.autofillType); 189 item.autofillUIType = AutofillUITypeFromAutofillType(field.autofillType);
189 item.textFieldEnabled = self.editor.editing; 190 item.textFieldEnabled = self.editor.editing;
190 [model addItem:item toSectionWithIdentifier:SectionIdentifierFields]; 191 [model addItem:item toSectionWithIdentifier:SectionIdentifierFields];
191 } 192 }
192 } 193 }
193 194
194 #pragma mark - MDCCollectionViewEditingDelegate 195 #pragma mark - MDCCollectionViewEditingDelegate
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 [self.collectionView cellForItemAtIndexPath:indexPath]; 236 [self.collectionView cellForItemAtIndexPath:indexPath];
236 AutofillEditCell* textFieldCell = 237 AutofillEditCell* textFieldCell =
237 base::mac::ObjCCastStrict<AutofillEditCell>(cell); 238 base::mac::ObjCCastStrict<AutofillEditCell>(cell);
238 [textFieldCell.textField becomeFirstResponder]; 239 [textFieldCell.textField becomeFirstResponder];
239 } 240 }
240 return [super collectionView:collectionView 241 return [super collectionView:collectionView
241 shouldSelectItemAtIndexPath:indexPath]; 242 shouldSelectItemAtIndexPath:indexPath];
242 } 243 }
243 244
244 @end 245 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698