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

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

Issue 2768933005: Use CollectionViewTextItem instead of a cast (Closed)
Patch Set: Remove MDFRoboto 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/clear_browsing_data_collection_view_cont roller.h" 5 #import "ios/chrome/browser/ui/settings/clear_browsing_data_collection_view_cont roller.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/ios/ios_util.h" 10 #include "base/ios/ios_util.h"
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 prefName:browsing_data::prefs::kDeleteFormData]; 325 prefName:browsing_data::prefs::kDeleteFormData];
326 [model addItem:autofillItem 326 [model addItem:autofillItem
327 toSectionWithIdentifier:SectionIdentifierDataTypes]; 327 toSectionWithIdentifier:SectionIdentifierDataTypes];
328 328
329 // Clear Browsing Data button. 329 // Clear Browsing Data button.
330 [model addSectionWithIdentifier:SectionIdentifierClearBrowsingDataButton]; 330 [model addSectionWithIdentifier:SectionIdentifierClearBrowsingDataButton];
331 CollectionViewTextItem* clearButtonItem = [[[CollectionViewTextItem alloc] 331 CollectionViewTextItem* clearButtonItem = [[[CollectionViewTextItem alloc]
332 initWithType:ItemTypeClearBrowsingDataButton] autorelease]; 332 initWithType:ItemTypeClearBrowsingDataButton] autorelease];
333 clearButtonItem.text = l10n_util::GetNSString(IDS_IOS_CLEAR_BUTTON); 333 clearButtonItem.text = l10n_util::GetNSString(IDS_IOS_CLEAR_BUTTON);
334 clearButtonItem.accessibilityTraits |= UIAccessibilityTraitButton; 334 clearButtonItem.accessibilityTraits |= UIAccessibilityTraitButton;
335 clearButtonItem.textColor = [[MDCPalette cr_redPalette] tint500];
335 [model addItem:clearButtonItem 336 [model addItem:clearButtonItem
336 toSectionWithIdentifier:SectionIdentifierClearBrowsingDataButton]; 337 toSectionWithIdentifier:SectionIdentifierClearBrowsingDataButton];
337 338
338 // Google Account footer. 339 // Google Account footer.
339 SigninManager* signinManager = 340 SigninManager* signinManager =
340 ios::SigninManagerFactory::GetForBrowserState(_browserState); 341 ios::SigninManagerFactory::GetForBrowserState(_browserState);
341 if (signinManager->IsAuthenticated()) { 342 if (signinManager->IsAuthenticated()) {
342 // TODO(crbug.com/650424): Footer items must currently go into a separate 343 // TODO(crbug.com/650424): Footer items must currently go into a separate
343 // section, to work around a drawing bug in MDC. 344 // section, to work around a drawing bug in MDC.
344 [model addSectionWithIdentifier:SectionIdentifierGoogleAccount]; 345 [model addSectionWithIdentifier:SectionIdentifierGoogleAccount];
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 NSString* detailText = [TimeRangeSelectorCollectionViewController 492 NSString* detailText = [TimeRangeSelectorCollectionViewController
492 timePeriodLabelForPrefs:_browserState->GetPrefs()]; 493 timePeriodLabelForPrefs:_browserState->GetPrefs()];
493 DCHECK(detailText); 494 DCHECK(detailText);
494 timeRangeItem.detailText = detailText; 495 timeRangeItem.detailText = detailText;
495 timeRangeItem.accessoryType = 496 timeRangeItem.accessoryType =
496 MDCCollectionViewCellAccessoryDisclosureIndicator; 497 MDCCollectionViewCellAccessoryDisclosureIndicator;
497 timeRangeItem.accessibilityTraits |= UIAccessibilityTraitButton; 498 timeRangeItem.accessibilityTraits |= UIAccessibilityTraitButton;
498 return timeRangeItem; 499 return timeRangeItem;
499 } 500 }
500 501
501 #pragma mark UICollectionViewDataSource
502
503 - (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView
504 cellForItemAtIndexPath:(NSIndexPath*)indexPath {
505 UICollectionViewCell* cell =
506 [super collectionView:collectionView cellForItemAtIndexPath:indexPath];
507
508 NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath];
509 if (type == ItemTypeClearBrowsingDataButton) {
510 MDCCollectionViewTextCell* textCell =
511 base::mac::ObjCCastStrict<MDCCollectionViewTextCell>(cell);
512 textCell.textLabel.textColor = [[MDCPalette cr_redPalette] tint500];
513 }
514
515 return cell;
516 }
517
518 #pragma mark UICollectionViewDelegate 502 #pragma mark UICollectionViewDelegate
519 503
520 - (void)collectionView:(UICollectionView*)collectionView 504 - (void)collectionView:(UICollectionView*)collectionView
521 didSelectItemAtIndexPath:(NSIndexPath*)indexPath { 505 didSelectItemAtIndexPath:(NSIndexPath*)indexPath {
522 [super collectionView:collectionView didSelectItemAtIndexPath:indexPath]; 506 [super collectionView:collectionView didSelectItemAtIndexPath:indexPath];
523 NSInteger itemType = 507 NSInteger itemType =
524 [self.collectionViewModel itemTypeForIndexPath:indexPath]; 508 [self.collectionViewModel itemTypeForIndexPath:indexPath];
525 509
526 switch (itemType) { 510 switch (itemType) {
527 case ItemTypeTimeRange: { 511 case ItemTypeTimeRange: {
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 879
896 #pragma mark TimeRangeSelectorCollectionViewControllerDelegate 880 #pragma mark TimeRangeSelectorCollectionViewControllerDelegate
897 881
898 - (void)timeRangeSelectorViewController: 882 - (void)timeRangeSelectorViewController:
899 (TimeRangeSelectorCollectionViewController*)collectionViewController 883 (TimeRangeSelectorCollectionViewController*)collectionViewController
900 didSelectTimePeriod:(browsing_data::TimePeriod)timePeriod { 884 didSelectTimePeriod:(browsing_data::TimePeriod)timePeriod {
901 _timePeriod = timePeriod; 885 _timePeriod = timePeriod;
902 } 886 }
903 887
904 @end 888 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698