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

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

Issue 2897553002: Do not activate TrayBubbleView by default (Closed)
Patch Set: Remove unnecessary code. 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();
75 InitParams(const InitParams& other); 94 InitParams(const InitParams& other);
76 Delegate* delegate = nullptr; 95 Delegate* delegate = nullptr;
77 gfx::NativeWindow parent_window = nullptr; 96 gfx::NativeWindow parent_window = nullptr;
78 View* anchor_view = nullptr; 97 View* anchor_view = nullptr;
79 AnchorAlignment anchor_alignment = ANCHOR_ALIGNMENT_BOTTOM; 98 AnchorAlignment anchor_alignment = ANCHOR_ALIGNMENT_BOTTOM;
80 int min_width = 0; 99 int min_width = 0;
81 int max_width = 0; 100 int max_width = 0;
82 int max_height = 0; 101 int max_height = 0;
83 bool can_activate = false;
84 bool close_on_deactivate = true; 102 bool close_on_deactivate = true;
85 // If not provided, the bg color will be derived from the NativeTheme. 103 // If not provided, the bg color will be derived from the NativeTheme.
86 base::Optional<SkColor> bg_color; 104 base::Optional<SkColor> bg_color;
87 }; 105 };
88 106
89 explicit TrayBubbleView(const InitParams& init_params); 107 explicit TrayBubbleView(const InitParams& init_params);
90 ~TrayBubbleView() override; 108 ~TrayBubbleView() override;
91 109
92 // Returns whether a tray bubble is active. 110 // Returns whether a tray bubble is active.
93 static bool IsATrayBubbleOpen(); 111 static bool IsATrayBubbleOpen();
(...skipping 10 matching lines...) Expand all
104 122
105 // Sets the bottom padding that child views will be laid out within. 123 // Sets the bottom padding that child views will be laid out within.
106 void SetBottomPadding(int padding); 124 void SetBottomPadding(int padding);
107 125
108 // Sets the bubble width. 126 // Sets the bubble width.
109 void SetWidth(int width); 127 void SetWidth(int width);
110 128
111 // Returns the border insets. Called by TrayEventFilter. 129 // Returns the border insets. Called by TrayEventFilter.
112 gfx::Insets GetBorderInsets() const; 130 gfx::Insets GetBorderInsets() const;
113 131
114 // Called when the delegate is destroyed. 132 // Called when the delegate is destroyed. This must be called before the
115 void reset_delegate() { delegate_ = NULL; } 133 // delegate is actually destroyed. TrayBubbleView will do clean up in
134 // ResetDelegate.
135 void ResetDelegate();
116 136
117 Delegate* delegate() { return delegate_; } 137 Delegate* delegate() { return delegate_; }
118 138
119 void set_gesture_dragging(bool dragging) { is_gesture_dragging_ = dragging; } 139 void set_gesture_dragging(bool dragging) { is_gesture_dragging_ = dragging; }
120 bool is_gesture_dragging() const { return is_gesture_dragging_; } 140 bool is_gesture_dragging() const { return is_gesture_dragging_; }
121 141
122 // Overridden from views::WidgetDelegate. 142 // Overridden from views::WidgetDelegate.
123 views::NonClientFrameView* CreateNonClientFrameView( 143 views::NonClientFrameView* CreateNonClientFrameView(
124 views::Widget* widget) override; 144 views::Widget* widget) override;
125 bool WidgetHasHitTestMask() const override; 145 bool WidgetHasHitTestMask() const override;
126 void GetWidgetHitTestMask(gfx::Path* mask) const override; 146 void GetWidgetHitTestMask(gfx::Path* mask) const override;
127 base::string16 GetAccessibleWindowTitle() const override; 147 base::string16 GetAccessibleWindowTitle() const override;
128 148
129 // Overridden from views::BubbleDialogDelegateView. 149 // Overridden from views::BubbleDialogDelegateView.
130 void OnBeforeBubbleWidgetInit(Widget::InitParams* params, 150 void OnBeforeBubbleWidgetInit(Widget::InitParams* params,
131 Widget* bubble_widget) const override; 151 Widget* bubble_widget) const override;
132 void OnWidgetClosing(Widget* widget) override; 152 void OnWidgetClosing(Widget* widget) override;
133 153
134 // Overridden from views::View. 154 // Overridden from views::View.
135 gfx::Size CalculatePreferredSize() const override; 155 gfx::Size CalculatePreferredSize() const override;
136 gfx::Size GetMaximumSize() const override; 156 gfx::Size GetMaximumSize() const override;
137 int GetHeightForWidth(int width) const override; 157 int GetHeightForWidth(int width) const override;
138 void OnMouseEntered(const ui::MouseEvent& event) override; 158 void OnMouseEntered(const ui::MouseEvent& event) override;
139 void OnMouseExited(const ui::MouseEvent& event) override; 159 void OnMouseExited(const ui::MouseEvent& event) override;
140 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; 160 void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
141 161
142 // Overridden from MouseWatcherListener 162 // Overridden from MouseWatcherListener
143 void MouseMovedOutOfHost() override; 163 void MouseMovedOutOfHost() override;
144 164
165 // Overridden from ui::AcceleratorTarget
166 bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
167
145 protected: 168 protected:
146 // Overridden from views::BubbleDialogDelegateView. 169 // Overridden from views::BubbleDialogDelegateView.
147 int GetDialogButtons() const override; 170 int GetDialogButtons() const override;
148 171
149 // Overridden from views::View. 172 // Overridden from views::View.
150 void ChildPreferredSizeChanged(View* child) override; 173 void ChildPreferredSizeChanged(View* child) override;
151 void ViewHierarchyChanged( 174 void ViewHierarchyChanged(
152 const ViewHierarchyChangedDetails& details) override; 175 const ViewHierarchyChangedDetails& details) override;
153 176
154 private: 177 private:
178 void CloseBubbleView();
179 void ActivateAndStartNavigation(const ui::KeyEvent& key_event);
180
181 // Focus the default item if no item is focused.
182 void FocusDefaultIfNeeded();
183
155 InitParams params_; 184 InitParams params_;
156 BoxLayout* layout_; 185 BoxLayout* layout_;
157 Delegate* delegate_; 186 Delegate* delegate_;
158 int preferred_width_; 187 int preferred_width_;
159 // |bubble_border_| and |owned_bubble_border_| point to the same thing, but 188 // |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. 189 // the latter ensures we don't leak it before passing off ownership.
161 BubbleBorder* bubble_border_; 190 BubbleBorder* bubble_border_;
162 std::unique_ptr<views::BubbleBorder> owned_bubble_border_; 191 std::unique_ptr<views::BubbleBorder> owned_bubble_border_;
163 std::unique_ptr<internal::TrayBubbleContentMask> bubble_content_mask_; 192 std::unique_ptr<internal::TrayBubbleContentMask> bubble_content_mask_;
164 bool is_gesture_dragging_; 193 bool is_gesture_dragging_;
165 194
166 // True once the mouse cursor was actively moved by the user over the bubble. 195 // 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. 196 // Only then the OnMouseExitedView() event will get passed on to listeners.
168 bool mouse_actively_entered_; 197 bool mouse_actively_entered_;
169 198
170 // Used to find any mouse movements. 199 // Used to find any mouse movements.
171 std::unique_ptr<MouseWatcher> mouse_watcher_; 200 std::unique_ptr<MouseWatcher> mouse_watcher_;
172 201
173 DISALLOW_COPY_AND_ASSIGN(TrayBubbleView); 202 DISALLOW_COPY_AND_ASSIGN(TrayBubbleView);
174 }; 203 };
175 204
176 } // namespace views 205 } // namespace views
177 206
178 #endif // UI_VIEWS_BUBBLE_TRAY_BUBBLE_VIEW_H_ 207 #endif // UI_VIEWS_BUBBLE_TRAY_BUBBLE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698