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 d459cfa4eaac65724b90dcd874cfc65133b1eb3b..f82ee5d6b905f6145cd1804d36e3d9bfdd8c5e0a 100644 |
--- a/components/password_manager/content/browser/credential_manager_dispatcher.cc |
+++ b/components/password_manager/content/browser/credential_manager_dispatcher.cc |
@@ -23,6 +23,8 @@ |
namespace password_manager { |
+// CredentialManagerDispatcher::PendingRequestTask ----------------------------- |
+ |
class CredentialManagerDispatcher::PendingRequestTask |
: public PasswordStoreConsumer { |
public: |
@@ -102,6 +104,56 @@ class CredentialManagerDispatcher::PendingRequestTask |
DISALLOW_COPY_AND_ASSIGN(PendingRequestTask); |
}; |
+// CredentialManagerDispatcher::PendingSignedOutTask --------------------------- |
+ |
+class CredentialManagerDispatcher::PendingSignedOutTask |
+ : public PasswordStoreConsumer { |
+ public: |
+ PendingSignedOutTask(CredentialManagerDispatcher* const dispatcher, |
vasilii
2015/02/05 14:49:31
'const' doesn't make a lot of sense here.
|
+ int request_id, |
+ const GURL& origin); |
+ |
+ // PasswordStoreConsumer implementation. |
+ void OnGetPasswordStoreResults( |
+ const std::vector<autofill::PasswordForm*>& results) override; |
+ |
+ private: |
+ // Backlink to the CredentialManagerDispatcher that owns this object. |
+ CredentialManagerDispatcher* const dispatcher_; |
+ |
+ const int id_; |
+ const GURL origin_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PendingSignedOutTask); |
+}; |
+ |
+CredentialManagerDispatcher::PendingSignedOutTask::PendingSignedOutTask( |
+ CredentialManagerDispatcher* const dispatcher, |
+ int request_id, |
+ const GURL& origin) |
+ : dispatcher_(dispatcher), id_(request_id), origin_(origin) { |
+} |
+ |
+void CredentialManagerDispatcher::PendingSignedOutTask:: |
+ OnGetPasswordStoreResults( |
+ const std::vector<autofill::PasswordForm*>& results) { |
+ // We own the PasswordForm instances, so we're responsible for cleaning |
+ // up the instances we don't add to |updating| (which will delete itself). |
+ PasswordStore* store = dispatcher_->GetPasswordStore(); |
+ ScopedVector<autofill::PasswordForm> updating; |
+ for (autofill::PasswordForm* form : results) { |
+ if (form->origin == origin_) { |
+ form->skip_zero_click = true; |
+ store->UpdateLogin(*form); |
+ updating.push_back(form); |
+ } else { |
+ delete form; |
vabr (Chromium)
2015/02/05 14:08:40
Why not just delete them all directly? UpdateLogin
vasilii
2015/02/05 14:49:31
Acknowledged.
|
+ } |
+ } |
+} |
+ |
+// CredentialManagerDispatcher ------------------------------------------------- |
+ |
CredentialManagerDispatcher::CredentialManagerDispatcher( |
content::WebContents* web_contents, |
PasswordManagerClient* client) |
@@ -153,6 +205,7 @@ void CredentialManagerDispatcher::OnNotifySignedIn( |
scoped_ptr<autofill::PasswordForm> form(CreatePasswordFormFromCredentialInfo( |
credential, web_contents()->GetLastCommittedURL().GetOrigin())); |
+ form->skip_zero_click = !IsZeroClickAllowed(); |
// TODO(mkwst): This is a stub; we should be checking the PasswordStore to |
// determine whether or not the credential exists, and calling UpdateLogin |
@@ -168,7 +221,17 @@ void CredentialManagerDispatcher::OnProvisionalSaveComplete() { |
void CredentialManagerDispatcher::OnNotifySignedOut(int request_id) { |
DCHECK(request_id); |
- // TODO(mkwst): This is a stub. |
+ |
+ PasswordStore* store = GetPasswordStore(); |
+ if (!pending_sign_out_ && store) { |
vasilii
2015/02/05 14:49:31
I don't see the place where pending_sign_out_ actu
|
+ pending_sign_out_.reset(new PendingSignedOutTask( |
+ this, request_id, web_contents()->GetLastCommittedURL().GetOrigin())); |
+ |
+ // This will result in a callback to |
+ // PendingSignedOutTask::OnGetPasswordStoreResults(). |
+ store->GetAutofillableLogins(pending_sign_out_.get()); |
+ } |
+ |
web_contents()->GetRenderViewHost()->Send( |
new CredentialManagerMsg_AcknowledgeSignedOut( |
web_contents()->GetRenderViewHost()->GetRoutingID(), request_id)); |
@@ -234,6 +297,9 @@ void CredentialManagerDispatcher::SendCredential(int request_id, |
const CredentialInfo& info) { |
DCHECK(pending_request_); |
DCHECK_EQ(pending_request_->id(), request_id); |
+ // TODO(mkwst): We need to update the underlying PasswordForm if the user |
+ // has enabled zeroclick globally, and clicks through a non-zeroclick form |
+ // for an origin. |
web_contents()->GetRenderViewHost()->Send( |
new CredentialManagerMsg_SendCredential( |
web_contents()->GetRenderViewHost()->GetRoutingID(), |