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_factory.h" | 5 #include "chrome/browser/password_manager/password_store_factory.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/environment.h" | 8 #include "base/environment.h" |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "chrome/browser/password_manager/password_manager_util.h" | 11 #include "chrome/browser/password_manager/password_manager_util.h" |
12 #include "chrome/browser/password_manager/sync_metrics.h" | 12 #include "chrome/browser/password_manager/sync_metrics.h" |
13 #include "chrome/browser/profiles/incognito_helpers.h" | 13 #include "chrome/browser/profiles/incognito_helpers.h" |
14 #include "chrome/browser/sync/glue/sync_start_util.h" | 14 #include "chrome/browser/sync/glue/sync_start_util.h" |
15 #include "chrome/browser/webdata/web_data_service_factory.h" | 15 #include "chrome/browser/webdata/web_data_service_factory.h" |
16 #include "chrome/common/chrome_constants.h" | 16 #include "chrome/common/chrome_constants.h" |
17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
18 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 18 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
19 #include "components/os_crypt/os_crypt_switches.h" | 19 #include "components/os_crypt/os_crypt_switches.h" |
20 #include "components/password_manager/core/browser/login_database.h" | |
21 #include "components/password_manager/core/browser/password_store.h" | 20 #include "components/password_manager/core/browser/password_store.h" |
22 #include "components/password_manager/core/browser/password_store_default.h" | 21 #include "components/password_manager/core/browser/password_store_default.h" |
23 #include "components/password_manager/core/common/password_manager_pref_names.h" | 22 #include "components/password_manager/core/common/password_manager_pref_names.h" |
24 #include "components/pref_registry/pref_registry_syncable.h" | 23 #include "components/pref_registry/pref_registry_syncable.h" |
25 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
26 | 25 |
27 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
28 #include "chrome/browser/password_manager/password_store_win.h" | 27 #include "chrome/browser/password_manager/password_store_win.h" |
29 #include "components/password_manager/core/browser/webdata/password_web_data_ser
vice_win.h" | 28 #include "components/password_manager/core/browser/webdata/password_web_data_ser
vice_win.h" |
30 #elif defined(OS_MACOSX) | 29 #elif defined(OS_MACOSX) |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 } | 139 } |
141 #endif | 140 #endif |
142 | 141 |
143 KeyedService* PasswordStoreFactory::BuildServiceInstanceFor( | 142 KeyedService* PasswordStoreFactory::BuildServiceInstanceFor( |
144 content::BrowserContext* context) const { | 143 content::BrowserContext* context) const { |
145 DelayReportOsPassword(); | 144 DelayReportOsPassword(); |
146 Profile* profile = static_cast<Profile*>(context); | 145 Profile* profile = static_cast<Profile*>(context); |
147 | 146 |
148 base::FilePath login_db_file_path = profile->GetPath(); | 147 base::FilePath login_db_file_path = profile->GetPath(); |
149 login_db_file_path = login_db_file_path.Append(chrome::kLoginDataFileName); | 148 login_db_file_path = login_db_file_path.Append(chrome::kLoginDataFileName); |
150 scoped_ptr<password_manager::LoginDatabase> login_db( | |
151 new password_manager::LoginDatabase()); | |
152 { | |
153 // TODO(paivanof@gmail.com): execution of login_db->Init() should go | |
154 // to DB thread. http://crbug.com/138903 | |
155 base::ThreadRestrictions::ScopedAllowIO allow_io; | |
156 if (!login_db->Init(login_db_file_path)) { | |
157 LOG(ERROR) << "Could not initialize login database."; | |
158 return NULL; | |
159 } | |
160 } | |
161 | 149 |
162 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner( | 150 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner( |
163 base::MessageLoopProxy::current()); | 151 base::MessageLoopProxy::current()); |
164 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner( | 152 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner( |
165 content::BrowserThread::GetMessageLoopProxyForThread( | 153 content::BrowserThread::GetMessageLoopProxyForThread( |
166 content::BrowserThread::DB)); | 154 content::BrowserThread::DB)); |
167 | 155 |
168 scoped_refptr<PasswordStore> ps; | 156 scoped_refptr<PasswordStore> ps; |
169 #if defined(OS_WIN) | 157 #if defined(OS_WIN) |
170 ps = new PasswordStoreWin(main_thread_runner, | 158 ps = new PasswordStoreWin(main_thread_runner, |
171 db_thread_runner, | 159 db_thread_runner, |
172 login_db.release(), | 160 login_db_file_path, |
173 WebDataServiceFactory::GetPasswordWebDataForProfile( | 161 WebDataServiceFactory::GetPasswordWebDataForProfile( |
174 profile, Profile::EXPLICIT_ACCESS)); | 162 profile, Profile::EXPLICIT_ACCESS)); |
175 #elif defined(OS_MACOSX) | 163 #elif defined(OS_MACOSX) |
176 crypto::AppleKeychain* keychain = | 164 crypto::AppleKeychain* keychain = |
177 base::CommandLine::ForCurrentProcess()->HasSwitch( | 165 base::CommandLine::ForCurrentProcess()->HasSwitch( |
178 os_crypt::switches::kUseMockKeychain) | 166 os_crypt::switches::kUseMockKeychain) |
179 ? new crypto::MockAppleKeychain() | 167 ? new crypto::MockAppleKeychain() |
180 : new crypto::AppleKeychain(); | 168 : new crypto::AppleKeychain(); |
181 ps = new PasswordStoreMac( | 169 ps = new PasswordStoreMac( |
182 main_thread_runner, db_thread_runner, keychain, login_db.release()); | 170 main_thread_runner, db_thread_runner, keychain, login_db.release()); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 } | 222 } |
235 | 223 |
236 if (!backend.get()) { | 224 if (!backend.get()) { |
237 LOG(WARNING) << "Using basic (unencrypted) store for password storage. " | 225 LOG(WARNING) << "Using basic (unencrypted) store for password storage. " |
238 "See http://code.google.com/p/chromium/wiki/LinuxPasswordStorage for " | 226 "See http://code.google.com/p/chromium/wiki/LinuxPasswordStorage for " |
239 "more information about password storage options."; | 227 "more information about password storage options."; |
240 } | 228 } |
241 | 229 |
242 ps = new PasswordStoreX(main_thread_runner, | 230 ps = new PasswordStoreX(main_thread_runner, |
243 db_thread_runner, | 231 db_thread_runner, |
244 login_db.release(), | 232 login_db_file_path, |
245 backend.release()); | 233 backend.release()); |
246 #elif defined(USE_OZONE) | 234 #elif defined(USE_OZONE) |
247 ps = new password_manager::PasswordStoreDefault( | 235 ps = new password_manager::PasswordStoreDefault( |
248 main_thread_runner, db_thread_runner, login_db.release()); | 236 main_thread_runner, db_thread_runner, login_db.release()); |
249 #else | 237 #else |
250 NOTIMPLEMENTED(); | 238 NOTIMPLEMENTED(); |
251 #endif | 239 #endif |
252 if (!ps.get() || | 240 if (!ps.get() || |
253 !ps->Init( | 241 !ps->Init( |
254 sync_start_util::GetFlareForSyncableService(profile->GetPath()))) { | 242 sync_start_util::GetFlareForSyncableService(profile->GetPath()))) { |
(...skipping 17 matching lines...) Expand all Loading... |
272 } | 260 } |
273 | 261 |
274 content::BrowserContext* PasswordStoreFactory::GetBrowserContextToUse( | 262 content::BrowserContext* PasswordStoreFactory::GetBrowserContextToUse( |
275 content::BrowserContext* context) const { | 263 content::BrowserContext* context) const { |
276 return chrome::GetBrowserContextRedirectedInIncognito(context); | 264 return chrome::GetBrowserContextRedirectedInIncognito(context); |
277 } | 265 } |
278 | 266 |
279 bool PasswordStoreFactory::ServiceIsNULLWhileTesting() const { | 267 bool PasswordStoreFactory::ServiceIsNULLWhileTesting() const { |
280 return true; | 268 return true; |
281 } | 269 } |
OLD | NEW |