Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ash / system / chromeos / screen_security / screen_tray_item.h
blob4a2a12ee3c682cb1f636548ecb388e2668d87c60
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"
18 namespace views {
19 class View;
22 namespace ash {
23 class ScreenTrayItem;
25 namespace tray {
27 class ScreenTrayView : public TrayItemView {
28 public:
29 ScreenTrayView(ScreenTrayItem* screen_tray_item, int icon_id);
30 ~ScreenTrayView() override;
32 void Update();
34 private:
35 ScreenTrayItem* screen_tray_item_;
37 DISALLOW_COPY_AND_ASSIGN(ScreenTrayView);
40 class ScreenStatusView : public views::View,
41 public views::ButtonListener {
42 public:
43 ScreenStatusView(ScreenTrayItem* screen_tray_item,
44 int icon_id,
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;
55 void CreateItems();
56 void Update();
58 private:
59 ScreenTrayItem* screen_tray_item_;
60 views::ImageView* icon_;
61 views::Label* label_;
62 TrayPopupLabelButton* stop_button_;
63 int icon_id_;
64 base::string16 label_text_;
65 base::string16 stop_button_text_;
67 DISALLOW_COPY_AND_ASSIGN(ScreenStatusView);
70 class ScreenNotificationDelegate : public message_center::NotificationDelegate {
71 public:
72 explicit ScreenNotificationDelegate(ScreenTrayItem* screen_tray);
74 // message_center::NotificationDelegate overrides:
75 void ButtonClick(int button_index) override;
77 protected:
78 ~ScreenNotificationDelegate() override;
80 private:
81 ScreenTrayItem* screen_tray_;
83 DISALLOW_COPY_AND_ASSIGN(ScreenNotificationDelegate);
86 } // namespace tray
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 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; }
110 void Update();
111 void Start(const base::Closure& stop_callback);
112 void Stop();
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;
127 private:
128 tray::ScreenTrayView* tray_view_;
129 tray::ScreenStatusView* default_view_;
130 bool is_started_;
131 base::Closure stop_callback_;
133 DISALLOW_COPY_AND_ASSIGN(ScreenTrayItem);
136 } // namespace ash
138 #endif // ASH_SYSTEM_CHROMEOS_SCREEN_TRAY_ITEM_H_