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/profiles/incognito_helpers.h" | 10 #include "chrome/browser/profiles/incognito_helpers.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 << (name ? name : "(unknown)"); | 180 << (name ? name : "(unknown)"); |
181 } | 181 } |
182 | 182 |
183 PrefService* prefs = profile->GetPrefs(); | 183 PrefService* prefs = profile->GetPrefs(); |
184 LocalProfileId id = GetLocalProfileId(prefs); | 184 LocalProfileId id = GetLocalProfileId(prefs); |
185 | 185 |
186 scoped_ptr<PasswordStoreX::NativeBackend> backend; | 186 scoped_ptr<PasswordStoreX::NativeBackend> backend; |
187 if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE4) { | 187 if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE4) { |
188 // KDE3 didn't use DBus, which our KWallet store uses. | 188 // KDE3 didn't use DBus, which our KWallet store uses. |
189 VLOG(1) << "Trying KWallet for password storage."; | 189 VLOG(1) << "Trying KWallet for password storage."; |
190 backend.reset(new NativeBackendKWallet(id, prefs)); | 190 backend.reset(new NativeBackendKWallet(id)); |
191 if (backend->Init()) | 191 if (backend->Init()) |
192 VLOG(1) << "Using KWallet for password storage."; | 192 VLOG(1) << "Using KWallet for password storage."; |
193 else | 193 else |
194 backend.reset(); | 194 backend.reset(); |
195 } else if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_GNOME || | 195 } else if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_GNOME || |
196 desktop_env == base::nix::DESKTOP_ENVIRONMENT_UNITY || | 196 desktop_env == base::nix::DESKTOP_ENVIRONMENT_UNITY || |
197 desktop_env == base::nix::DESKTOP_ENVIRONMENT_XFCE) { | 197 desktop_env == base::nix::DESKTOP_ENVIRONMENT_XFCE) { |
198 #if defined(USE_GNOME_KEYRING) | 198 #if defined(USE_GNOME_KEYRING) |
199 VLOG(1) << "Trying GNOME keyring for password storage."; | 199 VLOG(1) << "Trying GNOME keyring for password storage."; |
200 backend.reset(new NativeBackendGnome(id, prefs)); | 200 backend.reset(new NativeBackendGnome(id)); |
201 if (backend->Init()) | 201 if (backend->Init()) |
202 VLOG(1) << "Using GNOME keyring for password storage."; | 202 VLOG(1) << "Using GNOME keyring for password storage."; |
203 else | 203 else |
204 backend.reset(); | 204 backend.reset(); |
205 #endif // defined(USE_GNOME_KEYRING) | 205 #endif // defined(USE_GNOME_KEYRING) |
206 } | 206 } |
207 | 207 |
208 if (!backend.get()) { | 208 if (!backend.get()) { |
209 LOG(WARNING) << "Using basic (unencrypted) store for password storage. " | 209 LOG(WARNING) << "Using basic (unencrypted) store for password storage. " |
210 "See http://code.google.com/p/chromium/wiki/LinuxPasswordStorage for " | 210 "See http://code.google.com/p/chromium/wiki/LinuxPasswordStorage for " |
(...skipping 15 matching lines...) Expand all Loading... |
226 NOTREACHED() << "Could not initialize password manager."; | 226 NOTREACHED() << "Could not initialize password manager."; |
227 return NULL; | 227 return NULL; |
228 } | 228 } |
229 | 229 |
230 return new PasswordStoreService(ps); | 230 return new PasswordStoreService(ps); |
231 } | 231 } |
232 | 232 |
233 void PasswordStoreFactory::RegisterProfilePrefs( | 233 void PasswordStoreFactory::RegisterProfilePrefs( |
234 user_prefs::PrefRegistrySyncable* registry) { | 234 user_prefs::PrefRegistrySyncable* registry) { |
235 #if !defined(OS_CHROMEOS) && defined(USE_X11) | 235 #if !defined(OS_CHROMEOS) && defined(USE_X11) |
| 236 // Notice that the preprocessor conditions above are exactly those that will |
| 237 // result in using PasswordStoreX in BuildServiceInstanceFor(). |
236 registry->RegisterIntegerPref( | 238 registry->RegisterIntegerPref( |
237 prefs::kLocalProfileId, | 239 prefs::kLocalProfileId, |
238 kInvalidLocalProfileId, | 240 kInvalidLocalProfileId, |
239 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 241 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
240 | |
241 // Notice that the preprocessor conditions above are exactly those that will | |
242 // result in using PasswordStoreX in CreatePasswordStore() below. | |
243 PasswordStoreX::RegisterProfilePrefs(registry); | |
244 #endif | 242 #endif |
245 } | 243 } |
246 | 244 |
247 content::BrowserContext* PasswordStoreFactory::GetBrowserContextToUse( | 245 content::BrowserContext* PasswordStoreFactory::GetBrowserContextToUse( |
248 content::BrowserContext* context) const { | 246 content::BrowserContext* context) const { |
249 return chrome::GetBrowserContextRedirectedInIncognito(context); | 247 return chrome::GetBrowserContextRedirectedInIncognito(context); |
250 } | 248 } |
251 | 249 |
252 bool PasswordStoreFactory::ServiceIsNULLWhileTesting() const { | 250 bool PasswordStoreFactory::ServiceIsNULLWhileTesting() const { |
253 return true; | 251 return true; |
254 } | 252 } |
OLD | NEW |