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

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 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) {
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& value) {
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(value, password)) {
31 if (web_contents_) { 29 // TODO(jeanfrancoisg): Remove 'if' once PasswordAutofillManagerTest fully
32 content::RenderViewHost* render_view_host = 30 // mocks the autofill_driver_. http://crbug.com/321721
33 web_contents_->GetRenderViewHost(); 31 if (autofill_driver_)
34 render_view_host->Send(new AutofillMsg_AcceptPasswordAutofillSuggestion( 32 autofill_driver_->RendererShouldAcceptPasswordAutofillSuggestion(value);
35 render_view_host->GetRoutingID(),
36 value));
37 }
38 return true; 33 return true;
39 } 34 }
40 35
41 return false; 36 return false;
42 } 37 }
43 38
44 void PasswordAutofillManager::AddPasswordFormMapping( 39 void PasswordAutofillManager::AddPasswordFormMapping(
45 const FormFieldData& username_element, 40 const FormFieldData& username_element,
46 const PasswordFormFillData& password) { 41 const PasswordFormFillData& password) {
47 login_to_password_info_[username_element] = password; 42 login_to_password_info_[username_element] = password;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 PasswordFormFillData* found_password) { 82 PasswordFormFillData* found_password) {
88 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(field); 83 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(field);
89 if (iter == login_to_password_info_.end()) 84 if (iter == login_to_password_info_.end())
90 return false; 85 return false;
91 86
92 *found_password = iter->second; 87 *found_password = iter->second;
93 return true; 88 return true;
94 } 89 }
95 90
96 } // namespace autofill 91 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698