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

Side by Side Diff: components/autofill/content/renderer/autofill_agent.cc

Issue 796493004: Remove FrameDetached and FrameWillClose listeners from AutofillAgent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix init order Created 5 years, 11 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
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/content/renderer/autofill_agent.h" 5 #include "components/autofill/content/renderer/autofill_agent.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 180 }
181 181
182 void AutofillAgent::DidCommitProvisionalLoad(bool is_new_navigation) { 182 void AutofillAgent::DidCommitProvisionalLoad(bool is_new_navigation) {
183 form_cache_.Reset(); 183 form_cache_.Reset();
184 } 184 }
185 185
186 void AutofillAgent::DidFinishDocumentLoad() { 186 void AutofillAgent::DidFinishDocumentLoad() {
187 ProcessForms(); 187 ProcessForms();
188 } 188 }
189 189
190 void AutofillAgent::FrameDetached(WebFrame* frame) {
191 if (frame != render_frame()->GetWebFrame())
192 return;
193
194 form_cache_.Reset();
195 }
196
197 void AutofillAgent::WillSubmitForm(const WebFormElement& form) { 190 void AutofillAgent::WillSubmitForm(const WebFormElement& form) {
198 FormData form_data; 191 FormData form_data;
199 if (WebFormElementToFormData(form, 192 if (WebFormElementToFormData(form,
200 WebFormControlElement(), 193 WebFormControlElement(),
201 REQUIRE_NONE, 194 REQUIRE_NONE,
202 static_cast<ExtractMask>( 195 static_cast<ExtractMask>(
203 EXTRACT_VALUE | EXTRACT_OPTION_TEXT), 196 EXTRACT_VALUE | EXTRACT_OPTION_TEXT),
204 &form_data, 197 &form_data,
205 NULL)) { 198 NULL)) {
206 Send(new AutofillHostMsg_FormSubmitted(routing_id(), form_data, 199 Send(new AutofillHostMsg_FormSubmitted(routing_id(), form_data,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 !element->isTextField() || element->isPasswordField()) 231 !element->isTextField() || element->isPasswordField())
239 return; 232 return;
240 233
241 element_ = *element; 234 element_ = *element;
242 } 235 }
243 236
244 void AutofillAgent::Resized() { 237 void AutofillAgent::Resized() {
245 HidePopup(); 238 HidePopup();
246 } 239 }
247 240
248 void AutofillAgent::LegacyFrameWillClose(blink::WebFrame* frame) {
249 if (in_flight_request_form_.isNull())
250 return;
251
252 for (blink::WebFrame* temp = render_frame()->GetWebFrame(); temp;
253 temp = temp->parent()) {
254 if (temp == frame) {
255 Send(new AutofillHostMsg_CancelRequestAutocomplete(routing_id()));
256 break;
257 }
258 }
259 }
260
261 void AutofillAgent::didRequestAutocomplete( 241 void AutofillAgent::didRequestAutocomplete(
262 const WebFormElement& form) { 242 const WebFormElement& form) {
263 DCHECK_EQ(form.document().frame(), render_frame()->GetWebFrame()); 243 DCHECK_EQ(form.document().frame(), render_frame()->GetWebFrame());
264 244
265 // Disallow the dialog over non-https or broken https, except when the 245 // Disallow the dialog over non-https or broken https, except when the
266 // ignore SSL flag is passed. See http://crbug.com/272512. 246 // ignore SSL flag is passed. See http://crbug.com/272512.
267 // TODO(palmer): this should be moved to the browser process after frames 247 // TODO(palmer): this should be moved to the browser process after frames
268 // get their own processes. 248 // get their own processes.
269 GURL url(form.document().url()); 249 GURL url(form.document().url());
270 content::SSLStatus ssl_status = 250 content::SSLStatus ssl_status =
271 render_frame()->GetRenderView()->GetSSLStatusOfFrame( 251 render_frame()->GetRenderView()->GetSSLStatusOfFrame(
272 form.document().frame()); 252 form.document().frame());
273 bool is_safe = url.SchemeIs(url::kHttpsScheme) && 253 bool is_safe = url.SchemeIs(url::kHttpsScheme) &&
274 !net::IsCertStatusError(ssl_status.cert_status); 254 !net::IsCertStatusError(ssl_status.cert_status);
275 bool allow_unsafe = base::CommandLine::ForCurrentProcess()->HasSwitch( 255 bool allow_unsafe = base::CommandLine::ForCurrentProcess()->HasSwitch(
276 ::switches::kReduceSecurityForTesting); 256 ::switches::kReduceSecurityForTesting);
277
278 FormData form_data; 257 FormData form_data;
279 std::string error_message; 258 std::string error_message;
280 if (!in_flight_request_form_.isNull()) { 259 if (!in_flight_request_form_.isNull()) {
281 error_message = "already active."; 260 error_message = "already active.";
282 } else if (!is_safe && !allow_unsafe) { 261 } else if (!is_safe && !allow_unsafe) {
283 error_message = 262 error_message =
284 "must use a secure connection or --reduce-security-for-testing."; 263 "must use a secure connection or --reduce-security-for-testing.";
285 } else if (!WebFormElementToFormData(form, 264 } else if (!WebFormElementToFormData(form,
286 WebFormControlElement(), 265 WebFormControlElement(),
287 REQUIRE_AUTOCOMPLETE, 266 REQUIRE_AUTOCOMPLETE,
(...skipping 15 matching lines...) Expand all
303 WebFormElement(form).finishRequestAutocomplete( 282 WebFormElement(form).finishRequestAutocomplete(
304 WebFormElement::AutocompleteResultErrorDisabled); 283 WebFormElement::AutocompleteResultErrorDisabled);
305 return; 284 return;
306 } 285 }
307 286
308 // Cancel any pending Autofill requests and hide any currently showing popups. 287 // Cancel any pending Autofill requests and hide any currently showing popups.
309 ++autofill_query_id_; 288 ++autofill_query_id_;
310 HidePopup(); 289 HidePopup();
311 290
312 in_flight_request_form_ = form; 291 in_flight_request_form_ = form;
313 Send(new AutofillHostMsg_RequestAutocomplete(routing_id(), form_data, url)); 292 Send(new AutofillHostMsg_RequestAutocomplete(routing_id(), form_data));
314 } 293 }
315 294
316 void AutofillAgent::setIgnoreTextChanges(bool ignore) { 295 void AutofillAgent::setIgnoreTextChanges(bool ignore) {
317 ignore_text_changes_ = ignore; 296 ignore_text_changes_ = ignore;
318 } 297 }
319 298
320 void AutofillAgent::FormControlElementClicked( 299 void AutofillAgent::FormControlElementClicked(
321 const WebFormControlElement& element, 300 const WebFormControlElement& element,
322 bool was_focused) { 301 bool was_focused) {
323 // TODO(estade): Remove this check when PageClickTracker is per-frame. 302 // TODO(estade): Remove this check when PageClickTracker is per-frame.
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 : content::RenderViewObserver(render_view), agent_(agent) { 773 : content::RenderViewObserver(render_view), agent_(agent) {
795 } 774 }
796 775
797 AutofillAgent::LegacyAutofillAgent::~LegacyAutofillAgent() { 776 AutofillAgent::LegacyAutofillAgent::~LegacyAutofillAgent() {
798 } 777 }
799 778
800 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { 779 void AutofillAgent::LegacyAutofillAgent::OnDestruct() {
801 // No-op. Don't delete |this|. 780 // No-op. Don't delete |this|.
802 } 781 }
803 782
804 void AutofillAgent::LegacyAutofillAgent::FrameDetached(WebFrame* frame) {
805 agent_->FrameDetached(frame);
806 }
807
808 void AutofillAgent::LegacyAutofillAgent::FocusedNodeChanged( 783 void AutofillAgent::LegacyAutofillAgent::FocusedNodeChanged(
809 const WebNode& node) { 784 const WebNode& node) {
810 agent_->FocusedNodeChanged(node); 785 agent_->FocusedNodeChanged(node);
811 } 786 }
812 787
813 void AutofillAgent::LegacyAutofillAgent::Resized() { 788 void AutofillAgent::LegacyAutofillAgent::Resized() {
814 agent_->Resized(); 789 agent_->Resized();
815 } 790 }
816 791
817 void AutofillAgent::LegacyAutofillAgent::FrameWillClose(
818 blink::WebFrame* frame) {
819 agent_->LegacyFrameWillClose(frame);
820 }
821
822 } // namespace autofill 792 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/content/renderer/autofill_agent.h ('k') | components/autofill/content/renderer/password_autofill_agent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698