| 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 5002254b2007d6de065df50e9f8a03682058568e..fb25fe6279373aa2a7e0822b3b0843839f48c7cd 100644
|
| --- a/components/os_crypt/key_storage_linux.cc
|
| +++ b/components/os_crypt/key_storage_linux.cc
|
| @@ -26,18 +26,35 @@ 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;
|
| +namespace {
|
| +
|
| +// Parameters to OSCrypt, which are set before the first call to OSCrypt, are
|
| +// stored here.
|
| +struct Configuration {
|
| + std::string store;
|
| + std::string product_name;
|
| + scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner;
|
| +};
|
| +
|
| +base::LazyInstance<Configuration> g_config = LAZY_INSTANCE_INITIALIZER;
|
| +
|
| +} // namespace
|
|
|
| // static
|
| void KeyStorageLinux::SetStore(const std::string& store_type) {
|
| - g_store.Get() = store_type;
|
| + g_config.Get().store = 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;
|
| + g_config.Get().product_name = product_name;
|
| +}
|
| +
|
| +// static
|
| +void KeyStorageLinux::SetMainThreadRunner(
|
| + scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner) {
|
| + g_config.Get().main_thread_runner = main_thread_runner;
|
| }
|
|
|
| // static
|
| @@ -47,7 +64,7 @@ std::unique_ptr<KeyStorageLinux> KeyStorageLinux::CreateService() {
|
| base::nix::DesktopEnvironment desktop_env =
|
| base::nix::GetDesktopEnvironment(env.get());
|
| os_crypt::SelectedLinuxBackend selected_backend =
|
| - os_crypt::SelectBackend(g_store.Get(), desktop_env);
|
| + os_crypt::SelectBackend(g_config.Get().store, desktop_env);
|
|
|
| // Try initializing the selected backend.
|
| std::unique_ptr<KeyStorageLinux> key_storage;
|
| @@ -63,13 +80,13 @@ std::unique_ptr<KeyStorageLinux> KeyStorageLinux::CreateService() {
|
| } else if (selected_backend == os_crypt::SelectedLinuxBackend::KWALLET ||
|
| selected_backend == os_crypt::SelectedLinuxBackend::KWALLET5) {
|
| #if defined(USE_KWALLET)
|
| - DCHECK(!g_product_name.Get().empty());
|
| + DCHECK(!g_config.Get().product_name.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()));
|
| + new KeyStorageKWallet(used_desktop_env, g_config.Get().product_name));
|
| if (key_storage->Init()) {
|
| VLOG(1) << "OSCrypt using KWallet as backend.";
|
| return key_storage;
|
|
|