diff options
author | tapted <tapted@chromium.org> | 2014-10-01 00:01:47 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-01 07:02:01 +0000 |
commit | dbd11635d503ba6bfe229cdeab96942bd0aea5d7 (patch) | |
tree | 7cd52e06d64b341aedfe1c1998ff19bd131392f7 | |
parent | 781c55e7805abe5882179d894ac1dea7575f0530 (diff) | |
download | chromium_src-dbd11635d503ba6bfe229cdeab96942bd0aea5d7.zip chromium_src-dbd11635d503ba6bfe229cdeab96942bd0aea5d7.tar.gz chromium_src-dbd11635d503ba6bfe229cdeab96942bd0aea5d7.tar.bz2 |
Revert of Credential Manager: Return the first valid item from the PasswordStore. (patchset #1 id:1 of https://codereview.chromium.org/613143003/)
Reason for revert:
Tests CredentialManagerOnRequestCredentialWhileRequestPending,
CredentialManagerOnRequestCredentialWithFullPasswordStore
failing on Linux ASan LSan Tests (1)
link: http://build.chromium.org/p/chromium.memory/builders/Linux%20ASan%20LSan%20Tests%20%281%29/builds/6228
errors like:
Direct leak of 1056 byte(s) in 1 object(s) allocated from:
#0 0x52e7cb in operator new(unsigned long) (/b/build/slave/Linux_ASan_LSan_Tests__1_/build/src/out/Release/components_unittests+0x52e7cb)
#1 0x21e965f in password_manager::TestPasswordStore::GetLoginsImpl(autofill::PasswordForm const&, password_manager::PasswordStore::AuthorizationPromptPolicy, base::Callback\u003Cvoid (std::__1::vector\u003Cautofill::PasswordForm*, std::__1::allocator\u003Cautofill::PasswordForm*> > const&)> const&) components/password_manager/core/browser/test_password_store.cc:103:5
Original issue's description:
> Credential Manager: Return the first valid item from the PasswordStore.
>
> This patch completes the initial, dead simple, pretty dumb implementation
> of '.request()'. We poke at the PasswordStore for the origin currently
> committed in the RenderViewHost's main frame, and if we get anything at
> all, we return it.
>
> We can't expose this implementation to the web for obvious reasons. But
> it's pefectly wonderful for testing.
>
> BUG=400674
>
> Committed: https://crrev.com/e4c5d27cdb953539094774f7b6c57637a2bba4e1
> Cr-Commit-Position: refs/heads/master@{#297598}
TBR=vabr@chromium.org,mkwst@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=400674
Review URL: https://codereview.chromium.org/619033002
Cr-Commit-Position: refs/heads/master@{#297603}
4 files changed, 11 insertions, 67 deletions
diff --git a/components/password_manager/content/browser/content_credential_manager_dispatcher.cc b/components/password_manager/content/browser/content_credential_manager_dispatcher.cc index 4f88040..be8a06c 100644 --- a/components/password_manager/content/browser/content_credential_manager_dispatcher.cc +++ b/components/password_manager/content/browser/content_credential_manager_dispatcher.cc @@ -46,7 +46,8 @@ bool ContentCredentialManagerDispatcher::OnMessageReceived( } void ContentCredentialManagerDispatcher::OnNotifyFailedSignIn( - int request_id, const CredentialInfo&) { + int request_id, + const password_manager::CredentialInfo&) { // TODO(mkwst): This is a stub. web_contents()->GetRenderViewHost()->Send( new CredentialManagerMsg_AcknowledgeFailedSignIn( @@ -54,7 +55,8 @@ void ContentCredentialManagerDispatcher::OnNotifyFailedSignIn( } void ContentCredentialManagerDispatcher::OnNotifySignedIn( - int request_id, const CredentialInfo&) { + int request_id, + const password_manager::CredentialInfo&) { // TODO(mkwst): This is a stub. web_contents()->GetRenderViewHost()->Send( new CredentialManagerMsg_AcknowledgeSignedIn( @@ -95,22 +97,11 @@ void ContentCredentialManagerDispatcher::OnGetPasswordStoreResults( const std::vector<autofill::PasswordForm*>& results) { DCHECK(pending_request_id_); - if (results.empty()) { - // TODO(mkwst): This should be a separate message from above in - // OnRequestCredential. Waiting on a Blink-side change to make that - // possible. - web_contents()->GetRenderViewHost()->Send( - new CredentialManagerMsg_RejectCredentialRequest( - web_contents()->GetRenderViewHost()->GetRoutingID(), - pending_request_id_)); - return; - } - - // TODO(mkwst): This is a stub. We're just grabbing the first result and - // piping it down into Blink. Really, we should be kicking off some sort - // of UI full of magic moments and delight. Also, we should deal with - // federated login types. - CredentialInfo info(*results[0]); + // TODO(mkwst): This is a stub. We should be looking at |results| here. Baby + // steps. + password_manager::CredentialInfo info(base::ASCIIToUTF16("id"), + base::ASCIIToUTF16("name"), + GURL("https://example.com/image.png")); web_contents()->GetRenderViewHost()->Send( new CredentialManagerMsg_SendCredential( web_contents()->GetRenderViewHost()->GetRoutingID(), diff --git a/components/password_manager/content/browser/content_credential_manager_dispatcher_unittest.cc b/components/password_manager/content/browser/content_credential_manager_dispatcher_unittest.cc index 4b2c40d..7cb43fb 100644 --- a/components/password_manager/content/browser/content_credential_manager_dispatcher_unittest.cc +++ b/components/password_manager/content/browser/content_credential_manager_dispatcher_unittest.cc @@ -12,7 +12,6 @@ #include "components/password_manager/content/common/credential_manager_types.h" #include "components/password_manager/core/browser/stub_password_manager_client.h" #include "components/password_manager/core/browser/test_password_store.h" -#include "content/public/browser/web_contents.h" #include "content/public/test/mock_render_process_host.h" #include "content/public/test/test_renderer_host.h" #include "testing/gmock/include/gmock/gmock.h" @@ -63,15 +62,6 @@ class ContentCredentialManagerDispatcherTest client_.reset(new TestPasswordManagerClient(store_.get())); dispatcher_.reset( new ContentCredentialManagerDispatcher(web_contents(), client_.get())); - - NavigateAndCommit(GURL("https://example.com/test.html")); - - form_.username_value = base::ASCIIToUTF16("Username"); - form_.display_name = base::ASCIIToUTF16("Display Name"); - form_.password_value = base::ASCIIToUTF16("Password"); - form_.origin = web_contents()->GetLastCommittedURL().GetOrigin(); - form_.signon_realm = form_.origin.spec(); - form_.scheme = autofill::PasswordForm::SCHEME_HTML; } virtual void TearDown() OVERRIDE { @@ -81,8 +71,7 @@ class ContentCredentialManagerDispatcherTest ContentCredentialManagerDispatcher* dispatcher() { return dispatcher_.get(); } - protected: - autofill::PasswordForm form_; + private: scoped_refptr<TestPasswordStore> store_; scoped_ptr<ContentCredentialManagerDispatcher> dispatcher_; scoped_ptr<TestPasswordManagerClient> client_; @@ -128,23 +117,7 @@ TEST_F(ContentCredentialManagerDispatcherTest, } TEST_F(ContentCredentialManagerDispatcherTest, - CredentialManagerOnRequestCredentialWithEmptyPasswordStore) { - std::vector<GURL> federations; - dispatcher()->OnRequestCredential(kRequestId, false, federations); - - RunAllPendingTasks(); - - const uint32 kMsgID = CredentialManagerMsg_RejectCredentialRequest::ID; - const IPC::Message* message = - process()->sink().GetFirstMessageMatching(kMsgID); - EXPECT_TRUE(message); - process()->sink().ClearMessages(); -} - -TEST_F(ContentCredentialManagerDispatcherTest, - CredentialManagerOnRequestCredentialWithFullPasswordStore) { - store_->AddLogin(form_); - + CredentialManagerOnRequestCredential) { std::vector<GURL> federations; dispatcher()->OnRequestCredential(kRequestId, false, federations); @@ -159,8 +132,6 @@ TEST_F(ContentCredentialManagerDispatcherTest, TEST_F(ContentCredentialManagerDispatcherTest, CredentialManagerOnRequestCredentialWhileRequestPending) { - store_->AddLogin(form_); - std::vector<GURL> federations; dispatcher()->OnRequestCredential(kRequestId, false, federations); dispatcher()->OnRequestCredential(kRequestId, false, federations); diff --git a/components/password_manager/content/common/credential_manager_types.cc b/components/password_manager/content/common/credential_manager_types.cc index 158b1e3..6d14d18 100644 --- a/components/password_manager/content/common/credential_manager_types.cc +++ b/components/password_manager/content/common/credential_manager_types.cc @@ -4,9 +4,6 @@ #include "components/password_manager/content/common/credential_manager_types.h" -#include "base/logging.h" -#include "components/autofill/core/common/password_form.h" - namespace password_manager { CredentialInfo::CredentialInfo() : type(CREDENTIAL_TYPE_UNKNOWN) { @@ -21,16 +18,6 @@ CredentialInfo::CredentialInfo(const base::string16& id, avatar(avatar) { } -CredentialInfo::CredentialInfo(const autofill::PasswordForm& form) - : id(form.username_value), - name(form.display_name), - avatar(form.avatar_url), - password(form.password_value), - federation(form.federation_url) { - DCHECK(!password.empty() || !federation.is_empty()); - type = password.empty() ? CREDENTIAL_TYPE_FEDERATED : CREDENTIAL_TYPE_LOCAL; -} - CredentialInfo::~CredentialInfo() { } diff --git a/components/password_manager/content/common/credential_manager_types.h b/components/password_manager/content/common/credential_manager_types.h index c825e6f..68242c9 100644 --- a/components/password_manager/content/common/credential_manager_types.h +++ b/components/password_manager/content/common/credential_manager_types.h @@ -12,10 +12,6 @@ #include "base/strings/string16.h" #include "url/gurl.h" -namespace autofill { -struct PasswordForm; -} - namespace password_manager { // Limit the size of the federations array that we pass to the browser to @@ -34,7 +30,6 @@ struct CredentialInfo { CredentialInfo(const base::string16& id, const base::string16& name, const GURL& avatar); - CredentialInfo(const autofill::PasswordForm& form); ~CredentialInfo(); CredentialType type; |