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" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 if (password_store_.get()) | 95 if (password_store_.get()) |
96 password_store_->Shutdown(); | 96 password_store_->Shutdown(); |
97 } | 97 } |
98 | 98 |
99 // static | 99 // static |
100 scoped_refptr<PasswordStore> PasswordStoreFactory::GetForProfile( | 100 scoped_refptr<PasswordStore> PasswordStoreFactory::GetForProfile( |
101 Profile* profile, | 101 Profile* profile, |
102 ServiceAccessType sat) { | 102 ServiceAccessType sat) { |
103 if (sat == ServiceAccessType::IMPLICIT_ACCESS && profile->IsOffTheRecord()) { | 103 if (sat == ServiceAccessType::IMPLICIT_ACCESS && profile->IsOffTheRecord()) { |
104 NOTREACHED() << "This profile is OffTheRecord"; | 104 NOTREACHED() << "This profile is OffTheRecord"; |
105 return NULL; | 105 return nullptr; |
106 } | 106 } |
107 | 107 |
108 PasswordStoreFactory* factory = GetInstance(); | 108 PasswordStoreFactory* factory = GetInstance(); |
109 PasswordStoreService* service = static_cast<PasswordStoreService*>( | 109 PasswordStoreService* service = static_cast<PasswordStoreService*>( |
110 factory->GetServiceForBrowserContext(profile, true)); | 110 factory->GetServiceForBrowserContext(profile, true)); |
111 if (!service) | 111 if (!service) |
112 return NULL; | 112 return nullptr; |
113 return service->GetPasswordStore(); | 113 return service->GetPasswordStore(); |
114 } | 114 } |
115 | 115 |
116 // static | 116 // static |
117 PasswordStoreFactory* PasswordStoreFactory::GetInstance() { | 117 PasswordStoreFactory* PasswordStoreFactory::GetInstance() { |
118 return Singleton<PasswordStoreFactory>::get(); | 118 return Singleton<PasswordStoreFactory>::get(); |
119 } | 119 } |
120 | 120 |
121 PasswordStoreFactory::PasswordStoreFactory() | 121 PasswordStoreFactory::PasswordStoreFactory() |
122 : BrowserContextKeyedServiceFactory( | 122 : BrowserContextKeyedServiceFactory( |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 #elif defined(USE_OZONE) | 264 #elif defined(USE_OZONE) |
265 ps = new password_manager::PasswordStoreDefault( | 265 ps = new password_manager::PasswordStoreDefault( |
266 main_thread_runner, db_thread_runner, login_db.Pass()); | 266 main_thread_runner, db_thread_runner, login_db.Pass()); |
267 #else | 267 #else |
268 NOTIMPLEMENTED(); | 268 NOTIMPLEMENTED(); |
269 #endif | 269 #endif |
270 if (!ps.get() || | 270 if (!ps.get() || |
271 !ps->Init( | 271 !ps->Init( |
272 sync_start_util::GetFlareForSyncableService(profile->GetPath()))) { | 272 sync_start_util::GetFlareForSyncableService(profile->GetPath()))) { |
273 NOTREACHED() << "Could not initialize password manager."; | 273 NOTREACHED() << "Could not initialize password manager."; |
274 return NULL; | 274 return nullptr; |
275 } | 275 } |
276 | 276 |
277 return new PasswordStoreService(ps); | 277 return new PasswordStoreService(ps); |
278 } | 278 } |
279 | 279 |
280 void PasswordStoreFactory::RegisterProfilePrefs( | 280 void PasswordStoreFactory::RegisterProfilePrefs( |
281 user_prefs::PrefRegistrySyncable* registry) { | 281 user_prefs::PrefRegistrySyncable* registry) { |
282 #if !defined(OS_CHROMEOS) && defined(USE_X11) | 282 #if !defined(OS_CHROMEOS) && defined(USE_X11) |
283 // Notice that the preprocessor conditions above are exactly those that will | 283 // Notice that the preprocessor conditions above are exactly those that will |
284 // result in using PasswordStoreX in BuildServiceInstanceFor(). | 284 // result in using PasswordStoreX in BuildServiceInstanceFor(). |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 break; | 357 break; |
358 case LIBSECRET: | 358 case LIBSECRET: |
359 usage = OTHER_LIBSECRET; | 359 usage = OTHER_LIBSECRET; |
360 break; | 360 break; |
361 } | 361 } |
362 } | 362 } |
363 UMA_HISTOGRAM_ENUMERATION("PasswordManager.LinuxBackendStatistics", usage, | 363 UMA_HISTOGRAM_ENUMERATION("PasswordManager.LinuxBackendStatistics", usage, |
364 MAX_BACKEND_USAGE_VALUE); | 364 MAX_BACKEND_USAGE_VALUE); |
365 } | 365 } |
366 #endif | 366 #endif |
OLD | NEW |