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

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 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 content::RenderViewHost* host = web_contents()->GetRenderViewHost();
57 host->Send(
58 new AutofillMsg_AcceptPasswordAutofillSuggestion(host->GetRoutingID(),
59 username,
60 password));
61 }
62
52 bool ContentPasswordManagerDriver::DidLastPageLoadEncounterSSLErrors() { 63 bool ContentPasswordManagerDriver::DidLastPageLoadEncounterSSLErrors() {
53 DCHECK(web_contents()); 64 DCHECK(web_contents());
54 content::NavigationEntry* entry = 65 content::NavigationEntry* entry =
55 web_contents()->GetController().GetActiveEntry(); 66 web_contents()->GetController().GetActiveEntry();
56 if (!entry) { 67 if (!entry) {
57 NOTREACHED(); 68 NOTREACHED();
58 return false; 69 return false;
59 } 70 }
60 71
61 return net::IsCertStatusError(entry->GetSSL().cert_status); 72 return net::IsCertStatusError(entry->GetSSL().cert_status);
62 } 73 }
63 74
64 bool ContentPasswordManagerDriver::IsOffTheRecord() { 75 bool ContentPasswordManagerDriver::IsOffTheRecord() {
65 DCHECK(web_contents()); 76 DCHECK(web_contents());
66 return web_contents()->GetBrowserContext()->IsOffTheRecord(); 77 return web_contents()->GetBrowserContext()->IsOffTheRecord();
67 } 78 }
68 79
69 PasswordGenerationManager* 80 PasswordGenerationManager*
70 ContentPasswordManagerDriver::GetPasswordGenerationManager() { 81 ContentPasswordManagerDriver::GetPasswordGenerationManager() {
71 return &password_generation_manager_; 82 return &password_generation_manager_;
72 } 83 }
73 84
74 PasswordManager* ContentPasswordManagerDriver::GetPasswordManager() { 85 PasswordManager* ContentPasswordManagerDriver::GetPasswordManager() {
75 return &password_manager_; 86 return &password_manager_;
76 } 87 }
77 88
89 PasswordAutofillManager*
90 ContentPasswordManagerDriver::GetPasswordAutofillManager() {
91 return &password_autofill_manager_;
92 }
93
78 void ContentPasswordManagerDriver::DidNavigateMainFrame( 94 void ContentPasswordManagerDriver::DidNavigateMainFrame(
79 const content::LoadCommittedDetails& details, 95 const content::LoadCommittedDetails& details,
80 const content::FrameNavigateParams& params) { 96 const content::FrameNavigateParams& params) {
81 password_manager_.DidNavigateMainFrame(details.is_in_page); 97 password_manager_.DidNavigateMainFrame(details.is_in_page);
82 } 98 }
83 99
84 bool ContentPasswordManagerDriver::OnMessageReceived( 100 bool ContentPasswordManagerDriver::OnMessageReceived(
85 const IPC::Message& message) { 101 const IPC::Message& message) {
86 bool handled = true; 102 bool handled = true;
87 IPC_BEGIN_MESSAGE_MAP(PasswordManager, message) 103 IPC_BEGIN_MESSAGE_MAP(PasswordManager, message)
88 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormsParsed, 104 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormsParsed,
89 &password_manager_, 105 &password_manager_,
90 PasswordManager::OnPasswordFormsParsed) 106 PasswordManager::OnPasswordFormsParsed)
91 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormsRendered, 107 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormsRendered,
92 &password_manager_, 108 &password_manager_,
93 PasswordManager::OnPasswordFormsRendered) 109 PasswordManager::OnPasswordFormsRendered)
94 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormSubmitted, 110 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormSubmitted,
95 &password_manager_, 111 &password_manager_,
96 PasswordManager::OnPasswordFormSubmitted) 112 PasswordManager::OnPasswordFormSubmitted)
113 IPC_MESSAGE_FORWARD(AutofillHostMsg_ShowPasswordSuggestions,
114 &password_autofill_manager_,
115 PasswordAutofillManager::OnShowPasswordSuggestions)
116 IPC_MESSAGE_FORWARD(AutofillHostMsg_AddPasswordFormMapping,
117 &password_autofill_manager_,
118 PasswordAutofillManager::OnAddPasswordFormMapping)
97 IPC_MESSAGE_UNHANDLED(handled = false) 119 IPC_MESSAGE_UNHANDLED(handled = false)
98 IPC_END_MESSAGE_MAP() 120 IPC_END_MESSAGE_MAP()
99 121
100 return handled; 122 return handled;
101 } 123 }
102 124
103 autofill::AutofillManager* ContentPasswordManagerDriver::GetAutofillManager() { 125 autofill::AutofillManager* ContentPasswordManagerDriver::GetAutofillManager() {
104 autofill::ContentAutofillDriver* driver = 126 autofill::ContentAutofillDriver* driver =
105 autofill::ContentAutofillDriver::FromWebContents(web_contents()); 127 autofill::ContentAutofillDriver::FromWebContents(web_contents());
106 return driver ? driver->autofill_manager() : NULL; 128 return driver ? driver->autofill_manager() : NULL;
107 } 129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698