| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/message_center/views/toast_contents_view.h" | 5 #include "ui/message_center/views/toast_contents_view.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 return; | 271 return; |
| 272 | 272 |
| 273 gfx::NativeView native_view = widget->GetNativeView(); | 273 gfx::NativeView native_view = widget->GetNativeView(); |
| 274 if (!native_view || !collection_.get()) | 274 if (!native_view || !collection_.get()) |
| 275 return; | 275 return; |
| 276 | 276 |
| 277 collection_->OnDisplayMetricsChanged( | 277 collection_->OnDisplayMetricsChanged( |
| 278 Screen::GetScreen()->GetDisplayNearestWindow(native_view)); | 278 Screen::GetScreen()->GetDisplayNearestWindow(native_view)); |
| 279 } | 279 } |
| 280 | 280 |
| 281 void ToastContentsView::OnWidgetActivationChanged(views::Widget* widget, |
| 282 bool active) { |
| 283 if (active) |
| 284 collection_->PausePopupTimers(); |
| 285 else |
| 286 collection_->RestartPopupTimers(); |
| 287 } |
| 288 |
| 281 // views::View | 289 // views::View |
| 282 void ToastContentsView::OnMouseEntered(const ui::MouseEvent& event) { | 290 void ToastContentsView::OnMouseEntered(const ui::MouseEvent& event) { |
| 283 if (collection_) | 291 if (collection_) |
| 284 collection_->OnMouseEntered(this); | 292 collection_->OnMouseEntered(this); |
| 285 } | 293 } |
| 286 | 294 |
| 287 void ToastContentsView::OnMouseExited(const ui::MouseEvent& event) { | 295 void ToastContentsView::OnMouseExited(const ui::MouseEvent& event) { |
| 288 if (collection_) | 296 if (collection_) |
| 289 collection_->OnMouseExited(this); | 297 collection_->OnMouseExited(this); |
| 290 } | 298 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 params.keep_on_top = true; | 390 params.keep_on_top = true; |
| 383 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 391 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 384 params.opacity = views::Widget::InitParams::OPAQUE_WINDOW; | 392 params.opacity = views::Widget::InitParams::OPAQUE_WINDOW; |
| 385 #else | 393 #else |
| 386 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 394 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 387 #endif | 395 #endif |
| 388 params.delegate = this; | 396 params.delegate = this; |
| 389 views::Widget* widget = new views::Widget(); | 397 views::Widget* widget = new views::Widget(); |
| 390 alignment_delegate->ConfigureWidgetInitParamsForContainer(widget, ¶ms); | 398 alignment_delegate->ConfigureWidgetInitParamsForContainer(widget, ¶ms); |
| 391 widget->set_focus_on_creation(false); | 399 widget->set_focus_on_creation(false); |
| 400 widget->AddObserver(this); |
| 392 | 401 |
| 393 #if defined(OS_WIN) | 402 #if defined(OS_WIN) |
| 394 // We want to ensure that this toast always goes to the native desktop, | 403 // We want to ensure that this toast always goes to the native desktop, |
| 395 // not the Ash desktop (since there is already another toast contents view | 404 // not the Ash desktop (since there is already another toast contents view |
| 396 // there. | 405 // there. |
| 397 if (!params.parent) | 406 if (!params.parent) |
| 398 params.native_widget = new views::DesktopNativeWidgetAura(widget); | 407 params.native_widget = new views::DesktopNativeWidgetAura(widget); |
| 399 #endif | 408 #endif |
| 400 | 409 |
| 401 widget->Init(params); | 410 widget->Init(params); |
| 402 } | 411 } |
| 403 | 412 |
| 404 gfx::Rect ToastContentsView::GetClosedToastBounds(gfx::Rect bounds) { | 413 gfx::Rect ToastContentsView::GetClosedToastBounds(gfx::Rect bounds) { |
| 405 return gfx::Rect(bounds.x() + bounds.width() - kClosedToastWidth, | 414 return gfx::Rect(bounds.x() + bounds.width() - kClosedToastWidth, |
| 406 bounds.y(), | 415 bounds.y(), |
| 407 kClosedToastWidth, | 416 kClosedToastWidth, |
| 408 bounds.height()); | 417 bounds.height()); |
| 409 } | 418 } |
| 410 | 419 |
| 411 } // namespace message_center | 420 } // namespace message_center |
| OLD | NEW |