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

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

Issue 879913004: Credential Management: Support zeroclick credential in 'request()'. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test. Created 5 years, 11 months 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/credential_manager_dispatcher.cc
diff --git a/components/password_manager/content/browser/credential_manager_dispatcher.cc b/components/password_manager/content/browser/credential_manager_dispatcher.cc
index fc7a026d82aeedde176ff647d07062cc9eb565fe..3ec0329e214dfc85550f91dfa8b95a2758cc2b1e 100644
--- a/components/password_manager/content/browser/credential_manager_dispatcher.cc
+++ b/components/password_manager/content/browser/credential_manager_dispatcher.cc
@@ -137,6 +137,7 @@ void CredentialManagerDispatcher::OnRequestCredential(
request_id, zero_click_only,
web_contents()->GetLastCommittedURL().GetOrigin(), federations));
+ // This will result in a callback to ::OnGetPasswordStoreResults().
store->GetAutofillableLogins(this);
}
@@ -152,17 +153,30 @@ void CredentialManagerDispatcher::OnGetPasswordStoreResults(
// up the instances we don't add to |local_results| or |federated_results|.
// We'll dump them into a ScopedVector and allow it to delete the
// PasswordForms upon destruction.
+ autofill::PasswordForm* to_send_as_zero_click = nullptr;
+ bool multiple_zero_click = false;
std::vector<autofill::PasswordForm*> local_results;
std::vector<autofill::PasswordForm*> federated_results;
ScopedVector<autofill::PasswordForm> discarded_results;
for (autofill::PasswordForm* form : results) {
- // TODO(mkwst): Extend this filter to include federations.
- if (form->origin == pending_request_->origin)
+ if (form->origin == pending_request_->origin) {
local_results.push_back(form);
- else if (federations.count(form->origin.spec()) != 0)
+
+ // If more than one local credential is_zero_click, then we punt on
+ // auto signin.
+ //
+ // TODO(mkwst): We should have a global on-off switch here alongside the
+ // credential-level toggle.
+ if (form->is_zero_click && !multiple_zero_click) {
vasilii 2015/01/28 13:25:30 AS we discussed, I'll rename form->is_zero_click t
Mike West 2015/01/28 14:42:14 Perfect, thanks.
+ if (to_send_as_zero_click)
+ multiple_zero_click = true;
+ to_send_as_zero_click = multiple_zero_click ? nullptr : form;
+ }
+ } else if (federations.count(form->origin.spec()) != 0) {
federated_results.push_back(form);
- else
+ } else {
discarded_results.push_back(form);
vabr (Chromium) 2015/01/28 13:37:52 Why not just delete form; ?
Mike West 2015/01/28 14:42:14 That would be too easy!
+ }
}
if ((local_results.empty() && federated_results.empty()) ||
@@ -172,9 +186,21 @@ void CredentialManagerDispatcher::OnGetPasswordStoreResults(
return;
}
- if (!client_->PromptUserToChooseCredentials(
- local_results,
- federated_results,
+ if (to_send_as_zero_click) {
+ discarded_results.assign(local_results.begin(), local_results.end());
vabr (Chromium) 2015/01/28 13:37:52 Why not use STLDeleteElements? This is a bit crypt
Mike West 2015/01/28 14:42:14 Sure. I can do that.
+ discarded_results.assign(federated_results.begin(),
+ federated_results.end());
+ CredentialInfo info(*to_send_as_zero_click,
+ to_send_as_zero_click->federation_url.is_empty()
+ ? CredentialType::CREDENTIAL_TYPE_LOCAL
+ : CredentialType::CREDENTIAL_TYPE_FEDERATED);
+ SendCredential(pending_request_->id, info);
+ return;
+ }
+
+ if (pending_request_->zero_click_only ||
+ !client_->PromptUserToChooseCredentials(
+ local_results, federated_results,
base::Bind(&CredentialManagerDispatcher::SendCredential,
base::Unretained(this), pending_request_->id))) {
SendCredential(pending_request_->id, CredentialInfo());

Powered by Google App Engine
This is Rietveld 408576698