diff options
author | vabr@chromium.org <vabr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-19 11:47:32 +0000 |
---|---|---|
committer | vabr@chromium.org <vabr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-19 11:47:32 +0000 |
commit | f735e931163a091deac3e17fbeda3761ef60e588 (patch) | |
tree | 6d04743847a86de786130dcf0e35dcfcc55a7ede | |
parent | ae9433a62dea0be309377112e722e07cd52c0fc5 (diff) | |
download | chromium_src-f735e931163a091deac3e17fbeda3761ef60e588.zip chromium_src-f735e931163a091deac3e17fbeda3761ef60e588.tar.gz chromium_src-f735e931163a091deac3e17fbeda3761ef60e588.tar.bz2 |
Revert 238561 "Basic autofill into password value on user gestur..."
> Basic autofill into password value on user gesture only.
>
> BUG=163072
>
> Review URL: https://codereview.chromium.org/83023017
TBR=vabr@chromium.org
Review URL: https://codereview.chromium.org/203673007
git-svn-id: svn://svn.chromium.org/chrome/branches/1847/src@257935 0039d316-1c4b-4281-b951-d872f2087c98
4 files changed, 3 insertions, 135 deletions
diff --git a/chrome/browser/password_manager/password_manager_browsertest.cc b/chrome/browser/password_manager/password_manager_browsertest.cc index 1e52816..5b09806 100644 --- a/chrome/browser/password_manager/password_manager_browsertest.cc +++ b/chrome/browser/password_manager/password_manager_browsertest.cc @@ -443,11 +443,6 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, // Now navigate to a login form that has similar HTML markup. NavigateToFile("/password/password_form.html"); - // Simulate a user click to force an autofill of the form's DOM value, not - // just the suggested value. - std::string click = "document.getElementById('testform_no_name').click()"; - ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), click)); - // The form should be filled with the previously submitted username. std::string get_username = "window.domAutomationController.send(" @@ -473,7 +468,6 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, base::HistogramBase* upload_histogram = base::StatisticsRecorder::FindHistogram( "PasswordGeneration.UploadStarted"); - ASSERT_TRUE(upload_histogram); scoped_ptr<base::HistogramSamples> snapshot = upload_histogram->SnapshotSamples(); EXPECT_EQ(0, snapshot->GetCount(0 /* failure */)); diff --git a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc index 1723480..679d88f 100644 --- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc +++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc @@ -135,16 +135,6 @@ const char kWebpageWithDynamicContent[] = " </body>" "</html>"; -const char kJavaScriptClick[] = - "var event = new MouseEvent('click', {" - " 'view': window," - " 'bubbles': true," - " 'cancelable': true" - "});" - "var form = document.getElementById('myform1');" - "form.dispatchEvent(event);" - "console.log('clicked!');"; - const char kOnChangeDetectionScript[] = "<script>" " usernameOnchangeCalled = false;" @@ -329,20 +319,15 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest { bool username_autofilled, const WebInputElement& password_element, const std::string& password, - bool password_autofilled, - bool checkSuggestedValue = true) { + bool password_autofilled) { EXPECT_EQ(username, static_cast<std::string>(username_element.value().utf8())); EXPECT_EQ(username_autofilled, username_element.isAutofilled()); EXPECT_EQ(password, - static_cast<std::string>( - checkSuggestedValue ? password_element.suggestedValue().utf8() - : password_element.value().utf8())); + static_cast<std::string>(password_element.value().utf8())); EXPECT_EQ(password_autofilled, password_element.isAutofilled()); } - // Checks the DOM-accessible value of the username element and the - // *suggested* value of the password element. void CheckTextFieldsState(const std::string& username, bool username_autofilled, const std::string& password, @@ -352,21 +337,6 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest { password, password_autofilled); } - // Checks the DOM-accessible value of the username element and the - // DOM-accessible value of the password element. - void CheckTextFieldsDOMState(const std::string& username, - bool username_autofilled, - const std::string& password, - bool password_autofilled) { - CheckTextFieldsStateForElements(username_element_, - username, - username_autofilled, - password_element_, - password, - password_autofilled, - false); - } - void CheckUsernameSelection(int start, int end) { EXPECT_EQ(start, username_element_.selectionStart()); EXPECT_EQ(end, username_element_.selectionEnd()); @@ -834,34 +804,6 @@ TEST_F(PasswordAutofillAgentTest, IframeNoFillTest) { password_input, kAlicePassword, true); } -// Tests that a password will only be filled as a suggested and will not be -// accessible by the DOM until a user gesture has occurred. -TEST_F(PasswordAutofillAgentTest, GestureRequiredTest) { - // Trigger the initial autocomplete. - SimulateOnFillPasswordForm(fill_data_); - - // The username and password should have been autocompleted. - CheckTextFieldsState(kAliceUsername, true, kAlicePassword, true); - - // However, it should only have completed with the suggested value, as tested - // above, and it should not have completed into the DOM accessible value for - // the password field. - CheckTextFieldsDOMState(kAliceUsername, true, std::string(), true); - - // Simulate a user click so that the password field's real value is filled. - SimulateElementClick(kUsernameName); - CheckTextFieldsDOMState(kAliceUsername, true, kAlicePassword, true); -} - -// Verfies that a DOM-activated UI event will not cause an autofill. -TEST_F(PasswordAutofillAgentTest, NoDOMActivationTest) { - // Trigger the initial autocomplete. - SimulateOnFillPasswordForm(fill_data_); - - ExecuteJavaScript(kJavaScriptClick); - CheckTextFieldsDOMState(kAliceUsername, true, "", true); -} - // Regression test for http://crbug.com/326679 TEST_F(PasswordAutofillAgentTest, SelectUsernameWithUsernameAutofillOff) { // Simulate the browser sending back the login info. diff --git a/components/autofill/content/renderer/password_autofill_agent.cc b/components/autofill/content/renderer/password_autofill_agent.cc index 84f6313..566ee1e 100644 --- a/components/autofill/content/renderer/password_autofill_agent.cc +++ b/components/autofill/content/renderer/password_autofill_agent.cc @@ -218,15 +218,10 @@ PasswordAutofillAgent::PasswordAutofillAgent(content::RenderView* render_view) : content::RenderViewObserver(render_view), usernames_usage_(NOTHING_TO_AUTOFILL), web_view_(render_view->GetWebView()), - gesture_handler_(new AutofillWebUserGestureHandler(this)), - user_gesture_occurred_(false), weak_ptr_factory_(this) { - blink::WebUserGestureIndicator::setHandler(gesture_handler_.get()); } PasswordAutofillAgent::~PasswordAutofillAgent() { - DCHECK(gesture_handler_.get()); - blink::WebUserGestureIndicator::setHandler(NULL); } bool PasswordAutofillAgent::TextFieldDidEndEditing( @@ -552,11 +547,6 @@ void PasswordAutofillAgent::DidStartProvisionalLoad(blink::WebFrame* frame) { } // Clear the whole map during main frame navigation. provisionally_saved_forms_.clear(); - - // We are navigating, se we need to wait for a new user gesture before - // filling in passwords. - user_gesture_occurred_ = false; - gesture_handler_->clearElements(); } } @@ -791,16 +781,7 @@ bool PasswordAutofillAgent::FillUserNameAndPassword( return false; } - // If a user gesture has not occurred, we setup a handler to listen for the - // next user gesture, at which point we then fill in the password. This is to - // make sure that we do not fill in the DOM with a password until we believe - // the user is intentionally interacting with the page. - if (!user_gesture_occurred_) { - gesture_handler_->addElement(*password_element); - password_element->setSuggestedValue(password); - } else { - password_element->setValue(password, true); - } + password_element->setValue(password, true); // Note: Don't call SetElementAutofilled() here, as that dispatches an // onChange event in JavaScript, which is not appropriate for the password // element if a user gesture has not yet occured. @@ -876,23 +857,4 @@ bool PasswordAutofillAgent::FindLoginInfo(const blink::WebNode& node, return true; } -void PasswordAutofillAgent::AutofillWebUserGestureHandler::onGesture() { - agent_->set_user_gesture_occurred(true); - - std::vector<blink::WebInputElement>::iterator iter; - for (iter = elements_.begin(); iter != elements_.end(); ++iter) { - if (!iter->isNull() && !iter->suggestedValue().isNull()) - iter->setValue(iter->suggestedValue(), true); - } - - elements_.clear(); -} - -PasswordAutofillAgent::AutofillWebUserGestureHandler:: - AutofillWebUserGestureHandler(PasswordAutofillAgent* agent) - : agent_(agent) {} - -PasswordAutofillAgent::AutofillWebUserGestureHandler:: - ~AutofillWebUserGestureHandler() {} - } // namespace autofill diff --git a/components/autofill/content/renderer/password_autofill_agent.h b/components/autofill/content/renderer/password_autofill_agent.h index 72ad5b0..503621b 100644 --- a/components/autofill/content/renderer/password_autofill_agent.h +++ b/components/autofill/content/renderer/password_autofill_agent.h @@ -9,12 +9,10 @@ #include <vector> #include "base/memory/linked_ptr.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "components/autofill/core/common/password_form_fill_data.h" #include "content/public/renderer/render_view_observer.h" #include "third_party/WebKit/public/web/WebInputElement.h" -#include "third_party/WebKit/public/web/WebUserGestureIndicator.h" namespace blink { class WebInputElement; @@ -81,26 +79,6 @@ class PasswordAutofillAgent : public content::RenderViewObserver { typedef std::map<blink::WebFrame*, linked_ptr<PasswordForm> > FrameToPasswordFormMap; - class AutofillWebUserGestureHandler : public blink::WebUserGestureHandler { - public: - AutofillWebUserGestureHandler(PasswordAutofillAgent* agent); - virtual ~AutofillWebUserGestureHandler(); - - void addElement(const blink::WebInputElement& element) { - elements_.push_back(element); - } - - void clearElements() { - elements_.clear(); - } - - virtual void onGesture(); - - private: - PasswordAutofillAgent* agent_; - std::vector<blink::WebInputElement> elements_; - }; - // RenderViewObserver: virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; virtual void DidStartProvisionalLoad(blink::WebFrame* frame) OVERRIDE; @@ -166,10 +144,6 @@ class PasswordAutofillAgent : public content::RenderViewObserver { blink::WebFrame* CurrentOrChildFrameWithSavedForms( const blink::WebFrame* current_frame); - void set_user_gesture_occurred(bool occurred) { - user_gesture_occurred_ = occurred; - } - // The logins we have filled so far with their associated info. LoginToPasswordInfoMap login_to_password_info_; @@ -183,10 +157,6 @@ class PasswordAutofillAgent : public content::RenderViewObserver { // but the submit may still fail (i.e. doesn't pass JavaScript validation). FrameToPasswordFormMap provisionally_saved_forms_; - scoped_ptr<AutofillWebUserGestureHandler> gesture_handler_; - - bool user_gesture_occurred_; - base::WeakPtrFactory<PasswordAutofillAgent> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent); |