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

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: gyp 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
Anand Mistry (off Chromium) 2016/03/18 01:24:13 nit: We generally don't have blank lines between f
leonhsl(Using Gerrit) 2016/03/18 10:02:16 Done.
54 // Called in response to an IPC from the renderer, triggered by a page's call 55 void RequireUserMediation(
55 // to 'navigator.credentials.request'. 56 const RequireUserMediationCallback& callback) override;
56 //
57 // TODO(vabr): Determine if we can drop the `const` here to save some copies
58 // while processing the request.
59 virtual void OnRequestCredential(int request_id,
60 bool zero_click_only,
61 bool include_passwords,
62 const std::vector<GURL>& federations);
63 57
64 // content::WebContentsObserver implementation. 58 void Get(bool zero_click_only,
65 bool OnMessageReceived(const IPC::Message& message) override; 59 bool include_passwords,
60 mojo::Array<mojo::String> federations,
61 const GetCallback& callback) override;
66 62
67 // CredentialManagerPendingRequestTaskDelegate: 63 // CredentialManagerPendingRequestTaskDelegate:
68 bool IsZeroClickAllowed() const override; 64 bool IsZeroClickAllowed() const override;
69 GURL GetOrigin() const override; 65 GURL GetOrigin() const override;
70 void SendCredential(int request_id, const CredentialInfo& info) override; 66 void SendCredential(const SendCredentialCallback& send_callback,
67 const CredentialInfo& info) override;
71 PasswordManagerClient* client() const override; 68 PasswordManagerClient* client() const override;
72 autofill::PasswordForm GetSynthesizedFormForOrigin() const override; 69 autofill::PasswordForm GetSynthesizedFormForOrigin() const override;
73 70
74 // CredentialManagerPendingSignedOutTaskDelegate: 71 // CredentialManagerPendingSignedOutTaskDelegate:
75 PasswordStore* GetPasswordStore() override; 72 PasswordStore* GetPasswordStore() override;
76 void DoneRequiringUserMediation() override; 73 void DoneRequiringUserMediation() override;
77 74
78 // CredentialManagerPasswordFormManagerDelegate: 75 // CredentialManagerPasswordFormManagerDelegate:
79 void OnProvisionalSaveComplete() override; 76 void OnProvisionalSaveComplete() override;
80 77
81 private: 78 private:
82 // Returns the driver for the current main frame. 79 // Returns the driver for the current main frame.
83 // Virtual for testing. 80 // Virtual for testing.
84 virtual base::WeakPtr<PasswordManagerDriver> GetDriver(); 81 virtual base::WeakPtr<PasswordManagerDriver> GetDriver();
85 82
86 // Schedules a CredentiaManagerPendingRequestTask (during 83 // Schedules a CredentiaManagerPendingRequestTask (during
87 // |OnRequestCredential()|) after the PasswordStore's AffiliationMatchHelper 84 // |OnRequestCredential()|) after the PasswordStore's AffiliationMatchHelper
88 // grabs a list of realms related to the current web origin. 85 // grabs a list of realms related to the current web origin.
89 void ScheduleRequestTask(int request_id, 86 void ScheduleRequestTask(const GetCallback& callback,
90 bool zero_click_only, 87 bool zero_click_only,
91 bool include_passwords, 88 bool include_passwords,
92 const std::vector<GURL>& federations, 89 const std::vector<GURL>& federations,
93 const std::vector<std::string>& android_realms); 90 const std::vector<std::string>& android_realms);
94 91
95 // Schedules a CredentialManagerPendingRequireUserMediationTask after the 92 // Schedules a CredentialManagerPendingRequireUserMediationTask after the
96 // AffiliationMatchHelper grabs a list of realms related to the current 93 // AffiliationMatchHelper grabs a list of realms related to the current
97 // web origin. 94 // web origin.
98 void ScheduleRequireMediationTask( 95 void ScheduleRequireMediationTask(
99 int request_id, 96 const RequireUserMediationCallback& callback,
100 const std::vector<std::string>& android_realms); 97 const std::vector<std::string>& android_realms);
101 98
102 // Returns true iff it's OK to update credentials in the password store. 99 // Returns true iff it's OK to update credentials in the password store.
103 bool IsUpdatingCredentialAllowed() const; 100 bool IsUpdatingCredentialAllowed() const;
104 101
105 PasswordManagerClient* client_; 102 PasswordManagerClient* client_;
106 scoped_ptr<CredentialManagerPasswordFormManager> form_manager_; 103 scoped_ptr<CredentialManagerPasswordFormManager> form_manager_;
107 104
108 // Set to false to disable automatic signing in. 105 // Set to false to disable automatic signing in.
109 BooleanPrefMember auto_signin_enabled_; 106 BooleanPrefMember auto_signin_enabled_;
110 107
111 // When 'OnRequestCredential' is called, it in turn calls out to the 108 // When 'OnRequestCredential' is called, it in turn calls out to the
112 // PasswordStore; we push enough data into Pending*Task objects so that 109 // PasswordStore; we push enough data into Pending*Task objects so that
113 // they can properly respond to the request once the PasswordStore gives 110 // they can properly respond to the request once the PasswordStore gives
114 // us data. 111 // us data.
115 scoped_ptr<CredentialManagerPendingRequestTask> pending_request_; 112 scoped_ptr<CredentialManagerPendingRequestTask> pending_request_;
116 scoped_ptr<CredentialManagerPendingRequireUserMediationTask> 113 scoped_ptr<CredentialManagerPendingRequireUserMediationTask>
117 pending_require_user_mediation_; 114 pending_require_user_mediation_;
118 115
119 base::WeakPtrFactory<CredentialManagerDispatcher> weak_factory_; 116 mojo::BindingSet<mojom::CredentialManager> bindings_;
120 117
121 DISALLOW_COPY_AND_ASSIGN(CredentialManagerDispatcher); 118 base::WeakPtrFactory<CredentialManagerImpl> weak_factory_;
119
120 DISALLOW_COPY_AND_ASSIGN(CredentialManagerImpl);
122 }; 121 };
123 122
124 } // namespace password_manager 123 } // namespace password_manager
125 124
126 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGE R_DISPATCHER_H_ 125 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGE R_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698