| 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/browser/key_press_handler_manager.h" |
| 13 #include "components/autofill/content/common/autofill_agent.mojom.h" | 13 #include "components/autofill/content/common/autofill_agent.mojom.h" |
| 14 #include "components/autofill/content/common/autofill_driver.mojom.h" | 14 #include "components/autofill/content/common/autofill_driver.mojom.h" |
| 15 #include "components/autofill/core/browser/autofill_driver.h" | 15 #include "components/autofill/core/browser/autofill_driver.h" |
| 16 #include "components/autofill/core/browser/autofill_external_delegate.h" | 16 #include "components/autofill/core/browser/autofill_external_delegate.h" |
| 17 #include "components/autofill/core/browser/autofill_manager.h" | 17 #include "components/autofill/core/browser/autofill_manager.h" |
| 18 #include "mojo/public/cpp/bindings/binding.h" | 18 #include "mojo/public/cpp/bindings/binding.h" |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 class NavigationHandle; | 21 class NavigationHandle; |
| 22 class RenderFrameHost; | 22 class RenderFrameHost; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace autofill { | 25 namespace autofill { |
| 26 | 26 |
| 27 class AutofillClient; | 27 class AutofillClient; |
| 28 class AutofillProvider; |
| 28 | 29 |
| 29 // Class that drives autofill flow in the browser process based on | 30 // Class that drives autofill flow in the browser process based on |
| 30 // communication from the renderer and from the external world. There is one | 31 // communication from the renderer and from the external world. There is one |
| 31 // instance per RenderFrameHost. | 32 // instance per RenderFrameHost. |
| 32 class ContentAutofillDriver : public AutofillDriver, | 33 class ContentAutofillDriver : public AutofillDriver, |
| 33 public mojom::AutofillDriver, | 34 public mojom::AutofillDriver, |
| 34 public KeyPressHandlerManager::Delegate { | 35 public KeyPressHandlerManager::Delegate { |
| 35 public: | 36 public: |
| 36 ContentAutofillDriver( | 37 ContentAutofillDriver( |
| 37 content::RenderFrameHost* render_frame_host, | 38 content::RenderFrameHost* render_frame_host, |
| 38 AutofillClient* client, | 39 AutofillClient* client, |
| 39 const std::string& app_locale, | 40 const std::string& app_locale, |
| 40 AutofillManager::AutofillDownloadManagerState enable_download_manager); | 41 AutofillManager::AutofillDownloadManagerState enable_download_manager, |
| 42 AutofillProvider* provider); |
| 41 ~ContentAutofillDriver() override; | 43 ~ContentAutofillDriver() override; |
| 42 | 44 |
| 43 // Gets the driver for |render_frame_host|. | 45 // Gets the driver for |render_frame_host|. |
| 44 static ContentAutofillDriver* GetForRenderFrameHost( | 46 static ContentAutofillDriver* GetForRenderFrameHost( |
| 45 content::RenderFrameHost* render_frame_host); | 47 content::RenderFrameHost* render_frame_host); |
| 46 | 48 |
| 47 void BindRequest(mojom::AutofillDriverRequest request); | 49 void BindRequest(mojom::AutofillDriverRequest request); |
| 48 | 50 |
| 49 // AutofillDriver: | 51 // AutofillDriver: |
| 50 bool IsIncognito() const override; | 52 bool IsIncognito() const override; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 base::TimeTicks timestamp) override; | 89 base::TimeTicks timestamp) override; |
| 88 void DidPreviewAutofillFormData() override; | 90 void DidPreviewAutofillFormData() override; |
| 89 void DidEndTextFieldEditing() override; | 91 void DidEndTextFieldEditing() override; |
| 90 void SetDataList(const std::vector<base::string16>& values, | 92 void SetDataList(const std::vector<base::string16>& values, |
| 91 const std::vector<base::string16>& labels) override; | 93 const std::vector<base::string16>& labels) override; |
| 92 | 94 |
| 93 // Called when the frame has navigated. | 95 // Called when the frame has navigated. |
| 94 void DidNavigateFrame(content::NavigationHandle* navigation_handle); | 96 void DidNavigateFrame(content::NavigationHandle* navigation_handle); |
| 95 | 97 |
| 96 AutofillExternalDelegate* autofill_external_delegate() { | 98 AutofillExternalDelegate* autofill_external_delegate() { |
| 97 return &autofill_external_delegate_; | 99 return autofill_external_delegate_.get(); |
| 98 } | 100 } |
| 99 | 101 |
| 100 AutofillManager* autofill_manager() { return autofill_manager_.get(); } | 102 AutofillManager* autofill_manager() { return autofill_manager_; } |
| 101 content::RenderFrameHost* render_frame_host() { return render_frame_host_; } | 103 content::RenderFrameHost* render_frame_host() { return render_frame_host_; } |
| 102 | 104 |
| 103 const mojom::AutofillAgentPtr& GetAutofillAgent(); | 105 const mojom::AutofillAgentPtr& GetAutofillAgent(); |
| 104 | 106 |
| 105 // Methods forwarded to key_press_handler_manager_. | 107 // Methods forwarded to key_press_handler_manager_. |
| 106 void RegisterKeyPressHandler( | 108 void RegisterKeyPressHandler( |
| 107 const content::RenderWidgetHost::KeyPressEventCallback& handler); | 109 const content::RenderWidgetHost::KeyPressEventCallback& handler); |
| 108 void RemoveKeyPressHandler(); | 110 void RemoveKeyPressHandler(); |
| 109 | 111 |
| 110 protected: | 112 protected: |
| 111 // Sets the manager to |manager| and sets |manager|'s external delegate | 113 // Sets the manager to |manager| and sets |manager|'s external delegate |
| 112 // to |autofill_external_delegate_|. Takes ownership of |manager|. | 114 // to |autofill_external_delegate_|. Takes ownership of |manager|. |
| 113 void SetAutofillManager(std::unique_ptr<AutofillManager> manager); | 115 void SetAutofillManager(std::unique_ptr<AutofillManager> manager); |
| 114 | 116 |
| 115 private: | 117 private: |
| 116 // KeyPressHandlerManager::Delegate: | 118 // KeyPressHandlerManager::Delegate: |
| 117 void AddHandler( | 119 void AddHandler( |
| 118 const content::RenderWidgetHost::KeyPressEventCallback& handler) override; | 120 const content::RenderWidgetHost::KeyPressEventCallback& handler) override; |
| 119 void RemoveHandler( | 121 void RemoveHandler( |
| 120 const content::RenderWidgetHost::KeyPressEventCallback& handler) override; | 122 const content::RenderWidgetHost::KeyPressEventCallback& handler) override; |
| 121 | 123 |
| 122 // Weak ref to the RenderFrameHost the driver is associated with. Should | 124 // Weak ref to the RenderFrameHost the driver is associated with. Should |
| 123 // always be non-NULL and valid for lifetime of |this|. | 125 // always be non-NULL and valid for lifetime of |this|. |
| 124 content::RenderFrameHost* const render_frame_host_; | 126 content::RenderFrameHost* const render_frame_host_; |
| 125 | 127 |
| 126 // AutofillManager instance via which this object drives the shared Autofill | 128 // AutofillHandler instance via which this object drives the shared Autofill |
| 127 // code. | 129 // code. |
| 128 std::unique_ptr<AutofillManager> autofill_manager_; | 130 std::unique_ptr<AutofillHandler> autofill_handler_; |
| 131 |
| 132 // The pointer to autofill_handler_ if it is AutofillManager instance. |
| 133 // TODO: unify autofill_handler_ and autofill_manager_ to a single pointer to |
| 134 // a common root. |
| 135 AutofillManager* autofill_manager_; |
| 129 | 136 |
| 130 // AutofillExternalDelegate instance that this object instantiates in the | 137 // AutofillExternalDelegate instance that this object instantiates in the |
| 131 // case where the Autofill native UI is enabled. | 138 // case where the Autofill native UI is enabled. |
| 132 AutofillExternalDelegate autofill_external_delegate_; | 139 std::unique_ptr<AutofillExternalDelegate> autofill_external_delegate_; |
| 133 | 140 |
| 134 KeyPressHandlerManager key_press_handler_manager_; | 141 KeyPressHandlerManager key_press_handler_manager_; |
| 135 | 142 |
| 136 mojo::Binding<mojom::AutofillDriver> binding_; | 143 mojo::Binding<mojom::AutofillDriver> binding_; |
| 137 | 144 |
| 138 mojom::AutofillAgentPtr autofill_agent_; | 145 mojom::AutofillAgentPtr autofill_agent_; |
| 139 }; | 146 }; |
| 140 | 147 |
| 141 } // namespace autofill | 148 } // namespace autofill |
| 142 | 149 |
| 143 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_H_ | 150 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_CONTENT_AUTOFILL_DRIVER_H_ |
| OLD | NEW |