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

Side by Side Diff: chrome/browser/password_manager/password_store_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 (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_win.h" 5 #include "chrome/browser/password_manager/password_store_win.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory>
10 #include <utility> 11 #include <utility>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/bind.h" 14 #include "base/bind.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "base/profiler/scoped_tracker.h" 17 #include "base/profiler/scoped_tracker.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
20 #include "components/os_crypt/ie7_password_win.h" 20 #include "components/os_crypt/ie7_password_win.h"
21 #include "components/password_manager/core/browser/password_manager.h" 21 #include "components/password_manager/core/browser/password_manager.h"
22 #include "components/password_manager/core/browser/webdata/password_web_data_ser vice_win.h" 22 #include "components/password_manager/core/browser/webdata/password_web_data_ser vice_win.h"
23 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 24
25 using autofill::PasswordForm; 25 using autofill::PasswordForm;
26 using content::BrowserThread; 26 using content::BrowserThread;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // fixed. 149 // fixed.
150 tracked_objects::ScopedTracker tracking_profile( 150 tracked_objects::ScopedTracker tracking_profile(
151 FROM_HERE_WITH_EXPLICIT_FUNCTION( 151 FROM_HERE_WITH_EXPLICIT_FUNCTION(
152 "422460 PasswordStoreWin::DBHandler::OnWebDataServiceRequestDone")); 152 "422460 PasswordStoreWin::DBHandler::OnWebDataServiceRequestDone"));
153 153
154 DCHECK_CURRENTLY_ON(BrowserThread::DB); 154 DCHECK_CURRENTLY_ON(BrowserThread::DB);
155 155
156 PendingRequestMap::iterator i = pending_requests_.find(handle); 156 PendingRequestMap::iterator i = pending_requests_.find(handle);
157 DCHECK(i != pending_requests_.end()); 157 DCHECK(i != pending_requests_.end());
158 158
159 scoped_ptr<PasswordForm> form(i->second.form); 159 std::unique_ptr<PasswordForm> form(i->second.form);
160 ResultCallback result_callback(i->second.result_callback); 160 ResultCallback result_callback(i->second.result_callback);
161 pending_requests_.erase(i); 161 pending_requests_.erase(i);
162 162
163 if (!result) { 163 if (!result) {
164 // The WDS returns NULL if it is shutting down. Run callback with empty 164 // The WDS returns NULL if it is shutting down. Run callback with empty
165 // result. 165 // result.
166 result_callback.Run(ScopedVector<autofill::PasswordForm>()); 166 result_callback.Run(ScopedVector<autofill::PasswordForm>());
167 return; 167 return;
168 } 168 }
169 169
170 DCHECK_EQ(PASSWORD_IE7_RESULT, result->GetType()); 170 DCHECK_EQ(PASSWORD_IE7_RESULT, result->GetType());
171 result_callback.Run(GetIE7Results(result, *form)); 171 result_callback.Run(GetIE7Results(result, *form));
172 } 172 }
173 173
174 PasswordStoreWin::PasswordStoreWin( 174 PasswordStoreWin::PasswordStoreWin(
175 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, 175 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner,
176 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner, 176 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner,
177 scoped_ptr<password_manager::LoginDatabase> login_db, 177 std::unique_ptr<password_manager::LoginDatabase> login_db,
178 const scoped_refptr<PasswordWebDataService>& web_data_service) 178 const scoped_refptr<PasswordWebDataService>& web_data_service)
179 : PasswordStoreDefault(main_thread_runner, 179 : PasswordStoreDefault(main_thread_runner,
180 db_thread_runner, 180 db_thread_runner,
181 std::move(login_db)) { 181 std::move(login_db)) {
182 db_handler_.reset(new DBHandler(web_data_service, this)); 182 db_handler_.reset(new DBHandler(web_data_service, this));
183 } 183 }
184 184
185 PasswordStoreWin::~PasswordStoreWin() { 185 PasswordStoreWin::~PasswordStoreWin() {
186 } 186 }
187 187
188 void PasswordStoreWin::ShutdownOnDBThread() { 188 void PasswordStoreWin::ShutdownOnDBThread() {
189 DCHECK_CURRENTLY_ON(BrowserThread::DB); 189 DCHECK_CURRENTLY_ON(BrowserThread::DB);
190 db_handler_.reset(); 190 db_handler_.reset();
191 } 191 }
192 192
193 void PasswordStoreWin::ShutdownOnUIThread() { 193 void PasswordStoreWin::ShutdownOnUIThread() {
194 BrowserThread::PostTask( 194 BrowserThread::PostTask(
195 BrowserThread::DB, FROM_HERE, 195 BrowserThread::DB, FROM_HERE,
196 base::Bind(&PasswordStoreWin::ShutdownOnDBThread, this)); 196 base::Bind(&PasswordStoreWin::ShutdownOnDBThread, this));
197 PasswordStoreDefault::ShutdownOnUIThread(); 197 PasswordStoreDefault::ShutdownOnUIThread();
198 } 198 }
199 199
200 void PasswordStoreWin::GetLoginsImpl(const PasswordForm& form, 200 void PasswordStoreWin::GetLoginsImpl(
201 scoped_ptr<GetLoginsRequest> request) { 201 const PasswordForm& form,
202 std::unique_ptr<GetLoginsRequest> request) {
202 // When importing from IE7, the credentials are first stored into a temporary 203 // When importing from IE7, the credentials are first stored into a temporary
203 // Web SQL database. Then, after each GetLogins() request that does not yield 204 // Web SQL database. Then, after each GetLogins() request that does not yield
204 // any matches from the LoginDatabase, the matching credentials in the Web SQL 205 // any matches from the LoginDatabase, the matching credentials in the Web SQL
205 // database, if any, are returned as results instead, and simultaneously get 206 // database, if any, are returned as results instead, and simultaneously get
206 // moved to the LoginDatabase, so next time they will be found immediately. 207 // moved to the LoginDatabase, so next time they will be found immediately.
207 // TODO(engedy): Make the IE7-specific code synchronous, so FillMatchingLogins 208 // TODO(engedy): Make the IE7-specific code synchronous, so FillMatchingLogins
208 // can be overridden instead. See: https://crbug.com/78830. 209 // can be overridden instead. See: https://crbug.com/78830.
209 // TODO(engedy): Credentials should be imported into the LoginDatabase in the 210 // TODO(engedy): Credentials should be imported into the LoginDatabase in the
210 // first place. See: https://crbug.com/456119. 211 // first place. See: https://crbug.com/456119.
211 ScopedVector<autofill::PasswordForm> matched_forms(FillMatchingLogins(form)); 212 ScopedVector<autofill::PasswordForm> matched_forms(FillMatchingLogins(form));
212 if (matched_forms.empty() && db_handler_) { 213 if (matched_forms.empty() && db_handler_) {
213 db_handler_->GetIE7Login( 214 db_handler_->GetIE7Login(
214 form, base::Bind(&GetLoginsRequest::NotifyConsumerWithResults, 215 form, base::Bind(&GetLoginsRequest::NotifyConsumerWithResults,
215 base::Owned(request.release()))); 216 base::Owned(request.release())));
216 } else { 217 } else {
217 request->NotifyConsumerWithResults(std::move(matched_forms)); 218 request->NotifyConsumerWithResults(std::move(matched_forms));
218 } 219 }
219 } 220 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_store_win.h ('k') | chrome/browser/password_manager/password_store_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698