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

Side by Side Diff: components/autofill/content/renderer/autofill_agent.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 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"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "components/autofill/content/common/autofill_messages.h" 14 #include "components/autofill/content/common/autofill_messages.h"
15 #include "components/autofill/content/renderer/form_autofill_util.h" 15 #include "components/autofill/content/renderer/form_autofill_util.h"
16 #include "components/autofill/content/renderer/page_click_tracker.h" 16 #include "components/autofill/content/renderer/page_click_tracker.h"
17 #include "components/autofill/content/renderer/password_autofill_agent.h" 17 #include "components/autofill/content/renderer/password_autofill_agent.h"
18 #include "components/autofill/content/renderer/password_generation_agent.h" 18 #include "components/autofill/content/renderer/password_generation_agent.h"
19 #include "components/autofill/core/common/autofill_constants.h" 19 #include "components/autofill/core/common/autofill_constants.h"
20 #include "components/autofill/core/common/autofill_data_validation.h" 20 #include "components/autofill/core/common/autofill_data_validation.h"
21 #include "components/autofill/core/common/autofill_switches.h" 21 #include "components/autofill/core/common/autofill_switches.h"
22 #include "components/autofill/core/common/form_data.h" 22 #include "components/autofill/core/common/form_data.h"
23 #include "components/autofill/core/common/form_data_predictions.h" 23 #include "components/autofill/core/common/form_data_predictions.h"
24 #include "components/autofill/core/common/form_field_data.h" 24 #include "components/autofill/core/common/form_field_data.h"
25 #include "components/autofill/core/common/password_form.h" 25 #include "components/autofill/core/common/password_form.h"
26 #include "components/autofill/core/common/web_element_descriptor.h" 26 #include "components/autofill/core/common/web_element_descriptor.h"
27 #include "content/public/common/content_switches.h" 27 #include "content/public/common/content_switches.h"
28 #include "content/public/common/ssl_status.h" 28 #include "content/public/common/ssl_status.h"
29 #include "content/public/common/url_constants.h" 29 #include "content/public/common/url_constants.h"
30 #include "content/public/renderer/render_frame.h"
30 #include "content/public/renderer/render_view.h" 31 #include "content/public/renderer/render_view.h"
31 #include "net/cert/cert_status_flags.h" 32 #include "net/cert/cert_status_flags.h"
32 #include "third_party/WebKit/public/platform/WebRect.h" 33 #include "third_party/WebKit/public/platform/WebRect.h"
33 #include "third_party/WebKit/public/platform/WebURLRequest.h" 34 #include "third_party/WebKit/public/platform/WebURLRequest.h"
34 #include "third_party/WebKit/public/web/WebConsoleMessage.h" 35 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
35 #include "third_party/WebKit/public/web/WebDataSource.h" 36 #include "third_party/WebKit/public/web/WebDataSource.h"
36 #include "third_party/WebKit/public/web/WebDocument.h" 37 #include "third_party/WebKit/public/web/WebDocument.h"
37 #include "third_party/WebKit/public/web/WebElementCollection.h" 38 #include "third_party/WebKit/public/web/WebElementCollection.h"
38 #include "third_party/WebKit/public/web/WebFormControlElement.h" 39 #include "third_party/WebKit/public/web/WebFormControlElement.h"
39 #include "third_party/WebKit/public/web/WebFormElement.h" 40 #include "third_party/WebKit/public/web/WebFormElement.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 113
113 // Limit the size of the strings in the vector. 114 // Limit the size of the strings in the vector.
114 for (size_t i = 0; i < strings->size(); ++i) { 115 for (size_t i = 0; i < strings->size(); ++i) {
115 if ((*strings)[i].length() > kMaxDataLength) 116 if ((*strings)[i].length() > kMaxDataLength)
116 (*strings)[i].resize(kMaxDataLength); 117 (*strings)[i].resize(kMaxDataLength);
117 } 118 }
118 } 119 }
119 120
120 } // namespace 121 } // namespace
121 122
122 AutofillAgent::AutofillAgent(content::RenderView* render_view, 123 AutofillAgent::AutofillAgent(content::RenderFrame* render_frame,
123 PasswordAutofillAgent* password_autofill_agent, 124 PasswordAutofillAgent* password_autofill_agent,
124 PasswordGenerationAgent* password_generation_agent) 125 PasswordGenerationAgent* password_generation_agent)
125 : content::RenderViewObserver(render_view), 126 : content::RenderFrameObserver(render_frame),
126 password_autofill_agent_(password_autofill_agent), 127 password_autofill_agent_(password_autofill_agent),
127 password_generation_agent_(password_generation_agent), 128 password_generation_agent_(password_generation_agent),
129 legacy_(render_frame->GetRenderView(), this),
130 page_click_tracker_(render_frame->GetRenderView(), this),
128 autofill_query_id_(0), 131 autofill_query_id_(0),
129 web_view_(render_view->GetWebView()),
130 display_warning_if_disabled_(false), 132 display_warning_if_disabled_(false),
131 was_query_node_autofilled_(false), 133 was_query_node_autofilled_(false),
132 has_shown_autofill_popup_for_current_edit_(false), 134 has_shown_autofill_popup_for_current_edit_(false),
133 did_set_node_text_(false), 135 did_set_node_text_(false),
134 ignore_text_changes_(false), 136 ignore_text_changes_(false),
135 is_popup_possibly_visible_(false), 137 is_popup_possibly_visible_(false),
136 main_frame_processed_(false), 138 main_frame_processed_(false),
137 weak_ptr_factory_(this) { 139 weak_ptr_factory_(this) {
138 render_view->GetWebView()->setAutofillClient(this); 140 render_frame->GetWebFrame()->setAutofillClient(this);
139
140 // The PageClickTracker is a RenderViewObserver, and hence will be freed when
141 // the RenderView is destroyed.
142 new PageClickTracker(render_view, this);
143 } 141 }
144 142
145 AutofillAgent::~AutofillAgent() {} 143 AutofillAgent::~AutofillAgent() {}
146 144
147 bool AutofillAgent::OnMessageReceived(const IPC::Message& message) { 145 bool AutofillAgent::OnMessageReceived(const IPC::Message& message) {
148 bool handled = true; 146 bool handled = true;
149 IPC_BEGIN_MESSAGE_MAP(AutofillAgent, message) 147 IPC_BEGIN_MESSAGE_MAP(AutofillAgent, message)
150 IPC_MESSAGE_HANDLER(AutofillMsg_Ping, OnPing) 148 IPC_MESSAGE_HANDLER(AutofillMsg_Ping, OnPing)
151 IPC_MESSAGE_HANDLER(AutofillMsg_FillForm, OnFillForm) 149 IPC_MESSAGE_HANDLER(AutofillMsg_FillForm, OnFillForm)
152 IPC_MESSAGE_HANDLER(AutofillMsg_PreviewForm, OnPreviewForm) 150 IPC_MESSAGE_HANDLER(AutofillMsg_PreviewForm, OnPreviewForm)
(...skipping 10 matching lines...) Expand all
163 OnFillPasswordSuggestion) 161 OnFillPasswordSuggestion)
164 IPC_MESSAGE_HANDLER(AutofillMsg_PreviewPasswordSuggestion, 162 IPC_MESSAGE_HANDLER(AutofillMsg_PreviewPasswordSuggestion,
165 OnPreviewPasswordSuggestion) 163 OnPreviewPasswordSuggestion)
166 IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteResult, 164 IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteResult,
167 OnRequestAutocompleteResult) 165 OnRequestAutocompleteResult)
168 IPC_MESSAGE_UNHANDLED(handled = false) 166 IPC_MESSAGE_UNHANDLED(handled = false)
169 IPC_END_MESSAGE_MAP() 167 IPC_END_MESSAGE_MAP()
170 return handled; 168 return handled;
171 } 169 }
172 170
173 void AutofillAgent::DidFinishDocumentLoad(WebLocalFrame* frame) { 171 void AutofillAgent::DidCommitProvisionalLoad(bool is_new_navigation) {
172 // TODO(estade): |form_cache_| shouldn't track multiple frames.
173 form_cache_.ResetFrame(*render_frame()->GetWebFrame());
174 }
175
176 void AutofillAgent::DidFinishDocumentLoad() {
174 // If the main frame just finished loading, we should process it. 177 // If the main frame just finished loading, we should process it.
175 if (!frame->parent()) 178 if (!render_frame()->GetWebFrame()->parent())
176 main_frame_processed_ = false; 179 main_frame_processed_ = false;
177 180
178 ProcessForms(*frame); 181 ProcessForms();
179 } 182 }
180 183
181 void AutofillAgent::DidCommitProvisionalLoad(WebLocalFrame* frame, 184 void AutofillAgent::FrameWillClose() {
182 bool is_new_navigation) { 185 if (in_flight_request_form_.isNull())
183 form_cache_.ResetFrame(*frame); 186 return;
187
188 Send(new AutofillHostMsg_CancelRequestAutocomplete(routing_id()));
184 } 189 }
185 190
186 void AutofillAgent::FrameDetached(WebFrame* frame) { 191 void AutofillAgent::FrameDetached(WebFrame* frame) {
187 form_cache_.ResetFrame(*frame); 192 if (frame != render_frame()->GetWebFrame())
188 }
189
190 void AutofillAgent::FrameWillClose(WebFrame* frame) {
191 if (in_flight_request_form_.isNull())
192 return; 193 return;
193 194
194 for (WebFrame* temp = in_flight_request_form_.document().frame(); 195 form_cache_.ResetFrame(*frame);
195 temp; temp = temp->parent()) {
196 if (temp == frame) {
197 Send(new AutofillHostMsg_CancelRequestAutocomplete(routing_id()));
198 break;
199 }
200 }
201 } 196 }
202 197
203 void AutofillAgent::WillSubmitForm(WebLocalFrame* frame, 198 void AutofillAgent::WillSubmitForm(WebLocalFrame* frame,
204 const WebFormElement& form) { 199 const WebFormElement& form) {
200 if (frame != render_frame()->GetWebFrame())
201 return;
202
205 FormData form_data; 203 FormData form_data;
206 if (WebFormElementToFormData(form, 204 if (WebFormElementToFormData(form,
207 WebFormControlElement(), 205 WebFormControlElement(),
208 REQUIRE_NONE, 206 REQUIRE_NONE,
209 static_cast<ExtractMask>( 207 static_cast<ExtractMask>(
210 EXTRACT_VALUE | EXTRACT_OPTION_TEXT), 208 EXTRACT_VALUE | EXTRACT_OPTION_TEXT),
211 &form_data, 209 &form_data,
212 NULL)) { 210 NULL)) {
213 Send(new AutofillHostMsg_FormSubmitted(routing_id(), form_data, 211 Send(new AutofillHostMsg_FormSubmitted(routing_id(), form_data,
214 base::TimeTicks::Now())); 212 base::TimeTicks::Now()));
215 } 213 }
216 } 214 }
217 215
216 void AutofillAgent::DidChangeScrollOffset(WebLocalFrame* frame) {
217 if (frame != render_frame()->GetWebFrame())
218 return;
219
220 HidePopup();
221 }
222
218 void AutofillAgent::FocusedNodeChanged(const WebNode& node) { 223 void AutofillAgent::FocusedNodeChanged(const WebNode& node) {
219 HidePopup(); 224 HidePopup();
220 225
226 if (node.isNull() || !node.isElementNode())
227 return;
228
229 if (node.document().frame() != render_frame()->GetWebFrame())
230 return;
231
221 if (password_generation_agent_ && 232 if (password_generation_agent_ &&
222 password_generation_agent_->FocusedNodeHasChanged(node)) { 233 password_generation_agent_->FocusedNodeHasChanged(node)) {
223 is_popup_possibly_visible_ = true; 234 is_popup_possibly_visible_ = true;
224 return; 235 return;
225 } 236 }
226 237
227 if (node.isNull() || !node.isElementNode())
228 return;
229
230 WebElement web_element = node.toConst<WebElement>(); 238 WebElement web_element = node.toConst<WebElement>();
231 239
232 if (!web_element.document().frame()) 240 if (!web_element.document().frame())
233 return; 241 return;
234 242
235 const WebInputElement* element = toWebInputElement(&web_element); 243 const WebInputElement* element = toWebInputElement(&web_element);
236 244
237 if (!element || !element->isEnabled() || element->isReadOnly() || 245 if (!element || !element->isEnabled() || element->isReadOnly() ||
238 !element->isTextField() || element->isPasswordField()) 246 !element->isTextField() || element->isPasswordField())
239 return; 247 return;
240 248
241 element_ = *element; 249 element_ = *element;
242 } 250 }
243 251
244 void AutofillAgent::OrientationChangeEvent() { 252 void AutofillAgent::OrientationChangeEvent() {
245 HidePopup(); 253 HidePopup();
246 } 254 }
247 255
248 void AutofillAgent::Resized() { 256 void AutofillAgent::Resized() {
249 HidePopup(); 257 HidePopup();
250 } 258 }
251 259
252 void AutofillAgent::DidChangeScrollOffset(WebLocalFrame*) {
253 HidePopup();
254 }
255
256 void AutofillAgent::didRequestAutocomplete( 260 void AutofillAgent::didRequestAutocomplete(
257 const WebFormElement& form) { 261 const WebFormElement& form) {
262 DCHECK_EQ(form.document().frame(), render_frame()->GetWebFrame());
263
258 // Disallow the dialog over non-https or broken https, except when the 264 // Disallow the dialog over non-https or broken https, except when the
259 // ignore SSL flag is passed. See http://crbug.com/272512. 265 // ignore SSL flag is passed. See http://crbug.com/272512.
260 // TODO(palmer): this should be moved to the browser process after frames 266 // TODO(palmer): this should be moved to the browser process after frames
261 // get their own processes. 267 // get their own processes.
262 GURL url(form.document().url()); 268 GURL url(form.document().url());
263 content::SSLStatus ssl_status = 269 content::SSLStatus ssl_status =
264 render_view()->GetSSLStatusOfFrame(form.document().frame()); 270 render_frame()->GetRenderView()->GetSSLStatusOfFrame(
271 form.document().frame());
265 bool is_safe = url.SchemeIs(url::kHttpsScheme) && 272 bool is_safe = url.SchemeIs(url::kHttpsScheme) &&
266 !net::IsCertStatusError(ssl_status.cert_status); 273 !net::IsCertStatusError(ssl_status.cert_status);
267 bool allow_unsafe = CommandLine::ForCurrentProcess()->HasSwitch( 274 bool allow_unsafe = CommandLine::ForCurrentProcess()->HasSwitch(
268 ::switches::kReduceSecurityForTesting); 275 ::switches::kReduceSecurityForTesting);
269 276
270 FormData form_data; 277 FormData form_data;
271 std::string error_message; 278 std::string error_message;
272 if (!in_flight_request_form_.isNull()) { 279 if (!in_flight_request_form_.isNull()) {
273 error_message = "already active."; 280 error_message = "already active.";
274 } else if (!is_safe && !allow_unsafe) { 281 } else if (!is_safe && !allow_unsafe) {
(...skipping 30 matching lines...) Expand all
305 Send(new AutofillHostMsg_RequestAutocomplete(routing_id(), form_data, url)); 312 Send(new AutofillHostMsg_RequestAutocomplete(routing_id(), form_data, url));
306 } 313 }
307 314
308 void AutofillAgent::setIgnoreTextChanges(bool ignore) { 315 void AutofillAgent::setIgnoreTextChanges(bool ignore) {
309 ignore_text_changes_ = ignore; 316 ignore_text_changes_ = ignore;
310 } 317 }
311 318
312 void AutofillAgent::FormControlElementClicked( 319 void AutofillAgent::FormControlElementClicked(
313 const WebFormControlElement& element, 320 const WebFormControlElement& element,
314 bool was_focused) { 321 bool was_focused) {
322 // TODO(estade): Remove this check when PageClickTracker is per-frame.
323 if (element.document().frame() != render_frame()->GetWebFrame())
324 return;
325
315 const WebInputElement* input_element = toWebInputElement(&element); 326 const WebInputElement* input_element = toWebInputElement(&element);
316 if (!input_element && !IsTextAreaElement(element)) 327 if (!input_element && !IsTextAreaElement(element))
317 return; 328 return;
318 329
319 bool show_full_suggestion_list = element.isAutofilled() || was_focused; 330 bool show_full_suggestion_list = element.isAutofilled() || was_focused;
320 bool show_password_suggestions_only = !was_focused; 331 bool show_password_suggestions_only = !was_focused;
321 332
322 // TODO(gcasto): Remove after crbug.com/423464 has been fixed. 333 // TODO(gcasto): Remove after crbug.com/423464 has been fixed.
323 bool show_suggestions = true; 334 bool show_suggestions = true;
324 #if defined(OS_ANDROID) 335 #if defined(OS_ANDROID)
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 } 460 }
450 461
451 void AutofillAgent::OnFieldTypePredictionsAvailable( 462 void AutofillAgent::OnFieldTypePredictionsAvailable(
452 const std::vector<FormDataPredictions>& forms) { 463 const std::vector<FormDataPredictions>& forms) {
453 for (size_t i = 0; i < forms.size(); ++i) { 464 for (size_t i = 0; i < forms.size(); ++i) {
454 form_cache_.ShowPredictions(forms[i]); 465 form_cache_.ShowPredictions(forms[i]);
455 } 466 }
456 } 467 }
457 468
458 void AutofillAgent::OnFillForm(int query_id, const FormData& form) { 469 void AutofillAgent::OnFillForm(int query_id, const FormData& form) {
459 if (!render_view()->GetWebView() || query_id != autofill_query_id_) 470 if (query_id != autofill_query_id_)
460 return; 471 return;
461 472
462 was_query_node_autofilled_ = element_.isAutofilled(); 473 was_query_node_autofilled_ = element_.isAutofilled();
463 FillForm(form, element_); 474 FillForm(form, element_);
464 Send(new AutofillHostMsg_DidFillAutofillFormData(routing_id(), 475 Send(new AutofillHostMsg_DidFillAutofillFormData(routing_id(),
465 base::TimeTicks::Now())); 476 base::TimeTicks::Now()));
466 } 477 }
467 478
468 void AutofillAgent::OnPing() { 479 void AutofillAgent::OnPing() {
469 Send(new AutofillHostMsg_PingAck(routing_id())); 480 Send(new AutofillHostMsg_PingAck(routing_id()));
470 } 481 }
471 482
472 void AutofillAgent::OnPreviewForm(int query_id, const FormData& form) { 483 void AutofillAgent::OnPreviewForm(int query_id, const FormData& form) {
473 if (!render_view()->GetWebView() || query_id != autofill_query_id_) 484 if (query_id != autofill_query_id_)
474 return; 485 return;
475 486
476 was_query_node_autofilled_ = element_.isAutofilled(); 487 was_query_node_autofilled_ = element_.isAutofilled();
477 PreviewForm(form, element_); 488 PreviewForm(form, element_);
478 Send(new AutofillHostMsg_DidPreviewAutofillFormData(routing_id())); 489 Send(new AutofillHostMsg_DidPreviewAutofillFormData(routing_id()));
479 } 490 }
480 491
481 void AutofillAgent::OnClearForm() { 492 void AutofillAgent::OnClearForm() {
482 form_cache_.ClearFormWithElement(element_); 493 form_cache_.ClearFormWithElement(element_);
483 } 494 }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 FormFieldData field; 665 FormFieldData field;
655 if (!FindFormAndFieldForFormControlElement(element, &form, &field, 666 if (!FindFormAndFieldForFormControlElement(element, &form, &field,
656 requirements)) { 667 requirements)) {
657 // If we didn't find the cached form, at least let autocomplete have a shot 668 // If we didn't find the cached form, at least let autocomplete have a shot
658 // at providing suggestions. 669 // at providing suggestions.
659 WebFormControlElementToFormField(element, EXTRACT_VALUE, &field); 670 WebFormControlElementToFormField(element, EXTRACT_VALUE, &field);
660 } 671 }
661 if (datalist_only) 672 if (datalist_only)
662 field.should_autocomplete = false; 673 field.should_autocomplete = false;
663 674
664 gfx::RectF bounding_box_scaled = 675 gfx::RectF bounding_box_scaled = GetScaledBoundingBox(
665 GetScaledBoundingBox(web_view_->pageScaleFactor(), &element_); 676 render_frame()->GetRenderView()->GetWebView()->pageScaleFactor(),
677 &element_);
666 678
667 std::vector<base::string16> data_list_values; 679 std::vector<base::string16> data_list_values;
668 std::vector<base::string16> data_list_labels; 680 std::vector<base::string16> data_list_labels;
669 const WebInputElement* input_element = toWebInputElement(&element); 681 const WebInputElement* input_element = toWebInputElement(&element);
670 if (input_element) { 682 if (input_element) {
671 // Find the datalist values and send them to the browser process. 683 // Find the datalist values and send them to the browser process.
672 GetDataListSuggestions(*input_element, 684 GetDataListSuggestions(*input_element,
673 datalist_only, 685 datalist_only,
674 &data_list_values, 686 &data_list_values,
675 &data_list_labels); 687 &data_list_labels);
(...skipping 22 matching lines...) Expand all
698 710
699 void AutofillAgent::PreviewFieldWithValue(const base::string16& value, 711 void AutofillAgent::PreviewFieldWithValue(const base::string16& value,
700 WebInputElement* node) { 712 WebInputElement* node) {
701 was_query_node_autofilled_ = element_.isAutofilled(); 713 was_query_node_autofilled_ = element_.isAutofilled();
702 node->setSuggestedValue(value.substr(0, node->maxLength())); 714 node->setSuggestedValue(value.substr(0, node->maxLength()));
703 node->setAutofilled(true); 715 node->setAutofilled(true);
704 node->setSelectionRange(node->value().length(), 716 node->setSelectionRange(node->value().length(),
705 node->suggestedValue().length()); 717 node->suggestedValue().length());
706 } 718 }
707 719
708 void AutofillAgent::ProcessForms(const WebLocalFrame& frame) { 720 void AutofillAgent::ProcessForms() {
709 // Record timestamp of when the forms are first seen. This is used to 721 // Record timestamp of when the forms are first seen. This is used to
710 // measure the overhead of the Autofill feature. 722 // measure the overhead of the Autofill feature.
711 base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now(); 723 base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now();
712 724
713 std::vector<FormData> forms; 725 std::vector<FormData> forms;
714 form_cache_.ExtractNewForms(frame, &forms); 726 WebLocalFrame* frame = render_frame()->GetWebFrame();
727 form_cache_.ExtractNewForms(*frame, &forms);
715 728
716 // Always communicate to browser process for topmost frame. 729 // Always communicate to browser process for topmost frame.
717 if (!forms.empty() || 730 if (!forms.empty() || (!frame->parent() && !main_frame_processed_)) {
718 (!frame.parent() && !main_frame_processed_)) {
719 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms, 731 Send(new AutofillHostMsg_FormsSeen(routing_id(), forms,
720 forms_seen_timestamp)); 732 forms_seen_timestamp));
721 } 733 }
722 734
723 if (!frame.parent()) 735 if (!frame->parent())
724 main_frame_processed_ = true; 736 main_frame_processed_ = true;
725 } 737 }
726 738
727 void AutofillAgent::HidePopup() { 739 void AutofillAgent::HidePopup() {
728 if (!is_popup_possibly_visible_) 740 if (!is_popup_possibly_visible_)
729 return; 741 return;
730 742
731 if (!element_.isNull()) 743 if (!element_.isNull())
732 OnClearPreviewedForm(); 744 OnClearPreviewedForm();
733 745
734 is_popup_possibly_visible_ = false; 746 is_popup_possibly_visible_ = false;
735 Send(new AutofillHostMsg_HidePopup(routing_id())); 747 Send(new AutofillHostMsg_HidePopup(routing_id()));
736 } 748 }
737 749
738 void AutofillAgent::didAssociateFormControls(const WebVector<WebNode>& nodes) { 750 void AutofillAgent::didAssociateFormControls(const WebVector<WebNode>& nodes) {
739 for (size_t i = 0; i < nodes.size(); ++i) { 751 for (size_t i = 0; i < nodes.size(); ++i) {
740 WebLocalFrame* frame = nodes[i].document().frame(); 752 WebLocalFrame* frame = nodes[i].document().frame();
753 DCHECK_EQ(frame, render_frame()->GetWebFrame());
741 // Only monitors dynamic forms created in the top frame. Dynamic forms 754 // Only monitors dynamic forms created in the top frame. Dynamic forms
742 // inserted in iframes are not captured yet. Frame is only processed 755 // inserted in iframes are not captured yet. Frame is only processed
743 // if it has finished loading, otherwise you can end up with a partially 756 // if it has finished loading, otherwise you can end up with a partially
744 // parsed form. 757 // parsed form.
745 if (frame && !frame->parent() && !frame->isLoading()) { 758 if (!frame->isLoading()) {
746 ProcessForms(*frame); 759 ProcessForms();
747 password_autofill_agent_->OnDynamicFormsSeen(frame); 760 password_autofill_agent_->OnDynamicFormsSeen();
748 if (password_generation_agent_) 761 if (password_generation_agent_)
749 password_generation_agent_->OnDynamicFormsSeen(frame); 762 password_generation_agent_->OnDynamicFormsSeen();
750 return; 763 return;
751 } 764 }
752 } 765 }
753 } 766 }
754 767
768 // LegacyAutofillAgent ---------------------------------------------------------
769
770 AutofillAgent::LegacyAutofillAgent::LegacyAutofillAgent(
771 content::RenderView* render_view,
772 AutofillAgent* agent)
773 : content::RenderViewObserver(render_view), agent_(agent) {
774 }
775
776 AutofillAgent::LegacyAutofillAgent::~LegacyAutofillAgent() {
777 }
778
779 void AutofillAgent::LegacyAutofillAgent::OnDestruct() {
780 // No-op. Don't delete |this|.
781 }
782
783 void AutofillAgent::LegacyAutofillAgent::FrameDetached(WebFrame* frame) {
784 agent_->FrameDetached(frame);
785 }
786
787 void AutofillAgent::LegacyAutofillAgent::WillSubmitForm(
788 WebLocalFrame* frame,
789 const WebFormElement& form) {
790 agent_->WillSubmitForm(frame, form);
791 }
792
793 void AutofillAgent::LegacyAutofillAgent::DidChangeScrollOffset(
794 WebLocalFrame* frame) {
795 agent_->DidChangeScrollOffset(frame);
796 }
797
798 void AutofillAgent::LegacyAutofillAgent::FocusedNodeChanged(
799 const WebNode& node) {
800 agent_->FocusedNodeChanged(node);
801 }
802
803 void AutofillAgent::LegacyAutofillAgent::OrientationChangeEvent() {
804 agent_->OrientationChangeEvent();
805 }
806
807 void AutofillAgent::LegacyAutofillAgent::Resized() {
808 agent_->Resized();
809 }
810
755 } // namespace autofill 811 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698