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

Side by Side Diff: ash/common/system/toast/toast_overlay.cc

Issue 2194353002: mash: Migrate ScopedTargetRootWindow to //ash/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reflow comment Created 4 years, 4 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 #include "ash/common/system/toast/toast_overlay.h" 5 #include "ash/common/system/toast/toast_overlay.h"
6 6
7 #include "ash/common/shelf/wm_shelf.h" 7 #include "ash/common/shelf/wm_shelf.h"
8 #include "ash/common/shell_window_ids.h" 8 #include "ash/common/shell_window_ids.h"
9 #include "ash/common/wm_lookup.h" 9 #include "ash/common/wm_lookup.h"
10 #include "ash/common/wm_root_window_controller.h" 10 #include "ash/common/wm_root_window_controller.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // These values are in DIP. 49 // These values are in DIP.
50 const int kToastHorizontalSpacing = 16; 50 const int kToastHorizontalSpacing = 16;
51 const int kToastVerticalSpacing = 16; 51 const int kToastVerticalSpacing = 16;
52 const int kToastMaximumWidth = 568; 52 const int kToastMaximumWidth = 568;
53 const int kToastMinimumWidth = 288; 53 const int kToastMinimumWidth = 288;
54 54
55 // Returns the work area bounds for the root window where new windows are added 55 // Returns the work area bounds for the root window where new windows are added
56 // (including new toasts). 56 // (including new toasts).
57 gfx::Rect GetUserWorkAreaBounds() { 57 gfx::Rect GetUserWorkAreaBounds() {
58 return WmShell::Get() 58 return WmShell::Get()
59 ->GetRootWindowForNewWindows() 59 ->root_window_for_new_windows()
60 ->GetRootWindowController() 60 ->GetRootWindowController()
61 ->GetShelf() 61 ->GetShelf()
62 ->GetUserWorkAreaBounds(); 62 ->GetUserWorkAreaBounds();
63 } 63 }
64 64
65 } // anonymous namespace 65 } // anonymous namespace
66 66
67 /////////////////////////////////////////////////////////////////////////////// 67 ///////////////////////////////////////////////////////////////////////////////
68 // ToastOverlayLabel 68 // ToastOverlayLabel
69 class ToastOverlayLabel : public views::Label { 69 class ToastOverlayLabel : public views::Label {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 params.type = views::Widget::InitParams::TYPE_POPUP; 219 params.type = views::Widget::InitParams::TYPE_POPUP;
220 params.name = "ToastOverlay"; 220 params.name = "ToastOverlay";
221 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 221 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
222 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 222 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
223 params.accept_events = true; 223 params.accept_events = true;
224 params.keep_on_top = true; 224 params.keep_on_top = true;
225 params.remove_standard_frame = true; 225 params.remove_standard_frame = true;
226 params.bounds = CalculateOverlayBounds(); 226 params.bounds = CalculateOverlayBounds();
227 // Show toasts above the app list and below the lock screen. 227 // Show toasts above the app list and below the lock screen.
228 WmShell::Get() 228 WmShell::Get()
229 ->GetRootWindowForNewWindows() 229 ->root_window_for_new_windows()
230 ->GetRootWindowController() 230 ->GetRootWindowController()
231 ->ConfigureWidgetInitParamsForContainer( 231 ->ConfigureWidgetInitParamsForContainer(
232 overlay_widget_.get(), kShellWindowId_SystemModalContainer, &params); 232 overlay_widget_.get(), kShellWindowId_SystemModalContainer, &params);
233 overlay_widget_->Init(params); 233 overlay_widget_->Init(params);
234 overlay_widget_->SetVisibilityChangedAnimationsEnabled(true); 234 overlay_widget_->SetVisibilityChangedAnimationsEnabled(true);
235 overlay_widget_->SetContentsView(overlay_view_.get()); 235 overlay_widget_->SetContentsView(overlay_view_.get());
236 overlay_widget_->SetBounds(CalculateOverlayBounds()); 236 overlay_widget_->SetBounds(CalculateOverlayBounds());
237 237
238 WmWindow* overlay_window = 238 WmWindow* overlay_window =
239 WmLookup::Get()->GetWindowForWidget(overlay_widget_.get()); 239 WmLookup::Get()->GetWindowForWidget(overlay_widget_.get());
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 296
297 views::Widget* ToastOverlay::widget_for_testing() { 297 views::Widget* ToastOverlay::widget_for_testing() {
298 return overlay_widget_.get(); 298 return overlay_widget_.get();
299 } 299 }
300 300
301 void ToastOverlay::ClickDismissButtonForTesting(const ui::Event& event) { 301 void ToastOverlay::ClickDismissButtonForTesting(const ui::Event& event) {
302 overlay_view_->button()->NotifyClick(event); 302 overlay_view_->button()->NotifyClick(event);
303 } 303 }
304 304
305 } // namespace ash 305 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698