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

Side by Side 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: Rebase only Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGER_D ISPATCHER_H_ 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGER_I MPL_H_
6 #define COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGER_D ISPATCHER_H_ 6 #define COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGER_I MPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "components/password_manager/content/public/interfaces/credential_manag er.mojom.h"
13 #include "components/password_manager/core/browser/credential_manager_password_f orm_manager.h" 14 #include "components/password_manager/core/browser/credential_manager_password_f orm_manager.h"
14 #include "components/password_manager/core/browser/credential_manager_pending_re quest_task.h" 15 #include "components/password_manager/core/browser/credential_manager_pending_re quest_task.h"
15 #include "components/password_manager/core/browser/credential_manager_pending_re quire_user_mediation_task.h" 16 #include "components/password_manager/core/browser/credential_manager_pending_re quire_user_mediation_task.h"
16 #include "components/password_manager/core/browser/password_store_consumer.h" 17 #include "components/password_manager/core/browser/password_store_consumer.h"
17 #include "components/prefs/pref_member.h" 18 #include "components/prefs/pref_member.h"
18 #include "content/public/browser/web_contents_observer.h" 19 #include "content/public/browser/web_contents_observer.h"
20 #include "mojo/public/cpp/bindings/binding_set.h"
19 21
20 class GURL; 22 class GURL;
21 23
22 namespace autofill { 24 namespace autofill {
23 struct PasswordForm; 25 struct PasswordForm;
24 } 26 }
25 27
26 namespace content { 28 namespace content {
27 class WebContents; 29 class WebContents;
28 } 30 }
29 31
30 namespace password_manager { 32 namespace password_manager {
31 class CredentialManagerPasswordFormManager; 33 class CredentialManagerPasswordFormManager;
32 class PasswordManagerClient; 34 class PasswordManagerClient;
33 class PasswordManagerDriver; 35 class PasswordManagerDriver;
34 class PasswordStore; 36 class PasswordStore;
35 struct CredentialInfo; 37 struct CredentialInfo;
36 38
37 class CredentialManagerDispatcher 39 class CredentialManagerImpl
38 : public content::WebContentsObserver, 40 : public mojom::CredentialManager,
41 public content::WebContentsObserver,
39 public CredentialManagerPasswordFormManagerDelegate, 42 public CredentialManagerPasswordFormManagerDelegate,
40 public CredentialManagerPendingRequestTaskDelegate, 43 public CredentialManagerPendingRequestTaskDelegate,
41 public CredentialManagerPendingRequireUserMediationTaskDelegate { 44 public CredentialManagerPendingRequireUserMediationTaskDelegate {
42 public: 45 public:
43 CredentialManagerDispatcher(content::WebContents* web_contents, 46 CredentialManagerImpl(content::WebContents* web_contents,
44 PasswordManagerClient* client); 47 PasswordManagerClient* client);
45 ~CredentialManagerDispatcher() override; 48 ~CredentialManagerImpl() override;
46 49
47 // Called in response to an IPC from the renderer, triggered by a page's call 50 void BindRequest(mojom::CredentialManagerRequest request);
48 // to 'navigator.credentials.store'.
49 virtual void OnStore(int request_id, const password_manager::CredentialInfo&);
50 51
51 // Called in response to an IPC from the renderer, triggered by a page's call 52 // mojom::CredentialManager methods:
52 // to 'navigator.credentials.requireUserMediation'. 53 void Store(mojom::CredentialInfoPtr credential,
53 virtual void OnRequireUserMediation(int request_id); 54 const StoreCallback& callback) override;
54 55 void RequireUserMediation(
55 // Called in response to an IPC from the renderer, triggered by a page's call 56 const RequireUserMediationCallback& callback) override;
56 // to 'navigator.credentials.request'. 57 void Get(bool zero_click_only,
57 // 58 bool include_passwords,
58 // TODO(vabr): Determine if we can drop the `const` here to save some copies 59 mojo::Array<mojo::String> federations,
59 // while processing the request. 60 const GetCallback& callback) override;
60 virtual void OnRequestCredential(int request_id,
61 bool zero_click_only,
62 bool include_passwords,
63 const std::vector<GURL>& federations);
64
65 // content::WebContentsObserver implementation.
66 bool OnMessageReceived(const IPC::Message& message) override;
67 61
68 // CredentialManagerPendingRequestTaskDelegate: 62 // CredentialManagerPendingRequestTaskDelegate:
69 bool IsZeroClickAllowed() const override; 63 bool IsZeroClickAllowed() const override;
70 GURL GetOrigin() const override; 64 GURL GetOrigin() const override;
71 void SendCredential(int request_id, const CredentialInfo& info) override; 65 void SendCredential(const SendCredentialCallback& send_callback,
72 void SendPasswordForm(int request_id, 66 const CredentialInfo& info) override;
67 void SendPasswordForm(const SendCredentialCallback& send_callback,
73 const autofill::PasswordForm* form) override; 68 const autofill::PasswordForm* form) override;
74 PasswordManagerClient* client() const override; 69 PasswordManagerClient* client() const override;
75 autofill::PasswordForm GetSynthesizedFormForOrigin() const override; 70 autofill::PasswordForm GetSynthesizedFormForOrigin() const override;
76 71
77 // CredentialManagerPendingSignedOutTaskDelegate: 72 // CredentialManagerPendingSignedOutTaskDelegate:
78 PasswordStore* GetPasswordStore() override; 73 PasswordStore* GetPasswordStore() override;
79 void DoneRequiringUserMediation() override; 74 void DoneRequiringUserMediation() override;
80 75
81 // CredentialManagerPasswordFormManagerDelegate: 76 // CredentialManagerPasswordFormManagerDelegate:
82 void OnProvisionalSaveComplete() override; 77 void OnProvisionalSaveComplete() override;
83 78
84 private: 79 private:
85 // Returns the driver for the current main frame. 80 // Returns the driver for the current main frame.
86 // Virtual for testing. 81 // Virtual for testing.
87 virtual base::WeakPtr<PasswordManagerDriver> GetDriver(); 82 virtual base::WeakPtr<PasswordManagerDriver> GetDriver();
88 83
89 // Schedules a CredentiaManagerPendingRequestTask (during 84 // Schedules a CredentiaManagerPendingRequestTask (during
90 // |OnRequestCredential()|) after the PasswordStore's AffiliationMatchHelper 85 // |OnRequestCredential()|) after the PasswordStore's AffiliationMatchHelper
91 // grabs a list of realms related to the current web origin. 86 // grabs a list of realms related to the current web origin.
92 void ScheduleRequestTask(int request_id, 87 void ScheduleRequestTask(const GetCallback& callback,
93 bool zero_click_only, 88 bool zero_click_only,
94 bool include_passwords, 89 bool include_passwords,
95 const std::vector<GURL>& federations, 90 const std::vector<GURL>& federations,
96 const std::vector<std::string>& android_realms); 91 const std::vector<std::string>& android_realms);
97 92
98 // Schedules a CredentialManagerPendingRequireUserMediationTask after the 93 // Schedules a CredentialManagerPendingRequireUserMediationTask after the
99 // AffiliationMatchHelper grabs a list of realms related to the current 94 // AffiliationMatchHelper grabs a list of realms related to the current
100 // web origin. 95 // web origin.
101 void ScheduleRequireMediationTask( 96 void ScheduleRequireMediationTask(
102 int request_id, 97 const RequireUserMediationCallback& callback,
103 const std::vector<std::string>& android_realms); 98 const std::vector<std::string>& android_realms);
104 99
105 // Returns true iff it's OK to update credentials in the password store. 100 // Returns true iff it's OK to update credentials in the password store.
106 bool IsUpdatingCredentialAllowed() const; 101 bool IsUpdatingCredentialAllowed() const;
107 102
108 PasswordManagerClient* client_; 103 PasswordManagerClient* client_;
109 std::unique_ptr<CredentialManagerPasswordFormManager> form_manager_; 104 std::unique_ptr<CredentialManagerPasswordFormManager> form_manager_;
110 105
111 // Set to false to disable automatic signing in. 106 // Set to false to disable automatic signing in.
112 BooleanPrefMember auto_signin_enabled_; 107 BooleanPrefMember auto_signin_enabled_;
113 108
114 // When 'OnRequestCredential' is called, it in turn calls out to the 109 // When 'OnRequestCredential' is called, it in turn calls out to the
115 // PasswordStore; we push enough data into Pending*Task objects so that 110 // PasswordStore; we push enough data into Pending*Task objects so that
116 // they can properly respond to the request once the PasswordStore gives 111 // they can properly respond to the request once the PasswordStore gives
117 // us data. 112 // us data.
118 std::unique_ptr<CredentialManagerPendingRequestTask> pending_request_; 113 std::unique_ptr<CredentialManagerPendingRequestTask> pending_request_;
119 std::unique_ptr<CredentialManagerPendingRequireUserMediationTask> 114 std::unique_ptr<CredentialManagerPendingRequireUserMediationTask>
120 pending_require_user_mediation_; 115 pending_require_user_mediation_;
121 116
122 base::WeakPtrFactory<CredentialManagerDispatcher> weak_factory_; 117 mojo::BindingSet<mojom::CredentialManager> bindings_;
123 118
124 DISALLOW_COPY_AND_ASSIGN(CredentialManagerDispatcher); 119 base::WeakPtrFactory<CredentialManagerImpl> weak_factory_;
120
121 DISALLOW_COPY_AND_ASSIGN(CredentialManagerImpl);
125 }; 122 };
126 123
127 } // namespace password_manager 124 } // namespace password_manager
128 125
129 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGE R_DISPATCHER_H_ 126 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGE R_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698