Index: components/os_crypt/key_storage_util_linux.cc |
diff --git a/components/os_crypt/key_storage_util_linux.cc b/components/os_crypt/key_storage_util_linux.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..eb82a0d620bf82a6685fb78136e8fde75f332f11 |
--- /dev/null |
+++ b/components/os_crypt/key_storage_util_linux.cc |
@@ -0,0 +1,43 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "components/os_crypt/key_storage_util_linux.h" |
+ |
+#include "base/logging.h" |
+ |
+SelectedLinuxBackend SelectBackend(const std::string& command, |
+ base::nix::DesktopEnvironment desktop_env) { |
+ if (command == "kwallet") |
+ return SelectedLinuxBackend::KWALLET; |
+ if (command == "kwallet5") |
+ return SelectedLinuxBackend::KWALLET5; |
+ if (command == "gnome") |
+ return SelectedLinuxBackend::GNOME_ANY; |
+ if (command == "gnome-keyring") |
+ return SelectedLinuxBackend::GNOME_KEYRING; |
+ if (command == "gnome-libsecret") |
+ return SelectedLinuxBackend::GNOME_LIBSECRET; |
+ if (command == "basic") |
+ return SelectedLinuxBackend::BASIC_TEXT; |
+ |
+ const char* name = base::nix::GetDesktopEnvironmentName(desktop_env); |
+ VLOG(1) << "Password storage detected desktop environment: " |
+ << (name ? name : "(unknown)"); |
+ |
+ // Detect the store to use automatically. |
+ switch (desktop_env) { |
+ case base::nix::DESKTOP_ENVIRONMENT_KDE4: |
+ return SelectedLinuxBackend::KWALLET; |
+ case base::nix::DESKTOP_ENVIRONMENT_KDE5: |
+ return SelectedLinuxBackend::KWALLET5; |
+ case base::nix::DESKTOP_ENVIRONMENT_GNOME: |
+ case base::nix::DESKTOP_ENVIRONMENT_UNITY: |
+ case base::nix::DESKTOP_ENVIRONMENT_XFCE: |
+ return SelectedLinuxBackend::GNOME_ANY; |
+ // KDE3 didn't use DBus, which our KWallet store uses. |
+ case base::nix::DESKTOP_ENVIRONMENT_KDE3: |
+ case base::nix::DESKTOP_ENVIRONMENT_OTHER: |
+ return SelectedLinuxBackend::BASIC_TEXT; |
+ } |
+} |