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

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

Issue 1494373003: [Autofill] Send Autofill upload when active form loses focus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed test Created 5 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 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 <tuple> 7 #include <tuple>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 void AutofillAgent::DidChangeScrollOffset() { 252 void AutofillAgent::DidChangeScrollOffset() {
253 if (IsKeyboardAccessoryEnabled()) 253 if (IsKeyboardAccessoryEnabled())
254 return; 254 return;
255 255
256 HidePopup(); 256 HidePopup();
257 } 257 }
258 258
259 void AutofillAgent::FocusedNodeChanged(const WebNode& node) { 259 void AutofillAgent::FocusedNodeChanged(const WebNode& node) {
260 HidePopup(); 260 HidePopup();
261 261
262 if (node.isNull() || !node.isElementNode()) 262 if (node.isNull() || !node.isElementNode()) {
263 if (!last_interacted_form_.isNull()) {
264 // Focus moved away from the last interacted form to somewhere else on
265 // the page.
266 Send(new AutofillHostMsg_FocusNoLongerOnForm(routing_id()));
267 }
263 return; 268 return;
269 }
264 270
265 WebElement web_element = node.toConst<WebElement>(); 271 WebElement web_element = node.toConst<WebElement>();
266 const WebInputElement* element = toWebInputElement(&web_element); 272 const WebInputElement* element = toWebInputElement(&web_element);
273 if (!element || (!last_interacted_form_.isNull() &&
274 last_interacted_form_ != element->form())) {
275 // The focused element is not part of the last interacted form (could be
276 // in a different form).
277 Send(new AutofillHostMsg_FocusNoLongerOnForm(routing_id()));
278 return;
279 }
267 280
268 if (!element || !element->isEnabled() || element->isReadOnly() || 281 if (!element || !element->isEnabled() || element->isReadOnly() ||
269 !element->isTextField()) 282 !element->isTextField())
270 return; 283 return;
271 284
272 element_ = *element; 285 element_ = *element;
273 } 286 }
274 287
275 void AutofillAgent::FocusChangeComplete() { 288 void AutofillAgent::FocusChangeComplete() {
276 WebDocument doc = render_frame()->GetWebFrame()->document(); 289 WebDocument doc = render_frame()->GetWebFrame()->document();
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 525
513 void AutofillAgent::OnFillForm(int query_id, const FormData& form) { 526 void AutofillAgent::OnFillForm(int query_id, const FormData& form) {
514 if (query_id != autofill_query_id_) 527 if (query_id != autofill_query_id_)
515 return; 528 return;
516 529
517 was_query_node_autofilled_ = element_.isAutofilled(); 530 was_query_node_autofilled_ = element_.isAutofilled();
518 form_util::FillForm(form, element_); 531 form_util::FillForm(form, element_);
519 if (!element_.form().isNull()) 532 if (!element_.form().isNull())
520 last_interacted_form_ = element_.form(); 533 last_interacted_form_ = element_.form();
521 534
522 Send(new AutofillHostMsg_DidFillAutofillFormData(routing_id(), 535 Send(new AutofillHostMsg_DidFillAutofillFormData(routing_id(), form,
523 base::TimeTicks::Now())); 536 base::TimeTicks::Now()));
524 } 537 }
525 538
526 void AutofillAgent::OnFirstUserGestureObservedInTab() { 539 void AutofillAgent::OnFirstUserGestureObservedInTab() {
527 password_autofill_agent_->FirstUserGestureObserved(); 540 password_autofill_agent_->FirstUserGestureObserved();
528 } 541 }
529 542
530 void AutofillAgent::OnPing() { 543 void AutofillAgent::OnPing() {
531 Send(new AutofillHostMsg_PingAck(routing_id())); 544 Send(new AutofillHostMsg_PingAck(routing_id()));
532 } 545 }
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 828
816 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { 829 void AutofillAgent::LegacyAutofillAgent::OnDestruct() {
817 // No-op. Don't delete |this|. 830 // No-op. Don't delete |this|.
818 } 831 }
819 832
820 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { 833 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() {
821 agent_->FocusChangeComplete(); 834 agent_->FocusChangeComplete();
822 } 835 }
823 836
824 } // namespace autofill 837 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/content/common/autofill_messages.h ('k') | components/autofill/core/browser/autofill_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698