| 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/save_passwords_collection_view_controlle
r.h" | 5 #import "ios/chrome/browser/ui/settings/save_passwords_collection_view_controlle
r.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/ios/ios_util.h" | 10 #include "base/ios/ios_util.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "components/strings/grit/components_strings.h" | 30 #include "components/strings/grit/components_strings.h" |
| 31 #include "components/url_formatter/url_formatter.h" | 31 #include "components/url_formatter/url_formatter.h" |
| 32 #include "ios/chrome/browser/application_context.h" | 32 #include "ios/chrome/browser/application_context.h" |
| 33 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 33 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 34 #include "ios/chrome/browser/experimental_flags.h" | 34 #include "ios/chrome/browser/experimental_flags.h" |
| 35 #include "ios/chrome/browser/passwords/ios_chrome_password_store_factory.h" | 35 #include "ios/chrome/browser/passwords/ios_chrome_password_store_factory.h" |
| 36 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom
e.h" | 36 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom
e.h" |
| 37 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item
.h" | 37 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_footer_item
.h" |
| 38 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" | 38 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" |
| 39 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item
.h" | 39 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_switch_item
.h" |
| 40 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_cell.h
" |
| 40 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h
" | 41 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h
" |
| 41 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" | 42 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" |
| 42 #import "ios/chrome/browser/ui/settings/password_details_collection_view_control
ler.h" | 43 #import "ios/chrome/browser/ui/settings/password_details_collection_view_control
ler.h" |
| 43 #import "ios/chrome/browser/ui/settings/reauthentication_module.h" | 44 #import "ios/chrome/browser/ui/settings/reauthentication_module.h" |
| 44 #import "ios/chrome/browser/ui/settings/settings_utils.h" | 45 #import "ios/chrome/browser/ui/settings/settings_utils.h" |
| 45 #import "ios/chrome/browser/ui/settings/utils/pref_backed_boolean.h" | 46 #import "ios/chrome/browser/ui/settings/utils/pref_backed_boolean.h" |
| 46 #include "ios/chrome/grit/ios_strings.h" | 47 #include "ios/chrome/grit/ios_strings.h" |
| 47 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" | 48 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" |
| 49 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
| 48 #include "ui/base/l10n/l10n_util_mac.h" | 50 #include "ui/base/l10n/l10n_util_mac.h" |
| 49 #include "url/gurl.h" | 51 #include "url/gurl.h" |
| 50 | 52 |
| 51 namespace { | 53 namespace { |
| 52 | 54 |
| 53 typedef NS_ENUM(NSInteger, SectionIdentifier) { | 55 typedef NS_ENUM(NSInteger, SectionIdentifier) { |
| 54 SectionIdentifierMessage = kSectionIdentifierEnumZero, | 56 SectionIdentifierMessage = kSectionIdentifierEnumZero, |
| 55 SectionIdentifierSavePasswordsSwitch, | 57 SectionIdentifierSavePasswordsSwitch, |
| 56 SectionIdentifierSavedPasswords, | 58 SectionIdentifierSavedPasswords, |
| 57 SectionIdentifierBlacklist, | 59 SectionIdentifierBlacklist, |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 toSectionWithIdentifier:SectionIdentifierSavePasswordsSwitch]; | 229 toSectionWithIdentifier:SectionIdentifierSavePasswordsSwitch]; |
| 228 | 230 |
| 229 // Saved passwords. | 231 // Saved passwords. |
| 230 if ([passwordManagerEnabled_ value]) { | 232 if ([passwordManagerEnabled_ value]) { |
| 231 if (!savedForms_.empty()) { | 233 if (!savedForms_.empty()) { |
| 232 [model addSectionWithIdentifier:SectionIdentifierSavedPasswords]; | 234 [model addSectionWithIdentifier:SectionIdentifierSavedPasswords]; |
| 233 CollectionViewTextItem* headerItem = [[[CollectionViewTextItem alloc] | 235 CollectionViewTextItem* headerItem = [[[CollectionViewTextItem alloc] |
| 234 initWithType:ItemTypeHeader] autorelease]; | 236 initWithType:ItemTypeHeader] autorelease]; |
| 235 headerItem.text = | 237 headerItem.text = |
| 236 l10n_util::GetNSString(IDS_PASSWORD_MANAGER_SHOW_PASSWORDS_TAB_TITLE); | 238 l10n_util::GetNSString(IDS_PASSWORD_MANAGER_SHOW_PASSWORDS_TAB_TITLE); |
| 237 headerItem.textColor = [[MDCPalette greyPalette] tint500]; | |
| 238 [model setHeader:headerItem | 239 [model setHeader:headerItem |
| 239 forSectionWithIdentifier:SectionIdentifierSavedPasswords]; | 240 forSectionWithIdentifier:SectionIdentifierSavedPasswords]; |
| 240 for (const auto& form : savedForms_) { | 241 for (const auto& form : savedForms_) { |
| 241 [model addItem:[self savedFormItemWithForm:form.get()] | 242 [model addItem:[self savedFormItemWithForm:form.get()] |
| 242 toSectionWithIdentifier:SectionIdentifierSavedPasswords]; | 243 toSectionWithIdentifier:SectionIdentifierSavedPasswords]; |
| 243 } | 244 } |
| 244 } | 245 } |
| 245 if (!blacklistedForms_.empty()) { | 246 if (!blacklistedForms_.empty()) { |
| 246 [model addSectionWithIdentifier:SectionIdentifierBlacklist]; | 247 [model addSectionWithIdentifier:SectionIdentifierBlacklist]; |
| 247 CollectionViewTextItem* headerItem = [[[CollectionViewTextItem alloc] | 248 CollectionViewTextItem* headerItem = [[[CollectionViewTextItem alloc] |
| 248 initWithType:ItemTypeHeader] autorelease]; | 249 initWithType:ItemTypeHeader] autorelease]; |
| 249 headerItem.text = | 250 headerItem.text = |
| 250 l10n_util::GetNSString(IDS_PASSWORD_MANAGER_EXCEPTIONS_TAB_TITLE); | 251 l10n_util::GetNSString(IDS_PASSWORD_MANAGER_EXCEPTIONS_TAB_TITLE); |
| 251 headerItem.textColor = [[MDCPalette greyPalette] tint500]; | |
| 252 [model setHeader:headerItem | 252 [model setHeader:headerItem |
| 253 forSectionWithIdentifier:SectionIdentifierBlacklist]; | 253 forSectionWithIdentifier:SectionIdentifierBlacklist]; |
| 254 for (const auto& form : blacklistedForms_) { | 254 for (const auto& form : blacklistedForms_) { |
| 255 [model addItem:[self blacklistedFormItemWithForm:form.get()] | 255 [model addItem:[self blacklistedFormItemWithForm:form.get()] |
| 256 toSectionWithIdentifier:SectionIdentifierBlacklist]; | 256 toSectionWithIdentifier:SectionIdentifierBlacklist]; |
| 257 } | 257 } |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 } | 260 } |
| 261 | 261 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 } | 368 } |
| 369 } | 369 } |
| 370 | 370 |
| 371 #pragma mark - UICollectionViewDataSource | 371 #pragma mark - UICollectionViewDataSource |
| 372 | 372 |
| 373 - (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView | 373 - (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView |
| 374 cellForItemAtIndexPath:(NSIndexPath*)indexPath { | 374 cellForItemAtIndexPath:(NSIndexPath*)indexPath { |
| 375 UICollectionViewCell* cell = | 375 UICollectionViewCell* cell = |
| 376 [super collectionView:collectionView cellForItemAtIndexPath:indexPath]; | 376 [super collectionView:collectionView cellForItemAtIndexPath:indexPath]; |
| 377 | 377 |
| 378 if ([self.collectionViewModel itemTypeForIndexPath:indexPath] == | 378 NSInteger itemType = |
| 379 ItemTypeSavePasswordsSwitch) { | 379 [self.collectionViewModel itemTypeForIndexPath:indexPath]; |
| 380 |
| 381 if (itemType == ItemTypeSavePasswordsSwitch) { |
| 380 CollectionViewSwitchCell* switchCell = | 382 CollectionViewSwitchCell* switchCell = |
| 381 base::mac::ObjCCastStrict<CollectionViewSwitchCell>(cell); | 383 base::mac::ObjCCastStrict<CollectionViewSwitchCell>(cell); |
| 382 [switchCell.switchView addTarget:self | 384 [switchCell.switchView addTarget:self |
| 383 action:@selector(savePasswordsSwitchChanged:) | 385 action:@selector(savePasswordsSwitchChanged:) |
| 384 forControlEvents:UIControlEventValueChanged]; | 386 forControlEvents:UIControlEventValueChanged]; |
| 387 } else if (itemType == ItemTypeHeader || itemType == ItemTypeSavedPassword || |
| 388 itemType == ItemTypeBlacklisted) { |
| 389 CollectionViewTextCell* textCell = |
| 390 base::mac::ObjCCastStrict<CollectionViewTextCell>(cell); |
| 391 textCell.textLabel.font = [MDCTypography body2Font]; |
| 392 if (itemType == ItemTypeHeader) |
| 393 textCell.textLabel.textColor = [[MDCPalette greyPalette] tint500]; |
| 394 else |
| 395 textCell.textLabel.textColor = [[MDCPalette greyPalette] tint900]; |
| 396 textCell.detailTextLabel.font = [MDCTypography body1Font]; |
| 397 textCell.detailTextLabel.textColor = [[MDCPalette greyPalette] tint500]; |
| 385 } | 398 } |
| 386 return cell; | 399 return cell; |
| 387 } | 400 } |
| 388 | 401 |
| 389 #pragma mark - BooleanObserver | 402 #pragma mark - BooleanObserver |
| 390 | 403 |
| 391 - (void)booleanDidChange:(id<ObservableBoolean>)observableBoolean { | 404 - (void)booleanDidChange:(id<ObservableBoolean>)observableBoolean { |
| 392 DCHECK_EQ(observableBoolean, passwordManagerEnabled_.get()); | 405 DCHECK_EQ(observableBoolean, passwordManagerEnabled_.get()); |
| 393 | 406 |
| 394 // Update the item. | 407 // Update the item. |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 | 608 |
| 596 - (void)updateSuccessfulReauthTime { | 609 - (void)updateSuccessfulReauthTime { |
| 597 successfulReauthTime_.reset([[NSDate alloc] init]); | 610 successfulReauthTime_.reset([[NSDate alloc] init]); |
| 598 } | 611 } |
| 599 | 612 |
| 600 - (NSDate*)lastSuccessfulReauthTime { | 613 - (NSDate*)lastSuccessfulReauthTime { |
| 601 return successfulReauthTime_.get(); | 614 return successfulReauthTime_.get(); |
| 602 } | 615 } |
| 603 | 616 |
| 604 @end | 617 @end |
| OLD | NEW |