OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_VIEWS_DROPDOWN_BAR_HOST_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_DROPDOWN_BAR_HOST_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_DROPDOWN_BAR_HOST_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_DROPDOWN_BAR_HOST_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "content/public/browser/native_web_keyboard_event.h" | 10 #include "content/public/browser/native_web_keyboard_event.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 // dropdown_bar_host_aura.cc to draw its content and is responsible for showing, | 38 // dropdown_bar_host_aura.cc to draw its content and is responsible for showing, |
39 // hiding, animating, closing, and moving the bar if needed, for example if the | 39 // hiding, animating, closing, and moving the bar if needed, for example if the |
40 // widget is obscuring the selection results in FindBar. | 40 // widget is obscuring the selection results in FindBar. |
41 // | 41 // |
42 //////////////////////////////////////////////////////////////////////////////// | 42 //////////////////////////////////////////////////////////////////////////////// |
43 class DropdownBarHost : public ui::AcceleratorTarget, | 43 class DropdownBarHost : public ui::AcceleratorTarget, |
44 public views::FocusChangeListener, | 44 public views::FocusChangeListener, |
45 public gfx::AnimationDelegate { | 45 public gfx::AnimationDelegate { |
46 public: | 46 public: |
47 explicit DropdownBarHost(BrowserView* browser_view); | 47 explicit DropdownBarHost(BrowserView* browser_view); |
48 virtual ~DropdownBarHost(); | 48 ~DropdownBarHost() override; |
49 | 49 |
50 // Initializes the DropdownBarHost. This creates the widget that |view| paints | 50 // Initializes the DropdownBarHost. This creates the widget that |view| paints |
51 // into. | 51 // into. |
52 // |host_view| is the view whose position in the |browser_view_| view | 52 // |host_view| is the view whose position in the |browser_view_| view |
53 // hierarchy determines the z-order of the widget relative to views with | 53 // hierarchy determines the z-order of the widget relative to views with |
54 // layers and views with associated NativeViews. | 54 // layers and views with associated NativeViews. |
55 void Init(views::View* host_view, | 55 void Init(views::View* host_view, |
56 views::View* view, | 56 views::View* view, |
57 DropdownBarHostDelegate* delegate); | 57 DropdownBarHostDelegate* delegate); |
58 | 58 |
(...skipping 13 matching lines...) Expand all Loading... |
72 | 72 |
73 // Returns the rectangle representing where to position the dropdown widget. | 73 // Returns the rectangle representing where to position the dropdown widget. |
74 virtual gfx::Rect GetDialogPosition(gfx::Rect avoid_overlapping_rect) = 0; | 74 virtual gfx::Rect GetDialogPosition(gfx::Rect avoid_overlapping_rect) = 0; |
75 | 75 |
76 // Moves the widget to the provided location, moves it to top | 76 // Moves the widget to the provided location, moves it to top |
77 // in the z-order (HWND_TOP, not HWND_TOPMOST for windows) and shows | 77 // in the z-order (HWND_TOP, not HWND_TOPMOST for windows) and shows |
78 // the widget (if hidden). | 78 // the widget (if hidden). |
79 virtual void SetDialogPosition(const gfx::Rect& new_pos, bool no_redraw) = 0; | 79 virtual void SetDialogPosition(const gfx::Rect& new_pos, bool no_redraw) = 0; |
80 | 80 |
81 // Overridden from views::FocusChangeListener: | 81 // Overridden from views::FocusChangeListener: |
82 virtual void OnWillChangeFocus(views::View* focused_before, | 82 void OnWillChangeFocus(views::View* focused_before, |
83 views::View* focused_now) override; | 83 views::View* focused_now) override; |
84 virtual void OnDidChangeFocus(views::View* focused_before, | 84 void OnDidChangeFocus(views::View* focused_before, |
85 views::View* focused_now) override; | 85 views::View* focused_now) override; |
86 | 86 |
87 // Overridden from ui::AcceleratorTarget: | 87 // Overridden from ui::AcceleratorTarget: |
88 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) = 0; | 88 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) = 0; |
89 virtual bool CanHandleAccelerators() const = 0; | 89 virtual bool CanHandleAccelerators() const = 0; |
90 | 90 |
91 // gfx::AnimationDelegate implementation: | 91 // gfx::AnimationDelegate implementation: |
92 virtual void AnimationProgressed(const gfx::Animation* animation) override; | 92 void AnimationProgressed(const gfx::Animation* animation) override; |
93 virtual void AnimationEnded(const gfx::Animation* animation) override; | 93 void AnimationEnded(const gfx::Animation* animation) override; |
94 | 94 |
95 // During testing we can disable animations by setting this flag to true, | 95 // During testing we can disable animations by setting this flag to true, |
96 // so that opening and closing the dropdown bar is shown instantly, instead of | 96 // so that opening and closing the dropdown bar is shown instantly, instead of |
97 // having to poll it while it animates to open/closed status. | 97 // having to poll it while it animates to open/closed status. |
98 static bool disable_animations_during_testing_; | 98 static bool disable_animations_during_testing_; |
99 | 99 |
100 // Returns the browser view that the dropdown belongs to. | 100 // Returns the browser view that the dropdown belongs to. |
101 BrowserView* browser_view() const { return browser_view_; } | 101 BrowserView* browser_view() const { return browser_view_; } |
102 | 102 |
103 // Registers this class as the handler for when Escape is pressed. Once we | 103 // Registers this class as the handler for when Escape is pressed. Once we |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 scoped_ptr<views::Widget> host_; | 191 scoped_ptr<views::Widget> host_; |
192 | 192 |
193 // A flag to manually manage visibility. GTK/X11 is asynchronous and | 193 // A flag to manually manage visibility. GTK/X11 is asynchronous and |
194 // the state of the widget can be out of sync. | 194 // the state of the widget can be out of sync. |
195 bool is_visible_; | 195 bool is_visible_; |
196 | 196 |
197 DISALLOW_COPY_AND_ASSIGN(DropdownBarHost); | 197 DISALLOW_COPY_AND_ASSIGN(DropdownBarHost); |
198 }; | 198 }; |
199 | 199 |
200 #endif // CHROME_BROWSER_UI_VIEWS_DROPDOWN_BAR_HOST_H_ | 200 #endif // CHROME_BROWSER_UI_VIEWS_DROPDOWN_BAR_HOST_H_ |
OLD | NEW |