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_win.h" | 5 #include "chrome/browser/password_manager/password_store_win.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 // Handles requests to PasswordWebDataService. | 24 // Handles requests to PasswordWebDataService. |
25 class PasswordStoreWin::DBHandler : public WebDataServiceConsumer { | 25 class PasswordStoreWin::DBHandler : public WebDataServiceConsumer { |
26 public: | 26 public: |
27 typedef base::Callback<void(ScopedVector<PasswordForm>)> ResultCallback; | 27 typedef base::Callback<void(ScopedVector<PasswordForm>)> ResultCallback; |
28 | 28 |
29 DBHandler(const scoped_refptr<PasswordWebDataService>& web_data_service, | 29 DBHandler(const scoped_refptr<PasswordWebDataService>& web_data_service, |
30 PasswordStoreWin* password_store) | 30 PasswordStoreWin* password_store) |
31 : web_data_service_(web_data_service), password_store_(password_store) {} | 31 : web_data_service_(web_data_service), password_store_(password_store) {} |
32 | 32 |
33 ~DBHandler(); | 33 ~DBHandler() override; |
34 | 34 |
35 // Requests the IE7 login for |form|. This is async. |result_callback| will be | 35 // Requests the IE7 login for |form|. This is async. |result_callback| will be |
36 // run when complete. | 36 // run when complete. |
37 void GetIE7Login(const PasswordForm& form, | 37 void GetIE7Login(const PasswordForm& form, |
38 const ResultCallback& result_callback); | 38 const ResultCallback& result_callback); |
39 | 39 |
40 private: | 40 private: |
41 struct RequestInfo { | 41 struct RequestInfo { |
42 RequestInfo() {} | 42 RequestInfo() {} |
43 | 43 |
44 RequestInfo(PasswordForm* request_form, | 44 RequestInfo(PasswordForm* request_form, |
45 const ResultCallback& result_callback) | 45 const ResultCallback& result_callback) |
46 : form(request_form), result_callback(result_callback) {} | 46 : form(request_form), result_callback(result_callback) {} |
47 | 47 |
48 PasswordForm* form; | 48 PasswordForm* form; |
49 ResultCallback result_callback; | 49 ResultCallback result_callback; |
50 }; | 50 }; |
51 | 51 |
52 // Holds info associated with in-flight GetIE7Login requests. | 52 // Holds info associated with in-flight GetIE7Login requests. |
53 typedef std::map<PasswordWebDataService::Handle, RequestInfo> | 53 typedef std::map<PasswordWebDataService::Handle, RequestInfo> |
54 PendingRequestMap; | 54 PendingRequestMap; |
55 | 55 |
56 // Gets logins from IE7 if no others are found. Also copies them into | 56 // Gets logins from IE7 if no others are found. Also copies them into |
57 // Chrome's WebDatabase so we don't need to look next time. | 57 // Chrome's WebDatabase so we don't need to look next time. |
58 ScopedVector<autofill::PasswordForm> GetIE7Results( | 58 ScopedVector<autofill::PasswordForm> GetIE7Results( |
59 const WDTypedResult* result, | 59 const WDTypedResult* result, |
60 const PasswordForm& form); | 60 const PasswordForm& form); |
61 | 61 |
62 // WebDataServiceConsumer implementation. | 62 // WebDataServiceConsumer implementation. |
63 virtual void OnWebDataServiceRequestDone( | 63 void OnWebDataServiceRequestDone( |
64 PasswordWebDataService::Handle handle, | 64 PasswordWebDataService::Handle handle, |
65 const WDTypedResult* result) override; | 65 const WDTypedResult* result) override; |
66 | 66 |
67 scoped_refptr<PasswordWebDataService> web_data_service_; | 67 scoped_refptr<PasswordWebDataService> web_data_service_; |
68 | 68 |
69 // This creates a cycle between us and PasswordStore. The cycle is broken | 69 // This creates a cycle between us and PasswordStore. The cycle is broken |
70 // from PasswordStoreWin::Shutdown, which deletes us. | 70 // from PasswordStoreWin::Shutdown, which deletes us. |
71 scoped_refptr<PasswordStoreWin> password_store_; | 71 scoped_refptr<PasswordStoreWin> password_store_; |
72 | 72 |
73 PendingRequestMap pending_requests_; | 73 PendingRequestMap pending_requests_; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 ScopedVector<autofill::PasswordForm> matched_forms( | 207 ScopedVector<autofill::PasswordForm> matched_forms( |
208 FillMatchingLogins(form, prompt_policy)); | 208 FillMatchingLogins(form, prompt_policy)); |
209 if (matched_forms.empty() && db_handler_) { | 209 if (matched_forms.empty() && db_handler_) { |
210 db_handler_->GetIE7Login( | 210 db_handler_->GetIE7Login( |
211 form, base::Bind(&GetLoginsRequest::NotifyConsumerWithResults, | 211 form, base::Bind(&GetLoginsRequest::NotifyConsumerWithResults, |
212 base::Owned(request.release()))); | 212 base::Owned(request.release()))); |
213 } else { | 213 } else { |
214 request->NotifyConsumerWithResults(matched_forms.Pass()); | 214 request->NotifyConsumerWithResults(matched_forms.Pass()); |
215 } | 215 } |
216 } | 216 } |
OLD | NEW |