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

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

Issue 208453002: Add "previewing on hover" support for password field. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update code as per Ilya's comment. Created 6 years, 9 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 OnFieldTypePredictionsAvailable) 150 OnFieldTypePredictionsAvailable)
151 IPC_MESSAGE_HANDLER(AutofillMsg_ClearForm, OnClearForm) 151 IPC_MESSAGE_HANDLER(AutofillMsg_ClearForm, OnClearForm)
152 IPC_MESSAGE_HANDLER(AutofillMsg_ClearPreviewedForm, OnClearPreviewedForm) 152 IPC_MESSAGE_HANDLER(AutofillMsg_ClearPreviewedForm, OnClearPreviewedForm)
153 IPC_MESSAGE_HANDLER(AutofillMsg_FillFieldWithValue, OnFillFieldWithValue) 153 IPC_MESSAGE_HANDLER(AutofillMsg_FillFieldWithValue, OnFillFieldWithValue)
154 IPC_MESSAGE_HANDLER(AutofillMsg_PreviewFieldWithValue, 154 IPC_MESSAGE_HANDLER(AutofillMsg_PreviewFieldWithValue,
155 OnPreviewFieldWithValue) 155 OnPreviewFieldWithValue)
156 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptDataListSuggestion, 156 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptDataListSuggestion,
157 OnAcceptDataListSuggestion) 157 OnAcceptDataListSuggestion)
158 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptPasswordAutofillSuggestion, 158 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptPasswordAutofillSuggestion,
159 OnAcceptPasswordAutofillSuggestion) 159 OnAcceptPasswordAutofillSuggestion)
160 IPC_MESSAGE_HANDLER(AutofillMsg_PreviewPassword, OnPreviewPassword)
160 IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteResult, 161 IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteResult,
161 OnRequestAutocompleteResult) 162 OnRequestAutocompleteResult)
162 IPC_MESSAGE_UNHANDLED(handled = false) 163 IPC_MESSAGE_UNHANDLED(handled = false)
163 IPC_END_MESSAGE_MAP() 164 IPC_END_MESSAGE_MAP()
164 return handled; 165 return handled;
165 } 166 }
166 167
167 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) { 168 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) {
168 // Record timestamp on document load. This is used to record overhead of 169 // Record timestamp on document load. This is used to record overhead of
169 // Autofill feature. 170 // Autofill feature.
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 PreviewForm(form, element_); 430 PreviewForm(form, element_);
430 Send(new AutofillHostMsg_DidPreviewAutofillFormData(routing_id())); 431 Send(new AutofillHostMsg_DidPreviewAutofillFormData(routing_id()));
431 } 432 }
432 433
433 void AutofillAgent::OnClearForm() { 434 void AutofillAgent::OnClearForm() {
434 form_cache_.ClearFormWithElement(element_); 435 form_cache_.ClearFormWithElement(element_);
435 } 436 }
436 437
437 void AutofillAgent::OnClearPreviewedForm() { 438 void AutofillAgent::OnClearPreviewedForm() {
438 if (!element_.isNull()) { 439 if (!element_.isNull()) {
439 if (password_autofill_agent_->DidClearAutofillSelection(element_)) 440 if (password_autofill_agent_->DidClearAutofillSelection(element_) &&
441 !password_autofill_agent_->IsPasswordPreviewed())
440 return; 442 return;
441 443
442 ClearPreviewedFormWithElement(element_, was_query_node_autofilled_); 444 if(password_autofill_agent_->IsPasswordPreviewed()) {
445 ClearPreviewedFormWithElement(
446 element_,
447 REQUIRE_NONE,
448 was_query_node_autofilled_,
449 password_autofill_agent_->WasPasswordAutofilled());
Ilya Sherman 2014/03/25 19:45:27 Please move all of the password-related logic for
450 } else {
451 ClearPreviewedFormWithElement(element_,
452 REQUIRE_AUTOCOMPLETE,
453 was_query_node_autofilled_,
454 false);
455 }
443 } else { 456 } else {
444 // TODO(isherman): There seem to be rare cases where this code *is* 457 // TODO(isherman): There seem to be rare cases where this code *is*
445 // reachable: see [ http://crbug.com/96321#c6 ]. Ideally we would 458 // reachable: see [ http://crbug.com/96321#c6 ]. Ideally we would
446 // understand those cases and fix the code to avoid them. However, so far I 459 // understand those cases and fix the code to avoid them. However, so far I
447 // have been unable to reproduce such a case locally. If you hit this 460 // have been unable to reproduce such a case locally. If you hit this
448 // NOTREACHED(), please file a bug against me. 461 // NOTREACHED(), please file a bug against me.
449 NOTREACHED(); 462 NOTREACHED();
450 } 463 }
451 } 464 }
452 465
453 void AutofillAgent::OnFillFieldWithValue(const base::string16& value) { 466 void AutofillAgent::OnFillFieldWithValue(const base::string16& value) {
454 FillFieldWithValue(value, &element_); 467 FillFieldWithValue(value, &element_);
455 } 468 }
456 469
457 void AutofillAgent::OnPreviewFieldWithValue(const base::string16& value) { 470 void AutofillAgent::OnPreviewFieldWithValue(const base::string16& value) {
458 PreviewFieldWithValue(value, &element_); 471 PreviewFieldWithValue(value, &element_);
459 } 472 }
460 473
461 void AutofillAgent::OnAcceptDataListSuggestion(const base::string16& value) { 474 void AutofillAgent::OnAcceptDataListSuggestion(const base::string16& value) {
462 AcceptDataListSuggestion(value); 475 AcceptDataListSuggestion(value);
463 } 476 }
464 477
465 void AutofillAgent::OnAcceptPasswordAutofillSuggestion( 478 void AutofillAgent::OnAcceptPasswordAutofillSuggestion(
466 const base::string16& username) { 479 const base::string16& username) {
467 // We need to make sure this is handled here because the browser process 480 // We need to make sure this is handled here because the browser process
468 // skipped it handling because it believed it would be handled here. If it 481 // skipped it handling because it believed it would be handled here. If it
469 // isn't handled here then the browser logic needs to be updated. 482 // isn't handled here then the browser logic needs to be updated.
470 bool handled = password_autofill_agent_->DidAcceptAutofillSuggestion( 483 bool handled = password_autofill_agent_->DidAcceptSuggestion(
471 element_, 484 element_,
472 username); 485 username);
473 DCHECK(handled); 486 DCHECK(handled);
487 }
488
489 void AutofillAgent::OnPreviewPassword(const base::string16& username) {
490 was_query_node_autofilled_ = element_.isAutofilled();
491 bool handled = password_autofill_agent_->DidSelectSuggestion(
492 element_,
493 username);
494 DCHECK(handled);
474 } 495 }
475 496
476 void AutofillAgent::OnRequestAutocompleteResult( 497 void AutofillAgent::OnRequestAutocompleteResult(
477 WebFormElement::AutocompleteResult result, 498 WebFormElement::AutocompleteResult result,
478 const FormData& form_data) { 499 const FormData& form_data) {
479 if (in_flight_request_form_.isNull()) 500 if (in_flight_request_form_.isNull())
480 return; 501 return;
481 502
482 if (result == WebFormElement::AutocompleteResultSuccess) { 503 if (result == WebFormElement::AutocompleteResultSuccess) {
483 FillFormIncludingNonFocusableElements(form_data, in_flight_request_form_); 504 FillFormIncludingNonFocusableElements(form_data, in_flight_request_form_);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 // Only monitors dynamic forms created in the top frame. Dynamic forms 642 // Only monitors dynamic forms created in the top frame. Dynamic forms
622 // inserted in iframes are not captured yet. 643 // inserted in iframes are not captured yet.
623 if (frame && !frame->parent()) { 644 if (frame && !frame->parent()) {
624 password_autofill_agent_->OnDynamicFormsSeen(frame); 645 password_autofill_agent_->OnDynamicFormsSeen(frame);
625 return; 646 return;
626 } 647 }
627 } 648 }
628 } 649 }
629 650
630 } // namespace autofill 651 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698