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

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: 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 "components/autofill/core/browser/autofill_driver.h"
5 #include "components/autofill/core/browser/password_autofill_manager.h" 6 #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" 7 #include "ui/events/keycodes/keyboard_codes.h"
10 8
11 namespace autofill { 9 namespace autofill {
12 10
13 //////////////////////////////////////////////////////////////////////////////// 11 ////////////////////////////////////////////////////////////////////////////////
14 // PasswordAutofillManager, public: 12 // PasswordAutofillManager, public:
15 13
16 PasswordAutofillManager::PasswordAutofillManager( 14 PasswordAutofillManager::PasswordAutofillManager(
17 content::WebContents* web_contents) : web_contents_(web_contents) { 15 AutofillDriver* autofill_driver) : autofill_driver_(autofill_driver) {
Ilya Sherman 2013/11/22 00:26:29 nit: Please add DCHECK(autofill_driver) here, sinc
jif-google 2013/11/22 12:21:44 Done.
18 } 16 }
19 17
20 PasswordAutofillManager::~PasswordAutofillManager() { 18 PasswordAutofillManager::~PasswordAutofillManager() {
21 } 19 }
22 20
23 bool PasswordAutofillManager::DidAcceptAutofillSuggestion( 21 bool PasswordAutofillManager::DidAcceptAutofillSuggestion(
24 const FormFieldData& field, 22 const FormFieldData& field,
25 const base::string16& value) { 23 const base::string16& username) {
26 PasswordFormFillData password; 24 PasswordFormFillData password;
27 if (!FindLoginInfo(field, &password)) 25 if (!FindLoginInfo(field, &password))
28 return false; 26 return false;
29 27
30 if (WillFillUserNameAndPassword(value, password)) { 28 if (WillFillUserNameAndPassword(username, password)) {
31 if (web_contents_) { 29 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; 30 return true;
39 } 31 }
40 32
41 return false; 33 return false;
42 } 34 }
43 35
44 void PasswordAutofillManager::AddPasswordFormMapping( 36 void PasswordAutofillManager::AddPasswordFormMapping(
45 const FormFieldData& username_element, 37 const FormFieldData& username_element,
46 const PasswordFormFillData& password) { 38 const PasswordFormFillData& password) {
47 login_to_password_info_[username_element] = password; 39 login_to_password_info_[username_element] = password;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 PasswordFormFillData* found_password) { 79 PasswordFormFillData* found_password) {
88 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(field); 80 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(field);
89 if (iter == login_to_password_info_.end()) 81 if (iter == login_to_password_info_.end())
90 return false; 82 return false;
91 83
92 *found_password = iter->second; 84 *found_password = iter->second;
93 return true; 85 return true;
94 } 86 }
95 87
96 } // namespace autofill 88 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698