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

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

Powered by Google App Engine
This is Rietveld 408576698