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 #ifndef UI_ARC_NOTIFICATION_ARC_NOTIFICATION_CONTENT_VIEW_H_ | 5 #ifndef UI_ARC_NOTIFICATION_ARC_NOTIFICATION_CONTENT_VIEW_H_ |
6 #define UI_ARC_NOTIFICATION_ARC_NOTIFICATION_CONTENT_VIEW_H_ | 6 #define UI_ARC_NOTIFICATION_ARC_NOTIFICATION_CONTENT_VIEW_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "ui/arc/notification/arc_notification_content_view_delegate.h" | 12 #include "ui/arc/notification/arc_notification_content_view_delegate.h" |
13 #include "ui/arc/notification/arc_notification_item.h" | 13 #include "ui/arc/notification/arc_notification_item.h" |
14 #include "ui/arc/notification/arc_notification_surface_manager.h" | 14 #include "ui/arc/notification/arc_notification_surface_manager.h" |
15 #include "ui/aura/window_observer.h" | 15 #include "ui/aura/window_observer.h" |
16 #include "ui/gfx/animation/animation_delegate.h" | 16 #include "ui/gfx/animation/animation_delegate.h" |
17 #include "ui/message_center/views/padded_button.h" | 17 #include "ui/message_center/views/padded_button.h" |
18 #include "ui/views/controls/button/button.h" | 18 #include "ui/views/controls/button/button.h" |
19 #include "ui/views/controls/native/native_view_host.h" | 19 #include "ui/views/controls/native/native_view_host.h" |
20 | 20 |
21 namespace exo { | |
22 class NotificationSurface; | |
23 } | |
24 | |
25 namespace gfx { | 21 namespace gfx { |
26 class LinearAnimation; | 22 class LinearAnimation; |
27 } | 23 } |
28 | 24 |
29 namespace ui { | 25 namespace ui { |
30 struct AXActionData; | 26 struct AXActionData; |
31 } | 27 } |
32 | 28 |
33 namespace views { | 29 namespace views { |
34 class FocusTraversable; | 30 class FocusTraversable; |
35 class Widget; | 31 class Widget; |
36 } | 32 } |
37 | 33 |
38 namespace arc { | 34 namespace arc { |
39 | 35 |
| 36 class ArcNotificationSurface; |
| 37 |
40 // ArcNotificationContentView is a view to host NotificationSurface and show the | 38 // ArcNotificationContentView is a view to host NotificationSurface and show the |
41 // content in itself. This is implemented as a child of ArcNotificationView. | 39 // content in itself. This is implemented as a child of ArcNotificationView. |
42 class ArcNotificationContentView | 40 class ArcNotificationContentView |
43 : public views::NativeViewHost, | 41 : public views::NativeViewHost, |
44 public views::ButtonListener, | 42 public views::ButtonListener, |
45 public aura::WindowObserver, | 43 public aura::WindowObserver, |
46 public ArcNotificationItem::Observer, | 44 public ArcNotificationItem::Observer, |
47 public ArcNotificationSurfaceManager::Observer, | 45 public ArcNotificationSurfaceManager::Observer, |
48 public gfx::AnimationDelegate { | 46 public gfx::AnimationDelegate { |
49 public: | 47 public: |
| 48 static const char kViewClassName[]; |
| 49 |
50 explicit ArcNotificationContentView(ArcNotificationItem* item); | 50 explicit ArcNotificationContentView(ArcNotificationItem* item); |
51 ~ArcNotificationContentView() override; | 51 ~ArcNotificationContentView() override; |
52 | 52 |
| 53 // views::View overrides: |
| 54 const char* GetClassName() const override; |
| 55 |
53 std::unique_ptr<ArcNotificationContentViewDelegate> | 56 std::unique_ptr<ArcNotificationContentViewDelegate> |
54 CreateContentViewDelegate(); | 57 CreateContentViewDelegate(); |
55 | 58 |
56 private: | 59 private: |
| 60 friend class ArcNotificationContentViewTest; |
| 61 |
| 62 static ArcNotificationSurfaceManager* surface_manager_for_testing_; |
| 63 |
57 class ContentViewDelegate; | 64 class ContentViewDelegate; |
58 class EventForwarder; | 65 class EventForwarder; |
59 class SettingsButton; | 66 class SettingsButton; |
60 class SlideHelper; | 67 class SlideHelper; |
61 | 68 |
62 // A image button class used for the settings button and the close button. | 69 // A image button class used for the settings button and the close button. |
63 // We can't use forward declaration for this class due to std::unique_ptr<> | 70 // We can't use forward declaration for this class due to std::unique_ptr<> |
64 // requires size of this class. | 71 // requires size of this class. |
65 class ControlButton : public message_center::PaddedButton { | 72 class ControlButton : public message_center::PaddedButton { |
66 public: | 73 public: |
67 explicit ControlButton(ArcNotificationContentView* owner); | 74 explicit ControlButton(ArcNotificationContentView* owner); |
68 void OnFocus() override; | 75 void OnFocus() override; |
69 void OnBlur() override; | 76 void OnBlur() override; |
70 | 77 |
71 private: | 78 private: |
72 ArcNotificationContentView* const owner_; | 79 ArcNotificationContentView* const owner_; |
73 | 80 |
74 DISALLOW_COPY_AND_ASSIGN(ControlButton); | 81 DISALLOW_COPY_AND_ASSIGN(ControlButton); |
75 }; | 82 }; |
76 | 83 |
| 84 ArcNotificationSurfaceManager* GetSurfaceManager() const; |
77 void CreateCloseButton(); | 85 void CreateCloseButton(); |
78 void CreateSettingsButton(); | 86 void CreateSettingsButton(); |
79 void MaybeCreateFloatingControlButtons(); | 87 void MaybeCreateFloatingControlButtons(); |
80 void SetSurface(exo::NotificationSurface* surface); | 88 void SetSurface(ArcNotificationSurface* surface); |
81 void UpdatePreferredSize(); | 89 void UpdatePreferredSize(); |
82 void UpdateControlButtonsVisibility(); | 90 void UpdateControlButtonsVisibility(); |
83 void UpdatePinnedState(); | 91 void UpdatePinnedState(); |
84 void UpdateSnapshot(); | 92 void UpdateSnapshot(); |
85 void AttachSurface(); | 93 void AttachSurface(); |
86 void ActivateToast(); | 94 void ActivateToast(); |
87 void StartControlButtonsColorAnimation(); | 95 void StartControlButtonsColorAnimation(); |
88 bool ShouldUpdateControlButtonsColor() const; | 96 bool ShouldUpdateControlButtonsColor() const; |
89 void UpdateAccessibleName(); | 97 void UpdateAccessibleName(); |
90 | 98 |
(...skipping 17 matching lines...) Expand all Loading... |
108 void OnWindowBoundsChanged(aura::Window* window, | 116 void OnWindowBoundsChanged(aura::Window* window, |
109 const gfx::Rect& old_bounds, | 117 const gfx::Rect& old_bounds, |
110 const gfx::Rect& new_bounds) override; | 118 const gfx::Rect& new_bounds) override; |
111 void OnWindowDestroying(aura::Window* window) override; | 119 void OnWindowDestroying(aura::Window* window) override; |
112 | 120 |
113 // ArcNotificationItem::Observer | 121 // ArcNotificationItem::Observer |
114 void OnItemDestroying() override; | 122 void OnItemDestroying() override; |
115 void OnItemUpdated() override; | 123 void OnItemUpdated() override; |
116 | 124 |
117 // ArcNotificationSurfaceManager::Observer: | 125 // ArcNotificationSurfaceManager::Observer: |
118 void OnNotificationSurfaceAdded(exo::NotificationSurface* surface) override; | 126 void OnNotificationSurfaceAdded(ArcNotificationSurface* surface) override; |
119 void OnNotificationSurfaceRemoved(exo::NotificationSurface* surface) override; | 127 void OnNotificationSurfaceRemoved(ArcNotificationSurface* surface) override; |
120 | 128 |
121 // AnimationDelegate | 129 // AnimationDelegate |
122 void AnimationEnded(const gfx::Animation* animation) override; | 130 void AnimationEnded(const gfx::Animation* animation) override; |
123 void AnimationProgressed(const gfx::Animation* animation) override; | 131 void AnimationProgressed(const gfx::Animation* animation) override; |
124 | 132 |
125 // If |item_| is null, we may be about to be destroyed. In this case, | 133 // If |item_| is null, we may be about to be destroyed. In this case, |
126 // we have to be careful about what we do. | 134 // we have to be careful about what we do. |
127 ArcNotificationItem* item_ = nullptr; | 135 ArcNotificationItem* item_ = nullptr; |
128 exo::NotificationSurface* surface_ = nullptr; | 136 ArcNotificationSurface* surface_ = nullptr; |
129 | 137 |
130 const std::string notification_key_; | 138 const std::string notification_key_; |
131 | 139 |
132 // A pre-target event handler to forward events on the surface to this view. | 140 // A pre-target event handler to forward events on the surface to this view. |
133 // Using a pre-target event handler instead of a target handler on the surface | 141 // Using a pre-target event handler instead of a target handler on the surface |
134 // window because it has descendant aura::Window and the events on them need | 142 // window because it has descendant aura::Window and the events on them need |
135 // to be handled as well. | 143 // to be handled as well. |
136 // TODO(xiyuan): Revisit after exo::Surface no longer has an aura::Window. | 144 // TODO(xiyuan): Revisit after exo::Surface no longer has an aura::Window. |
137 std::unique_ptr<EventForwarder> event_forwarder_; | 145 std::unique_ptr<EventForwarder> event_forwarder_; |
138 | 146 |
(...skipping 17 matching lines...) Expand all Loading... |
156 std::unique_ptr<gfx::LinearAnimation> control_button_color_animation_; | 164 std::unique_ptr<gfx::LinearAnimation> control_button_color_animation_; |
157 | 165 |
158 base::string16 accessible_name_; | 166 base::string16 accessible_name_; |
159 | 167 |
160 DISALLOW_COPY_AND_ASSIGN(ArcNotificationContentView); | 168 DISALLOW_COPY_AND_ASSIGN(ArcNotificationContentView); |
161 }; | 169 }; |
162 | 170 |
163 } // namespace arc | 171 } // namespace arc |
164 | 172 |
165 #endif // UI_ARC_NOTIFICATION_ARC_NOTIFICATION_CONTENT_VIEW_H_ | 173 #endif // UI_ARC_NOTIFICATION_ARC_NOTIFICATION_CONTENT_VIEW_H_ |
OLD | NEW |