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

Side by Side Diff: chrome/browser/password_manager/password_store_factory.cc

Issue 1858513002: chrome/browser/password_manager: scoped_ptr -> unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Windows -- revert unwanted change Created 4 years, 8 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 unified diff | Download patch
OLDNEW
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 <utility> 8 #include <utility>
8 9
9 #include "base/command_line.h" 10 #include "base/command_line.h"
10 #include "base/environment.h" 11 #include "base/environment.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/rand_util.h" 13 #include "base/rand_util.h"
14 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "chrome/browser/profiles/incognito_helpers.h" 16 #include "chrome/browser/profiles/incognito_helpers.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/sync/glue/sync_start_util.h" 18 #include "chrome/browser/sync/glue/sync_start_util.h"
19 #include "chrome/browser/sync/profile_sync_service_factory.h" 19 #include "chrome/browser/sync/profile_sync_service_factory.h"
20 #include "chrome/browser/web_data_service_factory.h" 20 #include "chrome/browser/web_data_service_factory.h"
21 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 #endif 143 #endif
144 144
145 scoped_refptr<RefcountedKeyedService> 145 scoped_refptr<RefcountedKeyedService>
146 PasswordStoreFactory::BuildServiceInstanceFor( 146 PasswordStoreFactory::BuildServiceInstanceFor(
147 content::BrowserContext* context) const { 147 content::BrowserContext* context) const {
148 #if defined(OS_WIN) 148 #if defined(OS_WIN)
149 password_manager_util_win::DelayReportOsPassword(); 149 password_manager_util_win::DelayReportOsPassword();
150 #endif 150 #endif
151 Profile* profile = static_cast<Profile*>(context); 151 Profile* profile = static_cast<Profile*>(context);
152 152
153 scoped_ptr<password_manager::LoginDatabase> login_db( 153 std::unique_ptr<password_manager::LoginDatabase> login_db(
154 password_manager::CreateLoginDatabase(profile->GetPath())); 154 password_manager::CreateLoginDatabase(profile->GetPath()));
155 155
156 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner( 156 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner(
157 base::ThreadTaskRunnerHandle::Get()); 157 base::ThreadTaskRunnerHandle::Get());
158 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner( 158 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner(
159 content::BrowserThread::GetMessageLoopProxyForThread( 159 content::BrowserThread::GetMessageLoopProxyForThread(
160 content::BrowserThread::DB)); 160 content::BrowserThread::DB));
161 161
162 scoped_refptr<PasswordStore> ps; 162 scoped_refptr<PasswordStore> ps;
163 #if defined(OS_WIN) 163 #if defined(OS_WIN)
164 ps = new PasswordStoreWin(main_thread_runner, db_thread_runner, 164 ps = new PasswordStoreWin(main_thread_runner, db_thread_runner,
165 std::move(login_db), 165 std::move(login_db),
166 WebDataServiceFactory::GetPasswordWebDataForProfile( 166 WebDataServiceFactory::GetPasswordWebDataForProfile(
167 profile, ServiceAccessType::EXPLICIT_ACCESS)); 167 profile, ServiceAccessType::EXPLICIT_ACCESS));
168 #elif defined(OS_MACOSX) 168 #elif defined(OS_MACOSX)
169 scoped_ptr<crypto::AppleKeychain> keychain( 169 std::unique_ptr<crypto::AppleKeychain> keychain(
170 base::CommandLine::ForCurrentProcess()->HasSwitch( 170 base::CommandLine::ForCurrentProcess()->HasSwitch(
171 os_crypt::switches::kUseMockKeychain) 171 os_crypt::switches::kUseMockKeychain)
172 ? new crypto::MockAppleKeychain() 172 ? new crypto::MockAppleKeychain()
173 : new crypto::AppleKeychain()); 173 : new crypto::AppleKeychain());
174 ps = new PasswordStoreProxyMac(main_thread_runner, std::move(keychain), 174 ps = new PasswordStoreProxyMac(main_thread_runner, std::move(keychain),
175 std::move(login_db), profile->GetPrefs()); 175 std::move(login_db), profile->GetPrefs());
176 #elif defined(OS_CHROMEOS) || defined(OS_ANDROID) 176 #elif defined(OS_CHROMEOS) || defined(OS_ANDROID)
177 // For now, we use PasswordStoreDefault. We might want to make a native 177 // For now, we use PasswordStoreDefault. We might want to make a native
178 // backend for PasswordStoreX (see below) in the future though. 178 // backend for PasswordStoreX (see below) in the future though.
179 ps = new password_manager::PasswordStoreDefault( 179 ps = new password_manager::PasswordStoreDefault(
(...skipping 20 matching lines...) Expand all
200 // Detect the store to use automatically. 200 // Detect the store to use automatically.
201 used_desktop_env = desktop_env; 201 used_desktop_env = desktop_env;
202 const char* name = base::nix::GetDesktopEnvironmentName(desktop_env); 202 const char* name = base::nix::GetDesktopEnvironmentName(desktop_env);
203 VLOG(1) << "Password storage detected desktop environment: " 203 VLOG(1) << "Password storage detected desktop environment: "
204 << (name ? name : "(unknown)"); 204 << (name ? name : "(unknown)");
205 } 205 }
206 206
207 PrefService* prefs = profile->GetPrefs(); 207 PrefService* prefs = profile->GetPrefs();
208 LocalProfileId id = GetLocalProfileId(prefs); 208 LocalProfileId id = GetLocalProfileId(prefs);
209 209
210 scoped_ptr<PasswordStoreX::NativeBackend> backend; 210 std::unique_ptr<PasswordStoreX::NativeBackend> backend;
211 if (used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE4 || 211 if (used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE4 ||
212 used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE5) { 212 used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE5) {
213 // KDE3 didn't use DBus, which our KWallet store uses. 213 // KDE3 didn't use DBus, which our KWallet store uses.
214 VLOG(1) << "Trying KWallet for password storage."; 214 VLOG(1) << "Trying KWallet for password storage.";
215 backend.reset(new NativeBackendKWallet(id, used_desktop_env)); 215 backend.reset(new NativeBackendKWallet(id, used_desktop_env));
216 if (backend->Init()) { 216 if (backend->Init()) {
217 VLOG(1) << "Using KWallet for password storage."; 217 VLOG(1) << "Using KWallet for password storage.";
218 used_backend = KWALLET; 218 used_backend = KWALLET;
219 } else { 219 } else {
220 backend.reset(); 220 backend.reset();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 content::BrowserContext* context) const { 287 content::BrowserContext* context) const {
288 return chrome::GetBrowserContextRedirectedInIncognito(context); 288 return chrome::GetBrowserContextRedirectedInIncognito(context);
289 } 289 }
290 290
291 bool PasswordStoreFactory::ServiceIsNULLWhileTesting() const { 291 bool PasswordStoreFactory::ServiceIsNULLWhileTesting() const {
292 return true; 292 return true;
293 } 293 }
294 294
295 #if defined(USE_X11) 295 #if defined(USE_X11)
296 base::nix::DesktopEnvironment PasswordStoreFactory::GetDesktopEnvironment() { 296 base::nix::DesktopEnvironment PasswordStoreFactory::GetDesktopEnvironment() {
297 scoped_ptr<base::Environment> env(base::Environment::Create()); 297 std::unique_ptr<base::Environment> env(base::Environment::Create());
298 return base::nix::GetDesktopEnvironment(env.get()); 298 return base::nix::GetDesktopEnvironment(env.get());
299 } 299 }
300 300
301 void PasswordStoreFactory::RecordBackendStatistics( 301 void PasswordStoreFactory::RecordBackendStatistics(
302 base::nix::DesktopEnvironment desktop_env, 302 base::nix::DesktopEnvironment desktop_env,
303 const std::string& command_line_flag, 303 const std::string& command_line_flag,
304 LinuxBackendUsed used_backend) { 304 LinuxBackendUsed used_backend) {
305 LinuxBackendUsage usage = OTHER_PLAINTEXT; 305 LinuxBackendUsage usage = OTHER_PLAINTEXT;
306 if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE4 || 306 if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE4 ||
307 desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE5) { 307 desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE5) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 break; 352 break;
353 case LIBSECRET: 353 case LIBSECRET:
354 usage = OTHER_LIBSECRET; 354 usage = OTHER_LIBSECRET;
355 break; 355 break;
356 } 356 }
357 } 357 }
358 UMA_HISTOGRAM_ENUMERATION("PasswordManager.LinuxBackendStatistics", usage, 358 UMA_HISTOGRAM_ENUMERATION("PasswordManager.LinuxBackendStatistics", usage,
359 MAX_BACKEND_USAGE_VALUE); 359 MAX_BACKEND_USAGE_VALUE);
360 } 360 }
361 #endif 361 #endif
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_manager_util_win.cc ('k') | chrome/browser/password_manager/password_store_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698