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

Unified Diff: components/password_manager/content/browser/credential_manager_impl.h

Issue 1762603002: Switch components/password_manager code from IPC messages to Mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add browsertests. Created 4 years, 9 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_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..b72759261a2b2c770119af693d3fb28adf26c2d8 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,20 @@ class CredentialManagerDispatcher
void OnProvisionalSaveComplete() override;
private:
+ friend class CredentialManagerImplTest;
vabr (Chromium) 2016/03/14 15:40:26 What exactly is this needed for? It is usually a w
leonhsl(Using Gerrit) 2016/03/16 07:07:28 Done. Removed this line. This was to enable Creden
vabr (Chromium) 2016/03/16 07:16:20 Acknowledged, SGTM.
+
+ // 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 +85,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 +95,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 +115,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_

Powered by Google App Engine
This is Rietveld 408576698