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

Side by Side Diff: chrome/browser/password_manager/password_manager_util_win.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // windows.h must be first otherwise Win8 SDK breaks. 5 // windows.h must be first otherwise Win8 SDK breaks.
6 #include <windows.h> 6 #include <windows.h>
7 #include <LM.h> 7 #include <LM.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <wincred.h> 10 #include <wincred.h>
11 11
12 #include <memory>
13
12 // SECURITY_WIN32 must be defined in order to get 14 // SECURITY_WIN32 must be defined in order to get
13 // EXTENDED_NAME_FORMAT enumeration. 15 // EXTENDED_NAME_FORMAT enumeration.
14 #define SECURITY_WIN32 1 16 #define SECURITY_WIN32 1
15 #include <security.h> 17 #include <security.h>
16 #undef SECURITY_WIN32 18 #undef SECURITY_WIN32
17 19
18 #include "chrome/browser/password_manager/password_manager_util_win.h" 20 #include "chrome/browser/password_manager/password_manager_util_win.h"
19 21
20 #include "base/bind.h" 22 #include "base/bind.h"
21 #include "base/bind_helpers.h" 23 #include "base/bind_helpers.h"
22 #include "base/memory/scoped_ptr.h"
23 #include "base/metrics/histogram_macros.h" 24 #include "base/metrics/histogram_macros.h"
24 #include "base/strings/utf_string_conversions.h" 25 #include "base/strings/utf_string_conversions.h"
25 #include "base/threading/worker_pool.h" 26 #include "base/threading/worker_pool.h"
26 #include "base/time/time.h" 27 #include "base/time/time.h"
27 #include "base/win/windows_version.h" 28 #include "base/win/windows_version.h"
28 #include "chrome/browser/browser_process.h" 29 #include "chrome/browser/browser_process.h"
29 #include "chrome/grit/chromium_strings.h" 30 #include "chrome/grit/chromium_strings.h"
30 #include "components/password_manager/core/browser/password_manager.h" 31 #include "components/password_manager/core/browser/password_manager.h"
31 #include "components/password_manager/core/common/password_manager_pref_names.h" 32 #include "components/password_manager/core/common/password_manager_pref_names.h"
32 #include "components/prefs/pref_service.h" 33 #include "components/prefs/pref_service.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // http://crbug.com/345916 182 // http://crbug.com/345916
182 if (base::win::GetVersion() >= base::win::VERSION_WIN7 && 183 if (base::win::GetVersion() >= base::win::VERSION_WIN7 &&
183 GetUserName(username, &username_length)) { 184 GetUserName(username, &username_length)) {
184 *status = CheckBlankPasswordWithPrefs(username, prefs) ? 185 *status = CheckBlankPasswordWithPrefs(username, prefs) ?
185 PASSWORD_STATUS_BLANK : 186 PASSWORD_STATUS_BLANK :
186 PASSWORD_STATUS_NONBLANK; 187 PASSWORD_STATUS_NONBLANK;
187 } 188 }
188 } 189 }
189 } 190 }
190 191
191 void ReplyOsPasswordStatus(scoped_ptr<PasswordCheckPrefs> prefs, 192 void ReplyOsPasswordStatus(std::unique_ptr<PasswordCheckPrefs> prefs,
192 scoped_ptr<OsPasswordStatus> status) { 193 std::unique_ptr<OsPasswordStatus> status) {
193 PrefService* local_state = g_browser_process->local_state(); 194 PrefService* local_state = g_browser_process->local_state();
194 prefs->Write(local_state); 195 prefs->Write(local_state);
195 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OsPasswordStatus", *status, 196 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OsPasswordStatus", *status,
196 MAX_PASSWORD_STATUS); 197 MAX_PASSWORD_STATUS);
197 } 198 }
198 199
199 void GetOsPasswordStatus() { 200 void GetOsPasswordStatus() {
200 // Preferences can be accessed on the UI thread only. 201 // Preferences can be accessed on the UI thread only.
201 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 202 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
202 PrefService* local_state = g_browser_process->local_state(); 203 PrefService* local_state = g_browser_process->local_state();
203 scoped_ptr<PasswordCheckPrefs> prefs(new PasswordCheckPrefs); 204 std::unique_ptr<PasswordCheckPrefs> prefs(new PasswordCheckPrefs);
204 prefs->Read(local_state); 205 prefs->Read(local_state);
205 scoped_ptr<OsPasswordStatus> status( 206 std::unique_ptr<OsPasswordStatus> status(
206 new OsPasswordStatus(PASSWORD_STATUS_UNKNOWN)); 207 new OsPasswordStatus(PASSWORD_STATUS_UNKNOWN));
207 PasswordCheckPrefs* prefs_weak = prefs.get(); 208 PasswordCheckPrefs* prefs_weak = prefs.get();
208 OsPasswordStatus* status_weak = status.get(); 209 OsPasswordStatus* status_weak = status.get();
209 bool posted = base::WorkerPool::PostTaskAndReply( 210 bool posted = base::WorkerPool::PostTaskAndReply(
210 FROM_HERE, 211 FROM_HERE,
211 base::Bind(&GetOsPasswordStatusInternal, prefs_weak, status_weak), 212 base::Bind(&GetOsPasswordStatusInternal, prefs_weak, status_weak),
212 base::Bind(&ReplyOsPasswordStatus, base::Passed(&prefs), 213 base::Bind(&ReplyOsPasswordStatus, base::Passed(&prefs),
213 base::Passed(&status)), 214 base::Passed(&status)),
214 true); 215 true);
215 if (!posted) { 216 if (!posted) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 } 320 }
320 } 321 }
321 SecureZeroMemory(password, sizeof(password)); 322 SecureZeroMemory(password, sizeof(password));
322 } 323 }
323 } while (credErr == NO_ERROR && 324 } while (credErr == NO_ERROR &&
324 (retval == false && tries < kMaxPasswordRetries)); 325 (retval == false && tries < kMaxPasswordRetries));
325 return retval; 326 return retval;
326 } 327 }
327 328
328 } // namespace password_manager_util_win 329 } // namespace password_manager_util_win
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698