OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/arc/notification/arc_notification_surface_impl.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "components/exo/notification_surface.h" |
| 9 #include "components/exo/surface.h" |
| 10 #include "ui/aura/window.h" |
| 11 #include "ui/views/controls/native/native_view_host.h" |
| 12 |
| 13 namespace arc { |
| 14 |
| 15 // Handles notification surface role of a given surface. |
| 16 ArcNotificationSurfaceImpl::ArcNotificationSurfaceImpl( |
| 17 exo::NotificationSurface* surface) |
| 18 : surface_(surface) { |
| 19 DCHECK(surface); |
| 20 } |
| 21 |
| 22 gfx::Size ArcNotificationSurfaceImpl::GetSize() const { |
| 23 return surface_->GetSize(); |
| 24 } |
| 25 |
| 26 void ArcNotificationSurfaceImpl::Attach( |
| 27 views::NativeViewHost* native_view_host) { |
| 28 DCHECK(!native_view_host_); |
| 29 DCHECK(native_view_host); |
| 30 native_view_host_ = native_view_host; |
| 31 native_view_host->Attach(surface_->window()); |
| 32 } |
| 33 |
| 34 void ArcNotificationSurfaceImpl::Detach() { |
| 35 DCHECK(native_view_host_); |
| 36 DCHECK_EQ(surface_->window(), native_view_host_->native_view()); |
| 37 native_view_host_->Detach(); |
| 38 native_view_host_ = nullptr; |
| 39 } |
| 40 |
| 41 bool ArcNotificationSurfaceImpl::IsAttached() const { |
| 42 return native_view_host_; |
| 43 } |
| 44 |
| 45 aura::Window* ArcNotificationSurfaceImpl::GetWindow() const { |
| 46 return surface_->window(); |
| 47 } |
| 48 |
| 49 aura::Window* ArcNotificationSurfaceImpl::GetContentWindow() const { |
| 50 DCHECK(surface_->window()); |
| 51 DCHECK(!surface_->window()->children().empty()); |
| 52 |
| 53 aura::Window* content_window = surface_->window()->children()[0]; |
| 54 |
| 55 DCHECK(!content_window); |
| 56 return content_window; |
| 57 } |
| 58 |
| 59 const std::string& ArcNotificationSurfaceImpl::GetNotificationKey() const { |
| 60 return surface_->notification_key(); |
| 61 } |
| 62 |
| 63 } // namespace arc |
OLD | NEW |