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/block_popups_collection_view_controller.
h" | 5 #import "ios/chrome/browser/ui/settings/block_popups_collection_view_controller.
h" |
6 | 6 |
7 #import "base/ios/weak_nsobject.h" | 7 #import "base/ios/weak_nsobject.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #import "base/mac/foundation_util.h" | 9 #import "base/mac/foundation_util.h" |
10 #import "base/mac/scoped_nsobject.h" | 10 #import "base/mac/scoped_nsobject.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 ItemTypeMainSwitch) { | 139 ItemTypeMainSwitch) { |
140 CollectionViewSwitchCell* switchCell = | 140 CollectionViewSwitchCell* switchCell = |
141 base::mac::ObjCCastStrict<CollectionViewSwitchCell>(cell); | 141 base::mac::ObjCCastStrict<CollectionViewSwitchCell>(cell); |
142 [switchCell.switchView addTarget:self | 142 [switchCell.switchView addTarget:self |
143 action:@selector(blockPopupsSwitchChanged:) | 143 action:@selector(blockPopupsSwitchChanged:) |
144 forControlEvents:UIControlEventValueChanged]; | 144 forControlEvents:UIControlEventValueChanged]; |
145 } | 145 } |
146 return cell; | 146 return cell; |
147 } | 147 } |
148 | 148 |
149 - (UICollectionReusableView*)collectionView:(UICollectionView*)collectionView | |
150 viewForSupplementaryElementOfKind:(NSString*)kind | |
151 atIndexPath:(NSIndexPath*)indexPath { | |
152 UICollectionReusableView* view = [super collectionView:collectionView | |
153 viewForSupplementaryElementOfKind:kind | |
154 atIndexPath:indexPath]; | |
155 MDCCollectionViewTextCell* textCell = | |
156 base::mac::ObjCCast<MDCCollectionViewTextCell>(view); | |
157 if (textCell) { | |
158 textCell.textLabel.textColor = [[MDCPalette greyPalette] tint500]; | |
159 } | |
160 return view; | |
161 }; | |
162 | |
163 #pragma mark - MDCCollectionViewEditingDelegate | 149 #pragma mark - MDCCollectionViewEditingDelegate |
164 | 150 |
165 - (BOOL)collectionView:(UICollectionView*)collectionView | 151 - (BOOL)collectionView:(UICollectionView*)collectionView |
166 canEditItemAtIndexPath:(NSIndexPath*)indexPath { | 152 canEditItemAtIndexPath:(NSIndexPath*)indexPath { |
167 // Any item in SectionIdentifierExceptions is editable. | 153 // Any item in SectionIdentifierExceptions is editable. |
168 return [self.collectionViewModel | 154 return [self.collectionViewModel |
169 sectionIdentifierForSection:indexPath.section] == | 155 sectionIdentifierForSection:indexPath.section] == |
170 SectionIdentifierExceptions; | 156 SectionIdentifierExceptions; |
171 } | 157 } |
172 | 158 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 } | 290 } |
305 } | 291 } |
306 | 292 |
307 - (void)populateExceptionsItems { | 293 - (void)populateExceptionsItems { |
308 CollectionViewModel* model = self.collectionViewModel; | 294 CollectionViewModel* model = self.collectionViewModel; |
309 [model addSectionWithIdentifier:SectionIdentifierExceptions]; | 295 [model addSectionWithIdentifier:SectionIdentifierExceptions]; |
310 | 296 |
311 CollectionViewTextItem* header = [ | 297 CollectionViewTextItem* header = [ |
312 [[CollectionViewTextItem alloc] initWithType:ItemTypeHeader] autorelease]; | 298 [[CollectionViewTextItem alloc] initWithType:ItemTypeHeader] autorelease]; |
313 header.text = l10n_util::GetNSString(IDS_IOS_POPUPS_ALLOWED); | 299 header.text = l10n_util::GetNSString(IDS_IOS_POPUPS_ALLOWED); |
| 300 header.textColor = [[MDCPalette greyPalette] tint500]; |
314 [model setHeader:header forSectionWithIdentifier:SectionIdentifierExceptions]; | 301 [model setHeader:header forSectionWithIdentifier:SectionIdentifierExceptions]; |
315 | 302 |
316 for (size_t i = 0; i < _exceptions.GetSize(); ++i) { | 303 for (size_t i = 0; i < _exceptions.GetSize(); ++i) { |
317 std::string allowed_url; | 304 std::string allowed_url; |
318 _exceptions.GetString(i, &allowed_url); | 305 _exceptions.GetString(i, &allowed_url); |
319 CollectionViewTextItem* item = [[[CollectionViewTextItem alloc] | 306 CollectionViewTextItem* item = [[[CollectionViewTextItem alloc] |
320 initWithType:ItemTypeException] autorelease]; | 307 initWithType:ItemTypeException] autorelease]; |
321 item.text = base::SysUTF8ToNSString(allowed_url); | 308 item.text = base::SysUTF8ToNSString(allowed_url); |
322 [model addItem:item toSectionWithIdentifier:SectionIdentifierExceptions]; | 309 [model addItem:item toSectionWithIdentifier:SectionIdentifierExceptions]; |
323 } | 310 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 [[strongSelf collectionViewModel] | 344 [[strongSelf collectionViewModel] |
358 removeSectionWithIdentifier:SectionIdentifierExceptions]; | 345 removeSectionWithIdentifier:SectionIdentifierExceptions]; |
359 [[strongSelf collectionView] | 346 [[strongSelf collectionView] |
360 deleteSections:[NSIndexSet indexSetWithIndex:index]]; | 347 deleteSections:[NSIndexSet indexSetWithIndex:index]]; |
361 } | 348 } |
362 completion:nil]; | 349 completion:nil]; |
363 } | 350 } |
364 } | 351 } |
365 | 352 |
366 @end | 353 @end |
OLD | NEW |