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
3 // found in the LICENSE file.
5 #include "components/autofill/content/renderer/password_autofill_agent.h"
8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h"
11 #include "base/metrics/field_trial.h"
12 #include "base/metrics/histogram.h"
13 #include "base/strings/utf_string_conversions.h"
14 #include "components/autofill/content/common/autofill_messages.h"
15 #include "components/autofill/content/renderer/form_autofill_util.h"
16 #include "components/autofill/content/renderer/password_form_conversion_utils.h"
17 #include "components/autofill/content/renderer/renderer_save_password_progress_logger.h"
18 #include "components/autofill/core/common/autofill_constants.h"
19 #include "components/autofill/core/common/autofill_switches.h"
20 #include "components/autofill/core/common/form_field_data.h"
21 #include "components/autofill/core/common/password_form.h"
22 #include "components/autofill/core/common/password_form_fill_data.h"
23 #include "content/public/renderer/document_state.h"
24 #include "content/public/renderer/navigation_state.h"
25 #include "content/public/renderer/render_frame.h"
26 #include "content/public/renderer/render_view.h"
27 #include "third_party/WebKit/public/platform/WebVector.h"
28 #include "third_party/WebKit/public/web/WebAutofillClient.h"
29 #include "third_party/WebKit/public/web/WebDocument.h"
30 #include "third_party/WebKit/public/web/WebElement.h"
31 #include "third_party/WebKit/public/web/WebFormElement.h"
32 #include "third_party/WebKit/public/web/WebInputEvent.h"
33 #include "third_party/WebKit/public/web/WebLocalFrame.h"
34 #include "third_party/WebKit/public/web/WebNode.h"
35 #include "third_party/WebKit/public/web/WebNodeList.h"
36 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
37 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
38 #include "third_party/WebKit/public/web/WebView.h"
39 #include "ui/base/page_transition_types.h"
40 #include "ui/events/keycodes/keyboard_codes.h"
46 // The size above which we stop triggering autocomplete.
47 static const size_t kMaximumTextSizeForAutocomplete
= 1000;
49 // Experiment information
50 const char kFillOnAccountSelectFieldTrialName
[] = "FillOnAccountSelect";
51 const char kFillOnAccountSelectFieldTrialEnabledWithHighlightGroup
[] =
52 "EnableWithHighlight";
53 const char kFillOnAccountSelectFieldTrialEnabledWithNoHighlightGroup
[] =
54 "EnableWithNoHighlight";
56 // Maps element names to the actual elements to simplify form filling.
57 typedef std::map
<base::string16
, blink::WebInputElement
> FormInputElementMap
;
59 // Use the shorter name when referencing SavePasswordProgressLogger::StringID
60 // values to spare line breaks. The code provides enough context for that
62 typedef SavePasswordProgressLogger Logger
;
64 // Utility struct for form lookup and autofill. When we parse the DOM to look up
65 // a form, in addition to action and origin URL's we have to compare all
66 // necessary form elements. To avoid having to look these up again when we want
67 // to fill the form, the FindFormElements function stores the pointers
68 // in a FormElements* result, referenced to ensure they are safe to use.
70 blink::WebFormElement form_element
;
71 FormInputElementMap input_elements
;
74 typedef std::vector
<FormElements
*> FormElementsList
;
76 bool FillDataContainsUsername(const PasswordFormFillData
& fill_data
) {
77 return !fill_data
.username_field
.name
.empty();
80 // Utility function to find the unique entry of the |form_element| for the
81 // specified input |field|. On successful find, adds it to |result| and returns
82 // |true|. Otherwise clears the references from each |HTMLInputElement| from
83 // |result| and returns |false|.
84 bool FindFormInputElement(blink::WebFormElement
* form_element
,
85 const FormFieldData
& field
,
86 FormElements
* result
) {
87 blink::WebVector
<blink::WebNode
> temp_elements
;
88 form_element
->getNamedElements(field
.name
, temp_elements
);
90 // Match the first input element, if any.
91 // |getNamedElements| may return non-input elements where the names match,
92 // so the results are filtered for input elements.
93 // If more than one match is made, then we have ambiguity (due to misuse
94 // of "name" attribute) so is it considered not found.
95 bool found_input
= false;
96 for (size_t i
= 0; i
< temp_elements
.size(); ++i
) {
97 if (temp_elements
[i
].to
<blink::WebElement
>().hasHTMLTagName("input")) {
98 // Check for a non-unique match.
104 // Only fill saved passwords into password fields and usernames into
106 blink::WebInputElement input_element
=
107 temp_elements
[i
].to
<blink::WebInputElement
>();
108 if (input_element
.isPasswordField() !=
109 (field
.form_control_type
== "password"))
112 // This element matched, add it to our temporary result. It's possible
113 // there are multiple matches, but for purposes of identifying the form
114 // one suffices and if some function needs to deal with multiple
115 // matching elements it can get at them through the FormElement*.
116 // Note: This assignment adds a reference to the InputElement.
117 result
->input_elements
[field
.name
] = input_element
;
122 // A required element was not found. This is not the right form.
123 // Make sure no input elements from a partially matched form in this
124 // iteration remain in the result set.
125 // Note: clear will remove a reference from each InputElement.
127 result
->input_elements
.clear();
134 bool ShouldFillOnAccountSelect() {
135 std::string group_name
=
136 base::FieldTrialList::FindFullName(kFillOnAccountSelectFieldTrialName
);
138 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
139 switches::kDisableFillOnAccountSelect
)) {
143 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
144 switches::kEnableFillOnAccountSelect
) ||
145 base::CommandLine::ForCurrentProcess()->HasSwitch(
146 switches::kEnableFillOnAccountSelectNoHighlighting
)) {
151 kFillOnAccountSelectFieldTrialEnabledWithHighlightGroup
||
153 kFillOnAccountSelectFieldTrialEnabledWithNoHighlightGroup
;
156 bool ShouldHighlightFields() {
157 std::string group_name
=
158 base::FieldTrialList::FindFullName(kFillOnAccountSelectFieldTrialName
);
159 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
160 switches::kDisableFillOnAccountSelect
) ||
161 base::CommandLine::ForCurrentProcess()->HasSwitch(
162 switches::kEnableFillOnAccountSelect
)) {
166 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
167 switches::kEnableFillOnAccountSelectNoHighlighting
)) {
172 kFillOnAccountSelectFieldTrialEnabledWithNoHighlightGroup
;
175 // Helper to search the given form element for the specified input elements in
176 // |data|, and add results to |result|.
177 bool FindFormInputElements(blink::WebFormElement
* form_element
,
178 const PasswordFormFillData
& data
,
179 FormElements
* result
) {
180 return FindFormInputElement(form_element
, data
.password_field
, result
) &&
181 (!FillDataContainsUsername(data
) ||
182 FindFormInputElement(form_element
, data
.username_field
, result
));
185 // Helper to locate form elements identified by |data|.
186 void FindFormElements(content::RenderFrame
* render_frame
,
187 const PasswordFormFillData
& data
,
188 FormElementsList
* results
) {
191 GURL::Replacements rep
;
195 blink::WebDocument doc
= render_frame
->GetWebFrame()->document();
196 if (!doc
.isHTMLDocument())
199 GURL
full_origin(doc
.url());
200 if (data
.origin
!= full_origin
.ReplaceComponents(rep
))
203 blink::WebVector
<blink::WebFormElement
> forms
;
206 for (size_t i
= 0; i
< forms
.size(); ++i
) {
207 blink::WebFormElement fe
= forms
[i
];
209 GURL
full_action(doc
.completeURL(fe
.action()));
210 if (full_action
.is_empty()) {
211 // The default action URL is the form's origin.
212 full_action
= full_origin
;
215 // Action URL must match.
216 if (data
.action
!= full_action
.ReplaceComponents(rep
))
219 scoped_ptr
<FormElements
> curr_elements(new FormElements
);
220 if (!FindFormInputElements(&fe
, data
, curr_elements
.get()))
223 // We found the right element.
224 // Note: this assignment adds a reference to |fe|.
225 curr_elements
->form_element
= fe
;
226 results
->push_back(curr_elements
.release());
230 bool IsElementEditable(const blink::WebInputElement
& element
) {
231 return element
.isEnabled() && !element
.isReadOnly();
234 bool DoUsernamesMatch(const base::string16
& username1
,
235 const base::string16
& username2
,
238 return username1
== username2
;
239 return StartsWith(username1
, username2
, true);
242 // Returns |true| if the given element is editable. Otherwise, returns |false|.
243 bool IsElementAutocompletable(const blink::WebInputElement
& element
) {
244 return IsElementEditable(element
);
247 // Returns true if the password specified in |form| is a default value.
248 bool PasswordValueIsDefault(const base::string16
& password_element
,
249 const base::string16
& password_value
,
250 blink::WebFormElement form_element
) {
251 blink::WebVector
<blink::WebNode
> temp_elements
;
252 form_element
.getNamedElements(password_element
, temp_elements
);
254 // We are loose in our definition here and will return true if any of the
255 // appropriately named elements match the element to be saved. Currently
256 // we ignore filling passwords where naming is ambigious anyway.
257 for (size_t i
= 0; i
< temp_elements
.size(); ++i
) {
258 if (temp_elements
[i
].to
<blink::WebElement
>().getAttribute("value") ==
265 // Return true if either password_value or new_password_value is not empty and
267 bool FormContainsNonDefaultPasswordValue(const PasswordForm
& password_form
,
268 blink::WebFormElement form_element
) {
269 return (!password_form
.password_value
.empty() &&
270 !PasswordValueIsDefault(password_form
.password_element
,
271 password_form
.password_value
,
273 (!password_form
.new_password_value
.empty() &&
274 !PasswordValueIsDefault(password_form
.new_password_element
,
275 password_form
.new_password_value
,
279 // Log a message including the name, method and action of |form|.
280 void LogHTMLForm(SavePasswordProgressLogger
* logger
,
281 SavePasswordProgressLogger::StringID message_id
,
282 const blink::WebFormElement
& form
) {
283 logger
->LogHTMLForm(message_id
,
285 GURL(form
.action().utf8()));
288 // Sets |suggestions_present| to true if there are any suggestions to be derived
289 // from |fill_data|. Unless |show_all| is true, only considers suggestions with
290 // usernames having |current_username| as a prefix. Returns true if a username
291 // from the |fill_data.other_possible_usernames| would be included in the
293 bool GetSuggestionsStats(const PasswordFormFillData
& fill_data
,
294 const base::string16
& current_username
,
296 bool* suggestions_present
) {
297 *suggestions_present
= false;
299 for (const auto& usernames
: fill_data
.other_possible_usernames
) {
300 for (size_t i
= 0; i
< usernames
.second
.size(); ++i
) {
302 StartsWith(usernames
.second
[i
], current_username
, false)) {
303 *suggestions_present
= true;
310 StartsWith(fill_data
.username_field
.value
, current_username
, false)) {
311 *suggestions_present
= true;
315 for (const auto& login
: fill_data
.additional_logins
) {
316 if (show_all
|| StartsWith(login
.first
, current_username
, false)) {
317 *suggestions_present
= true;
325 // Returns true if there exists a credential suggestion whose username field is
326 // an exact match to the current username (not just a prefix).
327 bool HasExactMatchSuggestion(const PasswordFormFillData
& fill_data
,
328 const base::string16
& current_username
) {
329 if (fill_data
.username_field
.value
== current_username
)
332 for (const auto& usernames
: fill_data
.other_possible_usernames
) {
333 for (const auto& username_string
: usernames
.second
) {
334 if (username_string
== current_username
)
339 for (const auto& login
: fill_data
.additional_logins
) {
340 if (login
.first
== current_username
)
347 // This function attempts to fill |username_element| and |password_element|
348 // with values from |fill_data|. The |password_element| will only have the
349 // |suggestedValue| set, and will be registered for copying that to the real
350 // value through |registration_callback|. The function returns true when
351 // selected username comes from |fill_data.other_possible_usernames|. |options|
352 // should be a bitwise mask of FillUserNameAndPasswordOptions values.
353 bool FillUserNameAndPassword(
354 blink::WebInputElement
* username_element
,
355 blink::WebInputElement
* password_element
,
356 const PasswordFormFillData
& fill_data
,
357 bool exact_username_match
,
359 base::Callback
<void(blink::WebInputElement
*)> registration_callback
) {
360 bool other_possible_username_selected
= false;
361 // Don't fill username if password can't be set.
362 if (!IsElementAutocompletable(*password_element
))
365 base::string16 current_username
;
366 if (!username_element
->isNull()) {
367 current_username
= username_element
->value();
370 // username and password will contain the match found if any.
371 base::string16 username
;
372 base::string16 password
;
374 // Look for any suitable matches to current field text.
375 if (DoUsernamesMatch(fill_data
.username_field
.value
, current_username
,
376 exact_username_match
)) {
377 username
= fill_data
.username_field
.value
;
378 password
= fill_data
.password_field
.value
;
380 // Scan additional logins for a match.
381 PasswordFormFillData::LoginCollection::const_iterator iter
;
382 for (iter
= fill_data
.additional_logins
.begin();
383 iter
!= fill_data
.additional_logins
.end();
385 if (DoUsernamesMatch(
386 iter
->first
, current_username
, exact_username_match
)) {
387 username
= iter
->first
;
388 password
= iter
->second
.password
;
393 // Check possible usernames.
394 if (username
.empty() && password
.empty()) {
395 for (PasswordFormFillData::UsernamesCollection::const_iterator iter
=
396 fill_data
.other_possible_usernames
.begin();
397 iter
!= fill_data
.other_possible_usernames
.end();
399 for (size_t i
= 0; i
< iter
->second
.size(); ++i
) {
400 if (DoUsernamesMatch(
401 iter
->second
[i
], current_username
, exact_username_match
)) {
402 other_possible_username_selected
= true;
403 username
= iter
->second
[i
];
404 password
= iter
->first
.password
;
408 if (!username
.empty() && !password
.empty())
413 if (password
.empty())
414 return other_possible_username_selected
; // No match was found.
416 // TODO(tkent): Check maxlength and pattern for both username and password
419 // Input matches the username, fill in required values.
420 if (!username_element
->isNull() &&
421 IsElementAutocompletable(*username_element
)) {
422 username_element
->setValue(username
, true);
423 username_element
->setAutofilled(true);
426 username_element
->setSelectionRange(current_username
.length(),
429 } else if (current_username
!= username
) {
430 // If the username can't be filled and it doesn't match a saved password
431 // as is, don't autofill a password.
432 return other_possible_username_selected
;
435 // Wait to fill in the password until a user gesture occurs. This is to make
436 // sure that we do not fill in the DOM with a password until we believe the
437 // user is intentionally interacting with the page.
438 password_element
->setSuggestedValue(password
);
439 registration_callback
.Run(password_element
);
441 password_element
->setAutofilled(true);
442 return other_possible_username_selected
;
445 // Attempts to fill |username_element| and |password_element| with the
446 // |fill_data|. Will use the data corresponding to the preferred username,
447 // unless the |username_element| already has a value set. In that case,
448 // attempts to fill the password matching the already filled username, if
449 // such a password exists. The |password_element| will have the
450 // |suggestedValue| set, and |suggestedValue| will be registered for copying to
451 // the real value through |registration_callback|. Returns true when the
452 // username gets selected from |other_possible_usernames|, else returns false.
453 bool FillFormOnPasswordReceived(
454 const PasswordFormFillData
& fill_data
,
455 blink::WebInputElement username_element
,
456 blink::WebInputElement password_element
,
457 base::Callback
<void(blink::WebInputElement
*)> registration_callback
) {
458 // Do not fill if the password field is in an iframe.
459 DCHECK(password_element
.document().frame());
460 if (password_element
.document().frame()->parent())
463 // If we can't modify the password, don't try to set the username
464 if (!IsElementAutocompletable(password_element
))
467 bool form_contains_username_field
= FillDataContainsUsername(fill_data
);
468 // If the form contains an autocompletable username field, try to set the
469 // username to the preferred name, but only if:
470 // (a) The fill-on-account-select flag is not set, and
471 // (b) The username element isn't prefilled
473 // If (a) is false, then just mark the username element as autofilled if the
474 // user is not in the "no highlighting" group and return so the fill step is
477 // If there is no autocompletable username field, and (a) is false, then the
478 // username element cannot be autofilled, but the user should still be able to
479 // select to fill the password element, so the password element must be marked
480 // as autofilled and the fill step should also be skipped if the user is not
481 // in the "no highlighting" group.
483 // In all other cases, do nothing.
484 bool form_has_fillable_username
= form_contains_username_field
&&
485 IsElementAutocompletable(username_element
);
487 if (ShouldFillOnAccountSelect()) {
488 if (!ShouldHighlightFields()) {
492 if (form_has_fillable_username
) {
493 username_element
.setAutofilled(true);
494 } else if (username_element
.isNull() ||
495 HasExactMatchSuggestion(fill_data
, username_element
.value())) {
496 password_element
.setAutofilled(true);
501 if (form_has_fillable_username
&& username_element
.value().isEmpty()) {
502 // TODO(tkent): Check maxlength and pattern.
503 username_element
.setValue(fill_data
.username_field
.value
, true);
506 // Fill if we have an exact match for the username. Note that this sets
507 // username to autofilled.
508 return FillUserNameAndPassword(&username_element
,
511 true /* exact_username_match */,
512 false /* set_selection */,
513 registration_callback
);
516 // Takes a |map| with pointers as keys and linked_ptr as values, and returns
517 // true if |key| is not NULL and |map| contains a non-NULL entry for |key|.
518 // Makes sure not to create an entry as a side effect of using the operator [].
519 template <class Key
, class Value
>
520 bool ContainsNonNullEntryForNonNullKey(
521 const std::map
<Key
*, linked_ptr
<Value
>>& map
,
525 auto it
= map
.find(key
);
526 return it
!= map
.end() && it
->second
.get();
531 ////////////////////////////////////////////////////////////////////////////////
532 // PasswordAutofillAgent, public:
534 PasswordAutofillAgent::PasswordAutofillAgent(content::RenderFrame
* render_frame
)
535 : content::RenderFrameObserver(render_frame
),
536 legacy_(render_frame
->GetRenderView(), this),
537 usernames_usage_(NOTHING_TO_AUTOFILL
),
538 logging_state_active_(false),
539 was_username_autofilled_(false),
540 was_password_autofilled_(false),
541 username_selection_start_(0),
542 did_stop_loading_(false),
543 weak_ptr_factory_(this) {
544 save_password_on_in_page_navigation_
=
545 base::CommandLine::ForCurrentProcess()->HasSwitch(
546 autofill::switches::kEnablePasswordSaveOnInPageNavigation
);
547 Send(new AutofillHostMsg_PasswordAutofillAgentConstructed(routing_id()));
550 PasswordAutofillAgent::~PasswordAutofillAgent() {
553 PasswordAutofillAgent::PasswordValueGatekeeper::PasswordValueGatekeeper()
554 : was_user_gesture_seen_(false) {
557 PasswordAutofillAgent::PasswordValueGatekeeper::~PasswordValueGatekeeper() {
560 void PasswordAutofillAgent::PasswordValueGatekeeper::RegisterElement(
561 blink::WebInputElement
* element
) {
562 if (was_user_gesture_seen_
)
565 elements_
.push_back(*element
);
568 void PasswordAutofillAgent::PasswordValueGatekeeper::OnUserGesture() {
569 was_user_gesture_seen_
= true;
571 for (std::vector
<blink::WebInputElement
>::iterator it
= elements_
.begin();
572 it
!= elements_
.end();
580 void PasswordAutofillAgent::PasswordValueGatekeeper::Reset() {
581 was_user_gesture_seen_
= false;
585 void PasswordAutofillAgent::PasswordValueGatekeeper::ShowValue(
586 blink::WebInputElement
* element
) {
587 if (!element
->isNull() && !element
->suggestedValue().isEmpty())
588 element
->setValue(element
->suggestedValue(), true);
591 bool PasswordAutofillAgent::TextFieldDidEndEditing(
592 const blink::WebInputElement
& element
) {
593 LoginToPasswordInfoMap::const_iterator iter
=
594 login_to_password_info_
.find(element
);
595 if (iter
== login_to_password_info_
.end())
598 const PasswordInfo
& password_info
= iter
->second
;
599 // Don't let autofill overwrite an explicit change made by the user.
600 if (password_info
.password_was_edited_last
)
603 const PasswordFormFillData
& fill_data
= password_info
.fill_data
;
605 // If wait_for_username is false, we should have filled when the text changed.
606 if (!fill_data
.wait_for_username
)
609 blink::WebInputElement password
= password_info
.password_field
;
610 if (!IsElementEditable(password
))
613 blink::WebInputElement username
= element
; // We need a non-const.
615 // Do not set selection when ending an editing session, otherwise it can
617 if (FillUserNameAndPassword(
618 &username
, &password
, fill_data
, true, false,
619 base::Bind(&PasswordValueGatekeeper::RegisterElement
,
620 base::Unretained(&gatekeeper_
)))) {
621 usernames_usage_
= OTHER_POSSIBLE_USERNAME_SELECTED
;
626 bool PasswordAutofillAgent::TextDidChangeInTextField(
627 const blink::WebInputElement
& element
) {
628 // TODO(vabr): Get a mutable argument instead. http://crbug.com/397083
629 blink::WebInputElement mutable_element
= element
; // We need a non-const.
631 if (element
.isTextField())
632 user_modified_elements_
[element
] = element
.value();
634 DCHECK_EQ(element
.document().frame(), render_frame()->GetWebFrame());
636 if (element
.isPasswordField()) {
637 // Some login forms have event handlers that put a hash of the password into
638 // a hidden field and then clear the password (http://crbug.com/28910,
639 // http://crbug.com/391693). This method gets called before any of those
640 // handlers run, so save away a copy of the password in case it gets lost.
641 // To honor the user having explicitly cleared the password, even an empty
642 // password will be saved here.
643 ProvisionallySavePassword(element
.form(), RESTRICTION_NONE
);
645 PasswordToLoginMap::iterator iter
= password_to_username_
.find(element
);
646 if (iter
!= password_to_username_
.end()) {
647 login_to_password_info_
[iter
->second
].password_was_edited_last
= true;
648 // Note that the suggested value of |mutable_element| was reset when its
650 mutable_element
.setAutofilled(false);
655 LoginToPasswordInfoMap::iterator iter
= login_to_password_info_
.find(element
);
656 if (iter
== login_to_password_info_
.end())
659 // The input text is being changed, so any autofilled password is now
661 mutable_element
.setAutofilled(false);
662 iter
->second
.password_was_edited_last
= false;
664 blink::WebInputElement password
= iter
->second
.password_field
;
665 if (password
.isAutofilled()) {
666 password
.setValue(base::string16(), true);
667 password
.setAutofilled(false);
670 // If wait_for_username is true we will fill when the username loses focus.
671 if (iter
->second
.fill_data
.wait_for_username
)
674 if (!element
.isText() || !IsElementAutocompletable(element
) ||
675 !IsElementAutocompletable(password
)) {
679 // Don't inline autocomplete if the user is deleting, that would be confusing.
680 // But refresh the popup. Note, since this is ours, return true to signal
681 // no further processing is required.
682 if (iter
->second
.backspace_pressed_last
) {
683 ShowSuggestionPopup(iter
->second
.fill_data
, element
, false, false);
687 blink::WebString name
= element
.nameForAutofill();
689 return false; // If the field has no name, then we won't have values.
691 // Don't attempt to autofill with values that are too large.
692 if (element
.value().length() > kMaximumTextSizeForAutocomplete
)
695 // The caret position should have already been updated.
696 PerformInlineAutocomplete(element
, password
, iter
->second
.fill_data
);
700 bool PasswordAutofillAgent::TextFieldHandlingKeyDown(
701 const blink::WebInputElement
& element
,
702 const blink::WebKeyboardEvent
& event
) {
703 // If using the new Autofill UI that lives in the browser, it will handle
704 // keypresses before this function. This is not currently an issue but if
705 // the keys handled there or here change, this issue may appear.
707 LoginToPasswordInfoMap::iterator iter
= login_to_password_info_
.find(element
);
708 if (iter
== login_to_password_info_
.end())
711 int win_key_code
= event
.windowsKeyCode
;
712 iter
->second
.backspace_pressed_last
=
713 (win_key_code
== ui::VKEY_BACK
|| win_key_code
== ui::VKEY_DELETE
);
717 bool PasswordAutofillAgent::FillSuggestion(
718 const blink::WebNode
& node
,
719 const blink::WebString
& username
,
720 const blink::WebString
& password
) {
721 // The element in context of the suggestion popup.
722 blink::WebInputElement filled_element
;
723 PasswordInfo
* password_info
;
725 if (!FindLoginInfo(node
, &filled_element
, &password_info
) ||
726 !IsElementAutocompletable(filled_element
) ||
727 !IsElementAutocompletable(password_info
->password_field
)) {
731 password_info
->password_was_edited_last
= false;
732 // Note that in cases where filled_element is the password element, the value
733 // gets overwritten with the correct one below.
734 filled_element
.setValue(username
, true);
735 filled_element
.setAutofilled(true);
737 password_info
->password_field
.setValue(password
, true);
738 password_info
->password_field
.setAutofilled(true);
740 filled_element
.setSelectionRange(filled_element
.value().length(),
741 filled_element
.value().length());
746 bool PasswordAutofillAgent::PreviewSuggestion(
747 const blink::WebNode
& node
,
748 const blink::WebString
& username
,
749 const blink::WebString
& password
) {
750 blink::WebInputElement username_element
;
751 PasswordInfo
* password_info
;
753 if (!FindLoginInfo(node
, &username_element
, &password_info
) ||
754 !IsElementAutocompletable(username_element
) ||
755 !IsElementAutocompletable(password_info
->password_field
)) {
759 was_username_autofilled_
= username_element
.isAutofilled();
760 username_selection_start_
= username_element
.selectionStart();
761 username_element
.setSuggestedValue(username
);
762 username_element
.setAutofilled(true);
763 username_element
.setSelectionRange(
764 username_selection_start_
,
765 username_element
.suggestedValue().length());
767 was_password_autofilled_
= password_info
->password_field
.isAutofilled();
768 password_info
->password_field
.setSuggestedValue(password
);
769 password_info
->password_field
.setAutofilled(true);
774 bool PasswordAutofillAgent::DidClearAutofillSelection(
775 const blink::WebNode
& node
) {
776 blink::WebInputElement username_element
;
777 PasswordInfo
* password_info
;
778 if (!FindLoginInfo(node
, &username_element
, &password_info
))
781 ClearPreview(&username_element
, &password_info
->password_field
);
785 bool PasswordAutofillAgent::FindPasswordInfoForElement(
786 const blink::WebInputElement
& element
,
787 const blink::WebInputElement
** username_element
,
788 PasswordInfo
** password_info
) {
789 DCHECK(username_element
&& password_info
);
790 if (!element
.isPasswordField()) {
791 *username_element
= &element
;
793 PasswordToLoginMap::const_iterator password_iter
=
794 password_to_username_
.find(element
);
795 if (password_iter
== password_to_username_
.end())
797 *username_element
= &password_iter
->second
;
800 LoginToPasswordInfoMap::iterator iter
=
801 login_to_password_info_
.find(**username_element
);
803 if (iter
== login_to_password_info_
.end())
806 *password_info
= &iter
->second
;
810 bool PasswordAutofillAgent::ShowSuggestions(
811 const blink::WebInputElement
& element
,
813 const blink::WebInputElement
* username_element
;
814 PasswordInfo
* password_info
;
815 if (!FindPasswordInfoForElement(element
, &username_element
, &password_info
))
818 // If autocomplete='off' is set on the form elements, no suggestion dialog
819 // should be shown. However, return |true| to indicate that this is a known
820 // password form and that the request to show suggestions has been handled (as
822 if (!IsElementAutocompletable(element
) ||
823 !IsElementAutocompletable(password_info
->password_field
))
826 bool username_is_available
=
827 !username_element
->isNull() && IsElementEditable(*username_element
);
828 // If the element is a password field, a popup should only be shown if there
829 // is no username or the corresponding username element is not editable since
830 // it is only in that case that the username element does not have a
831 // suggestions popup.
832 if (element
.isPasswordField() && username_is_available
)
835 // Chrome should never show more than one account for a password element since
836 // this implies that the username element cannot be modified. Thus even if
837 // |show_all| is true, check if the element in question is a password element
838 // for the call to ShowSuggestionPopup.
839 return ShowSuggestionPopup(
840 password_info
->fill_data
,
841 username_element
->isNull() ? element
: *username_element
,
842 show_all
&& !element
.isPasswordField(), element
.isPasswordField());
845 bool PasswordAutofillAgent::OriginCanAccessPasswordManager(
846 const blink::WebSecurityOrigin
& origin
) {
847 return origin
.canAccessPasswordManager();
850 void PasswordAutofillAgent::OnDynamicFormsSeen() {
851 SendPasswordForms(false /* only_visible */);
854 void PasswordAutofillAgent::FirstUserGestureObserved() {
855 gatekeeper_
.OnUserGesture();
858 void PasswordAutofillAgent::SendPasswordForms(bool only_visible
) {
859 scoped_ptr
<RendererSavePasswordProgressLogger
> logger
;
860 if (logging_state_active_
) {
861 logger
.reset(new RendererSavePasswordProgressLogger(this, routing_id()));
862 logger
->LogMessage(Logger::STRING_SEND_PASSWORD_FORMS_METHOD
);
863 logger
->LogBoolean(Logger::STRING_ONLY_VISIBLE
, only_visible
);
866 blink::WebFrame
* frame
= render_frame()->GetWebFrame();
867 // Make sure that this security origin is allowed to use password manager.
868 blink::WebSecurityOrigin origin
= frame
->document().securityOrigin();
870 logger
->LogURL(Logger::STRING_SECURITY_ORIGIN
,
871 GURL(origin
.toString().utf8()));
873 if (!OriginCanAccessPasswordManager(origin
)) {
875 logger
->LogMessage(Logger::STRING_SECURITY_ORIGIN_FAILURE
);
880 // Checks whether the webpage is a redirect page or an empty page.
881 if (IsWebpageEmpty(frame
)) {
883 logger
->LogMessage(Logger::STRING_WEBPAGE_EMPTY
);
888 blink::WebVector
<blink::WebFormElement
> forms
;
889 frame
->document().forms(forms
);
891 logger
->LogNumber(Logger::STRING_NUMBER_OF_ALL_FORMS
, forms
.size());
893 std::vector
<PasswordForm
> password_forms
;
894 for (size_t i
= 0; i
< forms
.size(); ++i
) {
895 const blink::WebFormElement
& form
= forms
[i
];
897 bool is_form_visible
= IsWebNodeVisible(form
);
899 LogHTMLForm(logger
.get(), Logger::STRING_FORM_FOUND_ON_PAGE
, form
);
900 logger
->LogBoolean(Logger::STRING_FORM_IS_VISIBLE
, is_form_visible
);
903 // If requested, ignore non-rendered forms, e.g., those styled with
905 if (!is_form_visible
)
909 scoped_ptr
<PasswordForm
> password_form(CreatePasswordForm(form
, nullptr));
910 if (password_form
.get()) {
912 logger
->LogPasswordForm(Logger::STRING_FORM_IS_PASSWORD
,
915 password_forms
.push_back(*password_form
);
919 if (password_forms
.empty() && !only_visible
) {
920 // We need to send the PasswordFormsRendered message regardless of whether
921 // there are any forms visible, as this is also the code path that triggers
922 // showing the infobar.
927 Send(new AutofillHostMsg_PasswordFormsRendered(routing_id(),
931 Send(new AutofillHostMsg_PasswordFormsParsed(routing_id(), password_forms
));
935 bool PasswordAutofillAgent::OnMessageReceived(const IPC::Message
& message
) {
937 IPC_BEGIN_MESSAGE_MAP(PasswordAutofillAgent
, message
)
938 IPC_MESSAGE_HANDLER(AutofillMsg_FillPasswordForm
, OnFillPasswordForm
)
939 IPC_MESSAGE_HANDLER(AutofillMsg_SetLoggingState
, OnSetLoggingState
)
940 IPC_MESSAGE_UNHANDLED(handled
= false)
941 IPC_END_MESSAGE_MAP()
945 void PasswordAutofillAgent::DidFinishDocumentLoad() {
946 // The |frame| contents have been parsed, but not yet rendered. Let the
947 // PasswordManager know that forms are loaded, even though we can't yet tell
948 // whether they're visible.
949 SendPasswordForms(false);
952 void PasswordAutofillAgent::DidFinishLoad() {
953 // The |frame| contents have been rendered. Let the PasswordManager know
954 // which of the loaded frames are actually visible to the user. This also
955 // triggers the "Save password?" infobar if the user just submitted a password
957 SendPasswordForms(true);
960 void PasswordAutofillAgent::FrameWillClose() {
964 void PasswordAutofillAgent::DidCommitProvisionalLoad(
965 bool is_new_navigation
, bool is_same_page_navigation
) {
966 if (!save_password_on_in_page_navigation_
)
968 blink::WebFrame
* frame
= render_frame()->GetWebFrame();
969 // TODO(dvadym): check if we need to check if it is main frame navigation
970 // http://crbug.com/443155
972 return; // Not a top-level navigation.
974 if (is_same_page_navigation
&& provisionally_saved_form_
) {
975 Send(new AutofillHostMsg_InPageNavigation(routing_id(),
976 *provisionally_saved_form_
));
977 provisionally_saved_form_
.reset();
981 void PasswordAutofillAgent::DidStartLoading() {
982 did_stop_loading_
= false;
983 if (usernames_usage_
!= NOTHING_TO_AUTOFILL
) {
984 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OtherPossibleUsernamesUsage",
985 usernames_usage_
, OTHER_POSSIBLE_USERNAMES_MAX
);
986 usernames_usage_
= NOTHING_TO_AUTOFILL
;
990 void PasswordAutofillAgent::DidStopLoading() {
991 did_stop_loading_
= true;
994 void PasswordAutofillAgent::FrameDetached() {
998 void PasswordAutofillAgent::WillSendSubmitEvent(
999 const blink::WebFormElement
& form
) {
1000 // Forms submitted via XHR are not seen by WillSubmitForm if the default
1001 // onsubmit handler is overridden. Such submission first gets detected in
1002 // DidStartProvisionalLoad, which no longer knows about the particular form,
1003 // and uses the candidate stored in |provisionally_saved_form_|.
1005 // User-typed password will get stored to |provisionally_saved_form_| in
1006 // TextDidChangeInTextField. Autofilled or JavaScript-copied passwords need to
1009 // Only non-empty passwords are saved here. Empty passwords were likely
1010 // cleared by some scripts (http://crbug.com/28910, http://crbug.com/391693).
1011 // Had the user cleared the password, |provisionally_saved_form_| would
1012 // already have been updated in TextDidChangeInTextField.
1013 ProvisionallySavePassword(form
, RESTRICTION_NON_EMPTY_PASSWORD
);
1016 void PasswordAutofillAgent::WillSubmitForm(const blink::WebFormElement
& form
) {
1017 scoped_ptr
<RendererSavePasswordProgressLogger
> logger
;
1018 if (logging_state_active_
) {
1019 logger
.reset(new RendererSavePasswordProgressLogger(this, routing_id()));
1020 logger
->LogMessage(Logger::STRING_WILL_SUBMIT_FORM_METHOD
);
1021 LogHTMLForm(logger
.get(), Logger::STRING_HTML_FORM_FOR_SUBMIT
, form
);
1024 scoped_ptr
<PasswordForm
> submitted_form
= CreatePasswordForm(form
, nullptr);
1026 // If there is a provisionally saved password, copy over the previous
1027 // password value so we get the user's typed password, not the value that
1028 // may have been transformed for submit.
1029 // TODO(gcasto): Do we need to have this action equality check? Is it trying
1030 // to prevent accidentally copying over passwords from a different form?
1031 if (submitted_form
) {
1033 logger
->LogPasswordForm(Logger::STRING_CREATED_PASSWORD_FORM
,
1036 if (provisionally_saved_form_
&&
1037 submitted_form
->action
== provisionally_saved_form_
->action
) {
1039 logger
->LogMessage(Logger::STRING_SUBMITTED_PASSWORD_REPLACED
);
1040 submitted_form
->password_value
=
1041 provisionally_saved_form_
->password_value
;
1042 submitted_form
->new_password_value
=
1043 provisionally_saved_form_
->new_password_value
;
1044 submitted_form
->username_value
=
1045 provisionally_saved_form_
->username_value
;
1048 // Some observers depend on sending this information now instead of when
1049 // the frame starts loading. If there are redirects that cause a new
1050 // RenderView to be instantiated (such as redirects to the WebStore)
1051 // we will never get to finish the load.
1052 Send(new AutofillHostMsg_PasswordFormSubmitted(routing_id(),
1054 provisionally_saved_form_
.reset();
1055 } else if (logger
) {
1056 logger
->LogMessage(Logger::STRING_FORM_IS_NOT_PASSWORD
);
1060 void PasswordAutofillAgent::LegacyDidStartProvisionalLoad(
1061 blink::WebLocalFrame
* navigated_frame
) {
1062 scoped_ptr
<RendererSavePasswordProgressLogger
> logger
;
1063 if (logging_state_active_
) {
1064 logger
.reset(new RendererSavePasswordProgressLogger(this, routing_id()));
1065 logger
->LogMessage(Logger::STRING_DID_START_PROVISIONAL_LOAD_METHOD
);
1068 if (navigated_frame
->parent()) {
1070 logger
->LogMessage(Logger::STRING_FRAME_NOT_MAIN_FRAME
);
1074 // Bug fix for crbug.com/368690. isProcessingUserGesture() is false when
1075 // the user is performing actions outside the page (e.g. typed url,
1076 // history navigation). We don't want to trigger saving in these cases.
1077 content::DocumentState
* document_state
=
1078 content::DocumentState::FromDataSource(
1079 navigated_frame
->provisionalDataSource());
1080 content::NavigationState
* navigation_state
=
1081 document_state
->navigation_state();
1082 ui::PageTransition type
= navigation_state
->transition_type();
1083 if (ui::PageTransitionIsWebTriggerable(type
) &&
1084 ui::PageTransitionIsNewNavigation(type
) &&
1085 !blink::WebUserGestureIndicator::isProcessingUserGesture()) {
1086 // If onsubmit has been called, try and save that form.
1087 if (provisionally_saved_form_
) {
1089 logger
->LogPasswordForm(
1090 Logger::STRING_PROVISIONALLY_SAVED_FORM_FOR_FRAME
,
1091 *provisionally_saved_form_
);
1093 Send(new AutofillHostMsg_PasswordFormSubmitted(
1094 routing_id(), *provisionally_saved_form_
));
1095 provisionally_saved_form_
.reset();
1097 // Loop through the forms on the page looking for one that has been
1098 // filled out. If one exists, try and save the credentials.
1099 blink::WebVector
<blink::WebFormElement
> forms
;
1100 render_frame()->GetWebFrame()->document().forms(forms
);
1102 bool password_forms_found
= false;
1103 for (size_t i
= 0; i
< forms
.size(); ++i
) {
1104 blink::WebFormElement form_element
= forms
[i
];
1106 LogHTMLForm(logger
.get(), Logger::STRING_FORM_FOUND_ON_PAGE
,
1109 scoped_ptr
<PasswordForm
> password_form(
1110 CreatePasswordForm(form_element
, &user_modified_elements_
));
1111 if (password_form
.get() && !password_form
->username_value
.empty() &&
1112 FormContainsNonDefaultPasswordValue(*password_form
, form_element
)) {
1113 password_forms_found
= true;
1115 logger
->LogPasswordForm(Logger::STRING_PASSWORD_FORM_FOUND_ON_PAGE
,
1118 Send(new AutofillHostMsg_PasswordFormSubmitted(routing_id(),
1122 if (!password_forms_found
&& logger
)
1123 logger
->LogMessage(Logger::STRING_PASSWORD_FORM_NOT_FOUND_ON_PAGE
);
1127 // This is a new navigation, so require a new user gesture before filling in
1129 gatekeeper_
.Reset();
1132 void PasswordAutofillAgent::OnFillPasswordForm(
1134 const PasswordFormFillData
& form_data
) {
1135 if (usernames_usage_
== NOTHING_TO_AUTOFILL
) {
1136 if (form_data
.other_possible_usernames
.size())
1137 usernames_usage_
= OTHER_POSSIBLE_USERNAMES_PRESENT
;
1138 else if (usernames_usage_
== NOTHING_TO_AUTOFILL
)
1139 usernames_usage_
= OTHER_POSSIBLE_USERNAMES_ABSENT
;
1142 FormElementsList forms
;
1143 // We own the FormElements* in forms.
1144 FindFormElements(render_frame(), form_data
, &forms
);
1145 FormElementsList::iterator iter
;
1146 for (iter
= forms
.begin(); iter
!= forms
.end(); ++iter
) {
1147 scoped_ptr
<FormElements
> form_elements(*iter
);
1149 // Attach autocomplete listener to enable selecting alternate logins.
1150 blink::WebInputElement username_element
, password_element
;
1152 // Check whether the password form has a username input field.
1153 bool form_contains_username_field
= FillDataContainsUsername(form_data
);
1154 if (form_contains_username_field
) {
1156 form_elements
->input_elements
[form_data
.username_field
.name
];
1159 // No password field, bail out.
1160 if (form_data
.password_field
.name
.empty())
1163 // We might have already filled this form if there are two <form> elements
1164 // with identical markup.
1165 if (login_to_password_info_
.find(username_element
) !=
1166 login_to_password_info_
.end())
1169 // Get pointer to password element. (We currently only support single
1172 form_elements
->input_elements
[form_data
.password_field
.name
];
1174 // If wait_for_username is true, we don't want to initially fill the form
1175 // until the user types in a valid username.
1176 if (!form_data
.wait_for_username
&&
1177 FillFormOnPasswordReceived(
1181 base::Bind(&PasswordValueGatekeeper::RegisterElement
,
1182 base::Unretained(&gatekeeper_
)))) {
1183 usernames_usage_
= OTHER_POSSIBLE_USERNAME_SELECTED
;
1186 PasswordInfo password_info
;
1187 password_info
.fill_data
= form_data
;
1188 password_info
.password_field
= password_element
;
1189 login_to_password_info_
[username_element
] = password_info
;
1190 password_to_username_
[password_element
] = username_element
;
1191 login_to_password_info_key_
[username_element
] = key
;
1195 void PasswordAutofillAgent::OnSetLoggingState(bool active
) {
1196 logging_state_active_
= active
;
1199 ////////////////////////////////////////////////////////////////////////////////
1200 // PasswordAutofillAgent, private:
1202 PasswordAutofillAgent::PasswordInfo::PasswordInfo()
1203 : backspace_pressed_last(false), password_was_edited_last(false) {
1206 bool PasswordAutofillAgent::ShowSuggestionPopup(
1207 const PasswordFormFillData
& fill_data
,
1208 const blink::WebInputElement
& user_input
,
1210 bool show_on_password_field
) {
1211 DCHECK(!user_input
.isNull());
1212 blink::WebFrame
* frame
= user_input
.document().frame();
1216 blink::WebView
* webview
= frame
->view();
1221 FormFieldData field
;
1222 FindFormAndFieldForFormControlElement(
1223 user_input
, &form
, &field
, REQUIRE_NONE
);
1225 blink::WebInputElement selected_element
= user_input
;
1226 if (show_on_password_field
&& !selected_element
.isPasswordField()) {
1227 LoginToPasswordInfoMap::const_iterator iter
=
1228 login_to_password_info_
.find(user_input
);
1229 DCHECK(iter
!= login_to_password_info_
.end());
1230 selected_element
= iter
->second
.password_field
;
1232 gfx::Rect
bounding_box(selected_element
.boundsInViewportSpace());
1234 blink::WebInputElement username
;
1235 if (!show_on_password_field
|| !user_input
.isPasswordField()) {
1236 username
= user_input
;
1238 LoginToPasswordInfoKeyMap::const_iterator key_it
=
1239 login_to_password_info_key_
.find(username
);
1240 DCHECK(key_it
!= login_to_password_info_key_
.end());
1243 render_frame()->GetRenderView()->GetWebView()->pageScaleFactor();
1244 gfx::RectF
bounding_box_scaled(bounding_box
.x() * scale
,
1245 bounding_box
.y() * scale
,
1246 bounding_box
.width() * scale
,
1247 bounding_box
.height() * scale
);
1250 options
|= SHOW_ALL
;
1251 if (show_on_password_field
)
1252 options
|= IS_PASSWORD_FIELD
;
1253 base::string16
username_string(
1254 username
.isNull() ? base::string16()
1255 : static_cast<base::string16
>(user_input
.value()));
1256 Send(new AutofillHostMsg_ShowPasswordSuggestions(
1257 routing_id(), key_it
->second
, field
.text_direction
, username_string
,
1258 options
, bounding_box_scaled
));
1260 bool suggestions_present
= false;
1261 if (GetSuggestionsStats(fill_data
, username_string
, show_all
,
1262 &suggestions_present
)) {
1263 usernames_usage_
= OTHER_POSSIBLE_USERNAME_SHOWN
;
1265 return suggestions_present
;
1268 void PasswordAutofillAgent::PerformInlineAutocomplete(
1269 const blink::WebInputElement
& username_input
,
1270 const blink::WebInputElement
& password_input
,
1271 const PasswordFormFillData
& fill_data
) {
1272 DCHECK(!fill_data
.wait_for_username
);
1274 // We need non-const versions of the username and password inputs.
1275 blink::WebInputElement username
= username_input
;
1276 blink::WebInputElement password
= password_input
;
1278 // Don't inline autocomplete if the caret is not at the end.
1279 // TODO(jcivelli): is there a better way to test the caret location?
1280 if (username
.selectionStart() != username
.selectionEnd() ||
1281 username
.selectionEnd() != static_cast<int>(username
.value().length())) {
1285 // Show the popup with the list of available usernames.
1286 ShowSuggestionPopup(fill_data
, username
, false, false);
1288 #if !defined(OS_ANDROID)
1289 // Fill the user and password field with the most relevant match. Android
1290 // only fills in the fields after the user clicks on the suggestion popup.
1291 if (FillUserNameAndPassword(
1295 false /* exact_username_match */,
1296 true /* set selection */,
1297 base::Bind(&PasswordValueGatekeeper::RegisterElement
,
1298 base::Unretained(&gatekeeper_
)))) {
1299 usernames_usage_
= OTHER_POSSIBLE_USERNAME_SELECTED
;
1304 void PasswordAutofillAgent::FrameClosing() {
1305 for (auto const& iter
: login_to_password_info_
) {
1306 login_to_password_info_key_
.erase(iter
.first
);
1307 password_to_username_
.erase(iter
.second
.password_field
);
1309 login_to_password_info_
.clear();
1310 provisionally_saved_form_
.reset();
1311 user_modified_elements_
.clear();
1314 bool PasswordAutofillAgent::FindLoginInfo(const blink::WebNode
& node
,
1315 blink::WebInputElement
* found_input
,
1316 PasswordInfo
** found_password
) {
1317 if (!node
.isElementNode())
1320 blink::WebElement element
= node
.toConst
<blink::WebElement
>();
1321 if (!element
.hasHTMLTagName("input"))
1324 *found_input
= element
.to
<blink::WebInputElement
>();
1325 const blink::WebInputElement
* username_element
; // ignored
1326 return FindPasswordInfoForElement(*found_input
, &username_element
,
1330 void PasswordAutofillAgent::ClearPreview(
1331 blink::WebInputElement
* username
,
1332 blink::WebInputElement
* password
) {
1333 if (!username
->suggestedValue().isEmpty()) {
1334 username
->setSuggestedValue(blink::WebString());
1335 username
->setAutofilled(was_username_autofilled_
);
1336 username
->setSelectionRange(username_selection_start_
,
1337 username
->value().length());
1339 if (!password
->suggestedValue().isEmpty()) {
1340 password
->setSuggestedValue(blink::WebString());
1341 password
->setAutofilled(was_password_autofilled_
);
1345 void PasswordAutofillAgent::ProvisionallySavePassword(
1346 const blink::WebFormElement
& form
,
1347 ProvisionallySaveRestriction restriction
) {
1348 scoped_ptr
<PasswordForm
> password_form(
1349 CreatePasswordForm(form
, &user_modified_elements_
));
1350 if (!password_form
|| (restriction
== RESTRICTION_NON_EMPTY_PASSWORD
&&
1351 password_form
->password_value
.empty() &&
1352 password_form
->new_password_value
.empty())) {
1355 provisionally_saved_form_
= password_form
.Pass();
1358 // LegacyPasswordAutofillAgent -------------------------------------------------
1360 PasswordAutofillAgent::LegacyPasswordAutofillAgent::LegacyPasswordAutofillAgent(
1361 content::RenderView
* render_view
,
1362 PasswordAutofillAgent
* agent
)
1363 : content::RenderViewObserver(render_view
), agent_(agent
) {
1366 PasswordAutofillAgent::LegacyPasswordAutofillAgent::
1367 ~LegacyPasswordAutofillAgent() {
1370 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::OnDestruct() {
1371 // No op. Do not delete |this|.
1374 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::DidStartLoading() {
1375 agent_
->DidStartLoading();
1378 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::DidStopLoading() {
1379 agent_
->DidStopLoading();
1382 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::
1383 DidStartProvisionalLoad(blink::WebLocalFrame
* navigated_frame
) {
1384 agent_
->LegacyDidStartProvisionalLoad(navigated_frame
);
1387 } // namespace autofill