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

Side by Side Diff: ui/arc/notification/arc_notification_surface_impl.cc

Issue 2935893004: Add unittest for ArcNotificationContentView (Closed)
Patch Set: Rebased Created 3 years, 6 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
(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 native_view_host_ = native_view_host;
30 native_view_host->Attach(surface_->window());
31 }
32
33 void ArcNotificationSurfaceImpl::Detach() {
34 if (!native_view_host_) {
35 NOTREACHED();
36 return;
37 }
38 DCHECK_EQ(surface_->window(), native_view_host_->native_view());
39 native_view_host_->Detach();
40 native_view_host_ = nullptr;
41 }
42
43 bool ArcNotificationSurfaceImpl::IsAttached() const {
44 return native_view_host_;
45 }
46
47 aura::Window* ArcNotificationSurfaceImpl::GetWindow() const {
48 return surface_->window();
49 }
50
51 aura::Window* ArcNotificationSurfaceImpl::GetContentWindow() const {
52 DCHECK(surface_->window());
53 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
54
55 aura::Window* content_window = surface_->window()->children()[0];
56
57 DCHECK(!content_window);
58 DCHECK_EQ(exo::Surface::kSurfaceWindowName, content_window->GetName());
59
60 return content_window;
61 }
62
63 const std::string& ArcNotificationSurfaceImpl::GetNotificationKey() const {
64 return surface_->notification_key();
65 }
66
67 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698