| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/password_manager/password_store_factory.h" | 5 #include "chrome/browser/password_manager/password_store_factory.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/environment.h" | 11 #include "base/environment.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 14 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
| 15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 18 #include "chrome/browser/profiles/incognito_helpers.h" | 18 #include "chrome/browser/profiles/incognito_helpers.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/signin/signin_manager_factory.h" | 20 #include "chrome/browser/signin/signin_manager_factory.h" |
| 21 #include "chrome/browser/sync/glue/sync_start_util.h" | 21 #include "chrome/browser/sync/glue/sync_start_util.h" |
| 22 #include "chrome/browser/sync/profile_sync_service_factory.h" | 22 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 23 #include "chrome/browser/web_data_service_factory.h" | 23 #include "chrome/browser/web_data_service_factory.h" |
| 24 #include "chrome/common/chrome_paths_internal.h" |
| 24 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 25 #include "components/browser_sync/profile_sync_service.h" | 26 #include "components/browser_sync/profile_sync_service.h" |
| 26 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 27 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 27 #include "components/os_crypt/os_crypt_switches.h" | 28 #include "components/os_crypt/os_crypt_switches.h" |
| 28 #include "components/password_manager/core/browser/http_data_cleaner.h" | 29 #include "components/password_manager/core/browser/http_data_cleaner.h" |
| 29 #include "components/password_manager/core/browser/login_database.h" | 30 #include "components/password_manager/core/browser/login_database.h" |
| 30 #include "components/password_manager/core/browser/password_store.h" | 31 #include "components/password_manager/core/browser/password_store.h" |
| 31 #include "components/password_manager/core/browser/password_store_default.h" | 32 #include "components/password_manager/core/browser/password_store_default.h" |
| 32 #include "components/password_manager/core/browser/password_store_factory_util.h
" | 33 #include "components/password_manager/core/browser/password_store_factory_util.h
" |
| 33 #include "components/password_manager/core/common/password_manager_pref_names.h" | 34 #include "components/password_manager/core/common/password_manager_pref_names.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // (In all cases we fall back on the basic store in case of failure.) | 190 // (In all cases we fall back on the basic store in case of failure.) |
| 190 base::nix::DesktopEnvironment desktop_env = GetDesktopEnvironment(); | 191 base::nix::DesktopEnvironment desktop_env = GetDesktopEnvironment(); |
| 191 std::string store_type = | 192 std::string store_type = |
| 192 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 193 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 193 switches::kPasswordStore); | 194 switches::kPasswordStore); |
| 194 LinuxBackendUsed used_backend = PLAINTEXT; | 195 LinuxBackendUsed used_backend = PLAINTEXT; |
| 195 | 196 |
| 196 PrefService* prefs = profile->GetPrefs(); | 197 PrefService* prefs = profile->GetPrefs(); |
| 197 LocalProfileId id = GetLocalProfileId(prefs); | 198 LocalProfileId id = GetLocalProfileId(prefs); |
| 198 | 199 |
| 200 bool use_preference = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 201 switches::kEnableEncryptionSelection); |
| 202 bool use_backend = true; |
| 203 if (use_preference) { |
| 204 base::FilePath user_data_dir; |
| 205 chrome::GetDefaultUserDataDirectory(&user_data_dir); |
| 206 use_backend = os_crypt::GetBackendUse(user_data_dir); |
| 207 } |
| 208 |
| 199 os_crypt::SelectedLinuxBackend selected_backend = | 209 os_crypt::SelectedLinuxBackend selected_backend = |
| 200 os_crypt::SelectBackend(store_type, desktop_env); | 210 os_crypt::SelectBackend(store_type, use_backend, desktop_env); |
| 201 | 211 |
| 202 std::unique_ptr<PasswordStoreX::NativeBackend> backend; | 212 std::unique_ptr<PasswordStoreX::NativeBackend> backend; |
| 203 if (selected_backend == os_crypt::SelectedLinuxBackend::KWALLET || | 213 if (selected_backend == os_crypt::SelectedLinuxBackend::KWALLET || |
| 204 selected_backend == os_crypt::SelectedLinuxBackend::KWALLET5) { | 214 selected_backend == os_crypt::SelectedLinuxBackend::KWALLET5) { |
| 205 VLOG(1) << "Trying KWallet for password storage."; | 215 VLOG(1) << "Trying KWallet for password storage."; |
| 206 base::nix::DesktopEnvironment used_desktop_env = | 216 base::nix::DesktopEnvironment used_desktop_env = |
| 207 selected_backend == os_crypt::SelectedLinuxBackend::KWALLET | 217 selected_backend == os_crypt::SelectedLinuxBackend::KWALLET |
| 208 ? base::nix::DESKTOP_ENVIRONMENT_KDE4 | 218 ? base::nix::DESKTOP_ENVIRONMENT_KDE4 |
| 209 : base::nix::DESKTOP_ENVIRONMENT_KDE5; | 219 : base::nix::DESKTOP_ENVIRONMENT_KDE5; |
| 210 backend.reset(new NativeBackendKWallet(id, used_desktop_env)); | 220 backend.reset(new NativeBackendKWallet(id, used_desktop_env)); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 break; | 377 break; |
| 368 case LIBSECRET: | 378 case LIBSECRET: |
| 369 usage = OTHER_LIBSECRET; | 379 usage = OTHER_LIBSECRET; |
| 370 break; | 380 break; |
| 371 } | 381 } |
| 372 } | 382 } |
| 373 UMA_HISTOGRAM_ENUMERATION("PasswordManager.LinuxBackendStatistics", usage, | 383 UMA_HISTOGRAM_ENUMERATION("PasswordManager.LinuxBackendStatistics", usage, |
| 374 MAX_BACKEND_USAGE_VALUE); | 384 MAX_BACKEND_USAGE_VALUE); |
| 375 } | 385 } |
| 376 #endif | 386 #endif |
| OLD | NEW |