| 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 | 8 |
| 9 #include "base/ios/ios_util.h" | 9 #include "base/ios/ios_util.h" |
| 10 #include "base/ios/weak_nsobject.h" | 10 #include "base/ios/weak_nsobject.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/mac/foundation_util.h" | 12 #include "base/mac/foundation_util.h" |
| 13 #include "base/mac/objc_property_releaser.h" | 13 #include "base/mac/objc_release_properties.h" |
| 14 #include "base/mac/scoped_nsobject.h" | 14 #include "base/mac/scoped_nsobject.h" |
| 15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
| 16 #include "base/numerics/safe_conversions.h" | 16 #include "base/numerics/safe_conversions.h" |
| 17 #include "base/strings/sys_string_conversions.h" | 17 #include "base/strings/sys_string_conversions.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "components/autofill/core/common/password_form.h" | 19 #include "components/autofill/core/common/password_form.h" |
| 20 #include "components/google/core/browser/google_util.h" | 20 #include "components/google/core/browser/google_util.h" |
| 21 #include "components/keyed_service/core/service_access_type.h" | 21 #include "components/keyed_service/core/service_access_type.h" |
| 22 #include "components/password_manager/core/browser/affiliation_utils.h" | 22 #include "components/password_manager/core/browser/affiliation_utils.h" |
| 23 #include "components/password_manager/core/browser/password_manager_constants.h" | 23 #include "components/password_manager/core/browser/password_manager_constants.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 // The current Chrome browser state. | 154 // The current Chrome browser state. |
| 155 ios::ChromeBrowserState* browserState_; | 155 ios::ChromeBrowserState* browserState_; |
| 156 // Object storing the time of the previous successful re-authentication. | 156 // Object storing the time of the previous successful re-authentication. |
| 157 // This is meant to be used by the |ReauthenticationModule| for keeping | 157 // This is meant to be used by the |ReauthenticationModule| for keeping |
| 158 // re-authentications valid for a certain time interval within the scope | 158 // re-authentications valid for a certain time interval within the scope |
| 159 // of the Save Passwords Settings. | 159 // of the Save Passwords Settings. |
| 160 base::scoped_nsobject<NSDate> successfulReauthTime_; | 160 base::scoped_nsobject<NSDate> successfulReauthTime_; |
| 161 // Module containing the reauthentication mechanism for viewing and copying | 161 // Module containing the reauthentication mechanism for viewing and copying |
| 162 // passwords. | 162 // passwords. |
| 163 base::scoped_nsobject<ReauthenticationModule> reauthenticationModule_; | 163 base::scoped_nsobject<ReauthenticationModule> reauthenticationModule_; |
| 164 | |
| 165 base::mac::ObjCPropertyReleaser | |
| 166 propertyReleaser_SavePasswordsCollectionViewController_; | |
| 167 } | 164 } |
| 168 // Kick off async request to get logins from password store. | 165 // Kick off async request to get logins from password store. |
| 169 - (void)getLoginsFromPasswordStore; | 166 - (void)getLoginsFromPasswordStore; |
| 170 @end | 167 @end |
| 171 | 168 |
| 172 @implementation SavePasswordsCollectionViewController | 169 @implementation SavePasswordsCollectionViewController |
| 173 | 170 |
| 174 #pragma mark - Initialization | 171 #pragma mark - Initialization |
| 175 | 172 |
| 176 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState { | 173 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState { |
| 177 DCHECK(browserState); | 174 DCHECK(browserState); |
| 178 self = [super initWithStyle:CollectionViewControllerStyleAppBar]; | 175 self = [super initWithStyle:CollectionViewControllerStyleAppBar]; |
| 179 if (self) { | 176 if (self) { |
| 180 browserState_ = browserState; | 177 browserState_ = browserState; |
| 181 reauthenticationModule_.reset([[ReauthenticationModule alloc] | 178 reauthenticationModule_.reset([[ReauthenticationModule alloc] |
| 182 initWithSuccessfulReauthTimeAccessor:self]); | 179 initWithSuccessfulReauthTimeAccessor:self]); |
| 183 self.title = l10n_util::GetNSString(IDS_IOS_SAVE_PASSWORDS); | 180 self.title = l10n_util::GetNSString(IDS_IOS_SAVE_PASSWORDS); |
| 184 self.shouldHideDoneButton = YES; | 181 self.shouldHideDoneButton = YES; |
| 185 passwordStore_ = IOSChromePasswordStoreFactory::GetForBrowserState( | 182 passwordStore_ = IOSChromePasswordStoreFactory::GetForBrowserState( |
| 186 browserState_, ServiceAccessType::EXPLICIT_ACCESS); | 183 browserState_, ServiceAccessType::EXPLICIT_ACCESS); |
| 187 DCHECK(passwordStore_); | 184 DCHECK(passwordStore_); |
| 188 passwordManagerEnabled_.reset([[PrefBackedBoolean alloc] | 185 passwordManagerEnabled_.reset([[PrefBackedBoolean alloc] |
| 189 initWithPrefService:browserState_->GetPrefs() | 186 initWithPrefService:browserState_->GetPrefs() |
| 190 prefName:password_manager::prefs:: | 187 prefName:password_manager::prefs:: |
| 191 kPasswordManagerSavingEnabled]); | 188 kPasswordManagerSavingEnabled]); |
| 192 [passwordManagerEnabled_ setObserver:self]; | 189 [passwordManagerEnabled_ setObserver:self]; |
| 193 [self getLoginsFromPasswordStore]; | 190 [self getLoginsFromPasswordStore]; |
| 194 [self updateEditButton]; | 191 [self updateEditButton]; |
| 195 [self loadModel]; | 192 [self loadModel]; |
| 196 | |
| 197 propertyReleaser_SavePasswordsCollectionViewController_.Init( | |
| 198 self, [SavePasswordsCollectionViewController class]); | |
| 199 } | 193 } |
| 200 return self; | 194 return self; |
| 201 } | 195 } |
| 202 | 196 |
| 203 - (void)dealloc { | 197 - (void)dealloc { |
| 204 [passwordManagerEnabled_ setObserver:nil]; | 198 [passwordManagerEnabled_ setObserver:nil]; |
| 199 base::mac::ReleaseProperties(self); |
| 205 [super dealloc]; | 200 [super dealloc]; |
| 206 } | 201 } |
| 207 | 202 |
| 208 #pragma mark - SettingsRootCollectionViewController | 203 #pragma mark - SettingsRootCollectionViewController |
| 209 | 204 |
| 210 - (void)loadModel { | 205 - (void)loadModel { |
| 211 [super loadModel]; | 206 [super loadModel]; |
| 212 CollectionViewModel* model = self.collectionViewModel; | 207 CollectionViewModel* model = self.collectionViewModel; |
| 213 | 208 |
| 214 // Manage account message. | 209 // Manage account message. |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 | 603 |
| 609 - (void)updateSuccessfulReauthTime { | 604 - (void)updateSuccessfulReauthTime { |
| 610 successfulReauthTime_.reset([[NSDate alloc] init]); | 605 successfulReauthTime_.reset([[NSDate alloc] init]); |
| 611 } | 606 } |
| 612 | 607 |
| 613 - (NSDate*)lastSuccessfulReauthTime { | 608 - (NSDate*)lastSuccessfulReauthTime { |
| 614 return successfulReauthTime_.get(); | 609 return successfulReauthTime_.get(); |
| 615 } | 610 } |
| 616 | 611 |
| 617 @end | 612 @end |
| OLD | NEW |