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

Side by Side Diff: components/password_manager/content/browser/content_credential_manager_dispatcher.cc

Issue 615383002: Credential Manager: Return the first valid item from the PasswordStore. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/password_manager/content/browser/content_credential_manager_dispatcher_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/password_manager/content/browser/content_credential_manager _dispatcher.h" 5 #include "components/password_manager/content/browser/content_credential_manager _dispatcher.h"
6 6
7 #include "base/strings/string16.h" 7 #include "base/strings/string16.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "components/autofill/core/common/password_form.h" 9 #include "components/autofill/core/common/password_form.h"
10 #include "components/password_manager/content/common/credential_manager_messages .h" 10 #include "components/password_manager/content/common/credential_manager_messages .h"
(...skipping 28 matching lines...) Expand all
39 IPC_MESSAGE_HANDLER(CredentialManagerHostMsg_NotifySignedOut, 39 IPC_MESSAGE_HANDLER(CredentialManagerHostMsg_NotifySignedOut,
40 OnNotifySignedOut); 40 OnNotifySignedOut);
41 IPC_MESSAGE_HANDLER(CredentialManagerHostMsg_RequestCredential, 41 IPC_MESSAGE_HANDLER(CredentialManagerHostMsg_RequestCredential,
42 OnRequestCredential); 42 OnRequestCredential);
43 IPC_MESSAGE_UNHANDLED(handled = false) 43 IPC_MESSAGE_UNHANDLED(handled = false)
44 IPC_END_MESSAGE_MAP() 44 IPC_END_MESSAGE_MAP()
45 return handled; 45 return handled;
46 } 46 }
47 47
48 void ContentCredentialManagerDispatcher::OnNotifyFailedSignIn( 48 void ContentCredentialManagerDispatcher::OnNotifyFailedSignIn(
49 int request_id, 49 int request_id, const CredentialInfo&) {
50 const password_manager::CredentialInfo&) {
51 // TODO(mkwst): This is a stub. 50 // TODO(mkwst): This is a stub.
52 web_contents()->GetRenderViewHost()->Send( 51 web_contents()->GetRenderViewHost()->Send(
53 new CredentialManagerMsg_AcknowledgeFailedSignIn( 52 new CredentialManagerMsg_AcknowledgeFailedSignIn(
54 web_contents()->GetRenderViewHost()->GetRoutingID(), request_id)); 53 web_contents()->GetRenderViewHost()->GetRoutingID(), request_id));
55 } 54 }
56 55
57 void ContentCredentialManagerDispatcher::OnNotifySignedIn( 56 void ContentCredentialManagerDispatcher::OnNotifySignedIn(
58 int request_id, 57 int request_id, const CredentialInfo&) {
59 const password_manager::CredentialInfo&) {
60 // TODO(mkwst): This is a stub. 58 // TODO(mkwst): This is a stub.
61 web_contents()->GetRenderViewHost()->Send( 59 web_contents()->GetRenderViewHost()->Send(
62 new CredentialManagerMsg_AcknowledgeSignedIn( 60 new CredentialManagerMsg_AcknowledgeSignedIn(
63 web_contents()->GetRenderViewHost()->GetRoutingID(), request_id)); 61 web_contents()->GetRenderViewHost()->GetRoutingID(), request_id));
64 } 62 }
65 63
66 void ContentCredentialManagerDispatcher::OnNotifySignedOut(int request_id) { 64 void ContentCredentialManagerDispatcher::OnNotifySignedOut(int request_id) {
67 // TODO(mkwst): This is a stub. 65 // TODO(mkwst): This is a stub.
68 web_contents()->GetRenderViewHost()->Send( 66 web_contents()->GetRenderViewHost()->Send(
69 new CredentialManagerMsg_AcknowledgeSignedOut( 67 new CredentialManagerMsg_AcknowledgeSignedOut(
(...skipping 20 matching lines...) Expand all
90 form.origin = web_contents()->GetLastCommittedURL().GetOrigin(); 88 form.origin = web_contents()->GetLastCommittedURL().GetOrigin();
91 form.signon_realm = form.origin.spec(); 89 form.signon_realm = form.origin.spec();
92 90
93 store->GetLogins(form, PasswordStore::DISALLOW_PROMPT, this); 91 store->GetLogins(form, PasswordStore::DISALLOW_PROMPT, this);
94 } 92 }
95 93
96 void ContentCredentialManagerDispatcher::OnGetPasswordStoreResults( 94 void ContentCredentialManagerDispatcher::OnGetPasswordStoreResults(
97 const std::vector<autofill::PasswordForm*>& results) { 95 const std::vector<autofill::PasswordForm*>& results) {
98 DCHECK(pending_request_id_); 96 DCHECK(pending_request_id_);
99 97
100 // TODO(mkwst): This is a stub. We should be looking at |results| here. Baby 98 // Take ownership of all the password form objects in the |results| vector.
101 // steps. 99 ScopedVector<autofill::PasswordForm> entries;
102 password_manager::CredentialInfo info(base::ASCIIToUTF16("id"), 100 entries.assign(results.begin(), results.end());
103 base::ASCIIToUTF16("name"), 101
104 GURL("https://example.com/image.png")); 102 if (results.empty()) {
103 // TODO(mkwst): This should be a separate message from above in
104 // OnRequestCredential. Waiting on a Blink-side change to make that
105 // possible.
106 web_contents()->GetRenderViewHost()->Send(
107 new CredentialManagerMsg_RejectCredentialRequest(
108 web_contents()->GetRenderViewHost()->GetRoutingID(),
109 pending_request_id_));
110 return;
111 }
112
113 // TODO(mkwst): This is a stub. We're just grabbing the first result and
114 // piping it down into Blink. Really, we should be kicking off some sort
115 // of UI full of magic moments and delight. Also, we should deal with
116 // federated login types.
117 CredentialInfo info(*entries[0]);
105 web_contents()->GetRenderViewHost()->Send( 118 web_contents()->GetRenderViewHost()->Send(
106 new CredentialManagerMsg_SendCredential( 119 new CredentialManagerMsg_SendCredential(
107 web_contents()->GetRenderViewHost()->GetRoutingID(), 120 web_contents()->GetRenderViewHost()->GetRoutingID(),
108 pending_request_id_, 121 pending_request_id_,
109 info)); 122 info));
110 pending_request_id_ = 0; 123 pending_request_id_ = 0;
111 } 124 }
112 125
113 PasswordStore* ContentCredentialManagerDispatcher::GetPasswordStore() { 126 PasswordStore* ContentCredentialManagerDispatcher::GetPasswordStore() {
114 return client_ ? client_->GetPasswordStore() : nullptr; 127 return client_ ? client_->GetPasswordStore() : nullptr;
115 } 128 }
116 129
117 } // namespace password_manager 130 } // namespace password_manager
OLDNEW
« no previous file with comments | « no previous file | components/password_manager/content/browser/content_credential_manager_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698