OLD | NEW |
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" |
11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
12 #include "ash/strings/grit/ash_strings.h" | 12 #include "ash/strings/grit/ash_strings.h" |
13 #include "ash/wm_window.h" | |
14 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
15 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
16 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
17 #include "third_party/skia/include/core/SkColor.h" | 16 #include "third_party/skia/include/core/SkColor.h" |
18 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
19 #include "ui/gfx/canvas.h" | 18 #include "ui/gfx/canvas.h" |
20 #include "ui/gfx/font_list.h" | 19 #include "ui/gfx/font_list.h" |
21 #include "ui/views/border.h" | 20 #include "ui/views/border.h" |
22 #include "ui/views/controls/button/label_button.h" | 21 #include "ui/views/controls/button/label_button.h" |
23 #include "ui/views/controls/label.h" | 22 #include "ui/views/controls/label.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 params.bounds = CalculateOverlayBounds(); | 216 params.bounds = CalculateOverlayBounds(); |
218 // Show toasts above the app list and below the lock screen. | 217 // Show toasts above the app list and below the lock screen. |
219 GetRootWindowController(Shell::GetRootWindowForNewWindows()) | 218 GetRootWindowController(Shell::GetRootWindowForNewWindows()) |
220 ->ConfigureWidgetInitParamsForContainer( | 219 ->ConfigureWidgetInitParamsForContainer( |
221 overlay_widget_.get(), kShellWindowId_SystemModalContainer, ¶ms); | 220 overlay_widget_.get(), kShellWindowId_SystemModalContainer, ¶ms); |
222 overlay_widget_->Init(params); | 221 overlay_widget_->Init(params); |
223 overlay_widget_->SetVisibilityChangedAnimationsEnabled(true); | 222 overlay_widget_->SetVisibilityChangedAnimationsEnabled(true); |
224 overlay_widget_->SetContentsView(overlay_view_.get()); | 223 overlay_widget_->SetContentsView(overlay_view_.get()); |
225 overlay_widget_->SetBounds(CalculateOverlayBounds()); | 224 overlay_widget_->SetBounds(CalculateOverlayBounds()); |
226 | 225 |
227 WmWindow* overlay_window = WmWindow::Get(overlay_widget_->GetNativeWindow()); | 226 aura::Window* overlay_window = overlay_widget_->GetNativeWindow(); |
228 overlay_window->SetVisibilityAnimationType( | 227 ::wm::SetWindowVisibilityAnimationType( |
229 ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL); | 228 overlay_window, ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL); |
230 overlay_window->SetVisibilityAnimationDuration( | 229 ::wm::SetWindowVisibilityAnimationDuration( |
| 230 overlay_window, |
231 base::TimeDelta::FromMilliseconds(kSlideAnimationDurationMs)); | 231 base::TimeDelta::FromMilliseconds(kSlideAnimationDurationMs)); |
232 } | 232 } |
233 | 233 |
234 ToastOverlay::~ToastOverlay() { | 234 ToastOverlay::~ToastOverlay() { |
235 overlay_widget_->Close(); | 235 overlay_widget_->Close(); |
236 } | 236 } |
237 | 237 |
238 void ToastOverlay::Show(bool visible) { | 238 void ToastOverlay::Show(bool visible) { |
239 if (overlay_widget_->GetLayer()->GetTargetVisibility() == visible) | 239 if (overlay_widget_->GetLayer()->GetTargetVisibility() == visible) |
240 return; | 240 return; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 ToastOverlayButton* ToastOverlay::dismiss_button_for_testing() { | 289 ToastOverlayButton* ToastOverlay::dismiss_button_for_testing() { |
290 return overlay_view_->button(); | 290 return overlay_view_->button(); |
291 } | 291 } |
292 | 292 |
293 void ToastOverlay::ClickDismissButtonForTesting(const ui::Event& event) { | 293 void ToastOverlay::ClickDismissButtonForTesting(const ui::Event& event) { |
294 DCHECK(overlay_view_->button()); | 294 DCHECK(overlay_view_->button()); |
295 overlay_view_->button()->NotifyClick(event); | 295 overlay_view_->button()->NotifyClick(event); |
296 } | 296 } |
297 | 297 |
298 } // namespace ash | 298 } // namespace ash |
OLD | NEW |