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_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_H_ |
6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_H_ | 6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/supports_user_data.h" | 11 #include "base/supports_user_data.h" |
| 12 #include "components/autofill/content/browser/key_press_handler_manager.h" |
12 #include "components/autofill/content/common/autofill_agent.mojom.h" | 13 #include "components/autofill/content/common/autofill_agent.mojom.h" |
13 #include "components/autofill/content/common/autofill_driver.mojom.h" | 14 #include "components/autofill/content/common/autofill_driver.mojom.h" |
14 #include "components/autofill/core/browser/autofill_driver.h" | 15 #include "components/autofill/core/browser/autofill_driver.h" |
15 #include "components/autofill/core/browser/autofill_external_delegate.h" | 16 #include "components/autofill/core/browser/autofill_external_delegate.h" |
16 #include "components/autofill/core/browser/autofill_manager.h" | 17 #include "components/autofill/core/browser/autofill_manager.h" |
17 #include "mojo/public/cpp/bindings/binding.h" | 18 #include "mojo/public/cpp/bindings/binding.h" |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 class NavigationHandle; | 21 class NavigationHandle; |
21 class RenderFrameHost; | 22 class RenderFrameHost; |
22 } | 23 } |
23 | 24 |
24 namespace autofill { | 25 namespace autofill { |
25 | 26 |
26 class AutofillClient; | 27 class AutofillClient; |
27 | 28 |
28 // Class that drives autofill flow in the browser process based on | 29 // Class that drives autofill flow in the browser process based on |
29 // communication from the renderer and from the external world. There is one | 30 // communication from the renderer and from the external world. There is one |
30 // instance per RenderFrameHost. | 31 // instance per RenderFrameHost. |
31 class ContentAutofillDriver : public AutofillDriver, | 32 class ContentAutofillDriver : public AutofillDriver, |
32 public mojom::AutofillDriver { | 33 public mojom::AutofillDriver, |
| 34 public KeyPressHandlerManager::Delegate { |
33 public: | 35 public: |
34 ContentAutofillDriver( | 36 ContentAutofillDriver( |
35 content::RenderFrameHost* render_frame_host, | 37 content::RenderFrameHost* render_frame_host, |
36 AutofillClient* client, | 38 AutofillClient* client, |
37 const std::string& app_locale, | 39 const std::string& app_locale, |
38 AutofillManager::AutofillDownloadManagerState enable_download_manager); | 40 AutofillManager::AutofillDownloadManagerState enable_download_manager); |
39 ~ContentAutofillDriver() override; | 41 ~ContentAutofillDriver() override; |
40 | 42 |
41 // Gets the driver for |render_frame_host|. | 43 // Gets the driver for |render_frame_host|. |
42 static ContentAutofillDriver* GetForRenderFrameHost( | 44 static ContentAutofillDriver* GetForRenderFrameHost( |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 98 |
97 AutofillExternalDelegate* autofill_external_delegate() { | 99 AutofillExternalDelegate* autofill_external_delegate() { |
98 return &autofill_external_delegate_; | 100 return &autofill_external_delegate_; |
99 } | 101 } |
100 | 102 |
101 AutofillManager* autofill_manager() { return autofill_manager_.get(); } | 103 AutofillManager* autofill_manager() { return autofill_manager_.get(); } |
102 content::RenderFrameHost* render_frame_host() { return render_frame_host_; } | 104 content::RenderFrameHost* render_frame_host() { return render_frame_host_; } |
103 | 105 |
104 const mojom::AutofillAgentPtr& GetAutofillAgent(); | 106 const mojom::AutofillAgentPtr& GetAutofillAgent(); |
105 | 107 |
| 108 // Methods forwarded to key_press_handler_manager_. |
| 109 void RegisterKeyPressHandler( |
| 110 const content::RenderWidgetHost::KeyPressEventCallback& handler); |
| 111 void RemoveKeyPressHandler(); |
| 112 |
106 protected: | 113 protected: |
107 // Sets the manager to |manager| and sets |manager|'s external delegate | 114 // Sets the manager to |manager| and sets |manager|'s external delegate |
108 // to |autofill_external_delegate_|. Takes ownership of |manager|. | 115 // to |autofill_external_delegate_|. Takes ownership of |manager|. |
109 void SetAutofillManager(std::unique_ptr<AutofillManager> manager); | 116 void SetAutofillManager(std::unique_ptr<AutofillManager> manager); |
110 | 117 |
111 private: | 118 private: |
| 119 // KeyPressHandlerManager::Delegate: |
| 120 void AddHandler( |
| 121 const content::RenderWidgetHost::KeyPressEventCallback& handler) override; |
| 122 void RemoveHandler( |
| 123 const content::RenderWidgetHost::KeyPressEventCallback& handler) override; |
| 124 |
112 // Weak ref to the RenderFrameHost the driver is associated with. Should | 125 // Weak ref to the RenderFrameHost the driver is associated with. Should |
113 // always be non-NULL and valid for lifetime of |this|. | 126 // always be non-NULL and valid for lifetime of |this|. |
114 content::RenderFrameHost* const render_frame_host_; | 127 content::RenderFrameHost* const render_frame_host_; |
115 | 128 |
116 // The per-tab client. | 129 // The per-tab client. |
117 AutofillClient* client_; | 130 AutofillClient* client_; |
118 | 131 |
119 // AutofillManager instance via which this object drives the shared Autofill | 132 // AutofillManager instance via which this object drives the shared Autofill |
120 // code. | 133 // code. |
121 std::unique_ptr<AutofillManager> autofill_manager_; | 134 std::unique_ptr<AutofillManager> autofill_manager_; |
122 | 135 |
123 // AutofillExternalDelegate instance that this object instantiates in the | 136 // AutofillExternalDelegate instance that this object instantiates in the |
124 // case where the Autofill native UI is enabled. | 137 // case where the Autofill native UI is enabled. |
125 AutofillExternalDelegate autofill_external_delegate_; | 138 AutofillExternalDelegate autofill_external_delegate_; |
126 | 139 |
| 140 KeyPressHandlerManager key_press_handler_manager_; |
| 141 |
127 mojo::Binding<mojom::AutofillDriver> binding_; | 142 mojo::Binding<mojom::AutofillDriver> binding_; |
128 | 143 |
129 mojom::AutofillAgentPtr autofill_agent_; | 144 mojom::AutofillAgentPtr autofill_agent_; |
130 }; | 145 }; |
131 | 146 |
132 } // namespace autofill | 147 } // namespace autofill |
133 | 148 |
134 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_H_ | 149 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_H_ |
OLD | NEW |