| 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 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 : password_manager::PasswordStore(main_thread_runner, db_thread_runner), | 868 : password_manager::PasswordStore(main_thread_runner, db_thread_runner), |
| 869 keychain_(keychain), | 869 keychain_(keychain), |
| 870 login_metadata_db_(login_db) { | 870 login_metadata_db_(login_db) { |
| 871 DCHECK(keychain_.get()); | 871 DCHECK(keychain_.get()); |
| 872 DCHECK(login_metadata_db_.get()); | 872 DCHECK(login_metadata_db_.get()); |
| 873 } | 873 } |
| 874 | 874 |
| 875 PasswordStoreMac::~PasswordStoreMac() {} | 875 PasswordStoreMac::~PasswordStoreMac() {} |
| 876 | 876 |
| 877 bool PasswordStoreMac::Init( | 877 bool PasswordStoreMac::Init( |
| 878 const syncer::SyncableService::StartSyncFlare& flare, | 878 const syncer::SyncableService::StartSyncFlare& flare) { |
| 879 const std::string& sync_username) { | |
| 880 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 879 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 881 thread_.reset(new base::Thread("Chrome_PasswordStore_Thread")); | 880 thread_.reset(new base::Thread("Chrome_PasswordStore_Thread")); |
| 882 | 881 |
| 883 if (!thread_->Start()) { | 882 if (!thread_->Start()) { |
| 884 thread_.reset(NULL); | 883 thread_.reset(NULL); |
| 885 return false; | 884 return false; |
| 886 } | 885 } |
| 887 return password_manager::PasswordStore::Init(flare, sync_username); | 886 return password_manager::PasswordStore::Init(flare); |
| 888 } | 887 } |
| 889 | 888 |
| 890 void PasswordStoreMac::Shutdown() { | 889 void PasswordStoreMac::Shutdown() { |
| 891 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 890 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 892 password_manager::PasswordStore::Shutdown(); | 891 password_manager::PasswordStore::Shutdown(); |
| 893 thread_->Stop(); | 892 thread_->Stop(); |
| 894 } | 893 } |
| 895 | 894 |
| 896 // Mac stores passwords in the system keychain, which can block for an | 895 // Mac stores passwords in the system keychain, which can block for an |
| 897 // arbitrarily long time (most notably, it can block on user confirmation | 896 // arbitrarily long time (most notably, it can block on user confirmation |
| 898 // from a dialog). Run tasks on a dedicated thread to avoid blocking the DB | 897 // from a dialog). Run tasks on a dedicated thread to avoid blocking the DB |
| 899 // thread. | 898 // thread. |
| 900 scoped_refptr<base::SingleThreadTaskRunner> | 899 scoped_refptr<base::SingleThreadTaskRunner> |
| 901 PasswordStoreMac::GetBackgroundTaskRunner() { | 900 PasswordStoreMac::GetBackgroundTaskRunner() { |
| 902 return (thread_.get()) ? thread_->message_loop_proxy() : NULL; | 901 return (thread_.get()) ? thread_->message_loop_proxy() : NULL; |
| 903 } | 902 } |
| 904 | 903 |
| 905 void PasswordStoreMac::ReportMetricsImpl(const std::string& sync_username) { | 904 void PasswordStoreMac::ReportMetricsImpl( |
| 906 login_metadata_db_->ReportMetrics(sync_username); | 905 password_manager::PasswordManagerClient* client) { |
| 906 login_metadata_db_->ReportMetrics(client); |
| 907 } | 907 } |
| 908 | 908 |
| 909 PasswordStoreChangeList PasswordStoreMac::AddLoginImpl( | 909 PasswordStoreChangeList PasswordStoreMac::AddLoginImpl( |
| 910 const PasswordForm& form) { | 910 const PasswordForm& form) { |
| 911 DCHECK(thread_->message_loop() == base::MessageLoop::current()); | 911 DCHECK(thread_->message_loop() == base::MessageLoop::current()); |
| 912 PasswordStoreChangeList changes; | 912 PasswordStoreChangeList changes; |
| 913 if (AddToKeychainIfNecessary(form)) { | 913 if (AddToKeychainIfNecessary(form)) { |
| 914 changes = login_metadata_db_->AddLogin(form); | 914 changes = login_metadata_db_->AddLogin(form); |
| 915 } | 915 } |
| 916 return changes; | 916 return changes; |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 | 1150 |
| 1151 ScopedVector<PasswordForm> merged_forms; | 1151 ScopedVector<PasswordForm> merged_forms; |
| 1152 merged_forms.get() = internal_keychain_helpers::GetPasswordsForForms( | 1152 merged_forms.get() = internal_keychain_helpers::GetPasswordsForForms( |
| 1153 *keychain_, &database_forms); | 1153 *keychain_, &database_forms); |
| 1154 | 1154 |
| 1155 // Clean up any orphaned database entries. | 1155 // Clean up any orphaned database entries. |
| 1156 RemoveDatabaseForms(database_forms); | 1156 RemoveDatabaseForms(database_forms); |
| 1157 | 1157 |
| 1158 forms->insert(forms->end(), database_forms.begin(), database_forms.end()); | 1158 forms->insert(forms->end(), database_forms.begin(), database_forms.end()); |
| 1159 } | 1159 } |
| OLD | NEW |