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

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

Issue 2901273003: chromeos: Remove TrayBubbleView::Delegate::OnBeforeBubbleWidgetInit (Closed)
Patch Set: cleanup Created 3 years, 7 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 #include "ui/views/bubble/tray_bubble_view.h" 5 #include "ui/views/bubble/tray_bubble_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "cc/paint/paint_flags.h" 10 #include "cc/paint/paint_flags.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 int max_width) 176 int max_width)
177 : anchor_alignment(anchor_alignment), 177 : anchor_alignment(anchor_alignment),
178 min_width(min_width), 178 min_width(min_width),
179 max_width(max_width), 179 max_width(max_width),
180 max_height(0), 180 max_height(0),
181 can_activate(false), 181 can_activate(false),
182 close_on_deactivate(true) {} 182 close_on_deactivate(true) {}
183 183
184 TrayBubbleView::InitParams::InitParams(const InitParams& other) = default; 184 TrayBubbleView::InitParams::InitParams(const InitParams& other) = default;
185 185
186 // static 186 TrayBubbleView::TrayBubbleView(gfx::NativeWindow parent_window,
msw 2017/05/24 18:04:38 q: Should this be passed in as init_params.parent?
James Cook 2017/05/24 18:27:04 I considered that, but decided to keep InitParams
msw 2017/05/24 18:48:36 I think it's a bit odd to have two parent params;
187 TrayBubbleView* TrayBubbleView::Create(View* anchor, 187 View* anchor,
188 Delegate* delegate,
189 InitParams* init_params) {
190 return new TrayBubbleView(anchor, delegate, *init_params);
191 }
192
193 TrayBubbleView::TrayBubbleView(View* anchor,
194 Delegate* delegate, 188 Delegate* delegate,
195 const InitParams& init_params) 189 const InitParams& init_params)
196 : BubbleDialogDelegateView(anchor, 190 : BubbleDialogDelegateView(anchor,
197 GetArrowAlignment(init_params.anchor_alignment)), 191 GetArrowAlignment(init_params.anchor_alignment)),
198 params_(init_params), 192 params_(init_params),
199 layout_(new BottomAlignedBoxLayout(this)), 193 layout_(new BottomAlignedBoxLayout(this)),
200 delegate_(delegate), 194 delegate_(delegate),
201 preferred_width_(init_params.min_width), 195 preferred_width_(init_params.min_width),
202 bubble_border_(new BubbleBorder( 196 bubble_border_(new BubbleBorder(
203 arrow(), 197 arrow(),
204 BubbleBorder::NO_ASSETS, 198 BubbleBorder::NO_ASSETS,
205 init_params.bg_color.value_or(gfx::kPlaceholderColor))), 199 init_params.bg_color.value_or(gfx::kPlaceholderColor))),
206 owned_bubble_border_(bubble_border_), 200 owned_bubble_border_(bubble_border_),
207 is_gesture_dragging_(false), 201 is_gesture_dragging_(false),
208 mouse_actively_entered_(false) { 202 mouse_actively_entered_(false) {
203 DCHECK(parent_window);
204 DCHECK(anchor_widget()); // Computed by BubbleDialogDelegateView().
209 bubble_border_->set_use_theme_background_color(!init_params.bg_color); 205 bubble_border_->set_use_theme_background_color(!init_params.bg_color);
210 bubble_border_->set_alignment(BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); 206 bubble_border_->set_alignment(BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
211 bubble_border_->set_paint_arrow(BubbleBorder::PAINT_NONE); 207 bubble_border_->set_paint_arrow(BubbleBorder::PAINT_NONE);
208 set_parent_window(parent_window);
212 set_can_activate(params_.can_activate); 209 set_can_activate(params_.can_activate);
213 DCHECK(anchor_widget()); // Computed by BubbleDialogDelegateView().
214 set_notify_enter_exit_on_child(true); 210 set_notify_enter_exit_on_child(true);
215 set_close_on_deactivate(init_params.close_on_deactivate); 211 set_close_on_deactivate(init_params.close_on_deactivate);
216 set_margins(gfx::Insets()); 212 set_margins(gfx::Insets());
217 SetPaintToLayer(); 213 SetPaintToLayer();
218 214
219 bubble_content_mask_.reset( 215 bubble_content_mask_.reset(
220 new TrayBubbleContentMask(bubble_border_->GetBorderCornerRadius())); 216 new TrayBubbleContentMask(bubble_border_->GetBorderCornerRadius()));
221 217
222 layout_->SetDefaultFlex(1); 218 layout_->SetDefaultFlex(1);
223 SetLayoutManager(layout_); 219 SetLayoutManager(layout_);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 gfx::Insets TrayBubbleView::GetBorderInsets() const { 272 gfx::Insets TrayBubbleView::GetBorderInsets() const {
277 return bubble_border_->GetInsets(); 273 return bubble_border_->GetInsets();
278 } 274 }
279 275
280 int TrayBubbleView::GetDialogButtons() const { 276 int TrayBubbleView::GetDialogButtons() const {
281 return ui::DIALOG_BUTTON_NONE; 277 return ui::DIALOG_BUTTON_NONE;
282 } 278 }
283 279
284 void TrayBubbleView::OnBeforeBubbleWidgetInit(Widget::InitParams* params, 280 void TrayBubbleView::OnBeforeBubbleWidgetInit(Widget::InitParams* params,
285 Widget* bubble_widget) const { 281 Widget* bubble_widget) const {
286 if (delegate_)
287 delegate_->OnBeforeBubbleWidgetInit(anchor_widget(), bubble_widget, params);
288 // Apply a WM-provided shadow (see ui/wm/core/). 282 // Apply a WM-provided shadow (see ui/wm/core/).
289 params->shadow_type = Widget::InitParams::SHADOW_TYPE_DROP; 283 params->shadow_type = Widget::InitParams::SHADOW_TYPE_DROP;
290 params->shadow_elevation = wm::ShadowElevation::LARGE; 284 params->shadow_elevation = wm::ShadowElevation::LARGE;
291 } 285 }
292 286
293 void TrayBubbleView::OnWidgetClosing(Widget* widget) { 287 void TrayBubbleView::OnWidgetClosing(Widget* widget) {
294 BubbleDialogDelegateView::OnWidgetClosing(widget); 288 BubbleDialogDelegateView::OnWidgetClosing(widget);
295 --g_current_tray_bubble_showing_count_; 289 --g_current_tray_bubble_showing_count_;
296 DCHECK_GE(g_current_tray_bubble_showing_count_, 0); 290 DCHECK_GE(g_current_tray_bubble_showing_count_, 0);
297 } 291 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 389
396 void TrayBubbleView::ViewHierarchyChanged( 390 void TrayBubbleView::ViewHierarchyChanged(
397 const ViewHierarchyChangedDetails& details) { 391 const ViewHierarchyChangedDetails& details) {
398 if (details.is_add && details.child == this) { 392 if (details.is_add && details.child == this) {
399 details.parent->SetPaintToLayer(); 393 details.parent->SetPaintToLayer();
400 details.parent->layer()->SetMasksToBounds(true); 394 details.parent->layer()->SetMasksToBounds(true);
401 } 395 }
402 } 396 }
403 397
404 } // namespace views 398 } // namespace views
OLDNEW
« ui/views/bubble/bubble_dialog_delegate.h ('K') | « ui/views/bubble/tray_bubble_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698