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 // This function attempts to fill |username_element| and |password_element|
326 // with values from |fill_data|. The |password_element| will only have the
327 // |suggestedValue| set, and will be registered for copying that to the real
328 // value through |registration_callback|. The function returns true when
329 // selected username comes from |fill_data.other_possible_usernames|. |options|
330 // should be a bitwise mask of FillUserNameAndPasswordOptions values.
331 bool FillUserNameAndPassword(
332 blink::WebInputElement
* username_element
,
333 blink::WebInputElement
* password_element
,
334 const PasswordFormFillData
& fill_data
,
335 bool exact_username_match
,
337 base::Callback
<void(blink::WebInputElement
*)> registration_callback
) {
338 bool other_possible_username_selected
= false;
339 // Don't fill username if password can't be set.
340 if (!IsElementAutocompletable(*password_element
))
343 base::string16 current_username
;
344 if (!username_element
->isNull()) {
345 current_username
= username_element
->value();
348 // username and password will contain the match found if any.
349 base::string16 username
;
350 base::string16 password
;
352 // Look for any suitable matches to current field text.
353 if (DoUsernamesMatch(fill_data
.username_field
.value
, current_username
,
354 exact_username_match
)) {
355 username
= fill_data
.username_field
.value
;
356 password
= fill_data
.password_field
.value
;
358 // Scan additional logins for a match.
359 PasswordFormFillData::LoginCollection::const_iterator iter
;
360 for (iter
= fill_data
.additional_logins
.begin();
361 iter
!= fill_data
.additional_logins
.end();
363 if (DoUsernamesMatch(
364 iter
->first
, current_username
, exact_username_match
)) {
365 username
= iter
->first
;
366 password
= iter
->second
.password
;
371 // Check possible usernames.
372 if (username
.empty() && password
.empty()) {
373 for (PasswordFormFillData::UsernamesCollection::const_iterator iter
=
374 fill_data
.other_possible_usernames
.begin();
375 iter
!= fill_data
.other_possible_usernames
.end();
377 for (size_t i
= 0; i
< iter
->second
.size(); ++i
) {
378 if (DoUsernamesMatch(
379 iter
->second
[i
], current_username
, exact_username_match
)) {
380 other_possible_username_selected
= true;
381 username
= iter
->second
[i
];
382 password
= iter
->first
.password
;
386 if (!username
.empty() && !password
.empty())
391 if (password
.empty())
392 return other_possible_username_selected
; // No match was found.
394 // TODO(tkent): Check maxlength and pattern for both username and password
397 // Input matches the username, fill in required values.
398 if (!username_element
->isNull() &&
399 IsElementAutocompletable(*username_element
)) {
400 username_element
->setValue(username
, true);
401 username_element
->setAutofilled(true);
404 username_element
->setSelectionRange(current_username
.length(),
407 } else if (current_username
!= username
) {
408 // If the username can't be filled and it doesn't match a saved password
409 // as is, don't autofill a password.
410 return other_possible_username_selected
;
413 // Wait to fill in the password until a user gesture occurs. This is to make
414 // sure that we do not fill in the DOM with a password until we believe the
415 // user is intentionally interacting with the page.
416 password_element
->setSuggestedValue(password
);
417 registration_callback
.Run(password_element
);
419 password_element
->setAutofilled(true);
420 return other_possible_username_selected
;
423 // Attempts to fill |username_element| and |password_element| with the
424 // |fill_data|. Will use the data corresponding to the preferred username,
425 // unless the |username_element| already has a value set. In that case,
426 // attempts to fill the password matching the already filled username, if
427 // such a password exists. The |password_element| will have the
428 // |suggestedValue| set, and |suggestedValue| will be registered for copying to
429 // the real value through |registration_callback|. Returns true when the
430 // username gets selected from |other_possible_usernames|, else returns false.
431 bool FillFormOnPasswordReceived(
432 const PasswordFormFillData
& fill_data
,
433 blink::WebInputElement username_element
,
434 blink::WebInputElement password_element
,
435 base::Callback
<void(blink::WebInputElement
*)> registration_callback
) {
436 // Do not fill if the password field is in an iframe.
437 DCHECK(password_element
.document().frame());
438 if (password_element
.document().frame()->parent())
441 // If we can't modify the password, don't try to set the username
442 if (!IsElementAutocompletable(password_element
))
445 bool form_contains_username_field
= FillDataContainsUsername(fill_data
);
446 // If the form contains an autocompletable username field, try to set the
447 // username to the preferred name, but only if:
448 // (a) The fill-on-account-select flag is not set, and
449 // (b) The username element isn't prefilled
451 // If (a) is false, then just mark the username element as autofilled if the
452 // user is not in the "no highlighting" group and return so the fill step is
455 // If there is no autocompletable username field, and (a) is false, then the
456 // username element cannot be autofilled, but the user should still be able to
457 // select to fill the password element, so the password element must be marked
458 // as autofilled and the fill step should also be skipped if the user is not
459 // in the "no highlighting" group.
461 // In all other cases, do nothing.
462 bool form_has_fillable_username
= form_contains_username_field
&&
463 IsElementAutocompletable(username_element
);
465 if (ShouldFillOnAccountSelect()) {
466 if (!ShouldHighlightFields()) {
470 if (form_has_fillable_username
) {
471 username_element
.setAutofilled(true);
473 password_element
.setAutofilled(true);
478 if (form_has_fillable_username
&& username_element
.value().isEmpty()) {
479 // TODO(tkent): Check maxlength and pattern.
480 username_element
.setValue(fill_data
.username_field
.value
, true);
483 // Fill if we have an exact match for the username. Note that this sets
484 // username to autofilled.
485 return FillUserNameAndPassword(&username_element
,
488 true /* exact_username_match */,
489 false /* set_selection */,
490 registration_callback
);
493 // Takes a |map| with pointers as keys and linked_ptr as values, and returns
494 // true if |key| is not NULL and |map| contains a non-NULL entry for |key|.
495 // Makes sure not to create an entry as a side effect of using the operator [].
496 template <class Key
, class Value
>
497 bool ContainsNonNullEntryForNonNullKey(
498 const std::map
<Key
*, linked_ptr
<Value
>>& map
,
502 auto it
= map
.find(key
);
503 return it
!= map
.end() && it
->second
.get();
508 ////////////////////////////////////////////////////////////////////////////////
509 // PasswordAutofillAgent, public:
511 PasswordAutofillAgent::PasswordAutofillAgent(content::RenderFrame
* render_frame
)
512 : content::RenderFrameObserver(render_frame
),
513 legacy_(render_frame
->GetRenderView(), this),
514 usernames_usage_(NOTHING_TO_AUTOFILL
),
515 logging_state_active_(false),
516 was_username_autofilled_(false),
517 was_password_autofilled_(false),
518 username_selection_start_(0),
519 did_stop_loading_(false),
520 weak_ptr_factory_(this) {
521 Send(new AutofillHostMsg_PasswordAutofillAgentConstructed(routing_id()));
524 PasswordAutofillAgent::~PasswordAutofillAgent() {
527 PasswordAutofillAgent::PasswordValueGatekeeper::PasswordValueGatekeeper()
528 : was_user_gesture_seen_(false) {
531 PasswordAutofillAgent::PasswordValueGatekeeper::~PasswordValueGatekeeper() {
534 void PasswordAutofillAgent::PasswordValueGatekeeper::RegisterElement(
535 blink::WebInputElement
* element
) {
536 if (was_user_gesture_seen_
)
539 elements_
.push_back(*element
);
542 void PasswordAutofillAgent::PasswordValueGatekeeper::OnUserGesture() {
543 was_user_gesture_seen_
= true;
545 for (std::vector
<blink::WebInputElement
>::iterator it
= elements_
.begin();
546 it
!= elements_
.end();
554 void PasswordAutofillAgent::PasswordValueGatekeeper::Reset() {
555 was_user_gesture_seen_
= false;
559 void PasswordAutofillAgent::PasswordValueGatekeeper::ShowValue(
560 blink::WebInputElement
* element
) {
561 if (!element
->isNull() && !element
->suggestedValue().isEmpty())
562 element
->setValue(element
->suggestedValue(), true);
565 bool PasswordAutofillAgent::TextFieldDidEndEditing(
566 const blink::WebInputElement
& element
) {
567 LoginToPasswordInfoMap::const_iterator iter
=
568 login_to_password_info_
.find(element
);
569 if (iter
== login_to_password_info_
.end())
572 const PasswordInfo
& password_info
= iter
->second
;
573 // Don't let autofill overwrite an explicit change made by the user.
574 if (password_info
.password_was_edited_last
)
577 const PasswordFormFillData
& fill_data
= password_info
.fill_data
;
579 // If wait_for_username is false, we should have filled when the text changed.
580 if (!fill_data
.wait_for_username
)
583 blink::WebInputElement password
= password_info
.password_field
;
584 if (!IsElementEditable(password
))
587 blink::WebInputElement username
= element
; // We need a non-const.
589 // Do not set selection when ending an editing session, otherwise it can
591 if (FillUserNameAndPassword(
592 &username
, &password
, fill_data
, true, false,
593 base::Bind(&PasswordValueGatekeeper::RegisterElement
,
594 base::Unretained(&gatekeeper_
)))) {
595 usernames_usage_
= OTHER_POSSIBLE_USERNAME_SELECTED
;
600 bool PasswordAutofillAgent::TextDidChangeInTextField(
601 const blink::WebInputElement
& element
) {
602 // TODO(vabr): Get a mutable argument instead. http://crbug.com/397083
603 blink::WebInputElement mutable_element
= element
; // We need a non-const.
605 if (element
.isTextField())
606 user_modified_elements_
[element
] = element
.value();
608 DCHECK_EQ(element
.document().frame(), render_frame()->GetWebFrame());
610 if (element
.isPasswordField()) {
611 // Some login forms have event handlers that put a hash of the password into
612 // a hidden field and then clear the password (http://crbug.com/28910,
613 // http://crbug.com/391693). This method gets called before any of those
614 // handlers run, so save away a copy of the password in case it gets lost.
615 // To honor the user having explicitly cleared the password, even an empty
616 // password will be saved here.
617 ProvisionallySavePassword(element
.form(), RESTRICTION_NONE
);
619 PasswordToLoginMap::iterator iter
= password_to_username_
.find(element
);
620 if (iter
!= password_to_username_
.end()) {
621 login_to_password_info_
[iter
->second
].password_was_edited_last
= true;
622 // Note that the suggested value of |mutable_element| was reset when its
624 mutable_element
.setAutofilled(false);
629 LoginToPasswordInfoMap::iterator iter
= login_to_password_info_
.find(element
);
630 if (iter
== login_to_password_info_
.end())
633 // The input text is being changed, so any autofilled password is now
635 mutable_element
.setAutofilled(false);
636 iter
->second
.password_was_edited_last
= false;
638 blink::WebInputElement password
= iter
->second
.password_field
;
639 if (password
.isAutofilled()) {
640 password
.setValue(base::string16(), true);
641 password
.setAutofilled(false);
644 // If wait_for_username is true we will fill when the username loses focus.
645 if (iter
->second
.fill_data
.wait_for_username
)
648 if (!element
.isText() || !IsElementAutocompletable(element
) ||
649 !IsElementAutocompletable(password
)) {
653 // Don't inline autocomplete if the user is deleting, that would be confusing.
654 // But refresh the popup. Note, since this is ours, return true to signal
655 // no further processing is required.
656 if (iter
->second
.backspace_pressed_last
) {
657 ShowSuggestionPopup(iter
->second
.fill_data
, element
, false, false);
661 blink::WebString name
= element
.nameForAutofill();
663 return false; // If the field has no name, then we won't have values.
665 // Don't attempt to autofill with values that are too large.
666 if (element
.value().length() > kMaximumTextSizeForAutocomplete
)
669 // The caret position should have already been updated.
670 PerformInlineAutocomplete(element
, password
, iter
->second
.fill_data
);
674 bool PasswordAutofillAgent::TextFieldHandlingKeyDown(
675 const blink::WebInputElement
& element
,
676 const blink::WebKeyboardEvent
& event
) {
677 // If using the new Autofill UI that lives in the browser, it will handle
678 // keypresses before this function. This is not currently an issue but if
679 // the keys handled there or here change, this issue may appear.
681 LoginToPasswordInfoMap::iterator iter
= login_to_password_info_
.find(element
);
682 if (iter
== login_to_password_info_
.end())
685 int win_key_code
= event
.windowsKeyCode
;
686 iter
->second
.backspace_pressed_last
=
687 (win_key_code
== ui::VKEY_BACK
|| win_key_code
== ui::VKEY_DELETE
);
691 bool PasswordAutofillAgent::FillSuggestion(
692 const blink::WebNode
& node
,
693 const blink::WebString
& username
,
694 const blink::WebString
& password
) {
695 // The element in context of the suggestion popup.
696 blink::WebInputElement filled_element
;
697 PasswordInfo
* password_info
;
699 if (!FindLoginInfo(node
, &filled_element
, &password_info
) ||
700 !IsElementAutocompletable(filled_element
) ||
701 !IsElementAutocompletable(password_info
->password_field
)) {
705 password_info
->password_was_edited_last
= false;
706 // Note that in cases where filled_element is the password element, the value
707 // gets overwritten with the correct one below.
708 filled_element
.setValue(username
, true);
709 filled_element
.setAutofilled(true);
711 password_info
->password_field
.setValue(password
, true);
712 password_info
->password_field
.setAutofilled(true);
714 filled_element
.setSelectionRange(filled_element
.value().length(),
715 filled_element
.value().length());
720 bool PasswordAutofillAgent::PreviewSuggestion(
721 const blink::WebNode
& node
,
722 const blink::WebString
& username
,
723 const blink::WebString
& password
) {
724 blink::WebInputElement username_element
;
725 PasswordInfo
* password_info
;
727 if (!FindLoginInfo(node
, &username_element
, &password_info
) ||
728 !IsElementAutocompletable(username_element
) ||
729 !IsElementAutocompletable(password_info
->password_field
)) {
733 was_username_autofilled_
= username_element
.isAutofilled();
734 username_selection_start_
= username_element
.selectionStart();
735 username_element
.setSuggestedValue(username
);
736 username_element
.setAutofilled(true);
737 username_element
.setSelectionRange(
738 username_selection_start_
,
739 username_element
.suggestedValue().length());
741 was_password_autofilled_
= password_info
->password_field
.isAutofilled();
742 password_info
->password_field
.setSuggestedValue(password
);
743 password_info
->password_field
.setAutofilled(true);
748 bool PasswordAutofillAgent::DidClearAutofillSelection(
749 const blink::WebNode
& node
) {
750 blink::WebInputElement username_element
;
751 PasswordInfo
* password_info
;
752 if (!FindLoginInfo(node
, &username_element
, &password_info
))
755 ClearPreview(&username_element
, &password_info
->password_field
);
759 bool PasswordAutofillAgent::FindPasswordInfoForElement(
760 const blink::WebInputElement
& element
,
761 const blink::WebInputElement
** username_element
,
762 PasswordInfo
** password_info
) {
763 DCHECK(username_element
&& password_info
);
764 if (!element
.isPasswordField()) {
765 *username_element
= &element
;
767 PasswordToLoginMap::const_iterator password_iter
=
768 password_to_username_
.find(element
);
769 if (password_iter
== password_to_username_
.end())
771 *username_element
= &password_iter
->second
;
774 LoginToPasswordInfoMap::iterator iter
=
775 login_to_password_info_
.find(**username_element
);
777 if (iter
== login_to_password_info_
.end())
780 *password_info
= &iter
->second
;
784 bool PasswordAutofillAgent::ShowSuggestions(
785 const blink::WebInputElement
& element
,
787 const blink::WebInputElement
* username_element
;
788 PasswordInfo
* password_info
;
789 if (!FindPasswordInfoForElement(element
, &username_element
, &password_info
))
792 // If autocomplete='off' is set on the form elements, no suggestion dialog
793 // should be shown. However, return |true| to indicate that this is a known
794 // password form and that the request to show suggestions has been handled (as
796 if (!IsElementAutocompletable(element
) ||
797 !IsElementAutocompletable(password_info
->password_field
))
800 bool username_is_available
=
801 !username_element
->isNull() && IsElementEditable(*username_element
);
802 // If the element is a password field, a popup should only be shown if there
803 // is no username or the corresponding username element is not editable since
804 // it is only in that case that the username element does not have a
805 // suggestions popup.
806 if (element
.isPasswordField() && username_is_available
)
809 // Chrome should never show more than one account for a password element since
810 // this implies that the username element cannot be modified. Thus even if
811 // |show_all| is true, check if the element in question is a password element
812 // for the call to ShowSuggestionPopup.
813 return ShowSuggestionPopup(
814 password_info
->fill_data
,
815 username_element
->isNull() ? element
: *username_element
,
816 show_all
&& !element
.isPasswordField(), element
.isPasswordField());
819 bool PasswordAutofillAgent::OriginCanAccessPasswordManager(
820 const blink::WebSecurityOrigin
& origin
) {
821 return origin
.canAccessPasswordManager();
824 void PasswordAutofillAgent::OnDynamicFormsSeen() {
825 SendPasswordForms(false /* only_visible */);
828 void PasswordAutofillAgent::FirstUserGestureObserved() {
829 gatekeeper_
.OnUserGesture();
832 void PasswordAutofillAgent::SendPasswordForms(bool only_visible
) {
833 scoped_ptr
<RendererSavePasswordProgressLogger
> logger
;
834 if (logging_state_active_
) {
835 logger
.reset(new RendererSavePasswordProgressLogger(this, routing_id()));
836 logger
->LogMessage(Logger::STRING_SEND_PASSWORD_FORMS_METHOD
);
837 logger
->LogBoolean(Logger::STRING_ONLY_VISIBLE
, only_visible
);
840 blink::WebFrame
* frame
= render_frame()->GetWebFrame();
841 // Make sure that this security origin is allowed to use password manager.
842 blink::WebSecurityOrigin origin
= frame
->document().securityOrigin();
844 logger
->LogURL(Logger::STRING_SECURITY_ORIGIN
,
845 GURL(origin
.toString().utf8()));
847 if (!OriginCanAccessPasswordManager(origin
)) {
849 logger
->LogMessage(Logger::STRING_SECURITY_ORIGIN_FAILURE
);
854 // Checks whether the webpage is a redirect page or an empty page.
855 if (IsWebpageEmpty(frame
)) {
857 logger
->LogMessage(Logger::STRING_WEBPAGE_EMPTY
);
862 blink::WebVector
<blink::WebFormElement
> forms
;
863 frame
->document().forms(forms
);
865 logger
->LogNumber(Logger::STRING_NUMBER_OF_ALL_FORMS
, forms
.size());
867 std::vector
<PasswordForm
> password_forms
;
868 for (size_t i
= 0; i
< forms
.size(); ++i
) {
869 const blink::WebFormElement
& form
= forms
[i
];
870 bool is_form_visible
= IsWebNodeVisible(form
);
872 LogHTMLForm(logger
.get(), Logger::STRING_FORM_FOUND_ON_PAGE
, form
);
873 logger
->LogBoolean(Logger::STRING_FORM_IS_VISIBLE
, is_form_visible
);
876 // If requested, ignore non-rendered forms, e.g. those styled with
878 if (only_visible
&& !is_form_visible
)
881 scoped_ptr
<PasswordForm
> password_form(CreatePasswordForm(form
, nullptr));
882 if (password_form
.get()) {
884 logger
->LogPasswordForm(Logger::STRING_FORM_IS_PASSWORD
,
887 password_forms
.push_back(*password_form
);
891 if (password_forms
.empty() && !only_visible
) {
892 // We need to send the PasswordFormsRendered message regardless of whether
893 // there are any forms visible, as this is also the code path that triggers
894 // showing the infobar.
899 Send(new AutofillHostMsg_PasswordFormsRendered(routing_id(),
903 Send(new AutofillHostMsg_PasswordFormsParsed(routing_id(), password_forms
));
907 bool PasswordAutofillAgent::OnMessageReceived(const IPC::Message
& message
) {
909 IPC_BEGIN_MESSAGE_MAP(PasswordAutofillAgent
, message
)
910 IPC_MESSAGE_HANDLER(AutofillMsg_FillPasswordForm
, OnFillPasswordForm
)
911 IPC_MESSAGE_HANDLER(AutofillMsg_SetLoggingState
, OnSetLoggingState
)
912 IPC_MESSAGE_UNHANDLED(handled
= false)
913 IPC_END_MESSAGE_MAP()
917 void PasswordAutofillAgent::DidFinishDocumentLoad() {
918 // The |frame| contents have been parsed, but not yet rendered. Let the
919 // PasswordManager know that forms are loaded, even though we can't yet tell
920 // whether they're visible.
921 SendPasswordForms(false);
924 void PasswordAutofillAgent::DidFinishLoad() {
925 // The |frame| contents have been rendered. Let the PasswordManager know
926 // which of the loaded frames are actually visible to the user. This also
927 // triggers the "Save password?" infobar if the user just submitted a password
929 SendPasswordForms(true);
932 void PasswordAutofillAgent::FrameWillClose() {
936 void PasswordAutofillAgent::DidCommitProvisionalLoad(bool is_new_navigation
) {
937 blink::WebFrame
* frame
= render_frame()->GetWebFrame();
938 // TODO(dvadym): check if we need to check if it is main frame navigation
939 // http://crbug.com/443155
941 return; // Not a top-level navigation.
943 content::DocumentState
* document_state
=
944 content::DocumentState::FromDataSource(frame
->dataSource());
945 content::NavigationState
* navigation_state
=
946 document_state
->navigation_state();
947 if (navigation_state
->was_within_same_page() && provisionally_saved_form_
) {
948 Send(new AutofillHostMsg_InPageNavigation(routing_id(),
949 *provisionally_saved_form_
));
950 provisionally_saved_form_
.reset();
954 void PasswordAutofillAgent::DidStartLoading() {
955 did_stop_loading_
= false;
956 if (usernames_usage_
!= NOTHING_TO_AUTOFILL
) {
957 UMA_HISTOGRAM_ENUMERATION("PasswordManager.OtherPossibleUsernamesUsage",
958 usernames_usage_
, OTHER_POSSIBLE_USERNAMES_MAX
);
959 usernames_usage_
= NOTHING_TO_AUTOFILL
;
963 void PasswordAutofillAgent::DidStopLoading() {
964 did_stop_loading_
= true;
967 void PasswordAutofillAgent::FrameDetached(blink::WebFrame
* frame
) {
968 if (frame
== render_frame()->GetWebFrame())
972 void PasswordAutofillAgent::WillSendSubmitEvent(
973 const blink::WebFormElement
& form
) {
974 // Forms submitted via XHR are not seen by WillSubmitForm if the default
975 // onsubmit handler is overridden. Such submission first gets detected in
976 // DidStartProvisionalLoad, which no longer knows about the particular form,
977 // and uses the candidate stored in |provisionally_saved_form_|.
979 // User-typed password will get stored to |provisionally_saved_form_| in
980 // TextDidChangeInTextField. Autofilled or JavaScript-copied passwords need to
983 // Only non-empty passwords are saved here. Empty passwords were likely
984 // cleared by some scripts (http://crbug.com/28910, http://crbug.com/391693).
985 // Had the user cleared the password, |provisionally_saved_form_| would
986 // already have been updated in TextDidChangeInTextField.
987 ProvisionallySavePassword(form
, RESTRICTION_NON_EMPTY_PASSWORD
);
990 void PasswordAutofillAgent::WillSubmitForm(const blink::WebFormElement
& form
) {
991 scoped_ptr
<RendererSavePasswordProgressLogger
> logger
;
992 if (logging_state_active_
) {
993 logger
.reset(new RendererSavePasswordProgressLogger(this, routing_id()));
994 logger
->LogMessage(Logger::STRING_WILL_SUBMIT_FORM_METHOD
);
995 LogHTMLForm(logger
.get(), Logger::STRING_HTML_FORM_FOR_SUBMIT
, form
);
998 scoped_ptr
<PasswordForm
> submitted_form
= CreatePasswordForm(form
, nullptr);
1000 // If there is a provisionally saved password, copy over the previous
1001 // password value so we get the user's typed password, not the value that
1002 // may have been transformed for submit.
1003 // TODO(gcasto): Do we need to have this action equality check? Is it trying
1004 // to prevent accidentally copying over passwords from a different form?
1005 if (submitted_form
) {
1007 logger
->LogPasswordForm(Logger::STRING_CREATED_PASSWORD_FORM
,
1010 if (provisionally_saved_form_
&&
1011 submitted_form
->action
== provisionally_saved_form_
->action
) {
1013 logger
->LogMessage(Logger::STRING_SUBMITTED_PASSWORD_REPLACED
);
1014 submitted_form
->password_value
=
1015 provisionally_saved_form_
->password_value
;
1016 submitted_form
->new_password_value
=
1017 provisionally_saved_form_
->new_password_value
;
1018 submitted_form
->username_value
=
1019 provisionally_saved_form_
->username_value
;
1022 // Some observers depend on sending this information now instead of when
1023 // the frame starts loading. If there are redirects that cause a new
1024 // RenderView to be instantiated (such as redirects to the WebStore)
1025 // we will never get to finish the load.
1026 Send(new AutofillHostMsg_PasswordFormSubmitted(routing_id(),
1028 provisionally_saved_form_
.reset();
1029 } else if (logger
) {
1030 logger
->LogMessage(Logger::STRING_FORM_IS_NOT_PASSWORD
);
1034 void PasswordAutofillAgent::LegacyDidStartProvisionalLoad(
1035 blink::WebLocalFrame
* navigated_frame
) {
1036 scoped_ptr
<RendererSavePasswordProgressLogger
> logger
;
1037 if (logging_state_active_
) {
1038 logger
.reset(new RendererSavePasswordProgressLogger(this, routing_id()));
1039 logger
->LogMessage(Logger::STRING_DID_START_PROVISIONAL_LOAD_METHOD
);
1042 if (navigated_frame
->parent()) {
1044 logger
->LogMessage(Logger::STRING_FRAME_NOT_MAIN_FRAME
);
1048 // Bug fix for crbug.com/368690. isProcessingUserGesture() is false when
1049 // the user is performing actions outside the page (e.g. typed url,
1050 // history navigation). We don't want to trigger saving in these cases.
1051 content::DocumentState
* document_state
=
1052 content::DocumentState::FromDataSource(
1053 navigated_frame
->provisionalDataSource());
1054 content::NavigationState
* navigation_state
=
1055 document_state
->navigation_state();
1056 if (ui::PageTransitionIsWebTriggerable(navigation_state
->transition_type()) &&
1057 !blink::WebUserGestureIndicator::isProcessingUserGesture()) {
1058 // If onsubmit has been called, try and save that form.
1059 if (provisionally_saved_form_
) {
1061 logger
->LogPasswordForm(
1062 Logger::STRING_PROVISIONALLY_SAVED_FORM_FOR_FRAME
,
1063 *provisionally_saved_form_
);
1065 Send(new AutofillHostMsg_PasswordFormSubmitted(
1066 routing_id(), *provisionally_saved_form_
));
1067 provisionally_saved_form_
.reset();
1069 // Loop through the forms on the page looking for one that has been
1070 // filled out. If one exists, try and save the credentials.
1071 blink::WebVector
<blink::WebFormElement
> forms
;
1072 render_frame()->GetWebFrame()->document().forms(forms
);
1074 bool password_forms_found
= false;
1075 for (size_t i
= 0; i
< forms
.size(); ++i
) {
1076 blink::WebFormElement form_element
= forms
[i
];
1078 LogHTMLForm(logger
.get(), Logger::STRING_FORM_FOUND_ON_PAGE
,
1081 scoped_ptr
<PasswordForm
> password_form(
1082 CreatePasswordForm(form_element
, &user_modified_elements_
));
1083 if (password_form
.get() && !password_form
->username_value
.empty() &&
1084 FormContainsNonDefaultPasswordValue(*password_form
, form_element
)) {
1085 password_forms_found
= true;
1087 logger
->LogPasswordForm(Logger::STRING_PASSWORD_FORM_FOUND_ON_PAGE
,
1090 Send(new AutofillHostMsg_PasswordFormSubmitted(routing_id(),
1094 if (!password_forms_found
&& logger
)
1095 logger
->LogMessage(Logger::STRING_PASSWORD_FORM_NOT_FOUND_ON_PAGE
);
1099 // This is a new navigation, so require a new user gesture before filling in
1101 gatekeeper_
.Reset();
1104 void PasswordAutofillAgent::OnFillPasswordForm(
1106 const PasswordFormFillData
& form_data
) {
1107 if (usernames_usage_
== NOTHING_TO_AUTOFILL
) {
1108 if (form_data
.other_possible_usernames
.size())
1109 usernames_usage_
= OTHER_POSSIBLE_USERNAMES_PRESENT
;
1110 else if (usernames_usage_
== NOTHING_TO_AUTOFILL
)
1111 usernames_usage_
= OTHER_POSSIBLE_USERNAMES_ABSENT
;
1114 FormElementsList forms
;
1115 // We own the FormElements* in forms.
1116 FindFormElements(render_frame(), form_data
, &forms
);
1117 FormElementsList::iterator iter
;
1118 for (iter
= forms
.begin(); iter
!= forms
.end(); ++iter
) {
1119 scoped_ptr
<FormElements
> form_elements(*iter
);
1121 // Attach autocomplete listener to enable selecting alternate logins.
1122 blink::WebInputElement username_element
, password_element
;
1124 // Check whether the password form has a username input field.
1125 bool form_contains_username_field
= FillDataContainsUsername(form_data
);
1126 if (form_contains_username_field
) {
1128 form_elements
->input_elements
[form_data
.username_field
.name
];
1131 // No password field, bail out.
1132 if (form_data
.password_field
.name
.empty())
1135 // We might have already filled this form if there are two <form> elements
1136 // with identical markup.
1137 if (login_to_password_info_
.find(username_element
) !=
1138 login_to_password_info_
.end())
1141 // Get pointer to password element. (We currently only support single
1144 form_elements
->input_elements
[form_data
.password_field
.name
];
1146 // If wait_for_username is true, we don't want to initially fill the form
1147 // until the user types in a valid username.
1148 if (!form_data
.wait_for_username
&&
1149 FillFormOnPasswordReceived(
1153 base::Bind(&PasswordValueGatekeeper::RegisterElement
,
1154 base::Unretained(&gatekeeper_
)))) {
1155 usernames_usage_
= OTHER_POSSIBLE_USERNAME_SELECTED
;
1158 PasswordInfo password_info
;
1159 password_info
.fill_data
= form_data
;
1160 password_info
.password_field
= password_element
;
1161 login_to_password_info_
[username_element
] = password_info
;
1162 password_to_username_
[password_element
] = username_element
;
1163 login_to_password_info_key_
[username_element
] = key
;
1167 void PasswordAutofillAgent::OnSetLoggingState(bool active
) {
1168 logging_state_active_
= active
;
1171 ////////////////////////////////////////////////////////////////////////////////
1172 // PasswordAutofillAgent, private:
1174 PasswordAutofillAgent::PasswordInfo::PasswordInfo()
1175 : backspace_pressed_last(false), password_was_edited_last(false) {
1178 bool PasswordAutofillAgent::ShowSuggestionPopup(
1179 const PasswordFormFillData
& fill_data
,
1180 const blink::WebInputElement
& user_input
,
1182 bool show_on_password_field
) {
1183 DCHECK(!user_input
.isNull());
1184 blink::WebFrame
* frame
= user_input
.document().frame();
1188 blink::WebView
* webview
= frame
->view();
1193 FormFieldData field
;
1194 FindFormAndFieldForFormControlElement(
1195 user_input
, &form
, &field
, REQUIRE_NONE
);
1197 blink::WebInputElement selected_element
= user_input
;
1198 if (show_on_password_field
&& !selected_element
.isPasswordField()) {
1199 LoginToPasswordInfoMap::const_iterator iter
=
1200 login_to_password_info_
.find(user_input
);
1201 DCHECK(iter
!= login_to_password_info_
.end());
1202 selected_element
= iter
->second
.password_field
;
1204 gfx::Rect
bounding_box(selected_element
.boundsInViewportSpace());
1206 blink::WebInputElement username
;
1207 if (!show_on_password_field
|| !user_input
.isPasswordField()) {
1208 username
= user_input
;
1210 LoginToPasswordInfoKeyMap::const_iterator key_it
=
1211 login_to_password_info_key_
.find(username
);
1212 DCHECK(key_it
!= login_to_password_info_key_
.end());
1215 render_frame()->GetRenderView()->GetWebView()->pageScaleFactor();
1216 gfx::RectF
bounding_box_scaled(bounding_box
.x() * scale
,
1217 bounding_box
.y() * scale
,
1218 bounding_box
.width() * scale
,
1219 bounding_box
.height() * scale
);
1222 options
|= SHOW_ALL
;
1223 if (show_on_password_field
)
1224 options
|= IS_PASSWORD_FIELD
;
1225 base::string16
username_string(
1226 username
.isNull() ? base::string16()
1227 : static_cast<base::string16
>(user_input
.value()));
1228 Send(new AutofillHostMsg_ShowPasswordSuggestions(
1229 routing_id(), key_it
->second
, field
.text_direction
, username_string
,
1230 options
, bounding_box_scaled
));
1232 bool suggestions_present
= false;
1233 if (GetSuggestionsStats(fill_data
, username_string
, show_all
,
1234 &suggestions_present
)) {
1235 usernames_usage_
= OTHER_POSSIBLE_USERNAME_SHOWN
;
1237 return suggestions_present
;
1240 void PasswordAutofillAgent::PerformInlineAutocomplete(
1241 const blink::WebInputElement
& username_input
,
1242 const blink::WebInputElement
& password_input
,
1243 const PasswordFormFillData
& fill_data
) {
1244 DCHECK(!fill_data
.wait_for_username
);
1246 // We need non-const versions of the username and password inputs.
1247 blink::WebInputElement username
= username_input
;
1248 blink::WebInputElement password
= password_input
;
1250 // Don't inline autocomplete if the caret is not at the end.
1251 // TODO(jcivelli): is there a better way to test the caret location?
1252 if (username
.selectionStart() != username
.selectionEnd() ||
1253 username
.selectionEnd() != static_cast<int>(username
.value().length())) {
1257 // Show the popup with the list of available usernames.
1258 ShowSuggestionPopup(fill_data
, username
, false, false);
1260 #if !defined(OS_ANDROID)
1261 // Fill the user and password field with the most relevant match. Android
1262 // only fills in the fields after the user clicks on the suggestion popup.
1263 if (FillUserNameAndPassword(
1267 false /* exact_username_match */,
1268 true /* set selection */,
1269 base::Bind(&PasswordValueGatekeeper::RegisterElement
,
1270 base::Unretained(&gatekeeper_
)))) {
1271 usernames_usage_
= OTHER_POSSIBLE_USERNAME_SELECTED
;
1276 void PasswordAutofillAgent::FrameClosing() {
1277 for (auto const& iter
: login_to_password_info_
) {
1278 login_to_password_info_key_
.erase(iter
.first
);
1279 password_to_username_
.erase(iter
.second
.password_field
);
1281 login_to_password_info_
.clear();
1282 provisionally_saved_form_
.reset();
1283 user_modified_elements_
.clear();
1286 bool PasswordAutofillAgent::FindLoginInfo(const blink::WebNode
& node
,
1287 blink::WebInputElement
* found_input
,
1288 PasswordInfo
** found_password
) {
1289 if (!node
.isElementNode())
1292 blink::WebElement element
= node
.toConst
<blink::WebElement
>();
1293 if (!element
.hasHTMLTagName("input"))
1296 *found_input
= element
.to
<blink::WebInputElement
>();
1297 const blink::WebInputElement
* username_element
; // ignored
1298 return FindPasswordInfoForElement(*found_input
, &username_element
,
1302 void PasswordAutofillAgent::ClearPreview(
1303 blink::WebInputElement
* username
,
1304 blink::WebInputElement
* password
) {
1305 if (!username
->suggestedValue().isEmpty()) {
1306 username
->setSuggestedValue(blink::WebString());
1307 username
->setAutofilled(was_username_autofilled_
);
1308 username
->setSelectionRange(username_selection_start_
,
1309 username
->value().length());
1311 if (!password
->suggestedValue().isEmpty()) {
1312 password
->setSuggestedValue(blink::WebString());
1313 password
->setAutofilled(was_password_autofilled_
);
1317 void PasswordAutofillAgent::ProvisionallySavePassword(
1318 const blink::WebFormElement
& form
,
1319 ProvisionallySaveRestriction restriction
) {
1320 scoped_ptr
<PasswordForm
> password_form(
1321 CreatePasswordForm(form
, &user_modified_elements_
));
1322 if (!password_form
|| (restriction
== RESTRICTION_NON_EMPTY_PASSWORD
&&
1323 password_form
->password_value
.empty() &&
1324 password_form
->new_password_value
.empty())) {
1327 provisionally_saved_form_
= password_form
.Pass();
1330 // LegacyPasswordAutofillAgent -------------------------------------------------
1332 PasswordAutofillAgent::LegacyPasswordAutofillAgent::LegacyPasswordAutofillAgent(
1333 content::RenderView
* render_view
,
1334 PasswordAutofillAgent
* agent
)
1335 : content::RenderViewObserver(render_view
), agent_(agent
) {
1338 PasswordAutofillAgent::LegacyPasswordAutofillAgent::
1339 ~LegacyPasswordAutofillAgent() {
1342 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::OnDestruct() {
1343 // No op. Do not delete |this|.
1346 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::DidStartLoading() {
1347 agent_
->DidStartLoading();
1350 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::DidStopLoading() {
1351 agent_
->DidStopLoading();
1354 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::
1355 DidStartProvisionalLoad(blink::WebLocalFrame
* navigated_frame
) {
1356 agent_
->LegacyDidStartProvisionalLoad(navigated_frame
);
1359 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::FrameDetached(
1360 blink::WebFrame
* frame
) {
1361 agent_
->FrameDetached(frame
);
1364 } // namespace autofill