diff options
author | mihaip@chromium.org <mihaip@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-30 22:00:51 +0000 |
---|---|---|
committer | mihaip@chromium.org <mihaip@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-30 22:00:51 +0000 |
commit | ace62514423ffe9c55eeb3c5b8069e87d1a30cc2 (patch) | |
tree | 548d6ed3b6976c4302138806ea26fc8153d19dea /chrome/renderer | |
parent | 4699f1faf715bc2714e0d6b0ca8b939b6cefcef7 (diff) | |
download | chromium_src-ace62514423ffe9c55eeb3c5b8069e87d1a30cc2.zip chromium_src-ace62514423ffe9c55eeb3c5b8069e87d1a30cc2.tar.gz chromium_src-ace62514423ffe9c55eeb3c5b8069e87d1a30cc2.tar.bz2 |
Revert 129946 - Enable password generation only if sync for passwords is enabled.
BUG=114092
TEST=Ran corresponding unit and browser tests.
Review URL: https://chromiumcodereview.appspot.com/9834082
TBR=gcasto@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9956041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129963 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
3 files changed, 25 insertions, 56 deletions
diff --git a/chrome/renderer/autofill/password_generation_manager.cc b/chrome/renderer/autofill/password_generation_manager.cc index 8f47947..a5b7dc3 100644 --- a/chrome/renderer/autofill/password_generation_manager.cc +++ b/chrome/renderer/autofill/password_generation_manager.cc @@ -19,15 +19,10 @@ namespace autofill { PasswordGenerationManager::PasswordGenerationManager( content::RenderView* render_view) - : content::RenderViewObserver(render_view), - sync_enabled_(false) {} + : content::RenderViewObserver(render_view) {} PasswordGenerationManager::~PasswordGenerationManager() {} void PasswordGenerationManager::DidFinishDocumentLoad(WebKit::WebFrame* frame) { - // We don't want to generate passwords if password sync isn't enabled. - if (!sync_enabled_) - return; - if (!ShouldAnalyzeFrame(*frame)) return; @@ -68,7 +63,7 @@ bool PasswordGenerationManager::ShouldAnalyzeFrame( DVLOG(1) << "No PasswordManager access"; return false; } - + // TODO(gcasto): Query the browser to see if password sync is enabled. return true; } @@ -76,8 +71,7 @@ void PasswordGenerationManager::FocusedNodeChanged( const WebKit::WebNode& node) { WebKit::WebInputElement input_element = node.toConst<WebKit::WebInputElement>(); - if (!input_element.isNull() && - account_creation_elements_.first == input_element) { + if (account_creation_elements_.first == input_element) { gfx::Rect rect(input_element.boundsInViewportSpace()); Send(new AutofillHostMsg_ShowPasswordGenerationPopup(routing_id(), rect)); @@ -89,8 +83,6 @@ bool PasswordGenerationManager::OnMessageReceived(const IPC::Message& message) { IPC_BEGIN_MESSAGE_MAP(PasswordGenerationManager, message) IPC_MESSAGE_HANDLER(AutofillMsg_GeneratedPasswordAccepted, OnPasswordAccepted) - IPC_MESSAGE_HANDLER(AutofillMsg_PasswordSyncEnabled, - OnPasswordSyncEnabled) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; @@ -105,8 +97,4 @@ void PasswordGenerationManager::OnPasswordAccepted(const string16& password) { } } -void PasswordGenerationManager::OnPasswordSyncEnabled(bool enabled) { - sync_enabled_ = enabled; -} - } // namespace autofill diff --git a/chrome/renderer/autofill/password_generation_manager.h b/chrome/renderer/autofill/password_generation_manager.h index a8c4bd8..a93eedd 100644 --- a/chrome/renderer/autofill/password_generation_manager.h +++ b/chrome/renderer/autofill/password_generation_manager.h @@ -38,13 +38,7 @@ class PasswordGenerationManager : public content::RenderViewObserver { virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) OVERRIDE; virtual void FocusedNodeChanged(const WebKit::WebNode& node) OVERRIDE; - // Message handlers. void OnPasswordAccepted(const string16& password); - void OnPasswordSyncEnabled(bool enabled); - - // True if password sync is enabled for the profile associated with this - // renderer. - bool sync_enabled_; std::pair<WebKit::WebInputElement, std::vector<WebKit::WebInputElement> > account_creation_elements_; diff --git a/chrome/renderer/autofill/password_generation_manager_browsertest.cc b/chrome/renderer/autofill/password_generation_manager_browsertest.cc index 1119bd4..72e612b 100644 --- a/chrome/renderer/autofill/password_generation_manager_browsertest.cc +++ b/chrome/renderer/autofill/password_generation_manager_browsertest.cc @@ -72,22 +72,14 @@ class PasswordGenerationManagerTest : public ChromeRenderViewTest { DISALLOW_COPY_AND_ASSIGN(PasswordGenerationManagerTest); }; -const char kSigninFormHTML[] = - "<FORM name = 'blah' action = 'www.random.com/'> " - " <INPUT type = 'text' id = 'username'/> " - " <INPUT type = 'password' id = 'password'/> " - " <INPUT type = 'submit' value = 'LOGIN' />" - "</FORM>"; - -const char kAccountCreationFormHTML[] = - "<FORM name = 'blah' action = 'www.random.com/'> " - " <INPUT type = 'text' id = 'username'/> " - " <INPUT type = 'password' id = 'first_password'/> " - " <INPUT type = 'password' id = 'second_password'/> " - " <INPUT type = 'submit' value = 'LOGIN' />" - "</FORM>"; TEST_F(PasswordGenerationManagerTest, DetectionTest) { + const char kSigninFormHTML[] = + "<FORM name = 'blah' action = 'www.random.com/'> " + " <INPUT type = 'text' id = 'username'/> " + " <INPUT type = 'password' id = 'password'/> " + " <INPUT type = 'submit' value = 'LOGIN' />" + "</FORM>"; LoadHTML(kSigninFormHTML); WebDocument document = GetMainFrame()->document(); @@ -97,9 +89,16 @@ TEST_F(PasswordGenerationManagerTest, DetectionTest) { WebInputElement password_element = element.to<WebInputElement>(); EXPECT_EQ(0u, generation_manager_->messages().size()); + const char kAccountCreationFormHTML[] = + "<FORM name = 'blah' action = 'www.random.com/'> " + " <INPUT type = 'text' id = 'username'/> " + " <INPUT type = 'password' id = 'first_password'/> " + " <INPUT type = 'password' id = 'second_password'/> " + " <INPUT type = 'submit' value = 'LOGIN' />" + "</FORM>"; LoadHTML(kAccountCreationFormHTML); - // We don't do anything yet because the feature is disabled. + // We don't autofill at first. document = GetMainFrame()->document(); element = document.getElementById(WebString::fromUTF8("first_password")); ASSERT_FALSE(element.isNull()); @@ -109,24 +108,8 @@ TEST_F(PasswordGenerationManagerTest, DetectionTest) { ASSERT_FALSE(element.isNull()); WebInputElement second_password_element = element.to<WebInputElement>(); EXPECT_EQ(0u, generation_manager_->messages().size()); - SetFocused(first_password_element.to<WebNode>()); - EXPECT_EQ(0u, generation_manager_->messages().size()); - - // Pretend like sync was enabled. - AutofillMsg_PasswordSyncEnabled msg(0, true); - generation_manager_->OnMessageReceived(msg); - // Now we will send a message once the first password feld is focused. - LoadHTML(kAccountCreationFormHTML); - document = GetMainFrame()->document(); - element = document.getElementById(WebString::fromUTF8("first_password")); - ASSERT_FALSE(element.isNull()); - first_password_element = element.to<WebInputElement>(); - EXPECT_EQ(0u, generation_manager_->messages().size()); - element = document.getElementById(WebString::fromUTF8("second_password")); - ASSERT_FALSE(element.isNull()); - second_password_element = element.to<WebInputElement>(); - EXPECT_EQ(0u, generation_manager_->messages().size()); + // After first element is focused, then we autofill. SetFocused(first_password_element.to<WebNode>()); EXPECT_EQ(1u, generation_manager_->messages().size()); EXPECT_EQ(AutofillHostMsg_ShowPasswordGenerationPopup::ID, @@ -134,9 +117,13 @@ TEST_F(PasswordGenerationManagerTest, DetectionTest) { } TEST_F(PasswordGenerationManagerTest, FillTest) { - // Make sure that we are enabled before loading HTML. - AutofillMsg_PasswordSyncEnabled enabled_msg(0, true); - generation_manager_->OnMessageReceived(enabled_msg); + const char kAccountCreationFormHTML[] = + "<FORM name = 'blah' action = 'www.random.com/'> " + " <INPUT type = 'text' id = 'username'/> " + " <INPUT type = 'password' id = 'first_password'/> " + " <INPUT type = 'password' id = 'second_password'/> " + " <INPUT type = 'submit' value = 'LOGIN' />" + "</FORM>"; LoadHTML(kAccountCreationFormHTML); WebDocument document = GetMainFrame()->document(); |