Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Unified Diff: components/os_crypt/key_storage_linux.cc

Issue 2256633002: Add two more options for the --password-store switch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: feedback Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/os_crypt/BUILD.gn ('k') | components/os_crypt/key_storage_util_linux.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/os_crypt/key_storage_linux.cc
diff --git a/components/os_crypt/key_storage_linux.cc b/components/os_crypt/key_storage_linux.cc
index 4feae11bb17d5d2ab4f261702ee723ab918348e1..5002254b2007d6de065df50e9f8a03682058568e 100644
--- a/components/os_crypt/key_storage_linux.cc
+++ b/components/os_crypt/key_storage_linux.cc
@@ -8,6 +8,7 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/nix/xdg_util.h"
+#include "components/os_crypt/key_storage_util_linux.h"
#if defined(USE_LIBSECRET)
#include "components/os_crypt/key_storage_libsecret.h"
@@ -41,25 +42,17 @@ void KeyStorageLinux::SetProductName(const std::string& product_name) {
// static
std::unique_ptr<KeyStorageLinux> KeyStorageLinux::CreateService() {
- base::nix::DesktopEnvironment used_desktop_env;
- if (g_store.Get() == "kwallet") {
- used_desktop_env = base::nix::DESKTOP_ENVIRONMENT_KDE4;
- } else if (g_store.Get() == "kwallet5") {
- used_desktop_env = base::nix::DESKTOP_ENVIRONMENT_KDE5;
- } else if (g_store.Get() == "gnome") {
- used_desktop_env = base::nix::DESKTOP_ENVIRONMENT_GNOME;
- } else if (g_store.Get() == "basic") {
- used_desktop_env = base::nix::DESKTOP_ENVIRONMENT_OTHER;
- } else {
- std::unique_ptr<base::Environment> env(base::Environment::Create());
- used_desktop_env = base::nix::GetDesktopEnvironment(env.get());
- }
+ // Select a backend.
+ std::unique_ptr<base::Environment> env(base::Environment::Create());
+ base::nix::DesktopEnvironment desktop_env =
+ base::nix::GetDesktopEnvironment(env.get());
+ os_crypt::SelectedLinuxBackend selected_backend =
+ os_crypt::SelectBackend(g_store.Get(), desktop_env);
- // Try initializing the appropriate store for our environment.
+ // Try initializing the selected backend.
std::unique_ptr<KeyStorageLinux> key_storage;
- if (used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_GNOME ||
- used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_UNITY ||
- used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_XFCE) {
+ if (selected_backend == os_crypt::SelectedLinuxBackend::GNOME_ANY ||
+ selected_backend == os_crypt::SelectedLinuxBackend::GNOME_LIBSECRET) {
#if defined(USE_LIBSECRET)
key_storage.reset(new KeyStorageLibsecret());
if (key_storage->Init()) {
@@ -67,10 +60,14 @@ std::unique_ptr<KeyStorageLinux> KeyStorageLinux::CreateService() {
return key_storage;
}
#endif
- } else if (used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE4 ||
- used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE5) {
+ } else if (selected_backend == os_crypt::SelectedLinuxBackend::KWALLET ||
+ selected_backend == os_crypt::SelectedLinuxBackend::KWALLET5) {
#if defined(USE_KWALLET)
DCHECK(!g_product_name.Get().empty());
+ base::nix::DesktopEnvironment used_desktop_env =
+ selected_backend == os_crypt::SelectedLinuxBackend::KWALLET
+ ? base::nix::DESKTOP_ENVIRONMENT_KDE4
+ : base::nix::DESKTOP_ENVIRONMENT_KDE5;
key_storage.reset(
new KeyStorageKWallet(used_desktop_env, g_product_name.Get()));
if (key_storage->Init()) {
« no previous file with comments | « components/os_crypt/BUILD.gn ('k') | components/os_crypt/key_storage_util_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698