OLD | NEW |
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 #include "components/password_manager/core/browser/password_autofill_manager.h" | 5 #include "components/password_manager/core/browser/password_autofill_manager.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 } // namespace | 55 } // namespace |
56 | 56 |
57 //////////////////////////////////////////////////////////////////////////////// | 57 //////////////////////////////////////////////////////////////////////////////// |
58 // PasswordAutofillManager, public: | 58 // PasswordAutofillManager, public: |
59 | 59 |
60 PasswordAutofillManager::PasswordAutofillManager( | 60 PasswordAutofillManager::PasswordAutofillManager( |
61 PasswordManagerClient* password_manager_client, | 61 PasswordManagerClient* password_manager_client, |
| 62 PasswordManagerDriver* password_manager_driver, |
62 autofill::AutofillClient* autofill_client) | 63 autofill::AutofillClient* autofill_client) |
63 : password_manager_client_(password_manager_client), | 64 : password_manager_client_(password_manager_client), |
| 65 password_manager_driver_(password_manager_driver), |
64 autofill_client_(autofill_client), | 66 autofill_client_(autofill_client), |
65 weak_ptr_factory_(this) { | 67 weak_ptr_factory_(this) { |
66 } | 68 } |
67 | 69 |
68 PasswordAutofillManager::~PasswordAutofillManager() { | 70 PasswordAutofillManager::~PasswordAutofillManager() { |
69 } | 71 } |
70 | 72 |
71 bool PasswordAutofillManager::FillSuggestion(int key, | 73 bool PasswordAutofillManager::FillSuggestion(int key, |
72 const base::string16& username) { | 74 const base::string16& username) { |
73 autofill::PasswordFormFillData fill_data; | 75 autofill::PasswordFormFillData fill_data; |
74 base::string16 password; | 76 base::string16 password; |
75 if (FindLoginInfo(key, &fill_data) && | 77 if (FindLoginInfo(key, &fill_data) && |
76 GetPasswordForUsername(username, fill_data, &password)) { | 78 GetPasswordForUsername(username, fill_data, &password)) { |
77 PasswordManagerDriver* driver = password_manager_client_->GetDriver(); | 79 password_manager_driver_->FillSuggestion(username, password); |
78 driver->FillSuggestion(username, password); | |
79 return true; | 80 return true; |
80 } | 81 } |
81 return false; | 82 return false; |
82 } | 83 } |
83 | 84 |
84 bool PasswordAutofillManager::PreviewSuggestion( | 85 bool PasswordAutofillManager::PreviewSuggestion( |
85 int key, | 86 int key, |
86 const base::string16& username) { | 87 const base::string16& username) { |
87 autofill::PasswordFormFillData fill_data; | 88 autofill::PasswordFormFillData fill_data; |
88 base::string16 password; | 89 base::string16 password; |
89 if (FindLoginInfo(key, &fill_data) && | 90 if (FindLoginInfo(key, &fill_data) && |
90 GetPasswordForUsername(username, fill_data, &password)) { | 91 GetPasswordForUsername(username, fill_data, &password)) { |
91 PasswordManagerDriver* driver = password_manager_client_->GetDriver(); | 92 password_manager_driver_->PreviewSuggestion(username, password); |
92 driver->PreviewSuggestion(username, password); | |
93 return true; | 93 return true; |
94 } | 94 } |
95 return false; | 95 return false; |
96 } | 96 } |
97 | 97 |
98 void PasswordAutofillManager::OnAddPasswordFormMapping( | 98 void PasswordAutofillManager::OnAddPasswordFormMapping( |
99 int key, | 99 int key, |
100 const autofill::PasswordFormFillData& fill_data) { | 100 const autofill::PasswordFormFillData& fill_data) { |
101 if (!autofill::IsValidPasswordFormFillData(fill_data)) | 101 if (!autofill::IsValidPasswordFormFillData(fill_data)) |
102 return; | 102 return; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 DCHECK(success); | 177 DCHECK(success); |
178 autofill_client_->HideAutofillPopup(); | 178 autofill_client_->HideAutofillPopup(); |
179 } | 179 } |
180 | 180 |
181 void PasswordAutofillManager::RemoveSuggestion(const base::string16& value, | 181 void PasswordAutofillManager::RemoveSuggestion(const base::string16& value, |
182 int identifier) { | 182 int identifier) { |
183 NOTREACHED(); | 183 NOTREACHED(); |
184 } | 184 } |
185 | 185 |
186 void PasswordAutofillManager::ClearPreviewedForm() { | 186 void PasswordAutofillManager::ClearPreviewedForm() { |
187 PasswordManagerDriver* driver = password_manager_client_->GetDriver(); | 187 password_manager_driver_->ClearPreviewedForm(); |
188 driver->ClearPreviewedForm(); | |
189 } | 188 } |
190 | 189 |
191 //////////////////////////////////////////////////////////////////////////////// | 190 //////////////////////////////////////////////////////////////////////////////// |
192 // PasswordAutofillManager, private: | 191 // PasswordAutofillManager, private: |
193 | 192 |
194 bool PasswordAutofillManager::GetPasswordForUsername( | 193 bool PasswordAutofillManager::GetPasswordForUsername( |
195 const base::string16& current_username, | 194 const base::string16& current_username, |
196 const autofill::PasswordFormFillData& fill_data, | 195 const autofill::PasswordFormFillData& fill_data, |
197 base::string16* password) { | 196 base::string16* password) { |
198 // TODO(dubroy): When password access requires some kind of authentication | 197 // TODO(dubroy): When password access requires some kind of authentication |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 autofill::PasswordFormFillData* found_password) { | 235 autofill::PasswordFormFillData* found_password) { |
237 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(key); | 236 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(key); |
238 if (iter == login_to_password_info_.end()) | 237 if (iter == login_to_password_info_.end()) |
239 return false; | 238 return false; |
240 | 239 |
241 *found_password = iter->second; | 240 *found_password = iter->second; |
242 return true; | 241 return true; |
243 } | 242 } |
244 | 243 |
245 } // namespace password_manager | 244 } // namespace password_manager |
OLD | NEW |