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

Unified Diff: components/password_manager/content/browser/content_credential_manager_dispatcher.cc

Issue 733463003: Show user credentials chooser bubble. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge with trunk Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: components/password_manager/content/browser/content_credential_manager_dispatcher.cc
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 fc498d707ce9e06f57bc4d240d92192006f003fa..94e95e10a20ffe3ba99910e9d1c94bc7ec6f8cac 100644
--- a/components/password_manager/content/browser/content_credential_manager_dispatcher.cc
+++ b/components/password_manager/content/browser/content_credential_manager_dispatcher.cc
@@ -4,6 +4,7 @@
#include "components/password_manager/content/browser/content_credential_manager_dispatcher.h"
+#include "base/bind.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/common/password_form.h"
@@ -90,7 +91,7 @@ void ContentCredentialManagerDispatcher::OnNotifySignedOut(int request_id) {
void ContentCredentialManagerDispatcher::OnRequestCredential(
int request_id,
bool /* zero_click_only */,
- const std::vector<GURL>& federations) {
+ const std::vector<GURL>& /* federations */) {
DCHECK(request_id);
PasswordStore* store = GetPasswordStore();
if (pending_request_id_ || !store) {
@@ -107,6 +108,7 @@ void ContentCredentialManagerDispatcher::OnRequestCredential(
pending_request_id_ = request_id;
+ // TODO(mkwst): we should deal with federated login types.
autofill::PasswordForm form;
form.scheme = autofill::PasswordForm::SCHEME_HTML;
form.origin = web_contents()->GetLastCommittedURL().GetOrigin();
@@ -119,16 +121,23 @@ void ContentCredentialManagerDispatcher::OnGetPasswordStoreResults(
const std::vector<autofill::PasswordForm*>& results) {
DCHECK(pending_request_id_);
- // Take ownership of all the password form objects in the |results| vector.
- ScopedVector<autofill::PasswordForm> entries;
- entries.assign(results.begin(), results.end());
+ if (results.empty() ||
+ !client_->PromptUserToChooseCredentials(results, base::Bind(
+ &ContentCredentialManagerDispatcher::SendCredential,
+ base::Unretained(this),
+ pending_request_id_))) {
+ SendCredential(pending_request_id_, CredentialInfo());
+ }
+}
+
+PasswordStore* ContentCredentialManagerDispatcher::GetPasswordStore() {
+ return client_ ? client_->GetPasswordStore() : nullptr;
+}
- // 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.empty() ? CredentialInfo()
- : CredentialInfo(*entries[0]);
+void ContentCredentialManagerDispatcher::SendCredential(
+ int request_id, const CredentialInfo& info) {
+ DCHECK(pending_request_id_);
+ DCHECK_EQ(pending_request_id_, request_id);
web_contents()->GetRenderViewHost()->Send(
new CredentialManagerMsg_SendCredential(
web_contents()->GetRenderViewHost()->GetRoutingID(),
@@ -137,8 +146,4 @@ void ContentCredentialManagerDispatcher::OnGetPasswordStoreResults(
pending_request_id_ = 0;
}
-PasswordStore* ContentCredentialManagerDispatcher::GetPasswordStore() {
- return client_ ? client_->GetPasswordStore() : nullptr;
-}
-
} // namespace password_manager

Powered by Google App Engine
This is Rietveld 408576698