OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/password_manager/password_store_mac.h" | 5 #include "chrome/browser/password_manager/password_store_mac.h" |
6 #include "chrome/browser/password_manager/password_store_mac_internal.h" | 6 #include "chrome/browser/password_manager/password_store_mac_internal.h" |
7 | 7 |
8 #include <CoreServices/CoreServices.h> | 8 #include <CoreServices/CoreServices.h> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 : password_manager::PasswordStore(main_thread_runner, db_thread_runner), | 953 : password_manager::PasswordStore(main_thread_runner, db_thread_runner), |
954 keychain_(keychain.Pass()), | 954 keychain_(keychain.Pass()), |
955 login_metadata_db_(nullptr) { | 955 login_metadata_db_(nullptr) { |
956 DCHECK(keychain_); | 956 DCHECK(keychain_); |
957 } | 957 } |
958 | 958 |
959 PasswordStoreMac::~PasswordStoreMac() {} | 959 PasswordStoreMac::~PasswordStoreMac() {} |
960 | 960 |
961 void PasswordStoreMac::InitWithTaskRunner( | 961 void PasswordStoreMac::InitWithTaskRunner( |
962 scoped_refptr<base::SingleThreadTaskRunner> background_task_runner) { | 962 scoped_refptr<base::SingleThreadTaskRunner> background_task_runner) { |
963 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
964 db_thread_runner_ = background_task_runner; | 963 db_thread_runner_ = background_task_runner; |
| 964 DCHECK(GetBackgroundTaskRunner()->BelongsToCurrentThread()); |
965 } | 965 } |
966 | 966 |
967 PasswordStoreMac::MigrationResult PasswordStoreMac::ImportFromKeychain() { | 967 PasswordStoreMac::MigrationResult PasswordStoreMac::ImportFromKeychain() { |
968 DCHECK(GetBackgroundTaskRunner()->BelongsToCurrentThread()); | 968 DCHECK(GetBackgroundTaskRunner()->BelongsToCurrentThread()); |
969 if (!login_metadata_db_) | 969 if (!login_metadata_db_) |
970 return LOGIN_DB_UNAVAILABLE; | 970 return LOGIN_DB_UNAVAILABLE; |
971 | 971 |
972 ScopedVector<PasswordForm> database_forms; | 972 ScopedVector<PasswordForm> database_forms; |
973 if (!login_metadata_db_->GetAutofillableLogins(&database_forms)) | 973 if (!login_metadata_db_->GetAutofillableLogins(&database_forms)) |
974 return LOGIN_DB_FAILURE; | 974 return LOGIN_DB_FAILURE; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 // Now all the passwords are available. It's time to update LoginDatabase. | 1043 // Now all the passwords are available. It's time to update LoginDatabase. |
1044 login_metadata_db_->set_clear_password_values(false); | 1044 login_metadata_db_->set_clear_password_values(false); |
1045 for (PasswordForm* form : database_forms) | 1045 for (PasswordForm* form : database_forms) |
1046 login_metadata_db_->UpdateLogin(*form); | 1046 login_metadata_db_->UpdateLogin(*form); |
1047 return MIGRATION_OK; | 1047 return MIGRATION_OK; |
1048 } | 1048 } |
1049 | 1049 |
1050 void PasswordStoreMac::set_login_metadata_db( | 1050 void PasswordStoreMac::set_login_metadata_db( |
1051 password_manager::LoginDatabase* login_db) { | 1051 password_manager::LoginDatabase* login_db) { |
1052 login_metadata_db_ = login_db; | 1052 login_metadata_db_ = login_db; |
1053 login_metadata_db_->set_clear_password_values(true); | 1053 if (login_metadata_db_) |
| 1054 login_metadata_db_->set_clear_password_values(true); |
1054 } | 1055 } |
1055 | 1056 |
1056 bool PasswordStoreMac::Init( | 1057 bool PasswordStoreMac::Init( |
1057 const syncer::SyncableService::StartSyncFlare& flare) { | 1058 const syncer::SyncableService::StartSyncFlare& flare) { |
1058 // The class should be used inside PasswordStoreProxyMac only. | 1059 // The class should be used inside PasswordStoreProxyMac only. |
1059 NOTREACHED(); | 1060 NOTREACHED(); |
1060 return true; | 1061 return true; |
1061 } | 1062 } |
1062 | 1063 |
1063 void PasswordStoreMac::ReportMetricsImpl(const std::string& sync_username, | 1064 void PasswordStoreMac::ReportMetricsImpl(const std::string& sync_username, |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 ScopedVector<PasswordForm> forms_with_keychain_entry; | 1325 ScopedVector<PasswordForm> forms_with_keychain_entry; |
1325 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, | 1326 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, |
1326 &forms_with_keychain_entry); | 1327 &forms_with_keychain_entry); |
1327 | 1328 |
1328 // Clean up any orphaned database entries. | 1329 // Clean up any orphaned database entries. |
1329 RemoveDatabaseForms(&database_forms); | 1330 RemoveDatabaseForms(&database_forms); |
1330 | 1331 |
1331 // Move the orphaned DB forms to the output parameter. | 1332 // Move the orphaned DB forms to the output parameter. |
1332 AppendSecondToFirst(orphaned_forms, &database_forms); | 1333 AppendSecondToFirst(orphaned_forms, &database_forms); |
1333 } | 1334 } |
OLD | NEW |