| 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 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 : password_manager::PasswordStore(main_thread_runner, db_thread_runner), | 859 : password_manager::PasswordStore(main_thread_runner, db_thread_runner), |
| 860 keychain_(keychain), | 860 keychain_(keychain), |
| 861 login_metadata_db_(login_db) { | 861 login_metadata_db_(login_db) { |
| 862 DCHECK(keychain_.get()); | 862 DCHECK(keychain_.get()); |
| 863 DCHECK(login_metadata_db_.get()); | 863 DCHECK(login_metadata_db_.get()); |
| 864 } | 864 } |
| 865 | 865 |
| 866 PasswordStoreMac::~PasswordStoreMac() {} | 866 PasswordStoreMac::~PasswordStoreMac() {} |
| 867 | 867 |
| 868 bool PasswordStoreMac::Init( | 868 bool PasswordStoreMac::Init( |
| 869 const syncer::SyncableService::StartSyncFlare& flare) { | 869 const syncer::SyncableService::StartSyncFlare& flare, |
| 870 const std::string& sync_username) { |
| 870 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 871 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 871 thread_.reset(new base::Thread("Chrome_PasswordStore_Thread")); | 872 thread_.reset(new base::Thread("Chrome_PasswordStore_Thread")); |
| 872 | 873 |
| 873 if (!thread_->Start()) { | 874 if (!thread_->Start()) { |
| 874 thread_.reset(NULL); | 875 thread_.reset(NULL); |
| 875 return false; | 876 return false; |
| 876 } | 877 } |
| 877 return password_manager::PasswordStore::Init(flare); | 878 return password_manager::PasswordStore::Init(flare, sync_username); |
| 878 } | 879 } |
| 879 | 880 |
| 880 void PasswordStoreMac::Shutdown() { | 881 void PasswordStoreMac::Shutdown() { |
| 881 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 882 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 882 password_manager::PasswordStore::Shutdown(); | 883 password_manager::PasswordStore::Shutdown(); |
| 883 thread_->Stop(); | 884 thread_->Stop(); |
| 884 } | 885 } |
| 885 | 886 |
| 886 // Mac stores passwords in the system keychain, which can block for an | 887 // Mac stores passwords in the system keychain, which can block for an |
| 887 // arbitrarily long time (most notably, it can block on user confirmation | 888 // arbitrarily long time (most notably, it can block on user confirmation |
| 888 // from a dialog). Run tasks on a dedicated thread to avoid blocking the DB | 889 // from a dialog). Run tasks on a dedicated thread to avoid blocking the DB |
| 889 // thread. | 890 // thread. |
| 890 scoped_refptr<base::SingleThreadTaskRunner> | 891 scoped_refptr<base::SingleThreadTaskRunner> |
| 891 PasswordStoreMac::GetBackgroundTaskRunner() { | 892 PasswordStoreMac::GetBackgroundTaskRunner() { |
| 892 return (thread_.get()) ? thread_->message_loop_proxy() : NULL; | 893 return (thread_.get()) ? thread_->message_loop_proxy() : NULL; |
| 893 } | 894 } |
| 894 | 895 |
| 895 void PasswordStoreMac::ReportMetricsImpl() { | 896 void PasswordStoreMac::ReportMetricsImpl(const std::string& sync_username) { |
| 896 login_metadata_db_->ReportMetrics(); | 897 login_metadata_db_->ReportMetrics(sync_username); |
| 897 } | 898 } |
| 898 | 899 |
| 899 PasswordStoreChangeList PasswordStoreMac::AddLoginImpl( | 900 PasswordStoreChangeList PasswordStoreMac::AddLoginImpl( |
| 900 const PasswordForm& form) { | 901 const PasswordForm& form) { |
| 901 DCHECK(thread_->message_loop() == base::MessageLoop::current()); | 902 DCHECK(thread_->message_loop() == base::MessageLoop::current()); |
| 902 PasswordStoreChangeList changes; | 903 PasswordStoreChangeList changes; |
| 903 if (AddToKeychainIfNecessary(form)) { | 904 if (AddToKeychainIfNecessary(form)) { |
| 904 changes = login_metadata_db_->AddLogin(form); | 905 changes = login_metadata_db_->AddLogin(form); |
| 905 } | 906 } |
| 906 return changes; | 907 return changes; |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1133 | 1134 |
| 1134 void PasswordStoreMac::RemoveKeychainForms( | 1135 void PasswordStoreMac::RemoveKeychainForms( |
| 1135 const std::vector<PasswordForm*>& forms) { | 1136 const std::vector<PasswordForm*>& forms) { |
| 1136 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_.get()); | 1137 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_.get()); |
| 1137 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); | 1138 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); |
| 1138 for (std::vector<PasswordForm*>::const_iterator i = forms.begin(); | 1139 for (std::vector<PasswordForm*>::const_iterator i = forms.begin(); |
| 1139 i != forms.end(); ++i) { | 1140 i != forms.end(); ++i) { |
| 1140 owned_keychain_adapter.RemovePassword(**i); | 1141 owned_keychain_adapter.RemovePassword(**i); |
| 1141 } | 1142 } |
| 1142 } | 1143 } |
| OLD | NEW |