Chromium Code Reviews| 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..40aa28c5695c917579011cb2d8aba034643e9412 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,50 @@ class CredentialManagerDispatcher::PendingRequestTask |
| DISALLOW_COPY_AND_ASSIGN(PendingRequestTask); |
| }; |
| +// CredentialManagerDispatcher::PendingSignedOutTask --------------------------- |
| + |
| +class CredentialManagerDispatcher::PendingSignedOutTask |
| + : public PasswordStoreConsumer { |
| + public: |
| + PendingSignedOutTask(CredentialManagerDispatcher* const dispatcher, |
| + 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( |
|
vabr (Chromium)
2015/02/05 14:06:48
CredentialManagerDispatcher::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) { |
|
vabr (Chromium)
2015/02/05 14:06:48
Also, "The implementation owns all PasswordForms i
|
| + PasswordStore* store = dispatcher_->GetPasswordStore(); |
| + for (autofill::PasswordForm* form : results) { |
| + if (form->origin == origin_) { |
| + form->skip_zero_click = true; |
| + store->UpdateLogin(*form); |
| + } |
| + } |
| +} |
| + |
| +// CredentialManagerDispatcher ------------------------------------------------- |
| + |
| CredentialManagerDispatcher::CredentialManagerDispatcher( |
| content::WebContents* web_contents, |
| PasswordManagerClient* client) |
| @@ -153,6 +199,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 +215,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) { |
| + 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 +291,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(), |