| Index: components/password_manager/content/browser/credential_manager_impl.h
|
| diff --git a/components/password_manager/content/browser/credential_manager_dispatcher.h b/components/password_manager/content/browser/credential_manager_impl.h
|
| similarity index 69%
|
| rename from components/password_manager/content/browser/credential_manager_dispatcher.h
|
| rename to components/password_manager/content/browser/credential_manager_impl.h
|
| index 0fa7f621c479a9b274ebb199a9b54cfa37276b18..3c9544063951d1bd84e9c37a2701e2c1aa5eb01a 100644
|
| --- a/components/password_manager/content/browser/credential_manager_dispatcher.h
|
| +++ b/components/password_manager/content/browser/credential_manager_impl.h
|
| @@ -2,19 +2,21 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGER_DISPATCHER_H_
|
| -#define COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGER_DISPATCHER_H_
|
| +#ifndef COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGER_IMPL_H_
|
| +#define COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGER_IMPL_H_
|
|
|
| #include "base/callback.h"
|
| #include "base/macros.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/memory/weak_ptr.h"
|
| +#include "components/password_manager/content/public/interfaces/credential_manager.mojom.h"
|
| #include "components/password_manager/core/browser/credential_manager_password_form_manager.h"
|
| #include "components/password_manager/core/browser/credential_manager_pending_request_task.h"
|
| #include "components/password_manager/core/browser/credential_manager_pending_require_user_mediation_task.h"
|
| #include "components/password_manager/core/browser/password_store_consumer.h"
|
| #include "components/prefs/pref_member.h"
|
| #include "content/public/browser/web_contents_observer.h"
|
| +#include "mojo/public/cpp/bindings/binding_set.h"
|
|
|
| class GURL;
|
|
|
| @@ -33,41 +35,24 @@ class PasswordManagerDriver;
|
| class PasswordStore;
|
| struct CredentialInfo;
|
|
|
| -class CredentialManagerDispatcher
|
| - : public content::WebContentsObserver,
|
| +class CredentialManagerImpl
|
| + : public mojom::CredentialManager,
|
| + public content::WebContentsObserver,
|
| public CredentialManagerPasswordFormManagerDelegate,
|
| public CredentialManagerPendingRequestTaskDelegate,
|
| public CredentialManagerPendingRequireUserMediationTaskDelegate {
|
| public:
|
| - CredentialManagerDispatcher(content::WebContents* web_contents,
|
| - PasswordManagerClient* client);
|
| - ~CredentialManagerDispatcher() override;
|
| -
|
| - // Called in response to an IPC from the renderer, triggered by a page's call
|
| - // to 'navigator.credentials.store'.
|
| - virtual void OnStore(int request_id, const password_manager::CredentialInfo&);
|
| -
|
| - // Called in response to an IPC from the renderer, triggered by a page's call
|
| - // to 'navigator.credentials.requireUserMediation'.
|
| - virtual void OnRequireUserMediation(int request_id);
|
| -
|
| - // Called in response to an IPC from the renderer, triggered by a page's call
|
| - // to 'navigator.credentials.request'.
|
| - //
|
| - // TODO(vabr): Determine if we can drop the `const` here to save some copies
|
| - // while processing the request.
|
| - virtual void OnRequestCredential(int request_id,
|
| - bool zero_click_only,
|
| - bool include_passwords,
|
| - const std::vector<GURL>& federations);
|
| -
|
| - // content::WebContentsObserver implementation.
|
| - bool OnMessageReceived(const IPC::Message& message) override;
|
| + CredentialManagerImpl(content::WebContents* web_contents,
|
| + PasswordManagerClient* client);
|
| + ~CredentialManagerImpl() override;
|
| +
|
| + void BindRequest(mojom::CredentialManagerRequest request);
|
|
|
| // CredentialManagerPendingRequestTaskDelegate:
|
| bool IsZeroClickAllowed() const override;
|
| GURL GetOrigin() const override;
|
| - void SendCredential(int request_id, const CredentialInfo& info) override;
|
| + void SendCredential(const SendCredentialCallback& send_callback,
|
| + const CredentialInfo& info) override;
|
| PasswordManagerClient* client() const override;
|
| autofill::PasswordForm GetSynthesizedFormForOrigin() const override;
|
|
|
| @@ -79,6 +64,18 @@ class CredentialManagerDispatcher
|
| void OnProvisionalSaveComplete() override;
|
|
|
| private:
|
| + // mojom::CredentialManager methods:
|
| + void Store(mojom::CredentialInfoPtr credential,
|
| + const StoreCallback& callback) override;
|
| +
|
| + void RequireUserMediation(
|
| + const RequireUserMediationCallback& callback) override;
|
| +
|
| + void Get(bool zero_click_only,
|
| + bool include_passwords,
|
| + mojo::Array<mojo::String> federations,
|
| + const GetCallback& callback) override;
|
| +
|
| // Returns the driver for the current main frame.
|
| // Virtual for testing.
|
| virtual base::WeakPtr<PasswordManagerDriver> GetDriver();
|
| @@ -86,7 +83,7 @@ class CredentialManagerDispatcher
|
| // Schedules a CredentiaManagerPendingRequestTask (during
|
| // |OnRequestCredential()|) after the PasswordStore's AffiliationMatchHelper
|
| // grabs a list of realms related to the current web origin.
|
| - void ScheduleRequestTask(int request_id,
|
| + void ScheduleRequestTask(const GetCallback& callback,
|
| bool zero_click_only,
|
| bool include_passwords,
|
| const std::vector<GURL>& federations,
|
| @@ -96,7 +93,7 @@ class CredentialManagerDispatcher
|
| // AffiliationMatchHelper grabs a list of realms related to the current
|
| // web origin.
|
| void ScheduleRequireMediationTask(
|
| - int request_id,
|
| + const RequireUserMediationCallback& callback,
|
| const std::vector<std::string>& android_realms);
|
|
|
| // Returns true iff it's OK to update credentials in the password store.
|
| @@ -116,11 +113,13 @@ class CredentialManagerDispatcher
|
| scoped_ptr<CredentialManagerPendingRequireUserMediationTask>
|
| pending_require_user_mediation_;
|
|
|
| - base::WeakPtrFactory<CredentialManagerDispatcher> weak_factory_;
|
| + mojo::BindingSet<mojom::CredentialManager> bindings_;
|
| +
|
| + base::WeakPtrFactory<CredentialManagerImpl> weak_factory_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(CredentialManagerDispatcher);
|
| + DISALLOW_COPY_AND_ASSIGN(CredentialManagerImpl);
|
| };
|
|
|
| } // namespace password_manager
|
|
|
| -#endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGER_DISPATCHER_H_
|
| +#endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGER_IMPL_H_
|
|
|