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

Side by Side Diff: components/autofill/core/browser/password_autofill_manager.cc

Issue 79103002: Abstracted AcceptPasswordAutofillSuggestion IPC out of core Autofill code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review fixes. Created 7 years, 1 month 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 #include "base/logging.h"
6 #include "components/autofill/core/browser/autofill_driver.h"
5 #include "components/autofill/core/browser/password_autofill_manager.h" 7 #include "components/autofill/core/browser/password_autofill_manager.h"
6 #include "components/autofill/core/common/autofill_messages.h"
7 #include "content/public/browser/render_view_host.h"
8 #include "content/public/browser/web_contents.h"
9 #include "ui/events/keycodes/keyboard_codes.h" 8 #include "ui/events/keycodes/keyboard_codes.h"
10 9
11 namespace autofill { 10 namespace autofill {
12 11
13 //////////////////////////////////////////////////////////////////////////////// 12 ////////////////////////////////////////////////////////////////////////////////
14 // PasswordAutofillManager, public: 13 // PasswordAutofillManager, public:
15 14
16 PasswordAutofillManager::PasswordAutofillManager( 15 PasswordAutofillManager::PasswordAutofillManager(
17 content::WebContents* web_contents) : web_contents_(web_contents) { 16 AutofillDriver* autofill_driver) : autofill_driver_(autofill_driver) {
17 DCHECK(autofill_driver);
18 } 18 }
19 19
20 PasswordAutofillManager::~PasswordAutofillManager() { 20 PasswordAutofillManager::~PasswordAutofillManager() {
21 } 21 }
22 22
23 bool PasswordAutofillManager::DidAcceptAutofillSuggestion( 23 bool PasswordAutofillManager::DidAcceptAutofillSuggestion(
24 const FormFieldData& field, 24 const FormFieldData& field,
25 const base::string16& value) { 25 const base::string16& username) {
26 PasswordFormFillData password; 26 PasswordFormFillData password;
27 if (!FindLoginInfo(field, &password)) 27 if (!FindLoginInfo(field, &password))
28 return false; 28 return false;
29 29
30 if (WillFillUserNameAndPassword(value, password)) { 30 if (WillFillUserNameAndPassword(username, password)) {
31 if (web_contents_) { 31 autofill_driver_->RendererShouldAcceptPasswordAutofillSuggestion(username);
32 content::RenderViewHost* render_view_host =
33 web_contents_->GetRenderViewHost();
34 render_view_host->Send(new AutofillMsg_AcceptPasswordAutofillSuggestion(
35 render_view_host->GetRoutingID(),
36 value));
37 }
38 return true; 32 return true;
39 } 33 }
40 34
41 return false; 35 return false;
42 } 36 }
43 37
44 void PasswordAutofillManager::AddPasswordFormMapping( 38 void PasswordAutofillManager::AddPasswordFormMapping(
45 const FormFieldData& username_element, 39 const FormFieldData& username_element,
46 const PasswordFormFillData& password) { 40 const PasswordFormFillData& password) {
47 login_to_password_info_[username_element] = password; 41 login_to_password_info_[username_element] = password;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 PasswordFormFillData* found_password) { 81 PasswordFormFillData* found_password) {
88 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(field); 82 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(field);
89 if (iter == login_to_password_info_.end()) 83 if (iter == login_to_password_info_.end())
90 return false; 84 return false;
91 85
92 *found_password = iter->second; 86 *found_password = iter->second;
93 return true; 87 return true;
94 } 88 }
95 89
96 } // namespace autofill 90 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698