| 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 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 keychain_(keychain.Pass()), | 915 keychain_(keychain.Pass()), |
| 916 login_metadata_db_(login_db.Pass()) { | 916 login_metadata_db_(login_db.Pass()) { |
| 917 DCHECK(keychain_.get()); | 917 DCHECK(keychain_.get()); |
| 918 DCHECK(login_metadata_db_.get()); | 918 DCHECK(login_metadata_db_.get()); |
| 919 } | 919 } |
| 920 | 920 |
| 921 PasswordStoreMac::~PasswordStoreMac() {} | 921 PasswordStoreMac::~PasswordStoreMac() {} |
| 922 | 922 |
| 923 bool PasswordStoreMac::Init( | 923 bool PasswordStoreMac::Init( |
| 924 const syncer::SyncableService::StartSyncFlare& flare) { | 924 const syncer::SyncableService::StartSyncFlare& flare) { |
| 925 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 925 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 926 thread_.reset(new base::Thread("Chrome_PasswordStore_Thread")); | 926 thread_.reset(new base::Thread("Chrome_PasswordStore_Thread")); |
| 927 | 927 |
| 928 if (!thread_->Start()) { | 928 if (!thread_->Start()) { |
| 929 thread_.reset(NULL); | 929 thread_.reset(NULL); |
| 930 return false; | 930 return false; |
| 931 } | 931 } |
| 932 | 932 |
| 933 ScheduleTask(base::Bind(&PasswordStoreMac::InitOnBackgroundThread, this)); | 933 ScheduleTask(base::Bind(&PasswordStoreMac::InitOnBackgroundThread, this)); |
| 934 return password_manager::PasswordStore::Init(flare); | 934 return password_manager::PasswordStore::Init(flare); |
| 935 } | 935 } |
| 936 | 936 |
| 937 void PasswordStoreMac::InitOnBackgroundThread() { | 937 void PasswordStoreMac::InitOnBackgroundThread() { |
| 938 DCHECK(thread_->message_loop() == base::MessageLoop::current()); | 938 DCHECK(thread_->message_loop() == base::MessageLoop::current()); |
| 939 DCHECK(login_metadata_db_); | 939 DCHECK(login_metadata_db_); |
| 940 if (!login_metadata_db_->Init()) { | 940 if (!login_metadata_db_->Init()) { |
| 941 login_metadata_db_.reset(); | 941 login_metadata_db_.reset(); |
| 942 LOG(ERROR) << "Could not create/open login database."; | 942 LOG(ERROR) << "Could not create/open login database."; |
| 943 } | 943 } |
| 944 } | 944 } |
| 945 | 945 |
| 946 void PasswordStoreMac::Shutdown() { | 946 void PasswordStoreMac::Shutdown() { |
| 947 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 947 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 948 password_manager::PasswordStore::Shutdown(); | 948 password_manager::PasswordStore::Shutdown(); |
| 949 thread_->Stop(); | 949 thread_->Stop(); |
| 950 } | 950 } |
| 951 | 951 |
| 952 // Mac stores passwords in the system keychain, which can block for an | 952 // Mac stores passwords in the system keychain, which can block for an |
| 953 // arbitrarily long time (most notably, it can block on user confirmation | 953 // arbitrarily long time (most notably, it can block on user confirmation |
| 954 // from a dialog). Run tasks on a dedicated thread to avoid blocking the DB | 954 // from a dialog). Run tasks on a dedicated thread to avoid blocking the DB |
| 955 // thread. | 955 // thread. |
| 956 scoped_refptr<base::SingleThreadTaskRunner> | 956 scoped_refptr<base::SingleThreadTaskRunner> |
| 957 PasswordStoreMac::GetBackgroundTaskRunner() { | 957 PasswordStoreMac::GetBackgroundTaskRunner() { |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 ScopedVector<PasswordForm> forms_with_keychain_entry; | 1239 ScopedVector<PasswordForm> forms_with_keychain_entry; |
| 1240 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, | 1240 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, |
| 1241 &forms_with_keychain_entry); | 1241 &forms_with_keychain_entry); |
| 1242 | 1242 |
| 1243 // Clean up any orphaned database entries. | 1243 // Clean up any orphaned database entries. |
| 1244 RemoveDatabaseForms(&database_forms); | 1244 RemoveDatabaseForms(&database_forms); |
| 1245 | 1245 |
| 1246 // Move the orphaned DB forms to the output parameter. | 1246 // Move the orphaned DB forms to the output parameter. |
| 1247 AppendSecondToFirst(orphaned_forms, &database_forms); | 1247 AppendSecondToFirst(orphaned_forms, &database_forms); |
| 1248 } | 1248 } |
| OLD | NEW |