OLD | NEW |
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_D
ISPATCHER_H_ |
6 #define 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 | 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" |
(...skipping 12 matching lines...) Expand all Loading... |
23 } | 23 } |
24 | 24 |
25 namespace password_manager { | 25 namespace password_manager { |
26 | 26 |
27 class CredentialManagerPasswordFormManager; | 27 class CredentialManagerPasswordFormManager; |
28 class PasswordManagerClient; | 28 class PasswordManagerClient; |
29 class PasswordManagerDriver; | 29 class PasswordManagerDriver; |
30 class PasswordStore; | 30 class PasswordStore; |
31 struct CredentialInfo; | 31 struct CredentialInfo; |
32 | 32 |
33 class CredentialManagerDispatcher : public content::WebContentsObserver, | 33 class CredentialManagerDispatcher : public content::WebContentsObserver { |
34 public PasswordStoreConsumer { | |
35 public: | 34 public: |
36 CredentialManagerDispatcher(content::WebContents* web_contents, | 35 CredentialManagerDispatcher(content::WebContents* web_contents, |
37 PasswordManagerClient* client); | 36 PasswordManagerClient* client); |
38 ~CredentialManagerDispatcher() override; | 37 ~CredentialManagerDispatcher() override; |
39 | 38 |
40 void OnProvisionalSaveComplete(); | 39 void OnProvisionalSaveComplete(); |
41 | 40 |
42 // Called in response to an IPC from the renderer, triggered by a page's call | 41 // Called in response to an IPC from the renderer, triggered by a page's call |
43 // to 'navigator.credentials.notifyFailedSignIn'. | 42 // to 'navigator.credentials.notifyFailedSignIn'. |
44 virtual void OnNotifyFailedSignIn(int request_id, | 43 virtual void OnNotifyFailedSignIn(int request_id, |
45 const password_manager::CredentialInfo&); | 44 const password_manager::CredentialInfo&); |
46 | 45 |
47 // Called in response to an IPC from the renderer, triggered by a page's call | 46 // Called in response to an IPC from the renderer, triggered by a page's call |
48 // to 'navigator.credentials.notifySignedIn'. | 47 // to 'navigator.credentials.notifySignedIn'. |
49 virtual void OnNotifySignedIn(int request_id, | 48 virtual void OnNotifySignedIn(int request_id, |
50 const password_manager::CredentialInfo&); | 49 const password_manager::CredentialInfo&); |
51 | 50 |
52 // Called in response to an IPC from the renderer, triggered by a page's call | 51 // Called in response to an IPC from the renderer, triggered by a page's call |
53 // to 'navigator.credentials.notifySignedOut'. | 52 // to 'navigator.credentials.notifySignedOut'. |
54 virtual void OnNotifySignedOut(int request_id); | 53 virtual void OnNotifySignedOut(int request_id); |
55 | 54 |
56 // Called in response to an IPC from the renderer, triggered by a page's call | 55 // Called in response to an IPC from the renderer, triggered by a page's call |
57 // to 'navigator.credentials.request'. | 56 // to 'navigator.credentials.request'. |
| 57 // |
| 58 // TODO(vabr): Determine if we can drop the `const` here to save some copies |
| 59 // while processing the request. |
58 virtual void OnRequestCredential(int request_id, | 60 virtual void OnRequestCredential(int request_id, |
59 bool zero_click_only, | 61 bool zero_click_only, |
60 const std::vector<GURL>& federations); | 62 const std::vector<GURL>& federations); |
61 | 63 |
62 // content::WebContentsObserver implementation. | 64 // content::WebContentsObserver implementation. |
63 bool OnMessageReceived(const IPC::Message& message) override; | 65 bool OnMessageReceived(const IPC::Message& message) override; |
64 | 66 |
65 // PasswordStoreConsumer implementation. | |
66 void OnGetPasswordStoreResults( | |
67 const std::vector<autofill::PasswordForm*>& results) override; | |
68 | |
69 using CredentialCallback = | 67 using CredentialCallback = |
70 base::Callback<void(const autofill::PasswordForm&)>; | 68 base::Callback<void(const autofill::PasswordForm&)>; |
71 | 69 |
| 70 PasswordManagerClient* client() const { return client_; } |
| 71 |
72 private: | 72 private: |
73 struct PendingRequestParameters; | 73 class PendingRequestTask; |
74 | 74 |
75 PasswordStore* GetPasswordStore(); | 75 PasswordStore* GetPasswordStore(); |
76 | 76 |
77 bool IsSavingEnabledForCurrentPage() const; | 77 bool IsSavingEnabledForCurrentPage() const; |
78 bool IsZeroClickAllowed() const; | 78 bool IsZeroClickAllowed() const; |
79 | 79 |
80 // Returns the driver for the current main frame. | 80 // Returns the driver for the current main frame. |
81 // Virtual for testing. | 81 // Virtual for testing. |
82 virtual base::WeakPtr<PasswordManagerDriver> GetDriver(); | 82 virtual base::WeakPtr<PasswordManagerDriver> GetDriver(); |
83 | 83 |
84 void SendCredential(int request_id, const CredentialInfo& info); | 84 void SendCredential(int request_id, const CredentialInfo& info); |
85 | 85 |
86 PasswordManagerClient* client_; | 86 PasswordManagerClient* client_; |
87 scoped_ptr<CredentialManagerPasswordFormManager> form_manager_; | 87 scoped_ptr<CredentialManagerPasswordFormManager> form_manager_; |
88 | 88 |
89 // When 'OnRequestCredential' is called, it in turn calls out to the | 89 // When 'OnRequestCredential' is called, it in turn calls out to the |
90 // PasswordStore; we store request details here in order to properly | 90 // PasswordStore; we push enough data into Pending*Task objects so that |
91 // respond to the request once the PasswordStore gives us data. | 91 // they can properly respond to the request once the PasswordStore gives |
92 scoped_ptr<PendingRequestParameters> pending_request_; | 92 // us data. |
| 93 scoped_ptr<PendingRequestTask> pending_request_; |
93 | 94 |
94 DISALLOW_COPY_AND_ASSIGN(CredentialManagerDispatcher); | 95 DISALLOW_COPY_AND_ASSIGN(CredentialManagerDispatcher); |
95 }; | 96 }; |
96 | 97 |
97 } // namespace password_manager | 98 } // namespace password_manager |
98 | 99 |
99 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGE
R_DISPATCHER_H_ | 100 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGE
R_DISPATCHER_H_ |
OLD | NEW |