Index: components/autofill/content/renderer/password_autofill_agent.cc |
diff --git a/components/autofill/content/renderer/password_autofill_agent.cc b/components/autofill/content/renderer/password_autofill_agent.cc |
index 629627dc4205c6821b3a4637909608aace03a82c..2b9c9d008545932a39d35cbb562918c13ba9e4af 100644 |
--- a/components/autofill/content/renderer/password_autofill_agent.cc |
+++ b/components/autofill/content/renderer/password_autofill_agent.cc |
@@ -8,6 +8,7 @@ |
#include "base/memory/scoped_ptr.h" |
#include "base/message_loop/message_loop.h" |
#include "base/metrics/histogram.h" |
+#include "base/stl_util.h" |
#include "base/strings/utf_string_conversions.h" |
#include "components/autofill/content/common/autofill_messages.h" |
#include "components/autofill/content/renderer/form_autofill_util.h" |
@@ -273,8 +274,11 @@ void PasswordAutofillAgent::PasswordValueGatekeeper::Reset() { |
void PasswordAutofillAgent::PasswordValueGatekeeper::ShowValue( |
blink::WebInputElement* element) { |
- if (!element->isNull() && !element->suggestedValue().isNull()) |
+ if (!element->isNull() && element->value().isNull() && |
+ !element->suggestedValue().isNull()) { |
element->setValue(element->suggestedValue(), true); |
+ element->setSuggestedValue(blink::WebString()); |
+ } |
} |
bool PasswordAutofillAgent::TextFieldDidEndEditing( |
@@ -308,6 +312,18 @@ bool PasswordAutofillAgent::TextFieldDidEndEditing( |
bool PasswordAutofillAgent::TextDidChangeInTextField( |
const blink::WebInputElement& element) { |
+ // TODO(vabr): Get a mutable argument instead. http://crbug.com/397083 |
+ blink::WebInputElement mutable_element = element; // We need a non-const. |
+ |
+ if (element.isPasswordField()) { |
+ PasswordToLoginMap::iterator iter = password_to_username_.find(element); |
+ if (iter != password_to_username_.end()) { |
+ temporary_disabled_password_fill_.insert(iter->second); |
+ mutable_element.setAutofilled(false); |
+ } |
+ return false; |
+ } |
+ |
LoginToPasswordInfoMap::const_iterator iter = |
login_to_password_info_.find(element); |
if (iter == login_to_password_info_.end()) |
@@ -315,8 +331,8 @@ bool PasswordAutofillAgent::TextDidChangeInTextField( |
// The input text is being changed, so any autofilled password is now |
// outdated. |
- blink::WebInputElement username = element; // We need a non-const. |
- username.setAutofilled(false); |
+ mutable_element.setAutofilled(false); |
+ temporary_disabled_password_fill_.erase(element); |
blink::WebInputElement password = iter->second.password_field; |
if (password.isAutofilled()) { |
@@ -337,7 +353,7 @@ bool PasswordAutofillAgent::TextDidChangeInTextField( |
// But refresh the popup. Note, since this is ours, return true to signal |
// no further processing is required. |
if (iter->second.backspace_pressed_last) { |
- ShowSuggestionPopup(iter->second.fill_data, username, false); |
+ ShowSuggestionPopup(iter->second.fill_data, element, false); |
return true; |
} |
@@ -790,6 +806,7 @@ void PasswordAutofillAgent::OnFillPasswordForm( |
password_info.fill_data = form_data; |
password_info.password_field = password_element; |
login_to_password_info_[username_element] = password_info; |
+ password_to_username_[password_element] = username_element; |
FormData form; |
FormFieldData field; |
@@ -919,6 +936,8 @@ bool PasswordAutofillAgent::FillUserNameAndPassword( |
const PasswordFormFillData& fill_data, |
bool exact_username_match, |
bool set_selection) { |
+ if (ContainsKey(temporary_disabled_password_fill_, *username_element)) |
engedy
2014/07/29 14:43:54
As discussed offline, many of these helper functio
vabr (Chromium)
2014/07/29 15:12:30
Done: the knowledge of this particular bit removed
|
+ return false; |
base::string16 current_username = username_element->value(); |
// username and password will contain the match found if any. |
base::string16 username; |
@@ -1034,10 +1053,13 @@ void PasswordAutofillAgent::PerformInlineAutocomplete( |
void PasswordAutofillAgent::FrameClosing(const blink::WebFrame* frame) { |
for (LoginToPasswordInfoMap::iterator iter = login_to_password_info_.begin(); |
iter != login_to_password_info_.end();) { |
- if (iter->first.document().frame() == frame) |
+ if (iter->first.document().frame() == frame) { |
+ password_to_username_.erase(iter->second.password_field); |
+ temporary_disabled_password_fill_.erase(iter->first); |
login_to_password_info_.erase(iter++); |
- else |
+ } else { |
++iter; |
+ } |
} |
for (FrameToPasswordFormMap::iterator iter = |
provisionally_saved_forms_.begin(); |