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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 // the desktop environment currently running, allowing GNOME Keyring in XFCE. | 269 // the desktop environment currently running, allowing GNOME Keyring in XFCE. |
270 // (In all cases we fall back on the basic store in case of failure.) | 270 // (In all cases we fall back on the basic store in case of failure.) |
271 base::nix::DesktopEnvironment desktop_env = GetDesktopEnvironment(); | 271 base::nix::DesktopEnvironment desktop_env = GetDesktopEnvironment(); |
272 base::nix::DesktopEnvironment used_desktop_env; | 272 base::nix::DesktopEnvironment used_desktop_env; |
273 std::string store_type = | 273 std::string store_type = |
274 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 274 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
275 switches::kPasswordStore); | 275 switches::kPasswordStore); |
276 LinuxBackendUsed used_backend = PLAINTEXT; | 276 LinuxBackendUsed used_backend = PLAINTEXT; |
277 if (store_type == "kwallet") { | 277 if (store_type == "kwallet") { |
278 used_desktop_env = base::nix::DESKTOP_ENVIRONMENT_KDE4; | 278 used_desktop_env = base::nix::DESKTOP_ENVIRONMENT_KDE4; |
| 279 } else if (store_type == "kwallet5") { |
| 280 used_desktop_env = base::nix::DESKTOP_ENVIRONMENT_KDE5; |
279 } else if (store_type == "gnome") { | 281 } else if (store_type == "gnome") { |
280 used_desktop_env = base::nix::DESKTOP_ENVIRONMENT_GNOME; | 282 used_desktop_env = base::nix::DESKTOP_ENVIRONMENT_GNOME; |
281 } else if (store_type == "basic") { | 283 } else if (store_type == "basic") { |
282 used_desktop_env = base::nix::DESKTOP_ENVIRONMENT_OTHER; | 284 used_desktop_env = base::nix::DESKTOP_ENVIRONMENT_OTHER; |
283 } else { | 285 } else { |
284 // Detect the store to use automatically. | 286 // Detect the store to use automatically. |
285 used_desktop_env = desktop_env; | 287 used_desktop_env = desktop_env; |
286 const char* name = base::nix::GetDesktopEnvironmentName(desktop_env); | 288 const char* name = base::nix::GetDesktopEnvironmentName(desktop_env); |
287 VLOG(1) << "Password storage detected desktop environment: " | 289 VLOG(1) << "Password storage detected desktop environment: " |
288 << (name ? name : "(unknown)"); | 290 << (name ? name : "(unknown)"); |
289 } | 291 } |
290 | 292 |
291 PrefService* prefs = profile->GetPrefs(); | 293 PrefService* prefs = profile->GetPrefs(); |
292 LocalProfileId id = GetLocalProfileId(prefs); | 294 LocalProfileId id = GetLocalProfileId(prefs); |
293 | 295 |
294 scoped_ptr<PasswordStoreX::NativeBackend> backend; | 296 scoped_ptr<PasswordStoreX::NativeBackend> backend; |
295 if (used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE4 || | 297 if (used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE4 || |
296 used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE5) { | 298 used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE5) { |
297 // KDE3 didn't use DBus, which our KWallet store uses. | 299 // KDE3 didn't use DBus, which our KWallet store uses. |
298 VLOG(1) << "Trying KWallet for password storage."; | 300 VLOG(1) << "Trying KWallet for password storage."; |
299 backend.reset(new NativeBackendKWallet(id)); | 301 backend.reset(new NativeBackendKWallet(id, used_desktop_env)); |
300 if (backend->Init()) { | 302 if (backend->Init()) { |
301 VLOG(1) << "Using KWallet for password storage."; | 303 VLOG(1) << "Using KWallet for password storage."; |
302 used_backend = KWALLET; | 304 used_backend = KWALLET; |
303 } else { | 305 } else { |
304 backend.reset(); | 306 backend.reset(); |
305 } | 307 } |
306 } else if (used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_GNOME || | 308 } else if (used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_GNOME || |
307 used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_UNITY || | 309 used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_UNITY || |
308 used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_XFCE) { | 310 used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_XFCE) { |
309 #if defined(USE_LIBSECRET) | 311 #if defined(USE_LIBSECRET) |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 break; | 439 break; |
438 case LIBSECRET: | 440 case LIBSECRET: |
439 usage = OTHER_LIBSECRET; | 441 usage = OTHER_LIBSECRET; |
440 break; | 442 break; |
441 } | 443 } |
442 } | 444 } |
443 UMA_HISTOGRAM_ENUMERATION("PasswordManager.LinuxBackendStatistics", usage, | 445 UMA_HISTOGRAM_ENUMERATION("PasswordManager.LinuxBackendStatistics", usage, |
444 MAX_BACKEND_USAGE_VALUE); | 446 MAX_BACKEND_USAGE_VALUE); |
445 } | 447 } |
446 #endif | 448 #endif |
OLD | NEW |