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

Unified Diff: components/os_crypt/key_storage_linux.cc

Issue 2150543002: OSCrypt supports encryption with KWallet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: feedback Created 4 years, 5 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/key_storage_linux.h ('k') | components/os_crypt/kwallet_dbus.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 e54bb9e6719f89d22e763eb8a0aa0b70afa4c2c4..4feae11bb17d5d2ab4f261702ee723ab918348e1 100644
--- a/components/os_crypt/key_storage_linux.cc
+++ b/components/os_crypt/key_storage_linux.cc
@@ -4,8 +4,6 @@
#include "components/os_crypt/key_storage_linux.h"
-#include <string.h>
-
#include "base/environment.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
@@ -15,24 +13,42 @@
#include "components/os_crypt/key_storage_libsecret.h"
#endif
-base::LazyInstance<std::string> g_store_ = LAZY_INSTANCE_INITIALIZER;
+#if defined(USE_KWALLET)
+#include "components/os_crypt/key_storage_kwallet.h"
+#endif
+
+#if defined(OFFICIAL_BUILD)
pdknsk 2016/08/21 07:36:53 There is a minor bug here in Chromium reporting it
Lei Zhang 2016/08/22 17:09:50 Thanks for noticing. Will fix.
+const char KeyStorageLinux::kFolderName[] = "Chrome Keys";
+const char KeyStorageLinux::kKey[] = "Chrome Safe Storage";
+#else
+const char KeyStorageLinux::kFolderName[] = "Chromium Keys";
+const char KeyStorageLinux::kKey[] = "Chromium Safe Storage";
+#endif
+
+base::LazyInstance<std::string> g_store = LAZY_INSTANCE_INITIALIZER;
+base::LazyInstance<std::string> g_product_name = LAZY_INSTANCE_INITIALIZER;
// static
void KeyStorageLinux::SetStore(const std::string& store_type) {
- g_store_.Get() = store_type;
+ g_store.Get() = store_type;
VLOG(1) << "OSCrypt store set to " << store_type;
}
// static
+void KeyStorageLinux::SetProductName(const std::string& product_name) {
+ g_product_name.Get() = product_name;
+}
+
+// static
std::unique_ptr<KeyStorageLinux> KeyStorageLinux::CreateService() {
base::nix::DesktopEnvironment used_desktop_env;
- if (g_store_.Get() == "kwallet") {
+ if (g_store.Get() == "kwallet") {
used_desktop_env = base::nix::DESKTOP_ENVIRONMENT_KDE4;
- } else if (g_store_.Get() == "kwallet5") {
+ } else if (g_store.Get() == "kwallet5") {
used_desktop_env = base::nix::DESKTOP_ENVIRONMENT_KDE5;
- } else if (g_store_.Get() == "gnome") {
+ } else if (g_store.Get() == "gnome") {
used_desktop_env = base::nix::DESKTOP_ENVIRONMENT_GNOME;
- } else if (g_store_.Get() == "basic") {
+ } else if (g_store.Get() == "basic") {
used_desktop_env = base::nix::DESKTOP_ENVIRONMENT_OTHER;
} else {
std::unique_ptr<base::Environment> env(base::Environment::Create());
@@ -51,6 +67,17 @@ 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) {
+#if defined(USE_KWALLET)
+ DCHECK(!g_product_name.Get().empty());
+ key_storage.reset(
+ new KeyStorageKWallet(used_desktop_env, g_product_name.Get()));
+ if (key_storage->Init()) {
+ VLOG(1) << "OSCrypt using KWallet as backend.";
+ return key_storage;
+ }
+#endif
}
// The appropriate store was not available.
« no previous file with comments | « components/os_crypt/key_storage_linux.h ('k') | components/os_crypt/kwallet_dbus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698