| 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/password_manager/sync_metrics.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 scoped_refptr<PasswordStore> password_store) | 55 scoped_refptr<PasswordStore> password_store) |
| 56 : password_store_(password_store) {} | 56 : password_store_(password_store) {} |
| 57 | 57 |
| 58 PasswordStoreService::~PasswordStoreService() {} | 58 PasswordStoreService::~PasswordStoreService() {} |
| 59 | 59 |
| 60 scoped_refptr<PasswordStore> PasswordStoreService::GetPasswordStore() { | 60 scoped_refptr<PasswordStore> PasswordStoreService::GetPasswordStore() { |
| 61 return password_store_; | 61 return password_store_; |
| 62 } | 62 } |
| 63 | 63 |
| 64 void PasswordStoreService::Shutdown() { | 64 void PasswordStoreService::Shutdown() { |
| 65 if (password_store_) | 65 if (password_store_.get()) |
| 66 password_store_->Shutdown(); | 66 password_store_->Shutdown(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 // static | 69 // static |
| 70 scoped_refptr<PasswordStore> PasswordStoreFactory::GetForProfile( | 70 scoped_refptr<PasswordStore> PasswordStoreFactory::GetForProfile( |
| 71 Profile* profile, | 71 Profile* profile, |
| 72 Profile::ServiceAccessType sat) { | 72 Profile::ServiceAccessType sat) { |
| 73 if (sat == Profile::IMPLICIT_ACCESS && profile->IsOffTheRecord()) { | 73 if (sat == Profile::IMPLICIT_ACCESS && profile->IsOffTheRecord()) { |
| 74 NOTREACHED() << "This profile is OffTheRecord"; | 74 NOTREACHED() << "This profile is OffTheRecord"; |
| 75 return NULL; | 75 return NULL; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 login_db.release(), | 222 login_db.release(), |
| 223 backend.release()); | 223 backend.release()); |
| 224 #elif defined(USE_OZONE) | 224 #elif defined(USE_OZONE) |
| 225 ps = new password_manager::PasswordStoreDefault( | 225 ps = new password_manager::PasswordStoreDefault( |
| 226 main_thread_runner, db_thread_runner, login_db.release()); | 226 main_thread_runner, db_thread_runner, login_db.release()); |
| 227 #else | 227 #else |
| 228 NOTIMPLEMENTED(); | 228 NOTIMPLEMENTED(); |
| 229 #endif | 229 #endif |
| 230 std::string sync_username = | 230 std::string sync_username = |
| 231 password_manager_sync_metrics::GetSyncUsername(profile); | 231 password_manager_sync_metrics::GetSyncUsername(profile); |
| 232 if (!ps || !ps->Init( | 232 if (!ps.get() || |
| 233 sync_start_util::GetFlareForSyncableService(profile->GetPath()), | 233 !ps->Init(sync_start_util::GetFlareForSyncableService(profile->GetPath()), |
| 234 sync_username)) { | 234 sync_username)) { |
| 235 NOTREACHED() << "Could not initialize password manager."; | 235 NOTREACHED() << "Could not initialize password manager."; |
| 236 return NULL; | 236 return NULL; |
| 237 } | 237 } |
| 238 | 238 |
| 239 return new PasswordStoreService(ps); | 239 return new PasswordStoreService(ps); |
| 240 } | 240 } |
| 241 | 241 |
| 242 void PasswordStoreFactory::RegisterProfilePrefs( | 242 void PasswordStoreFactory::RegisterProfilePrefs( |
| 243 user_prefs::PrefRegistrySyncable* registry) { | 243 user_prefs::PrefRegistrySyncable* registry) { |
| 244 #if !defined(OS_CHROMEOS) && defined(USE_X11) | 244 #if !defined(OS_CHROMEOS) && defined(USE_X11) |
| 245 // Notice that the preprocessor conditions above are exactly those that will | 245 // Notice that the preprocessor conditions above are exactly those that will |
| 246 // result in using PasswordStoreX in BuildServiceInstanceFor(). | 246 // result in using PasswordStoreX in BuildServiceInstanceFor(). |
| 247 registry->RegisterIntegerPref( | 247 registry->RegisterIntegerPref( |
| 248 password_manager::prefs::kLocalProfileId, | 248 password_manager::prefs::kLocalProfileId, |
| 249 kInvalidLocalProfileId, | 249 kInvalidLocalProfileId, |
| 250 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 250 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 251 #endif | 251 #endif |
| 252 } | 252 } |
| 253 | 253 |
| 254 content::BrowserContext* PasswordStoreFactory::GetBrowserContextToUse( | 254 content::BrowserContext* PasswordStoreFactory::GetBrowserContextToUse( |
| 255 content::BrowserContext* context) const { | 255 content::BrowserContext* context) const { |
| 256 return chrome::GetBrowserContextRedirectedInIncognito(context); | 256 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 257 } | 257 } |
| 258 | 258 |
| 259 bool PasswordStoreFactory::ServiceIsNULLWhileTesting() const { | 259 bool PasswordStoreFactory::ServiceIsNULLWhileTesting() const { |
| 260 return true; | 260 return true; |
| 261 } | 261 } |
| OLD | NEW |