OLD | NEW |
| (Empty) |
1 // Copyright 2013 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 ASH_COMMON_SYSTEM_CHROMEOS_SCREEN_SECURITY_SCREEN_TRAY_ITEM_H_ | |
6 #define ASH_COMMON_SYSTEM_CHROMEOS_SCREEN_SECURITY_SCREEN_TRAY_ITEM_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "ash/common/system/tray/system_tray.h" | |
11 #include "ash/common/system/tray/system_tray_item.h" | |
12 #include "ash/common/system/tray/tray_item_view.h" | |
13 #include "ash/common/system/tray/tray_notification_view.h" | |
14 #include "base/macros.h" | |
15 #include "ui/message_center/notification_delegate.h" | |
16 #include "ui/views/controls/button/button.h" | |
17 #include "ui/views/controls/image_view.h" | |
18 | |
19 namespace views { | |
20 class View; | |
21 } | |
22 | |
23 namespace ash { | |
24 class ScreenTrayItem; | |
25 | |
26 namespace tray { | |
27 | |
28 class ScreenTrayView : public TrayItemView { | |
29 public: | |
30 explicit ScreenTrayView(ScreenTrayItem* screen_tray_item); | |
31 ~ScreenTrayView() override; | |
32 | |
33 void Update(); | |
34 | |
35 private: | |
36 ScreenTrayItem* screen_tray_item_; | |
37 | |
38 DISALLOW_COPY_AND_ASSIGN(ScreenTrayView); | |
39 }; | |
40 | |
41 class ScreenStatusView : public views::View, public views::ButtonListener { | |
42 public: | |
43 ScreenStatusView(ScreenTrayItem* screen_tray_item, | |
44 const base::string16& label_text, | |
45 const base::string16& stop_button_text); | |
46 ~ScreenStatusView() override; | |
47 | |
48 // Overridden from views::ButtonListener. | |
49 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | |
50 | |
51 void CreateItems(); | |
52 void UpdateFromScreenTrayItem(); | |
53 | |
54 protected: | |
55 views::ImageView* icon() { return icon_; } | |
56 views::Label* label() { return label_; } | |
57 views::Button* stop_button() { return stop_button_; } | |
58 | |
59 private: | |
60 // The controller for this view. May be null. | |
61 ScreenTrayItem* screen_tray_item_; | |
62 views::ImageView* icon_; | |
63 views::Label* label_; | |
64 views::Button* stop_button_; | |
65 base::string16 label_text_; | |
66 base::string16 stop_button_text_; | |
67 | |
68 DISALLOW_COPY_AND_ASSIGN(ScreenStatusView); | |
69 }; | |
70 | |
71 class ScreenNotificationDelegate : public message_center::NotificationDelegate { | |
72 public: | |
73 explicit ScreenNotificationDelegate(ScreenTrayItem* screen_tray); | |
74 | |
75 // message_center::NotificationDelegate overrides: | |
76 void ButtonClick(int button_index) override; | |
77 | |
78 protected: | |
79 ~ScreenNotificationDelegate() override; | |
80 | |
81 private: | |
82 ScreenTrayItem* screen_tray_; | |
83 | |
84 DISALLOW_COPY_AND_ASSIGN(ScreenNotificationDelegate); | |
85 }; | |
86 | |
87 } // namespace tray | |
88 | |
89 // The base tray item for screen capture and screen sharing. The | |
90 // Start method brings up a notification and a tray item, and the user | |
91 // can stop the screen capture/sharing by pressing the stop button. | |
92 class ASH_EXPORT ScreenTrayItem : public SystemTrayItem { | |
93 public: | |
94 ScreenTrayItem(SystemTray* system_tray, UmaType uma_type); | |
95 ~ScreenTrayItem() override; | |
96 | |
97 tray::ScreenTrayView* tray_view() { return tray_view_; } | |
98 | |
99 tray::ScreenStatusView* default_view() { return default_view_; } | |
100 void set_default_view(tray::ScreenStatusView* default_view) { | |
101 default_view_ = default_view; | |
102 } | |
103 | |
104 bool is_started() const { return is_started_; } | |
105 void set_is_started(bool is_started) { is_started_ = is_started; } | |
106 | |
107 void Update(); | |
108 void Start(const base::Closure& stop_callback); | |
109 void Stop(); | |
110 | |
111 // Creates or updates the notification for the tray item. | |
112 virtual void CreateOrUpdateNotification() = 0; | |
113 | |
114 // Returns the id of the notification for the tray item. | |
115 virtual std::string GetNotificationId() = 0; | |
116 | |
117 // Called after Stop() is invoked from the default view. | |
118 virtual void RecordStoppedFromDefaultViewMetric() = 0; | |
119 | |
120 // Called after Stop() is invoked from the notification view. | |
121 virtual void RecordStoppedFromNotificationViewMetric() = 0; | |
122 | |
123 // Overridden from SystemTrayItem. | |
124 views::View* CreateTrayView(LoginStatus status) override; | |
125 views::View* CreateDefaultView(LoginStatus status) override = 0; | |
126 void DestroyTrayView() override; | |
127 void DestroyDefaultView() override; | |
128 | |
129 private: | |
130 tray::ScreenTrayView* tray_view_; | |
131 tray::ScreenStatusView* default_view_; | |
132 bool is_started_; | |
133 base::Closure stop_callback_; | |
134 | |
135 DISALLOW_COPY_AND_ASSIGN(ScreenTrayItem); | |
136 }; | |
137 | |
138 } // namespace ash | |
139 | |
140 #endif // ASH_COMMON_SYSTEM_CHROMEOS_SCREEN_SECURITY_SCREEN_TRAY_ITEM_H_ | |
OLD | NEW |