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