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

Side by Side Diff: chrome/browser/ui/autofill/popup_controller_common.h

Issue 2762233004: Fix autofill popup controller key press callback registration (Closed)
Patch Set: Fix typo 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 #ifndef CHROME_BROWSER_UI_AUTOFILL_POPUP_CONTROLLER_COMMON_H_ 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_POPUP_CONTROLLER_COMMON_H_
6 #define CHROME_BROWSER_UI_AUTOFILL_POPUP_CONTROLLER_COMMON_H_ 6 #define CHROME_BROWSER_UI_AUTOFILL_POPUP_CONTROLLER_COMMON_H_
7 7
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/macros.h"
10 #include "content/public/browser/render_widget_host.h"
11 #include "ui/gfx/geometry/rect_f.h" 9 #include "ui/gfx/geometry/rect_f.h"
12 #include "ui/gfx/native_widget_types.h" 10 #include "ui/gfx/native_widget_types.h"
13 11
14 namespace content {
15 class RenderViewHost;
16 class WebContents;
17 }
18
19 namespace autofill { 12 namespace autofill {
20 13
21 // Class that controls common functionality for Autofill style popups. Can 14 // A struct that holds some common data for Autofill style popups:
22 // determine the correct location of a popup of a desired size and can register 15 // the pop-up bounds, text direction and container view.
23 // a handler to key press events. 16 struct PopupControllerCommon {
24 class PopupControllerCommon {
25 public: 17 public:
26 PopupControllerCommon(const gfx::RectF& element_bounds, 18 PopupControllerCommon(const gfx::RectF& element_bounds,
27 base::i18n::TextDirection text_direction, 19 base::i18n::TextDirection text_direction,
28 gfx::NativeView container_view, 20 gfx::NativeView container_view);
29 content::WebContents* web_contents);
30 virtual ~PopupControllerCommon();
31 21
32 const gfx::RectF& element_bounds() const { return element_bounds_; } 22 ~PopupControllerCommon();
33 bool is_rtl() const { return text_direction_ == base::i18n::RIGHT_TO_LEFT; }
34 gfx::NativeView container_view() { return container_view_; }
35 content::WebContents* web_contents() { return web_contents_; }
36 23
37 // Callback used to register with RenderViewHost. This can only be set once,
38 // or else a callback may be registered that will not be removed
39 // (crbug.com/338070). Call will crash if callback is already set.
40 void SetKeyPressCallback(content::RenderWidgetHost::KeyPressEventCallback);
41
42 // Register listener for key press events with the current RenderViewHost
43 // associated with |web_contents_|. If callback has already been registered,
44 // this has no effect.
45 void RegisterKeyPressCallback();
46
47 // Remove previously registered callback, assuming that the current
48 // RenderViewHost is the same as when it was originally registered. Safe to
49 // call even if the callback is not currently registered.
50 void RemoveKeyPressCallback();
51
52 private:
53 // The bounds of the text element that is the focus of the popup. 24 // The bounds of the text element that is the focus of the popup.
54 // These coordinates are in screen space. 25 // These coordinates are in screen space.
55 gfx::RectF element_bounds_; 26 gfx::RectF element_bounds;
56 27
57 // The direction of the <input>. 28 // The direction of the <input>.
58 base::i18n::TextDirection text_direction_; 29 base::i18n::TextDirection text_direction;
59 30
60 // Weak reference 31 // Weak reference
61 gfx::NativeView container_view_; 32 gfx::NativeView container_view;
62
63 // The WebContents in which this object should listen for keyboard events
64 // while showing the popup. Can be NULL, in which case this object will not
65 // listen for keyboard events.
66 content::WebContents* web_contents_;
67
68 // The RenderViewHost that this object has registered its keyboard press
69 // callback with.
70 content::RenderViewHost* key_press_event_target_;
71
72 content::RenderWidgetHost::KeyPressEventCallback key_press_event_callback_;
73
74 DISALLOW_COPY_AND_ASSIGN(PopupControllerCommon);
75 }; 33 };
76 34
77 } // namespace autofill 35 } // namespace autofill
78 36
79 #endif // CHROME_BROWSER_UI_AUTOFILL_POPUP_CONTROLLER_COMMON_H_ 37 #endif // CHROME_BROWSER_UI_AUTOFILL_POPUP_CONTROLLER_COMMON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698