Chromium Code Reviews| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 content::BrowserThread::DB)); | 121 content::BrowserThread::DB)); |
| 121 } | 122 } |
| 122 | 123 |
| 123 PasswordStoreFactory::PasswordStoreFactory() | 124 PasswordStoreFactory::PasswordStoreFactory() |
| 124 : RefcountedBrowserContextKeyedServiceFactory( | 125 : RefcountedBrowserContextKeyedServiceFactory( |
| 125 "PasswordStore", | 126 "PasswordStore", |
| 126 BrowserContextDependencyManager::GetInstance()) { | 127 BrowserContextDependencyManager::GetInstance()) { |
| 127 DependsOn(WebDataServiceFactory::GetInstance()); | 128 DependsOn(WebDataServiceFactory::GetInstance()); |
| 128 #if defined(OS_WIN) || defined(OS_MACOSX) || \ | 129 #if defined(OS_WIN) || defined(OS_MACOSX) || \ |
| 129 (defined(OS_LINUX) && !defined(OS_CHROMEOS)) | 130 (defined(OS_LINUX) && !defined(OS_CHROMEOS)) |
| 130 // TODO(crbug.com/715987). Remove when PasswordReuseDetector is decoupled | 131 // TODO(crbug.com/715987) Remove when PasswordReuseDetector is decoupled |
|
vabr (Chromium)
2017/07/03 19:27:14
nit: Let's stick to changes related with the CL go
cfroussios
2017/07/04 09:58:15
Done.
| |
| 131 // from PasswordStore. | 132 // from PasswordStore. |
| 132 DependsOn(SigninManagerFactory::GetInstance()); | 133 DependsOn(SigninManagerFactory::GetInstance()); |
| 133 #endif | 134 #endif |
| 134 } | 135 } |
| 135 | 136 |
| 136 PasswordStoreFactory::~PasswordStoreFactory() {} | 137 PasswordStoreFactory::~PasswordStoreFactory() {} |
| 137 | 138 |
| 138 #if !defined(OS_CHROMEOS) && defined(USE_X11) | 139 #if !defined(OS_CHROMEOS) && defined(USE_X11) |
| 139 LocalProfileId PasswordStoreFactory::GetLocalProfileId( | 140 LocalProfileId PasswordStoreFactory::GetLocalProfileId( |
| 140 PrefService* prefs) const { | 141 PrefService* prefs) const { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 // (In all cases we fall back on the basic store in case of failure.) | 200 // (In all cases we fall back on the basic store in case of failure.) |
| 200 base::nix::DesktopEnvironment desktop_env = GetDesktopEnvironment(); | 201 base::nix::DesktopEnvironment desktop_env = GetDesktopEnvironment(); |
| 201 std::string store_type = | 202 std::string store_type = |
| 202 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 203 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 203 switches::kPasswordStore); | 204 switches::kPasswordStore); |
| 204 LinuxBackendUsed used_backend = PLAINTEXT; | 205 LinuxBackendUsed used_backend = PLAINTEXT; |
| 205 | 206 |
| 206 PrefService* prefs = profile->GetPrefs(); | 207 PrefService* prefs = profile->GetPrefs(); |
| 207 LocalProfileId id = GetLocalProfileId(prefs); | 208 LocalProfileId id = GetLocalProfileId(prefs); |
| 208 | 209 |
| 210 bool use_preference = base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 211 switches::kEnableEncryptionSelection); | |
| 212 base::FilePath user_data_dir; | |
| 213 chrome::GetDefaultUserDataDirectory(&user_data_dir); | |
|
vabr (Chromium)
2017/07/03 19:27:14
optional: GetDefaultUserDataDirectory does not loo
cfroussios
2017/07/04 09:58:15
Done.
| |
| 214 bool use_backend = !use_preference || os_crypt::GetBackendUse(user_data_dir); | |
| 215 | |
| 209 os_crypt::SelectedLinuxBackend selected_backend = | 216 os_crypt::SelectedLinuxBackend selected_backend = |
| 210 os_crypt::SelectBackend(store_type, desktop_env); | 217 os_crypt::SelectBackend(store_type, use_backend, desktop_env); |
| 211 | 218 |
| 212 std::unique_ptr<PasswordStoreX::NativeBackend> backend; | 219 std::unique_ptr<PasswordStoreX::NativeBackend> backend; |
| 213 if (selected_backend == os_crypt::SelectedLinuxBackend::KWALLET || | 220 if (selected_backend == os_crypt::SelectedLinuxBackend::KWALLET || |
| 214 selected_backend == os_crypt::SelectedLinuxBackend::KWALLET5) { | 221 selected_backend == os_crypt::SelectedLinuxBackend::KWALLET5) { |
| 215 VLOG(1) << "Trying KWallet for password storage."; | 222 VLOG(1) << "Trying KWallet for password storage."; |
| 216 base::nix::DesktopEnvironment used_desktop_env = | 223 base::nix::DesktopEnvironment used_desktop_env = |
| 217 selected_backend == os_crypt::SelectedLinuxBackend::KWALLET | 224 selected_backend == os_crypt::SelectedLinuxBackend::KWALLET |
| 218 ? base::nix::DESKTOP_ENVIRONMENT_KDE4 | 225 ? base::nix::DESKTOP_ENVIRONMENT_KDE4 |
| 219 : base::nix::DESKTOP_ENVIRONMENT_KDE5; | 226 : base::nix::DESKTOP_ENVIRONMENT_KDE5; |
| 220 backend.reset(new NativeBackendKWallet(id, used_desktop_env)); | 227 backend.reset(new NativeBackendKWallet(id, used_desktop_env)); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 break; | 384 break; |
| 378 case LIBSECRET: | 385 case LIBSECRET: |
| 379 usage = OTHER_LIBSECRET; | 386 usage = OTHER_LIBSECRET; |
| 380 break; | 387 break; |
| 381 } | 388 } |
| 382 } | 389 } |
| 383 UMA_HISTOGRAM_ENUMERATION("PasswordManager.LinuxBackendStatistics", usage, | 390 UMA_HISTOGRAM_ENUMERATION("PasswordManager.LinuxBackendStatistics", usage, |
| 384 MAX_BACKEND_USAGE_VALUE); | 391 MAX_BACKEND_USAGE_VALUE); |
| 385 } | 392 } |
| 386 #endif | 393 #endif |
| OLD | NEW |