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

Side by Side Diff: ui/message_center/views/toast_contents_view.cc

Issue 259253002: Add OnDisplayMetricsChanged in DisplayObserver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@update_orientation
Patch Set: oshima review comments Created 6 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) 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 10 matching lines...) Expand all
21 #include "ui/message_center/views/message_view.h" 21 #include "ui/message_center/views/message_view.h"
22 #include "ui/views/background.h" 22 #include "ui/views/background.h"
23 #include "ui/views/view.h" 23 #include "ui/views/view.h"
24 #include "ui/views/widget/widget.h" 24 #include "ui/views/widget/widget.h"
25 #include "ui/views/widget/widget_delegate.h" 25 #include "ui/views/widget/widget_delegate.h"
26 26
27 #if defined(OS_WIN) && defined(USE_ASH) 27 #if defined(OS_WIN) && defined(USE_ASH)
28 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 28 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
29 #endif 29 #endif
30 30
31 using gfx::Screen;
32
31 namespace message_center { 33 namespace message_center {
32 namespace { 34 namespace {
33 35
34 // The width of a toast before animated reveal and after closing. 36 // The width of a toast before animated reveal and after closing.
35 const int kClosedToastWidth = 5; 37 const int kClosedToastWidth = 5;
36 38
37 // FadeIn/Out look a bit better if they are slightly longer then default slide. 39 // FadeIn/Out look a bit better if they are slightly longer then default slide.
38 const int kFadeInOutDuration = 200; 40 const int kFadeInOutDuration = 200;
39 41
40 } // namespace. 42 } // namespace.
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 242
241 void ToastContentsView::OnDisplayChanged() { 243 void ToastContentsView::OnDisplayChanged() {
242 views::Widget* widget = GetWidget(); 244 views::Widget* widget = GetWidget();
243 if (!widget) 245 if (!widget)
244 return; 246 return;
245 247
246 gfx::NativeView native_view = widget->GetNativeView(); 248 gfx::NativeView native_view = widget->GetNativeView();
247 if (!native_view || !collection_.get()) 249 if (!native_view || !collection_.get())
248 return; 250 return;
249 251
250 collection_->OnDisplayBoundsChanged(gfx::Screen::GetScreenFor( 252 collection_->OnDisplayMetricsChanged(
251 native_view)->GetDisplayNearestWindow(native_view)); 253 Screen::GetScreenFor(native_view)->GetDisplayNearestWindow(native_view),
254 gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS |
255 gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
252 } 256 }
253 257
254 void ToastContentsView::OnWorkAreaChanged() { 258 void ToastContentsView::OnWorkAreaChanged() {
255 views::Widget* widget = GetWidget(); 259 views::Widget* widget = GetWidget();
256 if (!widget) 260 if (!widget)
257 return; 261 return;
258 262
259 gfx::NativeView native_view = widget->GetNativeView(); 263 gfx::NativeView native_view = widget->GetNativeView();
260 if (!native_view || !collection_.get()) 264 if (!native_view || !collection_.get())
261 return; 265 return;
262 266
263 collection_->OnDisplayBoundsChanged(gfx::Screen::GetScreenFor( 267 collection_->OnDisplayMetricsChanged(
264 native_view)->GetDisplayNearestWindow(native_view)); 268 Screen::GetScreenFor(native_view)->GetDisplayNearestWindow(native_view),
269 gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
265 } 270 }
266 271
267 // views::View 272 // views::View
268 void ToastContentsView::OnMouseEntered(const ui::MouseEvent& event) { 273 void ToastContentsView::OnMouseEntered(const ui::MouseEvent& event) {
269 if (collection_) 274 if (collection_)
270 collection_->OnMouseEntered(this); 275 collection_->OnMouseEntered(this);
271 } 276 }
272 277
273 void ToastContentsView::OnMouseExited(const ui::MouseEvent& event) { 278 void ToastContentsView::OnMouseExited(const ui::MouseEvent& event) {
274 if (collection_) 279 if (collection_)
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 } 357 }
353 358
354 gfx::Rect ToastContentsView::GetClosedToastBounds(gfx::Rect bounds) { 359 gfx::Rect ToastContentsView::GetClosedToastBounds(gfx::Rect bounds) {
355 return gfx::Rect(bounds.x() + bounds.width() - kClosedToastWidth, 360 return gfx::Rect(bounds.x() + bounds.width() - kClosedToastWidth,
356 bounds.y(), 361 bounds.y(),
357 kClosedToastWidth, 362 kClosedToastWidth,
358 bounds.height()); 363 bounds.height());
359 } 364 }
360 365
361 } // namespace message_center 366 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698