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

Side by Side Diff: ui/views/bubble/tray_bubble_view.h

Issue 2897553002: Do not activate TrayBubbleView by default (Closed)
Patch Set: Add comment. Created 3 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 UI_VIEWS_BUBBLE_TRAY_BUBBLE_VIEW_H_ 5 #ifndef UI_VIEWS_BUBBLE_TRAY_BUBBLE_VIEW_H_
6 #define UI_VIEWS_BUBBLE_TRAY_BUBBLE_VIEW_H_ 6 #define UI_VIEWS_BUBBLE_TRAY_BUBBLE_VIEW_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/optional.h" 11 #include "base/optional.h"
12 #include "ui/base/accelerators/accelerator.h"
13 #include "ui/events/event.h"
12 #include "ui/gfx/native_widget_types.h" 14 #include "ui/gfx/native_widget_types.h"
13 #include "ui/views/bubble/bubble_dialog_delegate.h" 15 #include "ui/views/bubble/bubble_dialog_delegate.h"
14 #include "ui/views/mouse_watcher.h" 16 #include "ui/views/mouse_watcher.h"
15 #include "ui/views/views_export.h" 17 #include "ui/views/views_export.h"
16 18
17 namespace views { 19 namespace views {
18 class BoxLayout; 20 class BoxLayout;
19 class View; 21 class View;
20 class Widget; 22 class Widget;
21 } 23 }
(...skipping 29 matching lines...) Expand all
51 // Called when the view is destroyed. Any pointers to the view should be 53 // Called when the view is destroyed. Any pointers to the view should be
52 // cleared when this gets called. 54 // cleared when this gets called.
53 virtual void BubbleViewDestroyed() = 0; 55 virtual void BubbleViewDestroyed() = 0;
54 56
55 // Called when the mouse enters/exits the view. 57 // Called when the mouse enters/exits the view.
56 // Note: This event will only be called if the mouse gets actively moved by 58 // Note: This event will only be called if the mouse gets actively moved by
57 // the user to enter the view. 59 // the user to enter the view.
58 virtual void OnMouseEnteredView() = 0; 60 virtual void OnMouseEnteredView() = 0;
59 virtual void OnMouseExitedView() = 0; 61 virtual void OnMouseExitedView() = 0;
60 62
63 // Called to register/unregister accelerators for TrayBubbleView.
64 // TrayBubbleView wants to register those accelerators at the global level.
65 // Those accelerators are used to activate TrayBubbleView, i.e. those
66 // accelerators need to be processed even if TrayBubbleView is not active.
67 // UnregisterAllAccelerators can be called even if RegisterAccelerators is
68 // not called.
69 virtual void RegisterAccelerators(
70 const std::vector<ui::Accelerator>& accelerators,
71 TrayBubbleView* tray_bubble_view) = 0;
72 virtual void UnregisterAllAccelerators(
73 TrayBubbleView* tray_bubble_view) = 0;
74
61 // Called from GetAccessibleNodeData(); should return the appropriate 75 // Called from GetAccessibleNodeData(); should return the appropriate
62 // accessible name for the bubble. 76 // accessible name for the bubble.
63 virtual base::string16 GetAccessibleNameForBubble() = 0; 77 virtual base::string16 GetAccessibleNameForBubble() = 0;
64 78
79 // Should return true if extra keyboard accessibility is enabled.
80 // TrayBubbleView will put focus on the default item if extra keyboard
81 // accessibility is enabled.
82 virtual bool ShouldEnableExtraKeyboardAccessibility() = 0;
83
65 // Called when a bubble wants to hide/destroy itself (e.g. last visible 84 // Called when a bubble wants to hide/destroy itself (e.g. last visible
66 // child view was closed). 85 // child view was closed).
67 virtual void HideBubble(const TrayBubbleView* bubble_view) = 0; 86 virtual void HideBubble(const TrayBubbleView* bubble_view) = 0;
68 87
69 private: 88 private:
70 DISALLOW_COPY_AND_ASSIGN(Delegate); 89 DISALLOW_COPY_AND_ASSIGN(Delegate);
71 }; 90 };
72 91
73 struct VIEWS_EXPORT InitParams { 92 struct VIEWS_EXPORT InitParams {
74 InitParams(); 93 InitParams();
(...skipping 26 matching lines...) Expand all
101 120
102 // Sets the maximum bubble height and resizes the bubble. 121 // Sets the maximum bubble height and resizes the bubble.
103 void SetMaxHeight(int height); 122 void SetMaxHeight(int height);
104 123
105 // Sets the bottom padding that child views will be laid out within. 124 // Sets the bottom padding that child views will be laid out within.
106 void SetBottomPadding(int padding); 125 void SetBottomPadding(int padding);
107 126
108 // Sets the bubble width. 127 // Sets the bubble width.
109 void SetWidth(int width); 128 void SetWidth(int width);
110 129
130 // Focus the default item if no item is focused.
131 void FocusDefaultIfNeeded();
132
111 // Returns the border insets. Called by TrayEventFilter. 133 // Returns the border insets. Called by TrayEventFilter.
112 gfx::Insets GetBorderInsets() const; 134 gfx::Insets GetBorderInsets() const;
113 135
114 // Called when the delegate is destroyed. 136 // Called when the delegate is destroyed. This must be called before the
115 void reset_delegate() { delegate_ = NULL; } 137 // delegate is actually destroyed. TrayBubbleView will do clean up in
138 // ResetDelegate.
139 void ResetDelegate();
116 140
117 Delegate* delegate() { return delegate_; } 141 Delegate* delegate() { return delegate_; }
118 142
119 void set_gesture_dragging(bool dragging) { is_gesture_dragging_ = dragging; } 143 void set_gesture_dragging(bool dragging) { is_gesture_dragging_ = dragging; }
120 bool is_gesture_dragging() const { return is_gesture_dragging_; } 144 bool is_gesture_dragging() const { return is_gesture_dragging_; }
121 145
122 // Overridden from views::WidgetDelegate. 146 // Overridden from views::WidgetDelegate.
123 views::NonClientFrameView* CreateNonClientFrameView( 147 views::NonClientFrameView* CreateNonClientFrameView(
124 views::Widget* widget) override; 148 views::Widget* widget) override;
125 bool WidgetHasHitTestMask() const override; 149 bool WidgetHasHitTestMask() const override;
126 void GetWidgetHitTestMask(gfx::Path* mask) const override; 150 void GetWidgetHitTestMask(gfx::Path* mask) const override;
127 base::string16 GetAccessibleWindowTitle() const override; 151 base::string16 GetAccessibleWindowTitle() const override;
128 152
129 // Overridden from views::BubbleDialogDelegateView. 153 // Overridden from views::BubbleDialogDelegateView.
130 void OnBeforeBubbleWidgetInit(Widget::InitParams* params, 154 void OnBeforeBubbleWidgetInit(Widget::InitParams* params,
131 Widget* bubble_widget) const override; 155 Widget* bubble_widget) const override;
132 void OnWidgetClosing(Widget* widget) override; 156 void OnWidgetClosing(Widget* widget) override;
133 157
134 // Overridden from views::View. 158 // Overridden from views::View.
135 gfx::Size CalculatePreferredSize() const override; 159 gfx::Size CalculatePreferredSize() const override;
136 gfx::Size GetMaximumSize() const override; 160 gfx::Size GetMaximumSize() const override;
137 int GetHeightForWidth(int width) const override; 161 int GetHeightForWidth(int width) const override;
138 void OnMouseEntered(const ui::MouseEvent& event) override; 162 void OnMouseEntered(const ui::MouseEvent& event) override;
139 void OnMouseExited(const ui::MouseEvent& event) override; 163 void OnMouseExited(const ui::MouseEvent& event) override;
140 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; 164 void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
141 165
142 // Overridden from MouseWatcherListener 166 // Overridden from MouseWatcherListener
143 void MouseMovedOutOfHost() override; 167 void MouseMovedOutOfHost() override;
144 168
169 // Overridden from ui::AcceleratorTarget
170 bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
171
145 protected: 172 protected:
146 // Overridden from views::BubbleDialogDelegateView. 173 // Overridden from views::BubbleDialogDelegateView.
147 int GetDialogButtons() const override; 174 int GetDialogButtons() const override;
148 175
149 // Overridden from views::View. 176 // Overridden from views::View.
150 void ChildPreferredSizeChanged(View* child) override; 177 void ChildPreferredSizeChanged(View* child) override;
151 void ViewHierarchyChanged( 178 void ViewHierarchyChanged(
152 const ViewHierarchyChangedDetails& details) override; 179 const ViewHierarchyChangedDetails& details) override;
153 180
154 private: 181 private:
182 void CloseBubbleView();
183 void ActivateAndStartNavigation(const ui::KeyEvent& key_event);
184
155 InitParams params_; 185 InitParams params_;
156 BoxLayout* layout_; 186 BoxLayout* layout_;
157 Delegate* delegate_; 187 Delegate* delegate_;
158 int preferred_width_; 188 int preferred_width_;
159 // |bubble_border_| and |owned_bubble_border_| point to the same thing, but 189 // |bubble_border_| and |owned_bubble_border_| point to the same thing, but
160 // the latter ensures we don't leak it before passing off ownership. 190 // the latter ensures we don't leak it before passing off ownership.
161 BubbleBorder* bubble_border_; 191 BubbleBorder* bubble_border_;
162 std::unique_ptr<views::BubbleBorder> owned_bubble_border_; 192 std::unique_ptr<views::BubbleBorder> owned_bubble_border_;
163 std::unique_ptr<internal::TrayBubbleContentMask> bubble_content_mask_; 193 std::unique_ptr<internal::TrayBubbleContentMask> bubble_content_mask_;
164 bool is_gesture_dragging_; 194 bool is_gesture_dragging_;
165 195
166 // True once the mouse cursor was actively moved by the user over the bubble. 196 // True once the mouse cursor was actively moved by the user over the bubble.
167 // Only then the OnMouseExitedView() event will get passed on to listeners. 197 // Only then the OnMouseExitedView() event will get passed on to listeners.
168 bool mouse_actively_entered_; 198 bool mouse_actively_entered_;
169 199
170 // Used to find any mouse movements. 200 // Used to find any mouse movements.
171 std::unique_ptr<MouseWatcher> mouse_watcher_; 201 std::unique_ptr<MouseWatcher> mouse_watcher_;
172 202
173 DISALLOW_COPY_AND_ASSIGN(TrayBubbleView); 203 DISALLOW_COPY_AND_ASSIGN(TrayBubbleView);
174 }; 204 };
175 205
176 } // namespace views 206 } // namespace views
177 207
178 #endif // UI_VIEWS_BUBBLE_TRAY_BUBBLE_VIEW_H_ 208 #endif // UI_VIEWS_BUBBLE_TRAY_BUBBLE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698