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/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/password_manager/sync_metrics.h" |
10 #include "chrome/browser/profiles/incognito_helpers.h" | 11 #include "chrome/browser/profiles/incognito_helpers.h" |
11 #include "chrome/browser/sync/glue/sync_start_util.h" | 12 #include "chrome/browser/sync/glue/sync_start_util.h" |
12 #include "chrome/browser/webdata/web_data_service.h" | 13 #include "chrome/browser/webdata/web_data_service.h" |
13 #include "chrome/browser/webdata/web_data_service_factory.h" | 14 #include "chrome/browser/webdata/web_data_service_factory.h" |
14 #include "chrome/common/chrome_constants.h" | 15 #include "chrome/common/chrome_constants.h" |
15 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
16 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 17 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
17 #include "components/os_crypt/os_crypt_switches.h" | 18 #include "components/os_crypt/os_crypt_switches.h" |
18 #include "components/password_manager/core/browser/login_database.h" | 19 #include "components/password_manager/core/browser/login_database.h" |
19 #include "components/password_manager/core/browser/password_store.h" | 20 #include "components/password_manager/core/browser/password_store.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 ps = new PasswordStoreX(main_thread_runner, | 219 ps = new PasswordStoreX(main_thread_runner, |
219 db_thread_runner, | 220 db_thread_runner, |
220 login_db.release(), | 221 login_db.release(), |
221 backend.release()); | 222 backend.release()); |
222 #elif defined(USE_OZONE) | 223 #elif defined(USE_OZONE) |
223 ps = new password_manager::PasswordStoreDefault( | 224 ps = new password_manager::PasswordStoreDefault( |
224 main_thread_runner, db_thread_runner, login_db.release()); | 225 main_thread_runner, db_thread_runner, login_db.release()); |
225 #else | 226 #else |
226 NOTIMPLEMENTED(); | 227 NOTIMPLEMENTED(); |
227 #endif | 228 #endif |
| 229 std::string sync_username = |
| 230 password_manager_sync_metrics::GetPasswordSyncUsername(profile); |
228 if (!ps || !ps->Init( | 231 if (!ps || !ps->Init( |
229 sync_start_util::GetFlareForSyncableService(profile->GetPath()))) { | 232 sync_start_util::GetFlareForSyncableService(profile->GetPath()), |
| 233 sync_username)) { |
230 NOTREACHED() << "Could not initialize password manager."; | 234 NOTREACHED() << "Could not initialize password manager."; |
231 return NULL; | 235 return NULL; |
232 } | 236 } |
233 | 237 |
234 return new PasswordStoreService(ps); | 238 return new PasswordStoreService(ps); |
235 } | 239 } |
236 | 240 |
237 void PasswordStoreFactory::RegisterProfilePrefs( | 241 void PasswordStoreFactory::RegisterProfilePrefs( |
238 user_prefs::PrefRegistrySyncable* registry) { | 242 user_prefs::PrefRegistrySyncable* registry) { |
239 #if !defined(OS_CHROMEOS) && defined(USE_X11) | 243 #if !defined(OS_CHROMEOS) && defined(USE_X11) |
240 // Notice that the preprocessor conditions above are exactly those that will | 244 // Notice that the preprocessor conditions above are exactly those that will |
241 // result in using PasswordStoreX in BuildServiceInstanceFor(). | 245 // result in using PasswordStoreX in BuildServiceInstanceFor(). |
242 registry->RegisterIntegerPref( | 246 registry->RegisterIntegerPref( |
243 password_manager::prefs::kLocalProfileId, | 247 password_manager::prefs::kLocalProfileId, |
244 kInvalidLocalProfileId, | 248 kInvalidLocalProfileId, |
245 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 249 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
246 #endif | 250 #endif |
247 } | 251 } |
248 | 252 |
249 content::BrowserContext* PasswordStoreFactory::GetBrowserContextToUse( | 253 content::BrowserContext* PasswordStoreFactory::GetBrowserContextToUse( |
250 content::BrowserContext* context) const { | 254 content::BrowserContext* context) const { |
251 return chrome::GetBrowserContextRedirectedInIncognito(context); | 255 return chrome::GetBrowserContextRedirectedInIncognito(context); |
252 } | 256 } |
253 | 257 |
254 bool PasswordStoreFactory::ServiceIsNULLWhileTesting() const { | 258 bool PasswordStoreFactory::ServiceIsNULLWhileTesting() const { |
255 return true; | 259 return true; |
256 } | 260 } |
OLD | NEW |