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.
5 #ifndef ASH_SYSTEM_CHROMEOS_SCREEN_TRAY_ITEM_H_
6 #define ASH_SYSTEM_CHROMEOS_SCREEN_TRAY_ITEM_H_
8 #include "ash/system/tray/system_tray.h"
9 #include "ash/system/tray/system_tray_item.h"
10 #include "ash/system/tray/system_tray_notifier.h"
11 #include "ash/system/tray/tray_item_view.h"
12 #include "ash/system/tray/tray_notification_view.h"
13 #include "ash/system/tray/tray_popup_label_button.h"
14 #include "ui/message_center/notification_delegate.h"
15 #include "ui/views/controls/button/button.h"
16 #include "ui/views/controls/image_view.h"
27 class ScreenTrayView
: public TrayItemView
{
29 ScreenTrayView(ScreenTrayItem
* screen_tray_item
, int icon_id
);
30 ~ScreenTrayView() override
;
35 ScreenTrayItem
* screen_tray_item_
;
37 DISALLOW_COPY_AND_ASSIGN(ScreenTrayView
);
40 class ScreenStatusView
: public views::View
,
41 public views::ButtonListener
{
43 ScreenStatusView(ScreenTrayItem
* screen_tray_item
,
45 const base::string16
& label_text
,
46 const base::string16
& stop_button_text
);
47 ~ScreenStatusView() override
;
49 // Overridden from views::View.
50 void Layout() override
;
52 // Overridden from views::ButtonListener.
53 void ButtonPressed(views::Button
* sender
, const ui::Event
& event
) override
;
59 ScreenTrayItem
* screen_tray_item_
;
60 views::ImageView
* icon_
;
62 TrayPopupLabelButton
* stop_button_
;
64 base::string16 label_text_
;
65 base::string16 stop_button_text_
;
67 DISALLOW_COPY_AND_ASSIGN(ScreenStatusView
);
70 class ScreenNotificationDelegate
: public message_center::NotificationDelegate
{
72 explicit ScreenNotificationDelegate(ScreenTrayItem
* screen_tray
);
74 // message_center::NotificationDelegate overrides:
75 void ButtonClick(int button_index
) override
;
78 ~ScreenNotificationDelegate() override
;
81 ScreenTrayItem
* screen_tray_
;
83 DISALLOW_COPY_AND_ASSIGN(ScreenNotificationDelegate
);
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
{
94 explicit ScreenTrayItem(SystemTray
* system_tray
);
95 ~ScreenTrayItem() override
;
97 tray::ScreenTrayView
* tray_view() { return tray_view_
; }
98 void set_tray_view(tray::ScreenTrayView
* tray_view
) {
99 tray_view_
= tray_view
;
102 tray::ScreenStatusView
* default_view() { return default_view_
; }
103 void set_default_view(tray::ScreenStatusView
* default_view
) {
104 default_view_
= default_view
;
107 bool is_started() const { return is_started_
; }
108 void set_is_started(bool is_started
) { is_started_
= is_started
; }
111 void Start(const base::Closure
& stop_callback
);
114 // Creates or updates the notification for the tray item.
115 virtual void CreateOrUpdateNotification() = 0;
117 // Returns the id of the notification for the tray item.
118 virtual std::string
GetNotificationId() = 0;
120 // Overridden from SystemTrayItem.
121 views::View
* CreateTrayView(user::LoginStatus status
) override
= 0;
122 views::View
* CreateDefaultView(user::LoginStatus status
) override
= 0;
123 void DestroyTrayView() override
;
124 void DestroyDefaultView() override
;
125 void UpdateAfterShelfAlignmentChange(ShelfAlignment alignment
) override
;
128 tray::ScreenTrayView
* tray_view_
;
129 tray::ScreenStatusView
* default_view_
;
131 base::Closure stop_callback_
;
133 DISALLOW_COPY_AND_ASSIGN(ScreenTrayItem
);
138 #endif // ASH_SYSTEM_CHROMEOS_SCREEN_TRAY_ITEM_H_