OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/os_crypt/key_storage_util_linux.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 |
| 9 SelectedLinuxBackend SelectBackend(const std::string& command, |
| 10 base::nix::DesktopEnvironment desktop_env) { |
| 11 if (command == "kwallet") |
| 12 return SelectedLinuxBackend::KWALLET; |
| 13 if (command == "kwallet5") |
| 14 return SelectedLinuxBackend::KWALLET5; |
| 15 if (command == "gnome") |
| 16 return SelectedLinuxBackend::GNOME_ANY; |
| 17 if (command == "gnome-keyring") |
| 18 return SelectedLinuxBackend::GNOME_KEYRING; |
| 19 if (command == "gnome-libsecret") |
| 20 return SelectedLinuxBackend::GNOME_LIBSECRET; |
| 21 if (command == "basic") |
| 22 return SelectedLinuxBackend::BASIC_TEXT; |
| 23 |
| 24 const char* name = base::nix::GetDesktopEnvironmentName(desktop_env); |
| 25 VLOG(1) << "Password storage detected desktop environment: " |
| 26 << (name ? name : "(unknown)"); |
| 27 |
| 28 // Detect the store to use automatically. |
| 29 switch (desktop_env) { |
| 30 case base::nix::DESKTOP_ENVIRONMENT_KDE4: |
| 31 return SelectedLinuxBackend::KWALLET; |
| 32 case base::nix::DESKTOP_ENVIRONMENT_KDE5: |
| 33 return SelectedLinuxBackend::KWALLET5; |
| 34 case base::nix::DESKTOP_ENVIRONMENT_GNOME: |
| 35 case base::nix::DESKTOP_ENVIRONMENT_UNITY: |
| 36 case base::nix::DESKTOP_ENVIRONMENT_XFCE: |
| 37 return SelectedLinuxBackend::GNOME_ANY; |
| 38 // KDE3 didn't use DBus, which our KWallet store uses. |
| 39 case base::nix::DESKTOP_ENVIRONMENT_KDE3: |
| 40 case base::nix::DESKTOP_ENVIRONMENT_OTHER: |
| 41 return SelectedLinuxBackend::BASIC_TEXT; |
| 42 } |
| 43 } |
OLD | NEW |