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

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: mem leak Created 6 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 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 client_(client),
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() {
86 DCHECK(web_contents());
87 // TODO(vabr): This is a wrong entry to look at for HTTP basic auth,
88 // http://crbug.com/388246.
89 content::NavigationEntry* entry =
90 web_contents()->GetController().GetLastCommittedEntry();
91 if (!entry) {
92 return false;
93 }
94
95 return net::IsCertStatusError(entry->GetSSL().cert_status);
96 }
97
98 bool ContentPasswordManagerDriver::IsOffTheRecord() {
99 DCHECK(web_contents());
100 return web_contents()->GetBrowserContext()->IsOffTheRecord();
101 }
102
103 PasswordGenerationManager* 96 PasswordGenerationManager*
104 ContentPasswordManagerDriver::GetPasswordGenerationManager() { 97 ContentPasswordManagerDriver::GetPasswordGenerationManager() {
105 return &password_generation_manager_; 98 return &password_generation_manager_;
106 } 99 }
107 100
108 PasswordManager* ContentPasswordManagerDriver::GetPasswordManager() { 101 PasswordManager* ContentPasswordManagerDriver::GetPasswordManager() {
109 return &password_manager_; 102 return client_->GetPasswordManager();
110 } 103 }
111 104
112 PasswordAutofillManager* 105 PasswordAutofillManager*
113 ContentPasswordManagerDriver::GetPasswordAutofillManager() { 106 ContentPasswordManagerDriver::GetPasswordAutofillManager() {
114 return &password_autofill_manager_; 107 return &password_autofill_manager_;
115 } 108 }
116 109
117 void ContentPasswordManagerDriver::DidNavigateMainFrame( 110 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; 111 bool handled = true;
126 IPC_BEGIN_MESSAGE_MAP(PasswordManager, message) 112 IPC_BEGIN_MESSAGE_MAP(ContentPasswordManagerDriver, message)
127 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormsParsed, 113 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormsParsed,
128 &password_manager_, 114 OnPasswordFormsParsed)
129 PasswordManager::OnPasswordFormsParsed) 115 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormsRendered,
130 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormsRendered, 116 OnPasswordFormsRendered)
131 &password_manager_, 117 IPC_MESSAGE_HANDLER(AutofillHostMsg_PasswordFormSubmitted,
132 PasswordManager::OnPasswordFormsRendered) 118 OnPasswordFormSubmitted)
133 IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormSubmitted,
134 &password_manager_,
135 PasswordManager::OnPasswordFormSubmitted)
136 IPC_MESSAGE_FORWARD(AutofillHostMsg_ShowPasswordSuggestions, 119 IPC_MESSAGE_FORWARD(AutofillHostMsg_ShowPasswordSuggestions,
137 &password_autofill_manager_, 120 &password_autofill_manager_,
138 PasswordAutofillManager::OnShowPasswordSuggestions) 121 PasswordAutofillManager::OnShowPasswordSuggestions)
139 IPC_MESSAGE_FORWARD(AutofillHostMsg_RecordSavePasswordProgress, 122 IPC_MESSAGE_FORWARD(AutofillHostMsg_RecordSavePasswordProgress, client_,
140 password_manager_.client(),
141 PasswordManagerClient::LogSavePasswordProgress) 123 PasswordManagerClient::LogSavePasswordProgress)
142 IPC_MESSAGE_UNHANDLED(handled = false) 124 IPC_MESSAGE_UNHANDLED(handled = false)
143 IPC_END_MESSAGE_MAP() 125 IPC_END_MESSAGE_MAP()
144
145 return handled; 126 return handled;
146 } 127 }
147 128
129 void ContentPasswordManagerDriver::OnPasswordFormsParsed(
130 const std::vector<autofill::PasswordForm>& forms) {
131 GetPasswordManager()->OnPasswordFormsParsed(this, forms);
132 }
133
134 void ContentPasswordManagerDriver::OnPasswordFormsRendered(
135 const std::vector<autofill::PasswordForm>& visible_forms,
136 bool did_stop_loading) {
137 GetPasswordManager()->OnPasswordFormsRendered(this, visible_forms,
138 did_stop_loading);
139 }
140
141 void ContentPasswordManagerDriver::OnPasswordFormSubmitted(
142 const autofill::PasswordForm& password_form) {
143 GetPasswordManager()->OnPasswordFormSubmitted(this, password_form);
144 }
145
146 void ContentPasswordManagerDriver::DidNavigateFrame(
147 const content::LoadCommittedDetails& details,
148 const content::FrameNavigateParams& params) {
149 GetPasswordAutofillManager()->Reset();
150 if (!render_frame_host_->GetParent())
151 GetPasswordManager()->DidNavigateMainFrame(details.is_in_page);
152 }
153
148 autofill::AutofillManager* ContentPasswordManagerDriver::GetAutofillManager() { 154 autofill::AutofillManager* ContentPasswordManagerDriver::GetAutofillManager() {
149 autofill::ContentAutofillDriver* driver = 155 autofill::ContentAutofillDriverFactory* factory =
150 autofill::ContentAutofillDriver::FromWebContents(web_contents()); 156 autofill::ContentAutofillDriverFactory::FromWebContents(
151 return driver ? driver->autofill_manager() : NULL; 157 content::WebContents::FromRenderFrameHost(render_frame_host_));
158 return factory
159 ? factory->DriverForFrame(render_frame_host_)->autofill_manager()
160 : nullptr;
152 } 161 }
153 162
154 } // namespace password_manager 163 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698