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

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: Impl done, unit_tests and browser_tests not ready yet 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 68%
rename from components/password_manager/content/browser/credential_manager_dispatcher.h
rename to components/password_manager/content/browser/credential_manager_impl.h
index 0fa7f621c479a9b274ebb199a9b54cfa37276b18..ca9c4bd745755b9a0a67b374aef4ddd781c8ea3b 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,25 @@ class PasswordManagerDriver;
class PasswordStore;
struct CredentialInfo;
-class CredentialManagerDispatcher
- : public content::WebContentsObserver,
+// This class implements the Mojo interface mojom::CredentialManager.
vabr (Chromium) 2016/03/09 16:26:29 optional: Drop this comment, line 40 says the same
leonhsl(Using Gerrit) 2016/03/10 06:42:41 Done.
+class CredentialManagerImpl
+ : public mojom::CredentialManager,
+ public content::WebContentsObserver,
public CredentialManagerPasswordFormManagerDelegate,
public CredentialManagerPendingRequestTaskDelegate,
public CredentialManagerPendingRequireUserMediationTaskDelegate {
public:
- CredentialManagerDispatcher(content::WebContents* web_contents,
- PasswordManagerClient* client);
- ~CredentialManagerDispatcher() override;
+ CredentialManagerImpl(content::WebContents* web_contents,
+ PasswordManagerClient* client);
+ ~CredentialManagerImpl() 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;
+ 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 +65,27 @@ class CredentialManagerDispatcher
void OnProvisionalSaveComplete() override;
private:
+ // mojom::CredentialManager methods:
+ // Called in response to the request from the renderer, triggered by a page's
vabr (Chromium) 2016/03/09 16:26:29 nit: Actually, the comments explaining the methods
leonhsl(Using Gerrit) 2016/03/10 06:42:41 Done. Only leave comments in the interface definit
+ // call
vabr (Chromium) 2016/03/09 16:26:29 nit: Please indent the comment block properly, do
leonhsl(Using Gerrit) 2016/03/10 06:42:41 Done.
+ // to 'navigator.credentials.store'.
+ void Store(mojom::CredentialInfoPtr credential,
+ const StoreCallback& callback) override;
+
+ // Called in response to the request from the renderer, triggered by a page's
+ // call
+ // to 'navigator.credentials.requireUserMediation'.
+ void RequireUserMediation(
+ const RequireUserMediationCallback& callback) override;
+
+ // Called in response to the request from the renderer, triggered by a page's
+ // call
+ // to 'navigator.credentials.request'.
vabr (Chromium) 2016/03/09 16:26:29 "request" or "get"? The mojom file says "get". The
leonhsl(Using Gerrit) 2016/03/10 06:42:41 Done. It should be 'navigator.credentials.get()'.
+ 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 +93,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 +103,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 +123,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