Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: components/autofill/content/browser/content_autofill_driver.cc

Issue 2805173003: Fix autofill popup controller key press callback registration (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 const mojom::AutofillAgentPtr& ContentAutofillDriver::GetAutofillAgent() { 260 const mojom::AutofillAgentPtr& ContentAutofillDriver::GetAutofillAgent() {
259 // Here is a lazy binding, and will not reconnect after connection error. 261 // Here is a lazy binding, and will not reconnect after connection error.
260 if (!autofill_agent_) { 262 if (!autofill_agent_) {
261 render_frame_host_->GetRemoteInterfaces()->GetInterface( 263 render_frame_host_->GetRemoteInterfaces()->GetInterface(
262 mojo::MakeRequest(&autofill_agent_)); 264 mojo::MakeRequest(&autofill_agent_));
263 } 265 }
264 266
265 return autofill_agent_; 267 return autofill_agent_;
266 } 268 }
267 269
270 void ContentAutofillDriver::RegisterKeyPressHandler(
271 const content::RenderWidgetHost::KeyPressEventCallback& handler) {
272 key_press_handler_manager_.RegisterKeyPressHandler(handler);
273 }
274
275 void ContentAutofillDriver::RemoveKeyPressHandler() {
276 key_press_handler_manager_.RemoveKeyPressHandler();
277 }
278
279 void ContentAutofillDriver::AddHandler(
280 const content::RenderWidgetHost::KeyPressEventCallback& handler) {
281 content::RenderWidgetHostView* view = render_frame_host_->GetView();
282 if (!view)
283 return;
284 view->GetRenderWidgetHost()->AddKeyPressEventCallback(handler);
285 }
286
287 void ContentAutofillDriver::RemoveHandler(
288 const content::RenderWidgetHost::KeyPressEventCallback& handler) {
289 content::RenderWidgetHostView* view = render_frame_host_->GetView();
290 if (!view)
291 return;
292 view->GetRenderWidgetHost()->RemoveKeyPressEventCallback(handler);
293 }
294
268 } // namespace autofill 295 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698