| 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 "ui/arc/notification/arc_custom_notification_view.h" | 5 #include "ui/arc/notification/arc_custom_notification_view.h" |
| 6 | 6 |
| 7 #include "components/exo/notification_surface.h" | 7 #include "components/exo/notification_surface.h" |
| 8 #include "components/exo/surface.h" | 8 #include "components/exo/surface.h" |
| 9 #include "third_party/skia/include/core/SkColor.h" | 9 #include "third_party/skia/include/core/SkColor.h" |
| 10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
| 11 #include "ui/base/resource/resource_bundle.h" | 11 #include "ui/base/resource/resource_bundle.h" |
| 12 #include "ui/compositor/layer_animation_observer.h" | 12 #include "ui/compositor/layer_animation_observer.h" |
| 13 #include "ui/display/screen.h" | 13 #include "ui/display/screen.h" |
| 14 #include "ui/events/event_handler.h" | 14 #include "ui/events/event_handler.h" |
| 15 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 16 #include "ui/gfx/image/image_skia.h" | 16 #include "ui/gfx/image/image_skia.h" |
| 17 #include "ui/gfx/transform.h" | 17 #include "ui/gfx/transform.h" |
| 18 #include "ui/message_center/message_center_style.h" | 18 #include "ui/message_center/message_center_style.h" |
| 19 #include "ui/message_center/views/custom_notification_view.h" |
| 19 #include "ui/resources/grit/ui_resources.h" | 20 #include "ui/resources/grit/ui_resources.h" |
| 20 #include "ui/strings/grit/ui_strings.h" | 21 #include "ui/strings/grit/ui_strings.h" |
| 21 #include "ui/views/background.h" | 22 #include "ui/views/background.h" |
| 22 #include "ui/views/border.h" | 23 #include "ui/views/border.h" |
| 23 #include "ui/views/controls/button/image_button.h" | 24 #include "ui/views/controls/button/image_button.h" |
| 24 #include "ui/views/widget/widget.h" | 25 #include "ui/views/widget/widget.h" |
| 25 #include "ui/wm/core/window_util.h" | 26 #include "ui/wm/core/window_util.h" |
| 26 | 27 |
| 27 namespace arc { | 28 namespace arc { |
| 28 | 29 |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 if (!GetWidget()) | 285 if (!GetWidget()) |
| 285 return; | 286 return; |
| 286 | 287 |
| 287 UpdatePreferredSize(); | 288 UpdatePreferredSize(); |
| 288 Attach(surface_->window()); | 289 Attach(surface_->window()); |
| 289 | 290 |
| 290 // Creates slide helper after this view is added to its parent. | 291 // Creates slide helper after this view is added to its parent. |
| 291 slide_helper_.reset(new SlideHelper(this)); | 292 slide_helper_.reset(new SlideHelper(this)); |
| 292 } | 293 } |
| 293 | 294 |
| 295 void ArcCustomNotificationView::UpdateAccessibleName() { |
| 296 DCHECK(parent() != nullptr); |
| 297 static_cast<message_center::CustomNotificationView *>( |
| 298 parent())->set_accessible_name(item_->accessibile_name()); |
| 299 } |
| 300 |
| 294 void ArcCustomNotificationView::ViewHierarchyChanged( | 301 void ArcCustomNotificationView::ViewHierarchyChanged( |
| 295 const views::View::ViewHierarchyChangedDetails& details) { | 302 const views::View::ViewHierarchyChangedDetails& details) { |
| 296 views::Widget* widget = GetWidget(); | 303 views::Widget* widget = GetWidget(); |
| 297 | 304 |
| 298 if (!details.is_add) { | 305 if (!details.is_add) { |
| 299 // Resets slide helper when this view is removed from its parent. | 306 // Resets slide helper when this view is removed from its parent. |
| 300 slide_helper_.reset(); | 307 slide_helper_.reset(); |
| 301 } | 308 } |
| 302 | 309 |
| 303 // Bail if native_view() has attached to a different widget. | 310 // Bail if native_view() has attached to a different widget. |
| 304 if (widget && native_view() && | 311 if (widget && native_view() && |
| 305 views::Widget::GetTopLevelWidgetForNativeView(native_view()) != widget) { | 312 views::Widget::GetTopLevelWidgetForNativeView(native_view()) != widget) { |
| 306 return; | 313 return; |
| 307 } | 314 } |
| 308 | 315 |
| 309 views::NativeViewHost::ViewHierarchyChanged(details); | 316 views::NativeViewHost::ViewHierarchyChanged(details); |
| 310 | 317 |
| 311 if (!widget || !surface_ || !details.is_add) | 318 if (!widget || !surface_ || !details.is_add) |
| 312 return; | 319 return; |
| 313 | 320 |
| 321 UpdateAccessibleName(); |
| 314 AttachSurface(); | 322 AttachSurface(); |
| 315 } | 323 } |
| 316 | 324 |
| 317 void ArcCustomNotificationView::Layout() { | 325 void ArcCustomNotificationView::Layout() { |
| 318 views::NativeViewHost::Layout(); | 326 views::NativeViewHost::Layout(); |
| 319 | 327 |
| 320 if (!surface_ || !GetWidget()) | 328 if (!surface_ || !GetWidget()) |
| 321 return; | 329 return; |
| 322 | 330 |
| 323 // Scale notification surface if necessary. | 331 // Scale notification surface if necessary. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 | 426 |
| 419 void ArcCustomNotificationView::OnNotificationSurfaceRemoved( | 427 void ArcCustomNotificationView::OnNotificationSurfaceRemoved( |
| 420 exo::NotificationSurface* surface) { | 428 exo::NotificationSurface* surface) { |
| 421 if (surface->notification_id() != notification_key_) | 429 if (surface->notification_id() != notification_key_) |
| 422 return; | 430 return; |
| 423 | 431 |
| 424 SetSurface(nullptr); | 432 SetSurface(nullptr); |
| 425 } | 433 } |
| 426 | 434 |
| 427 } // namespace arc | 435 } // namespace arc |
| OLD | NEW |