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

Side by Side Diff: components/password_manager/content/browser/content_password_manager_driver.cc

Issue 184103016: Autofill: Refactoring to support fetching password after a username is selected (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address gcasto's comments. Created 6 years, 9 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/content/browser/content_password_manager_d river.h" 5 #include "components/password_manager/content/browser/content_password_manager_d river.h"
6 6
7 #include "components/autofill/content/browser/content_autofill_driver.h" 7 #include "components/autofill/content/browser/content_autofill_driver.h"
8 #include "components/autofill/content/common/autofill_messages.h" 8 #include "components/autofill/content/common/autofill_messages.h"
9 #include "components/autofill/core/common/form_data.h" 9 #include "components/autofill/core/common/form_data.h"
10 #include "components/autofill/core/common/password_form.h" 10 #include "components/autofill/core/common/password_form.h"
11 #include "content/public/browser/browser_context.h" 11 #include "content/public/browser/browser_context.h"
12 #include "content/public/browser/navigation_details.h" 12 #include "content/public/browser/navigation_details.h"
13 #include "content/public/browser/navigation_entry.h" 13 #include "content/public/browser/navigation_entry.h"
14 #include "content/public/browser/render_view_host.h" 14 #include "content/public/browser/render_view_host.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #include "content/public/common/page_transition_types.h" 16 #include "content/public/common/page_transition_types.h"
17 #include "content/public/common/ssl_status.h" 17 #include "content/public/common/ssl_status.h"
18 #include "ipc/ipc_message_macros.h" 18 #include "ipc/ipc_message_macros.h"
19 #include "net/cert/cert_status_flags.h" 19 #include "net/cert/cert_status_flags.h"
20 20
21 ContentPasswordManagerDriver::ContentPasswordManagerDriver( 21 ContentPasswordManagerDriver::ContentPasswordManagerDriver(
22 content::WebContents* web_contents, 22 content::WebContents* web_contents,
23 PasswordManagerClient* client) 23 PasswordManagerClient* client)
24 : WebContentsObserver(web_contents), 24 : WebContentsObserver(web_contents),
25 password_manager_(client), 25 password_manager_(client),
26 password_generation_manager_(client) { 26 password_generation_manager_(client),
27 password_autofill_manager_(client, GetAutofillManager()->delegate()) {
27 DCHECK(web_contents); 28 DCHECK(web_contents);
28 } 29 }
29 30
30 ContentPasswordManagerDriver::~ContentPasswordManagerDriver() {} 31 ContentPasswordManagerDriver::~ContentPasswordManagerDriver() {}
31 32
32 void ContentPasswordManagerDriver::FillPasswordForm( 33 void ContentPasswordManagerDriver::FillPasswordForm(
33 const autofill::PasswordFormFillData& form_data) { 34 const autofill::PasswordFormFillData& form_data) {
34 DCHECK(web_contents()); 35 DCHECK(web_contents());
35 web_contents()->GetRenderViewHost()->Send(new AutofillMsg_FillPasswordForm( 36 web_contents()->GetRenderViewHost()->Send(new AutofillMsg_FillPasswordForm(
36 web_contents()->GetRenderViewHost()->GetRoutingID(), form_data)); 37 web_contents()->GetRenderViewHost()->GetRoutingID(), form_data));
37 } 38 }
38 39
39 void ContentPasswordManagerDriver::AllowPasswordGenerationForForm( 40 void ContentPasswordManagerDriver::AllowPasswordGenerationForForm(
40 autofill::PasswordForm* form) { 41 autofill::PasswordForm* form) {
41 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); 42 content::RenderViewHost* host = web_contents()->GetRenderViewHost();
42 host->Send(new AutofillMsg_FormNotBlacklisted(host->GetRoutingID(), *form)); 43 host->Send(new AutofillMsg_FormNotBlacklisted(host->GetRoutingID(), *form));
43 } 44 }
44 45
45 void ContentPasswordManagerDriver::AccountCreationFormsFound( 46 void ContentPasswordManagerDriver::AccountCreationFormsFound(
46 const std::vector<autofill::FormData>& forms) { 47 const std::vector<autofill::FormData>& forms) {
47 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); 48 content::RenderViewHost* host = web_contents()->GetRenderViewHost();
48 host->Send(new AutofillMsg_AccountCreationFormsDetected(host->GetRoutingID(), 49 host->Send(new AutofillMsg_AccountCreationFormsDetected(host->GetRoutingID(),
49 forms)); 50 forms));
50 } 51 }
51 52
53 void ContentPasswordManagerDriver::AcceptPasswordAutofillSuggestion(
54 const base::string16& username,
55 const base::string16& password) {
56 DCHECK(web_contents());
Ilya Sherman 2014/03/18 00:14:27 nit: This seems redundant with calling a method on
Patrick Dubroy 2014/03/28 15:44:22 Well, some have it, some don't. But, I agree that
57 content::RenderViewHost* host = web_contents()->GetRenderViewHost();
58 host->Send(
59 new AutofillMsg_AcceptPasswordAutofillSuggestion(host->GetRoutingID(),
60 username,
61 password));
62 }
63
52 bool ContentPasswordManagerDriver::DidLastPageLoadEncounterSSLErrors() { 64 bool ContentPasswordManagerDriver::DidLastPageLoadEncounterSSLErrors() {
53 DCHECK(web_contents()); 65 DCHECK(web_contents());
54 content::NavigationEntry* entry = 66 content::NavigationEntry* entry =
55 web_contents()->GetController().GetActiveEntry(); 67 web_contents()->GetController().GetActiveEntry();
56 if (!entry) { 68 if (!entry) {
57 NOTREACHED(); 69 NOTREACHED();
58 return false; 70 return false;
59 } 71 }
60 72
61 return net::IsCertStatusError(entry->GetSSL().cert_status); 73 return net::IsCertStatusError(entry->GetSSL().cert_status);
62 } 74 }
63 75
64 bool ContentPasswordManagerDriver::IsOffTheRecord() { 76 bool ContentPasswordManagerDriver::IsOffTheRecord() {
65 DCHECK(web_contents()); 77 DCHECK(web_contents());
66 return web_contents()->GetBrowserContext()->IsOffTheRecord(); 78 return web_contents()->GetBrowserContext()->IsOffTheRecord();
67 } 79 }
68 80
69 PasswordGenerationManager* 81 PasswordGenerationManager*
70 ContentPasswordManagerDriver::GetPasswordGenerationManager() { 82 ContentPasswordManagerDriver::GetPasswordGenerationManager() {
71 return &password_generation_manager_; 83 return &password_generation_manager_;
72 } 84 }
73 85
74 PasswordManager* ContentPasswordManagerDriver::GetPasswordManager() { 86 PasswordManager* ContentPasswordManagerDriver::GetPasswordManager() {
75 return &password_manager_; 87 return &password_manager_;
76 } 88 }
77 89
90 PasswordAutofillManager*
91 ContentPasswordManagerDriver::GetPasswordAutofillManager() {
92 return &password_autofill_manager_;
93 }
94
78 void ContentPasswordManagerDriver::DidNavigateMainFrame( 95 void ContentPasswordManagerDriver::DidNavigateMainFrame(
79 const content::LoadCommittedDetails& details, 96 const content::LoadCommittedDetails& details,
80 const content::FrameNavigateParams& params) { 97 const content::FrameNavigateParams& params) {
81 password_manager_.DidNavigateMainFrame(details.is_in_page); 98 password_manager_.DidNavigateMainFrame(details.is_in_page);
82 } 99 }
83 100
84 bool ContentPasswordManagerDriver::OnMessageReceived( 101 bool ContentPasswordManagerDriver::OnMessageReceived(
85 const IPC::Message& message) { 102 const IPC::Message& message) {
86 bool handled = true; 103 bool handled = true;
87 IPC_BEGIN_MESSAGE_MAP(PasswordManager, message) 104 IPC_BEGIN_MESSAGE_MAP(PasswordManager, message)
88 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormsParsed, 105 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormsParsed,
89 &password_manager_, 106 &password_manager_,
90 PasswordManager::OnPasswordFormsParsed) 107 PasswordManager::OnPasswordFormsParsed)
91 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormsRendered, 108 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormsRendered,
92 &password_manager_, 109 &password_manager_,
93 PasswordManager::OnPasswordFormsRendered) 110 PasswordManager::OnPasswordFormsRendered)
94 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormSubmitted, 111 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormSubmitted,
95 &password_manager_, 112 &password_manager_,
96 PasswordManager::OnPasswordFormSubmitted) 113 PasswordManager::OnPasswordFormSubmitted)
114 IPC_MESSAGE_FORWARD(AutofillHostMsg_ShowPasswordSuggestions,
115 &password_autofill_manager_,
116 PasswordAutofillManager::OnShowPasswordSuggestions)
117 IPC_MESSAGE_FORWARD(AutofillHostMsg_AddPasswordFormMapping,
118 &password_autofill_manager_,
119 PasswordAutofillManager::OnAddPasswordFormMapping)
97 IPC_MESSAGE_UNHANDLED(handled = false) 120 IPC_MESSAGE_UNHANDLED(handled = false)
98 IPC_END_MESSAGE_MAP() 121 IPC_END_MESSAGE_MAP()
99 122
100 return handled; 123 return handled;
101 } 124 }
102 125
103 autofill::AutofillManager* ContentPasswordManagerDriver::GetAutofillManager() { 126 autofill::AutofillManager* ContentPasswordManagerDriver::GetAutofillManager() {
104 autofill::ContentAutofillDriver* driver = 127 autofill::ContentAutofillDriver* driver =
105 autofill::ContentAutofillDriver::FromWebContents(web_contents()); 128 autofill::ContentAutofillDriver::FromWebContents(web_contents());
106 return driver ? driver->autofill_manager() : NULL; 129 return driver ? driver->autofill_manager() : NULL;
107 } 130 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698