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 #include "components/autofill/content/browser/content_autofill_driver.h" | 5 #include "components/autofill/content/browser/content_autofill_driver.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
11 #include "components/autofill/content/browser/content_autofill_driver_factory.h" | 11 #include "components/autofill/content/browser/content_autofill_driver_factory.h" |
12 #include "components/autofill/core/browser/autofill_client.h" | 12 #include "components/autofill/core/browser/autofill_client.h" |
13 #include "components/autofill/core/browser/autofill_external_delegate.h" | 13 #include "components/autofill/core/browser/autofill_external_delegate.h" |
14 #include "components/autofill/core/browser/autofill_manager.h" | 14 #include "components/autofill/core/browser/autofill_manager.h" |
15 #include "components/autofill/core/browser/form_structure.h" | 15 #include "components/autofill/core/browser/form_structure.h" |
16 #include "components/autofill/core/common/autofill_switches.h" | 16 #include "components/autofill/core/common/autofill_switches.h" |
17 #include "content/public/browser/browser_context.h" | 17 #include "content/public/browser/browser_context.h" |
18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
19 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
20 #include "content/public/browser/navigation_handle.h" | 20 #include "content/public/browser/navigation_handle.h" |
21 #include "content/public/browser/render_frame_host.h" | 21 #include "content/public/browser/render_frame_host.h" |
22 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
| 23 #include "content/public/browser/render_widget_host.h" |
23 #include "content/public/browser/render_widget_host_view.h" | 24 #include "content/public/browser/render_widget_host_view.h" |
24 #include "content/public/browser/site_instance.h" | 25 #include "content/public/browser/site_instance.h" |
25 #include "content/public/browser/storage_partition.h" | 26 #include "content/public/browser/storage_partition.h" |
26 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
27 #include "services/service_manager/public/cpp/interface_provider.h" | 28 #include "services/service_manager/public/cpp/interface_provider.h" |
28 #include "ui/gfx/geometry/size_f.h" | 29 #include "ui/gfx/geometry/size_f.h" |
29 | 30 |
30 namespace autofill { | 31 namespace autofill { |
31 | 32 |
32 ContentAutofillDriver::ContentAutofillDriver( | 33 ContentAutofillDriver::ContentAutofillDriver( |
33 content::RenderFrameHost* render_frame_host, | 34 content::RenderFrameHost* render_frame_host, |
34 AutofillClient* client, | 35 AutofillClient* client, |
35 const std::string& app_locale, | 36 const std::string& app_locale, |
36 AutofillManager::AutofillDownloadManagerState enable_download_manager) | 37 AutofillManager::AutofillDownloadManagerState enable_download_manager) |
37 : render_frame_host_(render_frame_host), | 38 : render_frame_host_(render_frame_host), |
38 client_(client), | 39 client_(client), |
39 autofill_manager_(new AutofillManager(this, | 40 autofill_manager_(new AutofillManager(this, |
40 client, | 41 client, |
41 app_locale, | 42 app_locale, |
42 enable_download_manager)), | 43 enable_download_manager)), |
43 autofill_external_delegate_(autofill_manager_.get(), this), | 44 autofill_external_delegate_(autofill_manager_.get(), this), |
| 45 key_press_handler_manager_(this), |
44 binding_(this) { | 46 binding_(this) { |
45 autofill_manager_->SetExternalDelegate(&autofill_external_delegate_); | 47 autofill_manager_->SetExternalDelegate(&autofill_external_delegate_); |
46 } | 48 } |
47 | 49 |
48 ContentAutofillDriver::~ContentAutofillDriver() {} | 50 ContentAutofillDriver::~ContentAutofillDriver() {} |
49 | 51 |
50 // static | 52 // static |
51 ContentAutofillDriver* ContentAutofillDriver::GetForRenderFrameHost( | 53 ContentAutofillDriver* ContentAutofillDriver::GetForRenderFrameHost( |
52 content::RenderFrameHost* render_frame_host) { | 54 content::RenderFrameHost* render_frame_host) { |
53 ContentAutofillDriverFactory* factory = | 55 ContentAutofillDriverFactory* factory = |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 const mojom::AutofillAgentPtr& ContentAutofillDriver::GetAutofillAgent() { | 262 const mojom::AutofillAgentPtr& ContentAutofillDriver::GetAutofillAgent() { |
261 // Here is a lazy binding, and will not reconnect after connection error. | 263 // Here is a lazy binding, and will not reconnect after connection error. |
262 if (!autofill_agent_) { | 264 if (!autofill_agent_) { |
263 render_frame_host_->GetRemoteInterfaces()->GetInterface( | 265 render_frame_host_->GetRemoteInterfaces()->GetInterface( |
264 mojo::MakeRequest(&autofill_agent_)); | 266 mojo::MakeRequest(&autofill_agent_)); |
265 } | 267 } |
266 | 268 |
267 return autofill_agent_; | 269 return autofill_agent_; |
268 } | 270 } |
269 | 271 |
| 272 void ContentAutofillDriver::RegisterKeyPressHandler( |
| 273 const content::RenderWidgetHost::KeyPressEventCallback& handler) { |
| 274 key_press_handler_manager_.RegisterKeyPressHandler(handler); |
| 275 } |
| 276 |
| 277 void ContentAutofillDriver::RemoveKeyPressHandler() { |
| 278 key_press_handler_manager_.RemoveKeyPressHandler(); |
| 279 } |
| 280 |
| 281 void ContentAutofillDriver::AddHandler( |
| 282 const content::RenderWidgetHost::KeyPressEventCallback& handler) { |
| 283 content::RenderWidgetHostView* view = render_frame_host_->GetView(); |
| 284 if (!view) |
| 285 return; |
| 286 view->GetRenderWidgetHost()->AddKeyPressEventCallback(handler); |
| 287 } |
| 288 |
| 289 void ContentAutofillDriver::RemoveHandler( |
| 290 const content::RenderWidgetHost::KeyPressEventCallback& handler) { |
| 291 content::RenderWidgetHostView* view = render_frame_host_->GetView(); |
| 292 if (!view) |
| 293 return; |
| 294 view->GetRenderWidgetHost()->RemoveKeyPressEventCallback(handler); |
| 295 } |
| 296 |
270 } // namespace autofill | 297 } // namespace autofill |
OLD | NEW |