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

Unified Diff: components/os_crypt/key_storage_linux.cc

Issue 2948783002: Create setting that disables password stores (Closed)
Patch Set: nits + tests Created 3 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/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 c8b18324ce7551d3df017f7bb26cd5b732ae8614..12c4a628cf39780d1341fe0cab09581b34921790 100644
--- a/components/os_crypt/key_storage_linux.cc
+++ b/components/os_crypt/key_storage_linux.cc
@@ -5,6 +5,9 @@
#include "components/os_crypt/key_storage_linux.h"
#include "base/environment.h"
+#include "base/files/file.h"
+#include "base/files/file_path.h"
+#include "base/files/file_util.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/nix/xdg_util.h"
@@ -37,6 +40,8 @@ struct Configuration {
std::string store;
std::string product_name;
scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner;
+ bool should_use_preference;
+ base::FilePath user_data_path;
};
base::LazyInstance<Configuration>::DestructorAtExit g_config =
@@ -61,15 +66,27 @@ void KeyStorageLinux::SetMainThreadRunner(
g_config.Get().main_thread_runner = main_thread_runner;
}
+// static
+void KeyStorageLinux::ShouldUsePreference(bool should_use_preference) {
+ g_config.Get().should_use_preference = should_use_preference;
+}
+
+// static
+void KeyStorageLinux::SetUserDataPath(const base::FilePath& path) {
+ g_config.Get().user_data_path = path;
+}
+
// static
std::unique_ptr<KeyStorageLinux> KeyStorageLinux::CreateService() {
#if defined(USE_LIBSECRET) || defined(USE_KEYRING) || defined(USE_KWALLET)
// Select a backend.
+ bool use_backend = !g_config.Get().should_use_preference ||
+ os_crypt::GetBackendUse(g_config.Get().user_data_path);
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_config.Get().store, desktop_env);
+ os_crypt::SelectBackend(g_config.Get().store, use_backend, desktop_env);
// Try initializing the selected backend.
// In case of GNOME_ANY, prefer Libsecret
@@ -117,6 +134,6 @@ std::unique_ptr<KeyStorageLinux> KeyStorageLinux::CreateService() {
// defined(USE_KWALLET)
// The appropriate store was not available.
- VLOG(1) << "OSCrypt could not initialize a backend.";
+ VLOG(1) << "OSCrypt did not initialize a backend.";
return nullptr;
}
« no previous file with comments | « components/os_crypt/key_storage_linux.h ('k') | components/os_crypt/key_storage_util_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698