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

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

Issue 2886253002: mash: remove more shell/shelf WmWindow usage. (Closed)
Patch Set: Fix WmShelf::ForWindow. 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 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/system/toast/toast_overlay.h" 5 #include "ash/system/toast/toast_overlay.h"
6 6
7 #include "ash/public/cpp/ash_typography.h" 7 #include "ash/public/cpp/ash_typography.h"
8 #include "ash/public/cpp/shell_window_ids.h" 8 #include "ash/public/cpp/shell_window_ids.h"
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/shelf/wm_shelf.h" 10 #include "ash/shelf/wm_shelf.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 // These values are in DIP. 44 // These values are in DIP.
45 const int kToastHorizontalSpacing = 16; 45 const int kToastHorizontalSpacing = 16;
46 const int kToastVerticalSpacing = 16; 46 const int kToastVerticalSpacing = 16;
47 const int kToastMaximumWidth = 568; 47 const int kToastMaximumWidth = 568;
48 const int kToastMinimumWidth = 288; 48 const int kToastMinimumWidth = 288;
49 49
50 // Returns the work area bounds for the root window where new windows are added 50 // Returns the work area bounds for the root window where new windows are added
51 // (including new toasts). 51 // (including new toasts).
52 gfx::Rect GetUserWorkAreaBounds() { 52 gfx::Rect GetUserWorkAreaBounds() {
53 return WmShelf::ForWindow(Shell::GetWmRootWindowForNewWindows()) 53 return WmShelf::ForWindow(Shell::GetRootWindowForNewWindows())
54 ->GetUserWorkAreaBounds(); 54 ->GetUserWorkAreaBounds();
55 } 55 }
56 56
57 } // anonymous namespace 57 } // anonymous namespace
58 58
59 /////////////////////////////////////////////////////////////////////////////// 59 ///////////////////////////////////////////////////////////////////////////////
60 // ToastOverlayLabel 60 // ToastOverlayLabel
61 class ToastOverlayLabel : public views::Label { 61 class ToastOverlayLabel : public views::Label {
62 public: 62 public:
63 explicit ToastOverlayLabel(const base::string16& label); 63 explicit ToastOverlayLabel(const base::string16& label);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 views::Widget::InitParams params; 209 views::Widget::InitParams params;
210 params.type = views::Widget::InitParams::TYPE_POPUP; 210 params.type = views::Widget::InitParams::TYPE_POPUP;
211 params.name = "ToastOverlay"; 211 params.name = "ToastOverlay";
212 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 212 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
213 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 213 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
214 params.accept_events = true; 214 params.accept_events = true;
215 params.keep_on_top = true; 215 params.keep_on_top = true;
216 params.remove_standard_frame = true; 216 params.remove_standard_frame = true;
217 params.bounds = CalculateOverlayBounds(); 217 params.bounds = CalculateOverlayBounds();
218 // Show toasts above the app list and below the lock screen. 218 // Show toasts above the app list and below the lock screen.
219 Shell::GetWmRootWindowForNewWindows() 219 GetRootWindowController(Shell::GetRootWindowForNewWindows())
220 ->GetRootWindowController()
221 ->ConfigureWidgetInitParamsForContainer( 220 ->ConfigureWidgetInitParamsForContainer(
222 overlay_widget_.get(), kShellWindowId_SystemModalContainer, &params); 221 overlay_widget_.get(), kShellWindowId_SystemModalContainer, &params);
223 overlay_widget_->Init(params); 222 overlay_widget_->Init(params);
224 overlay_widget_->SetVisibilityChangedAnimationsEnabled(true); 223 overlay_widget_->SetVisibilityChangedAnimationsEnabled(true);
225 overlay_widget_->SetContentsView(overlay_view_.get()); 224 overlay_widget_->SetContentsView(overlay_view_.get());
226 overlay_widget_->SetBounds(CalculateOverlayBounds()); 225 overlay_widget_->SetBounds(CalculateOverlayBounds());
227 226
228 WmWindow* overlay_window = WmWindow::Get(overlay_widget_->GetNativeWindow()); 227 WmWindow* overlay_window = WmWindow::Get(overlay_widget_->GetNativeWindow());
229 overlay_window->SetVisibilityAnimationType( 228 overlay_window->SetVisibilityAnimationType(
230 ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL); 229 ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 ToastOverlayButton* ToastOverlay::dismiss_button_for_testing() { 289 ToastOverlayButton* ToastOverlay::dismiss_button_for_testing() {
291 return overlay_view_->button(); 290 return overlay_view_->button();
292 } 291 }
293 292
294 void ToastOverlay::ClickDismissButtonForTesting(const ui::Event& event) { 293 void ToastOverlay::ClickDismissButtonForTesting(const ui::Event& event) {
295 DCHECK(overlay_view_->button()); 294 DCHECK(overlay_view_->button());
296 overlay_view_->button()->NotifyClick(event); 295 overlay_view_->button()->NotifyClick(event);
297 } 296 }
298 297
299 } // namespace ash 298 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/session/logout_confirmation_dialog.cc ('k') | ash/system/tray/system_tray_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698