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

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

Issue 1161023008: Suggest to fill password change forms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tiny fix Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/autofill/content/renderer/password_autofill_agent.h" 5 #include "components/autofill/content/renderer/password_autofill_agent.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 } 715 }
716 716
717 void PasswordAutofillAgent::UpdateStateForTextChange( 717 void PasswordAutofillAgent::UpdateStateForTextChange(
718 const blink::WebInputElement& element) { 718 const blink::WebInputElement& element) {
719 // TODO(vabr): Get a mutable argument instead. http://crbug.com/397083 719 // TODO(vabr): Get a mutable argument instead. http://crbug.com/397083
720 blink::WebInputElement mutable_element = element; // We need a non-const. 720 blink::WebInputElement mutable_element = element; // We need a non-const.
721 721
722 if (element.isTextField()) 722 if (element.isTextField())
723 nonscript_modified_values_[element] = element.value(); 723 nonscript_modified_values_[element] = element.value();
724 724
725 LoginToPasswordInfoMap::iterator password_info_iter =
726 login_to_password_info_.find(element);
727 if (password_info_iter != login_to_password_info_.end()) {
728 password_info_iter->second.username_was_edited = true;
729 }
730
725 DCHECK_EQ(element.document().frame(), render_frame()->GetWebFrame()); 731 DCHECK_EQ(element.document().frame(), render_frame()->GetWebFrame());
726 732
727 if (element.isPasswordField()) { 733 if (element.isPasswordField()) {
728 // Some login forms have event handlers that put a hash of the password into 734 // Some login forms have event handlers that put a hash of the password into
729 // a hidden field and then clear the password (http://crbug.com/28910, 735 // a hidden field and then clear the password (http://crbug.com/28910,
730 // http://crbug.com/391693). This method gets called before any of those 736 // http://crbug.com/391693). This method gets called before any of those
731 // handlers run, so save away a copy of the password in case it gets lost. 737 // handlers run, so save away a copy of the password in case it gets lost.
732 // To honor the user having explicitly cleared the password, even an empty 738 // To honor the user having explicitly cleared the password, even an empty
733 // password will be saved here. 739 // password will be saved here.
734 ProvisionallySavePassword(element.form(), RESTRICTION_NONE); 740 ProvisionallySavePassword(element.form(), RESTRICTION_NONE);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 if (!IsElementAutocompletable(element) || 857 if (!IsElementAutocompletable(element) ||
852 !IsElementAutocompletable(password_info->password_field)) 858 !IsElementAutocompletable(password_info->password_field))
853 return true; 859 return true;
854 860
855 bool username_is_available = 861 bool username_is_available =
856 !username_element->isNull() && IsElementEditable(*username_element); 862 !username_element->isNull() && IsElementEditable(*username_element);
857 // If the element is a password field, a popup should only be shown if there 863 // If the element is a password field, a popup should only be shown if there
858 // is no username or the corresponding username element is not editable since 864 // is no username or the corresponding username element is not editable since
859 // it is only in that case that the username element does not have a 865 // it is only in that case that the username element does not have a
860 // suggestions popup. 866 // suggestions popup.
861 if (element.isPasswordField() && username_is_available) 867 if (element.isPasswordField() && username_is_available &&
868 (!password_info->fill_data.is_possible_change_password_form ||
869 password_info->username_was_edited))
862 return true; 870 return true;
863 871
864 // Chrome should never show more than one account for a password element since 872 // Chrome should never show more than one account for a password element since
865 // this implies that the username element cannot be modified. Thus even if 873 // this implies that the username element cannot be modified. Thus even if
866 // |show_all| is true, check if the element in question is a password element 874 // |show_all| is true, check if the element in question is a password element
867 // for the call to ShowSuggestionPopup. 875 // for the call to ShowSuggestionPopup.
868 return ShowSuggestionPopup( 876 return ShowSuggestionPopup(
869 password_info->fill_data, 877 password_info->fill_data,
870 username_element->isNull() ? element : *username_element, 878 username_element->isNull() ? element : *username_element,
871 show_all && !element.isPasswordField(), element.isPasswordField()); 879 show_all && !element.isPasswordField(), element.isPasswordField());
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 password_form.reset(new PasswordForm()); 1288 password_form.reset(new PasswordForm());
1281 1289
1282 Send(new AutofillHostMsg_FocusedPasswordFormFound( 1290 Send(new AutofillHostMsg_FocusedPasswordFormFound(
1283 routing_id(), *password_form)); 1291 routing_id(), *password_form));
1284 } 1292 }
1285 1293
1286 //////////////////////////////////////////////////////////////////////////////// 1294 ////////////////////////////////////////////////////////////////////////////////
1287 // PasswordAutofillAgent, private: 1295 // PasswordAutofillAgent, private:
1288 1296
1289 PasswordAutofillAgent::PasswordInfo::PasswordInfo() 1297 PasswordAutofillAgent::PasswordInfo::PasswordInfo()
1290 : backspace_pressed_last(false), password_was_edited_last(false) { 1298 : backspace_pressed_last(false),
1299 password_was_edited_last(false),
1300 username_was_edited(false) {
1291 } 1301 }
1292 1302
1293 bool PasswordAutofillAgent::ShowSuggestionPopup( 1303 bool PasswordAutofillAgent::ShowSuggestionPopup(
1294 const PasswordFormFillData& fill_data, 1304 const PasswordFormFillData& fill_data,
1295 const blink::WebInputElement& user_input, 1305 const blink::WebInputElement& user_input,
1296 bool show_all, 1306 bool show_all,
1297 bool show_on_password_field) { 1307 bool show_on_password_field) {
1298 DCHECK(!user_input.isNull()); 1308 DCHECK(!user_input.isNull());
1299 blink::WebFrame* frame = user_input.document().frame(); 1309 blink::WebFrame* frame = user_input.document().frame();
1300 if (!frame) 1310 if (!frame)
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::DidStopLoading() { 1482 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::DidStopLoading() {
1473 agent_->DidStopLoading(); 1483 agent_->DidStopLoading();
1474 } 1484 }
1475 1485
1476 void PasswordAutofillAgent::LegacyPasswordAutofillAgent:: 1486 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::
1477 DidStartProvisionalLoad(blink::WebLocalFrame* navigated_frame) { 1487 DidStartProvisionalLoad(blink::WebLocalFrame* navigated_frame) {
1478 agent_->LegacyDidStartProvisionalLoad(navigated_frame); 1488 agent_->LegacyDidStartProvisionalLoad(navigated_frame);
1479 } 1489 }
1480 1490
1481 } // namespace autofill 1491 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698