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