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

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

Issue 707173004: Refactor Autofill for out of process iframes (OOPIF). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 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/browser/content_autofill_driver_factory.h"
8 #include "components/autofill/content/common/autofill_messages.h" 9 #include "components/autofill/content/common/autofill_messages.h"
9 #include "components/autofill/core/common/form_data.h" 10 #include "components/autofill/core/common/form_data.h"
10 #include "components/autofill/core/common/password_form.h" 11 #include "components/autofill/core/common/password_form.h"
12 #include "components/password_manager/content/browser/content_password_manager_d river_factory.h"
11 #include "components/password_manager/core/browser/password_manager_client.h" 13 #include "components/password_manager/core/browser/password_manager_client.h"
12 #include "content/public/browser/browser_context.h" 14 #include "content/public/browser/browser_context.h"
13 #include "content/public/browser/navigation_details.h" 15 #include "content/public/browser/navigation_details.h"
14 #include "content/public/browser/navigation_entry.h" 16 #include "content/public/browser/navigation_entry.h"
17 #include "content/public/browser/render_frame_host.h"
15 #include "content/public/browser/render_view_host.h" 18 #include "content/public/browser/render_view_host.h"
19 #include "content/public/browser/site_instance.h"
16 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
17 #include "content/public/common/ssl_status.h" 21 #include "content/public/common/ssl_status.h"
18 #include "ipc/ipc_message_macros.h" 22 #include "ipc/ipc_message_macros.h"
19 #include "net/cert/cert_status_flags.h" 23 #include "net/cert/cert_status_flags.h"
20 24
21 namespace password_manager { 25 namespace password_manager {
22 26
23 ContentPasswordManagerDriver::ContentPasswordManagerDriver( 27 ContentPasswordManagerDriver::ContentPasswordManagerDriver(
24 content::WebContents* web_contents, 28 content::RenderFrameHost* render_frame_host,
25 PasswordManagerClient* client, 29 PasswordManagerClient* client,
26 autofill::AutofillClient* autofill_client) 30 autofill::AutofillClient* autofill_client)
27 : WebContentsObserver(web_contents), 31 : render_frame_host_(render_frame_host),
28 password_manager_(client), 32 password_manager_(client, this),
29 password_generation_manager_(client), 33 password_generation_manager_(client, this),
30 password_autofill_manager_(client, autofill_client), 34 password_autofill_manager_(client, this, autofill_client),
31 next_free_key_(0) { 35 next_free_key_(0) {
32 DCHECK(web_contents);
33 } 36 }
34 37
35 ContentPasswordManagerDriver::~ContentPasswordManagerDriver() {} 38 ContentPasswordManagerDriver::~ContentPasswordManagerDriver() {}
36 39
40 // static
41 ContentPasswordManagerDriver*
42 ContentPasswordManagerDriver::GetForRenderFrameHost(
43 content::RenderFrameHost* render_frame_host) {
44 return ContentPasswordManagerDriverFactory::FromWebContents(
45 content::WebContents::FromRenderFrameHost(render_frame_host))
46 ->GetDriverForFrame(render_frame_host);
47 }
48
37 void ContentPasswordManagerDriver::FillPasswordForm( 49 void ContentPasswordManagerDriver::FillPasswordForm(
38 const autofill::PasswordFormFillData& form_data) { 50 const autofill::PasswordFormFillData& form_data) {
39 const int key = next_free_key_++; 51 const int key = next_free_key_++;
40 password_autofill_manager_.OnAddPasswordFormMapping(key, form_data); 52 password_autofill_manager_.OnAddPasswordFormMapping(key, form_data);
41 DCHECK(web_contents()); 53 render_frame_host_->Send(new AutofillMsg_FillPasswordForm(
42 web_contents()->GetRenderViewHost()->Send(new AutofillMsg_FillPasswordForm( 54 render_frame_host_->GetRoutingID(), key, form_data));
43 web_contents()->GetRenderViewHost()->GetRoutingID(), key, form_data));
44 } 55 }
45 56
46 void ContentPasswordManagerDriver::AllowPasswordGenerationForForm( 57 void ContentPasswordManagerDriver::AllowPasswordGenerationForForm(
47 const autofill::PasswordForm& form) { 58 const autofill::PasswordForm& form) {
48 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); 59 content::RenderFrameHost* host = render_frame_host_;
49 host->Send(new AutofillMsg_FormNotBlacklisted(host->GetRoutingID(), form)); 60 host->Send(new AutofillMsg_FormNotBlacklisted(host->GetRoutingID(), form));
50 } 61 }
51 62
52 void ContentPasswordManagerDriver::AccountCreationFormsFound( 63 void ContentPasswordManagerDriver::AccountCreationFormsFound(
53 const std::vector<autofill::FormData>& forms) { 64 const std::vector<autofill::FormData>& forms) {
54 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); 65 content::RenderFrameHost* host = render_frame_host_;
55 host->Send(new AutofillMsg_AccountCreationFormsDetected(host->GetRoutingID(), 66 host->Send(new AutofillMsg_AccountCreationFormsDetected(host->GetRoutingID(),
56 forms)); 67 forms));
57 } 68 }
58 69
59 void ContentPasswordManagerDriver::FillSuggestion( 70 void ContentPasswordManagerDriver::FillSuggestion(
60 const base::string16& username, 71 const base::string16& username,
61 const base::string16& password) { 72 const base::string16& password) {
62 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); 73 content::RenderFrameHost* host = render_frame_host_;
63 host->Send( 74 host->Send(
64 new AutofillMsg_FillPasswordSuggestion(host->GetRoutingID(), 75 new AutofillMsg_FillPasswordSuggestion(host->GetRoutingID(),
65 username, 76 username,
66 password)); 77 password));
67 } 78 }
68 79
69 void ContentPasswordManagerDriver::PreviewSuggestion( 80 void ContentPasswordManagerDriver::PreviewSuggestion(
70 const base::string16& username, 81 const base::string16& username,
71 const base::string16& password) { 82 const base::string16& password) {
72 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); 83 content::RenderFrameHost* host = render_frame_host_;
73 host->Send( 84 host->Send(
74 new AutofillMsg_PreviewPasswordSuggestion(host->GetRoutingID(), 85 new AutofillMsg_PreviewPasswordSuggestion(host->GetRoutingID(),
75 username, 86 username,
76 password)); 87 password));
77 } 88 }
78 89
79 void ContentPasswordManagerDriver::ClearPreviewedForm() { 90 void ContentPasswordManagerDriver::ClearPreviewedForm() {
80 content::RenderViewHost* host = web_contents()->GetRenderViewHost(); 91 content::RenderFrameHost* host = render_frame_host_;
81 host->Send( 92 host->Send(
82 new AutofillMsg_ClearPreviewedForm(host->GetRoutingID())); 93 new AutofillMsg_ClearPreviewedForm(host->GetRoutingID()));
83 } 94 }
84 95
85 bool ContentPasswordManagerDriver::DidLastPageLoadEncounterSSLErrors() { 96 bool ContentPasswordManagerDriver::DidLastPageLoadEncounterSSLErrors() {
86 DCHECK(web_contents());
87 // TODO(vabr): This is a wrong entry to look at for HTTP basic auth, 97 // TODO(vabr): This is a wrong entry to look at for HTTP basic auth,
88 // http://crbug.com/388246. 98 // http://crbug.com/388246.
89 content::NavigationEntry* entry = 99 content::NavigationEntry* entry =
90 web_contents()->GetController().GetLastCommittedEntry(); 100 content::WebContents::FromRenderFrameHost(render_frame_host_)
101 ->GetController()
102 .GetLastCommittedEntry();
91 if (!entry) { 103 if (!entry) {
92 return false; 104 return false;
93 } 105 }
94 106
95 return net::IsCertStatusError(entry->GetSSL().cert_status); 107 return net::IsCertStatusError(entry->GetSSL().cert_status);
96 } 108 }
97 109
98 bool ContentPasswordManagerDriver::IsOffTheRecord() { 110 bool ContentPasswordManagerDriver::IsOffTheRecord() {
99 DCHECK(web_contents()); 111 return render_frame_host_->GetSiteInstance()
100 return web_contents()->GetBrowserContext()->IsOffTheRecord(); 112 ->GetBrowserContext()
113 ->IsOffTheRecord();
101 } 114 }
102 115
103 PasswordGenerationManager* 116 PasswordGenerationManager*
104 ContentPasswordManagerDriver::GetPasswordGenerationManager() { 117 ContentPasswordManagerDriver::GetPasswordGenerationManager() {
105 return &password_generation_manager_; 118 return &password_generation_manager_;
106 } 119 }
107 120
108 PasswordManager* ContentPasswordManagerDriver::GetPasswordManager() { 121 PasswordManager* ContentPasswordManagerDriver::GetPasswordManager() {
109 return &password_manager_; 122 return &password_manager_;
110 } 123 }
111 124
112 PasswordAutofillManager* 125 PasswordAutofillManager*
113 ContentPasswordManagerDriver::GetPasswordAutofillManager() { 126 ContentPasswordManagerDriver::GetPasswordAutofillManager() {
114 return &password_autofill_manager_; 127 return &password_autofill_manager_;
115 } 128 }
116 129
117 void ContentPasswordManagerDriver::DidNavigateMainFrame( 130 bool ContentPasswordManagerDriver::HandleMessage(const IPC::Message& message) {
118 const content::LoadCommittedDetails& details,
119 const content::FrameNavigateParams& params) {
120 password_manager_.DidNavigateMainFrame(details.is_in_page);
121 }
122
123 bool ContentPasswordManagerDriver::OnMessageReceived(
124 const IPC::Message& message) {
125 bool handled = true; 131 bool handled = true;
126 IPC_BEGIN_MESSAGE_MAP(PasswordManager, message) 132 IPC_BEGIN_MESSAGE_MAP(PasswordManager, message)
127 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormsParsed, 133 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormsParsed,
128 &password_manager_, 134 &password_manager_,
129 PasswordManager::OnPasswordFormsParsed) 135 PasswordManager::OnPasswordFormsParsed)
130 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormsRendered, 136 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormsRendered,
131 &password_manager_, 137 &password_manager_,
132 PasswordManager::OnPasswordFormsRendered) 138 PasswordManager::OnPasswordFormsRendered)
133 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormSubmitted, 139 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormSubmitted,
134 &password_manager_, 140 &password_manager_,
135 PasswordManager::OnPasswordFormSubmitted) 141 PasswordManager::OnPasswordFormSubmitted)
136 IPC_MESSAGE_FORWARD(AutofillHostMsg_ShowPasswordSuggestions, 142 IPC_MESSAGE_FORWARD(AutofillHostMsg_ShowPasswordSuggestions,
137 &password_autofill_manager_, 143 &password_autofill_manager_,
138 PasswordAutofillManager::OnShowPasswordSuggestions) 144 PasswordAutofillManager::OnShowPasswordSuggestions)
139 IPC_MESSAGE_FORWARD(AutofillHostMsg_RecordSavePasswordProgress, 145 IPC_MESSAGE_FORWARD(AutofillHostMsg_RecordSavePasswordProgress,
140 password_manager_.client(), 146 password_manager_.client(),
141 PasswordManagerClient::LogSavePasswordProgress) 147 PasswordManagerClient::LogSavePasswordProgress)
142 IPC_MESSAGE_UNHANDLED(handled = false) 148 IPC_MESSAGE_UNHANDLED(handled = false)
143 IPC_END_MESSAGE_MAP() 149 IPC_END_MESSAGE_MAP()
144 150
145 return handled; 151 return handled;
146 } 152 }
147 153
154 void ContentPasswordManagerDriver::DidNavigateFrame(
155 const content::LoadCommittedDetails& details,
156 const content::FrameNavigateParams& params) {
157 password_manager_.DidNavigateMainFrame(details.is_in_page);
vabr (Chromium) 2014/11/10 14:34:40 I don't think we should call DidNavigateMainFrame
Evan Stade 2014/11/14 23:25:50 Done.
158 }
159
148 autofill::AutofillManager* ContentPasswordManagerDriver::GetAutofillManager() { 160 autofill::AutofillManager* ContentPasswordManagerDriver::GetAutofillManager() {
149 autofill::ContentAutofillDriver* driver = 161 autofill::ContentAutofillDriverFactory* factory =
150 autofill::ContentAutofillDriver::FromWebContents(web_contents()); 162 autofill::ContentAutofillDriverFactory::FromWebContents(
151 return driver ? driver->autofill_manager() : NULL; 163 content::WebContents::FromRenderFrameHost(render_frame_host_));
164 return factory
165 ? factory->DriverForFrame(render_frame_host_)->autofill_manager()
166 : NULL;
vabr (Chromium) 2014/11/10 14:34:40 nit: nullptr
152 } 167 }
153 168
154 } // namespace password_manager 169 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698