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

Side by Side Diff: ui/arc/notification/arc_custom_notification_view.h

Issue 2906323002: Rename ArcCustomNotificationView to ArcNotificationContentView (Closed)
Patch Set: Addressed comments 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
« no previous file with comments | « ui/arc/BUILD.gn ('k') | ui/arc/notification/arc_custom_notification_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef UI_ARC_NOTIFICATION_ARC_CUSTOM_NOTIFICATION_VIEW_H_
6 #define UI_ARC_NOTIFICATION_ARC_CUSTOM_NOTIFICATION_VIEW_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/macros.h"
12 #include "ui/arc/notification/arc_notification_content_view_delegate.h"
13 #include "ui/arc/notification/arc_notification_item.h"
14 #include "ui/arc/notification/arc_notification_surface_manager.h"
15 #include "ui/aura/window_observer.h"
16 #include "ui/gfx/animation/animation_delegate.h"
17 #include "ui/message_center/views/padded_button.h"
18 #include "ui/views/controls/button/button.h"
19 #include "ui/views/controls/native/native_view_host.h"
20
21 namespace exo {
22 class NotificationSurface;
23 }
24
25 namespace gfx {
26 class LinearAnimation;
27 }
28
29 namespace ui {
30 struct AXActionData;
31 }
32
33 namespace views {
34 class FocusTraversable;
35 class Widget;
36 }
37
38 namespace arc {
39
40 // ArcCustomNotificationView is a view to host NotificationSurface and show the
41 // content in itself. This is implemented as a child of ArcNotificationView.
42 // TODO(yoshiki): Rename this class to ArcNotificationContentsView.
43 class ArcCustomNotificationView
44 : public views::NativeViewHost,
45 public views::ButtonListener,
46 public aura::WindowObserver,
47 public ArcNotificationItem::Observer,
48 public ArcNotificationSurfaceManager::Observer,
49 public gfx::AnimationDelegate {
50 public:
51 explicit ArcCustomNotificationView(ArcNotificationItem* item);
52 ~ArcCustomNotificationView() override;
53
54 std::unique_ptr<ArcNotificationContentViewDelegate>
55 CreateContentViewDelegate();
56
57 private:
58 class ContentViewDelegate;
59 class EventForwarder;
60 class SettingsButton;
61 class SlideHelper;
62
63 // A image button class used for the settings button and the close button.
64 // We can't use forward declaration for this class due to std::unique_ptr<>
65 // requires size of this class.
66 class ControlButton : public message_center::PaddedButton {
67 public:
68 explicit ControlButton(ArcCustomNotificationView* owner);
69 void OnFocus() override;
70 void OnBlur() override;
71
72 private:
73 ArcCustomNotificationView* const owner_;
74
75 DISALLOW_COPY_AND_ASSIGN(ControlButton);
76 };
77
78 void CreateCloseButton();
79 void CreateSettingsButton();
80 void MaybeCreateFloatingControlButtons();
81 void SetSurface(exo::NotificationSurface* surface);
82 void UpdatePreferredSize();
83 void UpdateControlButtonsVisibility();
84 void UpdatePinnedState();
85 void UpdateSnapshot();
86 void AttachSurface();
87 void ActivateToast();
88 void StartControlButtonsColorAnimation();
89 bool ShouldUpdateControlButtonsColor() const;
90 void UpdateAccessibleName();
91
92 // views::NativeViewHost
93 void ViewHierarchyChanged(
94 const ViewHierarchyChangedDetails& details) override;
95 void Layout() override;
96 void OnPaint(gfx::Canvas* canvas) override;
97 void OnMouseEntered(const ui::MouseEvent& event) override;
98 void OnMouseExited(const ui::MouseEvent& event) override;
99 void OnFocus() override;
100 void OnBlur() override;
101 views::FocusTraversable* GetFocusTraversable() override;
102 bool HandleAccessibleAction(const ui::AXActionData& action) override;
103 void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
104
105 // views::ButtonListener
106 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
107
108 // aura::WindowObserver
109 void OnWindowBoundsChanged(aura::Window* window,
110 const gfx::Rect& old_bounds,
111 const gfx::Rect& new_bounds) override;
112 void OnWindowDestroying(aura::Window* window) override;
113
114 // ArcNotificationItem::Observer
115 void OnItemDestroying() override;
116 void OnItemUpdated() override;
117
118 // ArcNotificationSurfaceManager::Observer:
119 void OnNotificationSurfaceAdded(exo::NotificationSurface* surface) override;
120 void OnNotificationSurfaceRemoved(exo::NotificationSurface* surface) override;
121
122 // AnimationDelegate
123 void AnimationEnded(const gfx::Animation* animation) override;
124 void AnimationProgressed(const gfx::Animation* animation) override;
125
126 // If |item_| is null, we may be about to be destroyed. In this case,
127 // we have to be careful about what we do.
128 ArcNotificationItem* item_ = nullptr;
129 exo::NotificationSurface* surface_ = nullptr;
130
131 const std::string notification_key_;
132
133 // A pre-target event handler to forward events on the surface to this view.
134 // Using a pre-target event handler instead of a target handler on the surface
135 // window because it has descendant aura::Window and the events on them need
136 // to be handled as well.
137 // TODO(xiyuan): Revisit after exo::Surface no longer has an aura::Window.
138 std::unique_ptr<EventForwarder> event_forwarder_;
139
140 // A helper to observe slide transform/animation and use surface layer copy
141 // when a slide is in progress and restore the surface when it finishes.
142 std::unique_ptr<SlideHelper> slide_helper_;
143
144 // A control buttons on top of NotificationSurface. Needed because the
145 // aura::Window of NotificationSurface is added after hosting widget's
146 // RootView thus standard notification control buttons are always below
147 // it.
148 std::unique_ptr<views::Widget> floating_control_buttons_widget_;
149
150 views::View* control_buttons_view_ = nullptr;
151 std::unique_ptr<ControlButton> close_button_;
152 ControlButton* settings_button_ = nullptr;
153
154 // Protects from call loops between Layout and OnWindowBoundsChanged.
155 bool in_layout_ = false;
156
157 std::unique_ptr<gfx::LinearAnimation> control_button_color_animation_;
158
159 base::string16 accessible_name_;
160
161 DISALLOW_COPY_AND_ASSIGN(ArcCustomNotificationView);
162 };
163
164 } // namespace arc
165
166 #endif // UI_ARC_NOTIFICATION_ARC_CUSTOM_NOTIFICATION_VIEW_H_
OLDNEW
« no previous file with comments | « ui/arc/BUILD.gn ('k') | ui/arc/notification/arc_custom_notification_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698