Chromium Code Reviews| Index: ui/arc/notification/arc_notification_surface_impl.cc |
| diff --git a/ui/arc/notification/arc_notification_surface_impl.cc b/ui/arc/notification/arc_notification_surface_impl.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2202670aa9d2041f80cc266af9ef30169d7ec17a |
| --- /dev/null |
| +++ b/ui/arc/notification/arc_notification_surface_impl.cc |
| @@ -0,0 +1,67 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ui/arc/notification/arc_notification_surface_impl.h" |
| + |
| +#include "base/logging.h" |
| +#include "components/exo/notification_surface.h" |
| +#include "components/exo/surface.h" |
| +#include "ui/aura/window.h" |
| +#include "ui/views/controls/native/native_view_host.h" |
| + |
| +namespace arc { |
| + |
| +// Handles notification surface role of a given surface. |
| +ArcNotificationSurfaceImpl::ArcNotificationSurfaceImpl( |
| + exo::NotificationSurface* surface) |
| + : surface_(surface) { |
| + DCHECK(surface); |
| +} |
| + |
| +gfx::Size ArcNotificationSurfaceImpl::GetSize() const { |
| + return surface_->GetSize(); |
| +} |
| + |
| +void ArcNotificationSurfaceImpl::Attach( |
| + views::NativeViewHost* native_view_host) { |
| + DCHECK(!native_view_host_); |
| + native_view_host_ = native_view_host; |
| + native_view_host->Attach(surface_->window()); |
| +} |
| + |
| +void ArcNotificationSurfaceImpl::Detach() { |
| + if (!native_view_host_) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + DCHECK_EQ(surface_->window(), native_view_host_->native_view()); |
| + native_view_host_->Detach(); |
| + native_view_host_ = nullptr; |
| +} |
| + |
| +bool ArcNotificationSurfaceImpl::IsAttached() const { |
| + return native_view_host_; |
| +} |
| + |
| +aura::Window* ArcNotificationSurfaceImpl::GetWindow() const { |
| + return surface_->window(); |
| +} |
| + |
| +aura::Window* ArcNotificationSurfaceImpl::GetContentWindow() const { |
| + DCHECK(surface_->window()); |
| + DCHECK(!surface_->window()->children().empty()); |
|
hidehiko
2017/06/15 15:26:20
If above DCHECK fails (i.e. if surface_->window()
yoshiki
2017/06/16 11:29:08
Previously double-detach existed so we had null-ch
|
| + |
| + aura::Window* content_window = surface_->window()->children()[0]; |
| + |
| + DCHECK(!content_window); |
| + DCHECK_EQ(exo::Surface::kSurfaceWindowName, content_window->GetName()); |
| + |
| + return content_window; |
| +} |
| + |
| +const std::string& ArcNotificationSurfaceImpl::GetNotificationKey() const { |
| + return surface_->notification_key(); |
| +} |
| + |
| +} // namespace arc |