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

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

Issue 2934453004: [Autofill] Fixes bug where toggling Google Payments switch was crashing cr. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 296 }
297 } 297 }
298 completion:nil]; 298 completion:nil];
299 } 299 }
300 300
301 - (void)walletSwitchChanged:(UISwitch*)switchView { 301 - (void)walletSwitchChanged:(UISwitch*)switchView {
302 [self setSwitchItemOn:[switchView isOn] itemType:ItemTypeWalletSwitch]; 302 [self setSwitchItemOn:[switchView isOn] itemType:ItemTypeWalletSwitch];
303 _userInteractionInProgress = YES; 303 _userInteractionInProgress = YES;
304 [self setWalletEnabled:[switchView isOn]]; 304 [self setWalletEnabled:[switchView isOn]];
305 _userInteractionInProgress = NO; 305 _userInteractionInProgress = NO;
306 if ([switchView isOn]) {
307 [self insertCardSection];
308 } else {
309 [self removeCardSection];
310 }
311 } 306 }
312 307
313 #pragma mark - Switch Helpers 308 #pragma mark - Switch Helpers
314 309
315 // Sets switchItem's state to |on|. It is important that there is only one item 310 // Sets switchItem's state to |on|. It is important that there is only one item
316 // of |switchItemType| in SectionIdentifierSwitches. 311 // of |switchItemType| in SectionIdentifierSwitches.
317 - (void)setSwitchItemOn:(BOOL)on itemType:(ItemType)switchItemType { 312 - (void)setSwitchItemOn:(BOOL)on itemType:(ItemType)switchItemType {
318 NSIndexPath* switchPath = 313 NSIndexPath* switchPath =
319 [self.collectionViewModel indexPathForItemType:switchItemType 314 [self.collectionViewModel indexPathForItemType:switchItemType
320 sectionIdentifier:SectionIdentifierSwitches]; 315 sectionIdentifier:SectionIdentifierSwitches];
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 sectionForSectionIdentifier:SectionIdentifierProfiles]]; 377 sectionForSectionIdentifier:SectionIdentifierProfiles]];
383 } 378 }
384 if ([self.collectionViewModel 379 if ([self.collectionViewModel
385 hasSectionForSectionIdentifier:SectionIdentifierCards]) { 380 hasSectionForSectionIdentifier:SectionIdentifierCards]) {
386 [sections addIndex:[self.collectionViewModel 381 [sections addIndex:[self.collectionViewModel
387 sectionForSectionIdentifier:SectionIdentifierCards]]; 382 sectionForSectionIdentifier:SectionIdentifierCards]];
388 } 383 }
389 return sections; 384 return sections;
390 } 385 }
391 386
392 - (void)insertCardSection {
393 [self populateCardSection];
394 if ([self.collectionViewModel
395 hasSectionForSectionIdentifier:SectionIdentifierCards]) {
396 NSInteger section = [self.collectionViewModel
397 sectionForSectionIdentifier:SectionIdentifierCards];
398 [self.collectionView insertSections:[NSIndexSet indexSetWithIndex:section]];
399 }
400 }
401
402 - (void)removeCardSection {
403 if (![self.collectionViewModel
404 hasSectionForSectionIdentifier:SectionIdentifierCards]) {
405 return;
406 }
407 NSInteger section = [self.collectionViewModel
408 sectionForSectionIdentifier:SectionIdentifierCards];
409 [self.collectionViewModel removeSectionWithIdentifier:SectionIdentifierCards];
410 [self.collectionView deleteSections:[NSIndexSet indexSetWithIndex:section]];
411 }
412
413 #pragma mark - MDCCollectionViewStylingDelegate 387 #pragma mark - MDCCollectionViewStylingDelegate
414 388
415 - (CGFloat)collectionView:(UICollectionView*)collectionView 389 - (CGFloat)collectionView:(UICollectionView*)collectionView
416 cellHeightAtIndexPath:(NSIndexPath*)indexPath { 390 cellHeightAtIndexPath:(NSIndexPath*)indexPath {
417 CollectionViewItem* item = 391 CollectionViewItem* item =
418 [self.collectionViewModel itemAtIndexPath:indexPath]; 392 [self.collectionViewModel itemAtIndexPath:indexPath];
419 if (item.type == ItemTypeAddress || item.type == ItemTypeCard || 393 if (item.type == ItemTypeAddress || item.type == ItemTypeCard ||
420 item.type == ItemTypeWalletSwitch) { 394 item.type == ItemTypeWalletSwitch) {
421 return [MDCCollectionViewCell 395 return [MDCCollectionViewCell
422 cr_preferredHeightForWidth:CGRectGetWidth(collectionView.bounds) 396 cr_preferredHeightForWidth:CGRectGetWidth(collectionView.bounds)
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 return _browserState->GetPrefs()->GetBoolean( 577 return _browserState->GetPrefs()->GetBoolean(
604 autofill::prefs::kAutofillWalletImportEnabled); 578 autofill::prefs::kAutofillWalletImportEnabled);
605 } 579 }
606 580
607 - (void)setWalletEnabled:(BOOL)isEnabled { 581 - (void)setWalletEnabled:(BOOL)isEnabled {
608 _browserState->GetPrefs()->SetBoolean( 582 _browserState->GetPrefs()->SetBoolean(
609 autofill::prefs::kAutofillWalletImportEnabled, isEnabled); 583 autofill::prefs::kAutofillWalletImportEnabled, isEnabled);
610 } 584 }
611 585
612 @end 586 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698