| 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 password_manager::SyncState sync_state; |
| 230 std::string sync_username; |
| 231 password_manager_sync_metrics::GetSyncUsernameAndState(profile, |
| 232 &sync_username, |
| 233 &sync_state); |
| 228 if (!ps || !ps->Init( | 234 if (!ps || !ps->Init( |
| 229 sync_start_util::GetFlareForSyncableService(profile->GetPath()))) { | 235 sync_start_util::GetFlareForSyncableService(profile->GetPath()), |
| 236 sync_username, sync_state)) { |
| 230 NOTREACHED() << "Could not initialize password manager."; | 237 NOTREACHED() << "Could not initialize password manager."; |
| 231 return NULL; | 238 return NULL; |
| 232 } | 239 } |
| 233 | 240 |
| 234 return new PasswordStoreService(ps); | 241 return new PasswordStoreService(ps); |
| 235 } | 242 } |
| 236 | 243 |
| 237 void PasswordStoreFactory::RegisterProfilePrefs( | 244 void PasswordStoreFactory::RegisterProfilePrefs( |
| 238 user_prefs::PrefRegistrySyncable* registry) { | 245 user_prefs::PrefRegistrySyncable* registry) { |
| 239 #if !defined(OS_CHROMEOS) && defined(USE_X11) | 246 #if !defined(OS_CHROMEOS) && defined(USE_X11) |
| 240 // Notice that the preprocessor conditions above are exactly those that will | 247 // Notice that the preprocessor conditions above are exactly those that will |
| 241 // result in using PasswordStoreX in BuildServiceInstanceFor(). | 248 // result in using PasswordStoreX in BuildServiceInstanceFor(). |
| 242 registry->RegisterIntegerPref( | 249 registry->RegisterIntegerPref( |
| 243 password_manager::prefs::kLocalProfileId, | 250 password_manager::prefs::kLocalProfileId, |
| 244 kInvalidLocalProfileId, | 251 kInvalidLocalProfileId, |
| 245 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 252 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 246 #endif | 253 #endif |
| 247 } | 254 } |
| 248 | 255 |
| 249 content::BrowserContext* PasswordStoreFactory::GetBrowserContextToUse( | 256 content::BrowserContext* PasswordStoreFactory::GetBrowserContextToUse( |
| 250 content::BrowserContext* context) const { | 257 content::BrowserContext* context) const { |
| 251 return chrome::GetBrowserContextRedirectedInIncognito(context); | 258 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 252 } | 259 } |
| 253 | 260 |
| 254 bool PasswordStoreFactory::ServiceIsNULLWhileTesting() const { | 261 bool PasswordStoreFactory::ServiceIsNULLWhileTesting() const { |
| 255 return true; | 262 return true; |
| 256 } | 263 } |
| OLD | NEW |