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

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

Issue 1759453002: Convert location bar bubble delegates to bubble dialog delegates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile errs Created 4 years, 9 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_BUBBLE_DIALOG_DELEGATE_H_ 5 #ifndef UI_VIEWS_BUBBLE_BUBBLE_DIALOG_DELEGATE_H_
6 #define UI_VIEWS_BUBBLE_BUBBLE_DIALOG_DELEGATE_H_ 6 #define UI_VIEWS_BUBBLE_BUBBLE_DIALOG_DELEGATE_H_
7 7
8 #include "base/gtest_prod_util.h" 8 #include "base/gtest_prod_util.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "ui/views/bubble/bubble_border.h" 10 #include "ui/views/bubble/bubble_border.h"
(...skipping 12 matching lines...) Expand all
23 23
24 // BubbleDialogDelegateView is a special DialogDelegateView for bubbles. 24 // BubbleDialogDelegateView is a special DialogDelegateView for bubbles.
25 class VIEWS_EXPORT BubbleDialogDelegateView : public DialogDelegateView, 25 class VIEWS_EXPORT BubbleDialogDelegateView : public DialogDelegateView,
26 public WidgetObserver { 26 public WidgetObserver {
27 public: 27 public:
28 // Internal class name. 28 // Internal class name.
29 static const char kViewClassName[]; 29 static const char kViewClassName[];
30 30
31 enum class CloseReason { 31 enum class CloseReason {
32 DEACTIVATION, 32 DEACTIVATION,
33 ESCAPE,
34 CLOSE_BUTTON, 33 CLOSE_BUTTON,
35 UNKNOWN, 34 UNKNOWN,
36 }; 35 };
37 36
38 ~BubbleDialogDelegateView() override; 37 ~BubbleDialogDelegateView() override;
39 38
40 // Create and initialize the bubble Widget(s) with proper bounds. 39 // Create and initialize the bubble Widget(s) with proper bounds.
41 static Widget* CreateBubble(BubbleDialogDelegateView* bubble_delegate); 40 static Widget* CreateBubble(BubbleDialogDelegateView* bubble_delegate);
42 41
43 // WidgetDelegateView overrides: 42 // WidgetDelegateView overrides:
44 bool ShouldShowCloseButton() const override; 43 bool ShouldShowCloseButton() const override;
45 ClientView* CreateClientView(Widget* widget) override; 44 ClientView* CreateClientView(Widget* widget) override;
46 NonClientFrameView* CreateNonClientFrameView(Widget* widget) override; 45 NonClientFrameView* CreateNonClientFrameView(Widget* widget) override;
47 void GetAccessibleState(ui::AXViewState* state) override; 46 void GetAccessibleState(ui::AXViewState* state) override;
48 const char* GetClassName() const override; 47 const char* GetClassName() const override;
49 48
50 // WidgetObserver overrides: 49 // WidgetObserver overrides:
51 void OnWidgetClosing(Widget* widget) override; 50 void OnWidgetClosing(Widget* widget) override;
52 void OnWidgetDestroying(Widget* widget) override; 51 void OnWidgetDestroying(Widget* widget) override;
53 void OnWidgetVisibilityChanging(Widget* widget, bool visible) override; 52 void OnWidgetVisibilityChanging(Widget* widget, bool visible) override;
54 void OnWidgetVisibilityChanged(Widget* widget, bool visible) override; 53 void OnWidgetVisibilityChanged(Widget* widget, bool visible) override;
55 void OnWidgetActivationChanged(Widget* widget, bool active) override; 54 void OnWidgetActivationChanged(Widget* widget, bool active) override;
56 void OnWidgetBoundsChanged(Widget* widget, 55 void OnWidgetBoundsChanged(Widget* widget,
57 const gfx::Rect& new_bounds) override; 56 const gfx::Rect& new_bounds) override;
58 57
59 bool close_on_esc() const { return close_on_esc_; }
60 void set_close_on_esc(bool close_on_esc) { close_on_esc_ = close_on_esc; }
61
62 bool close_on_deactivate() const { return close_on_deactivate_; } 58 bool close_on_deactivate() const { return close_on_deactivate_; }
63 void set_close_on_deactivate(bool close) { close_on_deactivate_ = close; } 59 void set_close_on_deactivate(bool close) { close_on_deactivate_ = close; }
64 60
65 View* GetAnchorView() const; 61 View* GetAnchorView() const;
66 Widget* anchor_widget() const { return anchor_widget_; } 62 Widget* anchor_widget() const { return anchor_widget_; }
67 63
68 // The anchor rect is used in the absence of an assigned anchor view. 64 // The anchor rect is used in the absence of an assigned anchor view.
69 const gfx::Rect& anchor_rect() const { return anchor_rect_; } 65 const gfx::Rect& anchor_rect() const { return anchor_rect_; }
70 66
71 BubbleBorder::Arrow arrow() const { return arrow_; } 67 BubbleBorder::Arrow arrow() const { return arrow_; }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 BubbleDialogDelegateView(View* anchor_view, BubbleBorder::Arrow arrow); 123 BubbleDialogDelegateView(View* anchor_view, BubbleBorder::Arrow arrow);
128 124
129 // Get bubble bounds from the anchor rect and client view's preferred size. 125 // Get bubble bounds from the anchor rect and client view's preferred size.
130 virtual gfx::Rect GetBubbleBounds(); 126 virtual gfx::Rect GetBubbleBounds();
131 127
132 // Return a FontList to use for the title of the bubble. 128 // Return a FontList to use for the title of the bubble.
133 // (The default is MediumFont). 129 // (The default is MediumFont).
134 virtual const gfx::FontList& GetTitleFontList() const; 130 virtual const gfx::FontList& GetTitleFontList() const;
135 131
136 // View overrides: 132 // View overrides:
137 bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
138 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; 133 void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
139 134
140 // Perform view initialization on the contents for bubble sizing. 135 // Perform view initialization on the contents for bubble sizing.
141 virtual void Init(); 136 virtual void Init();
142 137
143 // Sets the anchor view or rect and repositions the bubble. Note that if a 138 // Sets the anchor view or rect and repositions the bubble. Note that if a
144 // valid view gets passed, the anchor rect will get ignored. If the view gets 139 // valid view gets passed, the anchor rect will get ignored. If the view gets
145 // deleted, but no new view gets set, the last known anchor postion will get 140 // deleted, but no new view gets set, the last known anchor postion will get
146 // returned. 141 // returned.
147 void SetAnchorView(View* anchor_view); 142 void SetAnchorView(View* anchor_view);
(...skipping 10 matching lines...) Expand all
158 153
159 FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, CreateDelegate); 154 FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, CreateDelegate);
160 FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, NonClientHitTest); 155 FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, NonClientHitTest);
161 156
162 // Update the bubble color from |theme|, unless it was explicitly set. 157 // Update the bubble color from |theme|, unless it was explicitly set.
163 void UpdateColorsFromTheme(const ui::NativeTheme* theme); 158 void UpdateColorsFromTheme(const ui::NativeTheme* theme);
164 159
165 // Handles widget visibility changes. 160 // Handles widget visibility changes.
166 void HandleVisibilityChanged(Widget* widget, bool visible); 161 void HandleVisibilityChanged(Widget* widget, bool visible);
167 162
168 // Flags controlling bubble closure on the escape key and deactivation. 163 // A flag controlling bubble closure on deactivation.
169 bool close_on_esc_;
170 bool close_on_deactivate_; 164 bool close_on_deactivate_;
171 165
172 // The view and widget to which this bubble is anchored. Since an anchor view 166 // The view and widget to which this bubble is anchored. Since an anchor view
173 // can be deleted without notice, we store it in the ViewStorage and retrieve 167 // can be deleted without notice, we store it in the ViewStorage and retrieve
174 // it from there. It will make sure that the view is still valid. 168 // it from there. It will make sure that the view is still valid.
175 const int anchor_view_storage_id_; 169 const int anchor_view_storage_id_;
176 Widget* anchor_widget_; 170 Widget* anchor_widget_;
177 171
178 // The anchor rect used in the absence of an anchor view. 172 // The anchor rect used in the absence of an anchor view.
179 mutable gfx::Rect anchor_rect_; 173 mutable gfx::Rect anchor_rect_;
(...skipping 26 matching lines...) Expand all
206 gfx::NativeView parent_window_; 200 gfx::NativeView parent_window_;
207 201
208 CloseReason close_reason_; 202 CloseReason close_reason_;
209 203
210 DISALLOW_COPY_AND_ASSIGN(BubbleDialogDelegateView); 204 DISALLOW_COPY_AND_ASSIGN(BubbleDialogDelegateView);
211 }; 205 };
212 206
213 } // namespace views 207 } // namespace views
214 208
215 #endif // UI_VIEWS_BUBBLE_BUBBLE_DELEGATE2_H_ 209 #endif // UI_VIEWS_BUBBLE_BUBBLE_DELEGATE2_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698