Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ASH_SYSTEM_CHROMEOS_SCREEN_TRAY_ITEM_H_ | 5 #ifndef ASH_SYSTEM_CHROMEOS_SCREEN_TRAY_ITEM_H_ |
| 6 #define ASH_SYSTEM_CHROMEOS_SCREEN_TRAY_ITEM_H_ | 6 #define ASH_SYSTEM_CHROMEOS_SCREEN_TRAY_ITEM_H_ |
| 7 | 7 |
| 8 #include "ash/system/tray/system_tray.h" | 8 #include "ash/system/tray/system_tray.h" |
| 9 #include "ash/system/tray/system_tray_item.h" | 9 #include "ash/system/tray/system_tray_item.h" |
| 10 #include "ash/system/tray/system_tray_notifier.h" | 10 #include "ash/system/tray/system_tray_notifier.h" |
| 11 #include "ash/system/tray/tray_item_view.h" | 11 #include "ash/system/tray/tray_item_view.h" |
| 12 #include "ash/system/tray/tray_notification_view.h" | 12 #include "ash/system/tray/tray_notification_view.h" |
| 13 #include "ash/system/tray/tray_popup_label_button.h" | 13 #include "ash/system/tray/tray_popup_label_button.h" |
| 14 #include "ui/message_center/notification_delegate.h" | 14 #include "ui/message_center/notification_delegate.h" |
| 15 #include "ui/views/controls/button/button.h" | 15 #include "ui/views/controls/button/button.h" |
| 16 #include "ui/views/controls/image_view.h" | 16 #include "ui/views/controls/image_view.h" |
| 17 | 17 |
| 18 namespace views { | 18 namespace views { |
| 19 class View; | 19 class View; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace ash { | 22 namespace ash { |
| 23 class ScreenTrayItem; | 23 class ScreenTrayItem; |
| 24 | 24 |
| 25 namespace tray { | 25 namespace tray { |
| 26 | 26 |
| 27 class ScreenTrayView : public TrayItemView { | 27 class ScreenTrayView : public TrayItemView { |
| 28 public: | 28 public: |
| 29 ScreenTrayView(ScreenTrayItem* screen_tray_item, int icon_id); | 29 ScreenTrayView(ScreenTrayItem* screen_tray_item, int icon_id); |
| 30 virtual ~ScreenTrayView(); | 30 ~ScreenTrayView() override; |
| 31 | 31 |
| 32 void Update(); | 32 void Update(); |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 ScreenTrayItem* screen_tray_item_; | 35 ScreenTrayItem* screen_tray_item_; |
| 36 | 36 |
| 37 DISALLOW_COPY_AND_ASSIGN(ScreenTrayView); | 37 DISALLOW_COPY_AND_ASSIGN(ScreenTrayView); |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 class ScreenStatusView : public views::View, | 40 class ScreenStatusView : public views::View, |
| 41 public views::ButtonListener { | 41 public views::ButtonListener { |
| 42 public: | 42 public: |
| 43 ScreenStatusView(ScreenTrayItem* screen_tray_item, | 43 ScreenStatusView(ScreenTrayItem* screen_tray_item, |
| 44 int icon_id, | 44 int icon_id, |
| 45 const base::string16& label_text, | 45 const base::string16& label_text, |
| 46 const base::string16& stop_button_text); | 46 const base::string16& stop_button_text); |
| 47 virtual ~ScreenStatusView(); | 47 ~ScreenStatusView() override; |
| 48 | 48 |
| 49 // Overridden from views::View. | 49 // Overridden from views::View. |
| 50 virtual void Layout() override; | 50 void Layout() override; |
| 51 | 51 |
| 52 // Overridden from views::ButtonListener. | 52 // Overridden from views::ButtonListener. |
| 53 virtual void ButtonPressed(views::Button* sender, | 53 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 54 const ui::Event& event) override; | |
| 55 | 54 |
| 56 void CreateItems(); | 55 void CreateItems(); |
| 57 void Update(); | 56 void Update(); |
| 58 | 57 |
| 59 private: | 58 private: |
| 60 ScreenTrayItem* screen_tray_item_; | 59 ScreenTrayItem* screen_tray_item_; |
| 61 views::ImageView* icon_; | 60 views::ImageView* icon_; |
| 62 views::Label* label_; | 61 views::Label* label_; |
| 63 TrayPopupLabelButton* stop_button_; | 62 TrayPopupLabelButton* stop_button_; |
| 64 int icon_id_; | 63 int icon_id_; |
| 65 base::string16 label_text_; | 64 base::string16 label_text_; |
| 66 base::string16 stop_button_text_; | 65 base::string16 stop_button_text_; |
| 67 | 66 |
| 68 DISALLOW_COPY_AND_ASSIGN(ScreenStatusView); | 67 DISALLOW_COPY_AND_ASSIGN(ScreenStatusView); |
| 69 }; | 68 }; |
| 70 | 69 |
| 71 class ScreenNotificationDelegate : public message_center::NotificationDelegate { | 70 class ScreenNotificationDelegate : public message_center::NotificationDelegate { |
| 72 public: | 71 public: |
| 73 explicit ScreenNotificationDelegate(ScreenTrayItem* screen_tray); | 72 explicit ScreenNotificationDelegate(ScreenTrayItem* screen_tray); |
| 74 | 73 |
| 75 // message_center::NotificationDelegate overrides: | 74 // message_center::NotificationDelegate overrides: |
| 76 virtual void ButtonClick(int button_index) override; | 75 void ButtonClick(int button_index) override; |
| 77 | 76 |
| 78 protected: | 77 protected: |
| 79 virtual ~ScreenNotificationDelegate(); | 78 ~ScreenNotificationDelegate() override; |
| 80 | 79 |
| 81 private: | 80 private: |
| 82 ScreenTrayItem* screen_tray_; | 81 ScreenTrayItem* screen_tray_; |
| 83 | 82 |
| 84 DISALLOW_COPY_AND_ASSIGN(ScreenNotificationDelegate); | 83 DISALLOW_COPY_AND_ASSIGN(ScreenNotificationDelegate); |
| 85 }; | 84 }; |
| 86 | 85 |
| 87 } // namespace tray | 86 } // namespace tray |
| 88 | 87 |
| 89 | 88 |
| 90 // The base tray item for screen capture and screen sharing. The | 89 // The base tray item for screen capture and screen sharing. The |
| 91 // Start method brings up a notification and a tray item, and the user | 90 // Start method brings up a notification and a tray item, and the user |
| 92 // can stop the screen capture/sharing by pressing the stop button. | 91 // can stop the screen capture/sharing by pressing the stop button. |
| 93 class ASH_EXPORT ScreenTrayItem : public SystemTrayItem { | 92 class ASH_EXPORT ScreenTrayItem : public SystemTrayItem { |
| 94 public: | 93 public: |
| 95 explicit ScreenTrayItem(SystemTray* system_tray); | 94 explicit ScreenTrayItem(SystemTray* system_tray); |
| 96 virtual ~ScreenTrayItem(); | 95 ~ScreenTrayItem() override; |
| 97 | 96 |
| 98 tray::ScreenTrayView* tray_view() { return tray_view_; } | 97 tray::ScreenTrayView* tray_view() { return tray_view_; } |
| 99 void set_tray_view(tray::ScreenTrayView* tray_view) { | 98 void set_tray_view(tray::ScreenTrayView* tray_view) { |
| 100 tray_view_ = tray_view; | 99 tray_view_ = tray_view; |
| 101 } | 100 } |
| 102 | 101 |
| 103 tray::ScreenStatusView* default_view() { return default_view_; } | 102 tray::ScreenStatusView* default_view() { return default_view_; } |
| 104 void set_default_view(tray::ScreenStatusView* default_view) { | 103 void set_default_view(tray::ScreenStatusView* default_view) { |
| 105 default_view_ = default_view; | 104 default_view_ = default_view; |
| 106 } | 105 } |
| 107 | 106 |
| 108 bool is_started() const { return is_started_; } | 107 bool is_started() const { return is_started_; } |
| 109 void set_is_started(bool is_started) { is_started_ = is_started; } | 108 void set_is_started(bool is_started) { is_started_ = is_started; } |
| 110 | 109 |
| 111 void Update(); | 110 void Update(); |
| 112 void Start(const base::Closure& stop_callback); | 111 void Start(const base::Closure& stop_callback); |
| 113 void Stop(); | 112 void Stop(); |
| 114 | 113 |
| 115 // Creates or updates the notification for the tray item. | 114 // Creates or updates the notification for the tray item. |
| 116 virtual void CreateOrUpdateNotification() = 0; | 115 virtual void CreateOrUpdateNotification() = 0; |
| 117 | 116 |
| 118 // Returns the id of the notification for the tray item. | 117 // Returns the id of the notification for the tray item. |
| 119 virtual std::string GetNotificationId() = 0; | 118 virtual std::string GetNotificationId() = 0; |
| 120 | 119 |
| 121 // Overridden from SystemTrayItem. | 120 // Overridden from SystemTrayItem. |
| 122 virtual views::View* CreateTrayView(user::LoginStatus status) override = 0; | 121 views::View* CreateTrayView(user::LoginStatus status) override = 0; |
|
James Cook
2015/01/15 20:43:18
I think this is correct, but it looks a little odd
dcheng
2015/01/15 21:01:45
Usually people don't specify these if they're just
| |
| 123 virtual views::View* CreateDefaultView(user::LoginStatus status) override = 0; | 122 views::View* CreateDefaultView(user::LoginStatus status) override = 0; |
| 124 virtual void DestroyTrayView() override; | 123 void DestroyTrayView() override; |
| 125 virtual void DestroyDefaultView() override; | 124 void DestroyDefaultView() override; |
| 126 virtual void UpdateAfterShelfAlignmentChange( | 125 void UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) override; |
| 127 ShelfAlignment alignment) override; | |
| 128 | 126 |
| 129 private: | 127 private: |
| 130 tray::ScreenTrayView* tray_view_; | 128 tray::ScreenTrayView* tray_view_; |
| 131 tray::ScreenStatusView* default_view_; | 129 tray::ScreenStatusView* default_view_; |
| 132 bool is_started_; | 130 bool is_started_; |
| 133 base::Closure stop_callback_; | 131 base::Closure stop_callback_; |
| 134 | 132 |
| 135 DISALLOW_COPY_AND_ASSIGN(ScreenTrayItem); | 133 DISALLOW_COPY_AND_ASSIGN(ScreenTrayItem); |
| 136 }; | 134 }; |
| 137 | 135 |
| 138 } // namespace ash | 136 } // namespace ash |
| 139 | 137 |
| 140 #endif // ASH_SYSTEM_CHROMEOS_SCREEN_TRAY_ITEM_H_ | 138 #endif // ASH_SYSTEM_CHROMEOS_SCREEN_TRAY_ITEM_H_ |
| OLD | NEW |