Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 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_SYSTEM_CHROMEOS_SCREEN_TRAY_ITEM_H_ |
| 6 | #define ASH_SYSTEM_CHROMEOS_SCREEN_TRAY_ITEM_H_ |
| 7 | |
| 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" |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 14 | #include "ui/message_center/notification_delegate.h" |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 15 | #include "ui/views/controls/button/button.h" |
| 16 | #include "ui/views/controls/image_view.h" |
| 17 | |
| 18 | namespace views { |
| 19 | class View; |
| 20 | } |
| 21 | |
| 22 | namespace ash { |
| 23 | namespace internal { |
| 24 | |
| 25 | class ScreenTrayItem; |
| 26 | |
| 27 | namespace tray { |
| 28 | |
| 29 | class ScreenTrayView : public TrayItemView { |
| 30 | public: |
| 31 | ScreenTrayView(ScreenTrayItem* screen_tray_item, int icon_id); |
| 32 | virtual ~ScreenTrayView(); |
| 33 | |
| 34 | void Update(); |
| 35 | |
| 36 | private: |
| 37 | ScreenTrayItem* screen_tray_item_; |
| 38 | |
| 39 | DISALLOW_COPY_AND_ASSIGN(ScreenTrayView); |
| 40 | }; |
| 41 | |
| 42 | class ScreenStatusView : public views::View, |
| 43 | public views::ButtonListener { |
| 44 | public: |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 45 | ScreenStatusView(ScreenTrayItem* screen_tray_item, |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 46 | int icon_id, |
| 47 | const base::string16& label_text, |
| 48 | const base::string16& stop_button_text); |
| 49 | virtual ~ScreenStatusView(); |
| 50 | |
| 51 | // Overridden from views::View. |
| 52 | virtual void Layout() OVERRIDE; |
| 53 | |
| 54 | // Overridden from views::ButtonListener. |
| 55 | virtual void ButtonPressed(views::Button* sender, |
| 56 | const ui::Event& event) OVERRIDE; |
| 57 | |
| 58 | void CreateItems(); |
| 59 | void Update(); |
| 60 | |
| 61 | private: |
| 62 | ScreenTrayItem* screen_tray_item_; |
| 63 | views::ImageView* icon_; |
| 64 | views::Label* label_; |
| 65 | TrayPopupLabelButton* stop_button_; |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 66 | int icon_id_; |
| 67 | base::string16 label_text_; |
| 68 | base::string16 stop_button_text_; |
| 69 | |
| 70 | DISALLOW_COPY_AND_ASSIGN(ScreenStatusView); |
| 71 | }; |
| 72 | |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 73 | class ScreenNotificationDelegate : public message_center::NotificationDelegate { |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 74 | public: |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 75 | explicit ScreenNotificationDelegate(ScreenTrayItem* screen_tray); |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 76 | |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 77 | // message_center::NotificationDelegate overrides: |
| 78 | virtual void Display() OVERRIDE; |
| 79 | virtual void Error() OVERRIDE; |
| 80 | virtual void Close(bool by_user) OVERRIDE; |
| 81 | virtual void Click() OVERRIDE; |
| 82 | virtual void ButtonClick(int button_index) OVERRIDE; |
| 83 | |
| 84 | protected: |
| 85 | virtual ~ScreenNotificationDelegate(); |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 86 | |
| 87 | private: |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 88 | ScreenTrayItem* screen_tray_; |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 89 | |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 90 | DISALLOW_COPY_AND_ASSIGN(ScreenNotificationDelegate); |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | } // namespace tray |
| 94 | |
| 95 | |
| 96 | // The base tray item for screen capture and screen sharing. The |
| 97 | // Start method brings up a notification and a tray item, and the user |
| 98 | // can stop the screen capture/sharing by pressing the stop button. |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 99 | class ASH_EXPORT ScreenTrayItem : public SystemTrayItem { |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 100 | public: |
| 101 | explicit ScreenTrayItem(SystemTray* system_tray); |
| 102 | virtual ~ScreenTrayItem(); |
| 103 | |
| 104 | tray::ScreenTrayView* tray_view() { return tray_view_; } |
| 105 | void set_tray_view(tray::ScreenTrayView* tray_view) { |
| 106 | tray_view_ = tray_view; |
| 107 | } |
| 108 | |
| 109 | tray::ScreenStatusView* default_view() { return default_view_; } |
| 110 | void set_default_view(tray::ScreenStatusView* default_view) { |
| 111 | default_view_ = default_view; |
| 112 | } |
| 113 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 114 | bool is_started() const { return is_started_; } |
| 115 | void set_is_started(bool is_started) { is_started_ = is_started; } |
| 116 | |
| 117 | void Update(); |
| 118 | void Start(const base::Closure& stop_callback); |
| 119 | void Stop(); |
| 120 | |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 121 | // Creates or updates the notification for the tray item. |
| 122 | virtual void CreateOrUpdateNotification() = 0; |
| 123 | |
| 124 | // Returns the id of the notification for the tray item. |
| 125 | virtual std::string GetNotificationId() = 0; |
| 126 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 127 | // Overridden from SystemTrayItem. |
| 128 | virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE = 0; |
| 129 | virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE = 0; |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 130 | virtual void DestroyTrayView() OVERRIDE; |
| 131 | virtual void DestroyDefaultView() OVERRIDE; |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 132 | |
| 133 | private: |
| 134 | tray::ScreenTrayView* tray_view_; |
| 135 | tray::ScreenStatusView* default_view_; |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 136 | bool is_started_; |
| 137 | base::Closure stop_callback_; |
| 138 | |
| 139 | DISALLOW_COPY_AND_ASSIGN(ScreenTrayItem); |
| 140 | }; |
| 141 | |
| 142 | } // namespace internal |
| 143 | } // namespace ash |
| 144 | |
| 145 | #endif // ASH_SYSTEM_CHROMEOS_SCREEN_TRAY_ITEM_H_ |