Index: ash/system/cast/tray_cast.h |
diff --git a/ash/system/cast/tray_cast.h b/ash/system/cast/tray_cast.h |
index 04a4bc28a802aebee55c40818e4a36ed0e16a31e..55264ce7f3ca972446eefadd189f3a92dee6fa50 100644 |
--- a/ash/system/cast/tray_cast.h |
+++ b/ash/system/cast/tray_cast.h |
@@ -5,10 +5,17 @@ |
#ifndef ASH_SYSTEM_CAST_TRAY_CAST_H_ |
#define ASH_SYSTEM_CAST_TRAY_CAST_H_ |
+#include "ash/ash_export.h" |
#include "ash/cast_config_delegate.h" |
#include "ash/shell_observer.h" |
#include "ash/system/tray/system_tray_item.h" |
+#include "ash/system/tray/tray_details_view.h" |
+#include "ash/system/tray/tray_item_more.h" |
+#include "ash/system/tray/tray_popup_label_button.h" |
+#include "ash/system/tray/view_click_listener.h" |
#include "base/memory/weak_ptr.h" |
+#include "ui/views/controls/button/button.h" |
+#include "ui/views/view.h" |
namespace ash { |
namespace tray { |
@@ -18,12 +25,14 @@ class CastDetailedView; |
class CastDuplexView; |
} // namespace tray |
-class TrayCast : public SystemTrayItem, public ShellObserver { |
+class ASH_EXPORT TrayCast : public SystemTrayItem, public ShellObserver { |
public: |
explicit TrayCast(SystemTray* system_tray); |
~TrayCast() override; |
private: |
+ friend class TrayCastTestAPI; |
+ |
// Overridden from SystemTrayItem. |
views::View* CreateTrayView(user::LoginStatus status) override; |
views::View* CreateDefaultView(user::LoginStatus status) override; |
@@ -64,6 +73,143 @@ class TrayCast : public SystemTrayItem, public ShellObserver { |
DISALLOW_COPY_AND_ASSIGN(TrayCast); |
}; |
+// The classes below are internal implementation details that are only exposed |
+// inside of this header for testing purposes. |
+namespace tray { |
+ |
+// This view is displayed in the system tray when the cast extension is active. |
+// It asks the user if they want to cast the desktop. If they click on the |
+// chevron, then a detail view will replace this view where the user will |
+// actually pick the cast receiver. |
+class CastSelectDefaultView : public TrayItemMore { |
+ public: |
+ CastSelectDefaultView(SystemTrayItem* owner, |
+ CastConfigDelegate* cast_config_delegate, |
+ bool show_more); |
+ ~CastSelectDefaultView() override; |
+ |
+ // Updates the label based on the current set of receivers (if there are or |
+ // are not any available receivers). |
+ void UpdateLabel(); |
+ |
+ private: |
+ void UpdateLabelCallback( |
+ const CastConfigDelegate::ReceiversAndActivites& receivers_activities); |
+ |
+ CastConfigDelegate* cast_config_delegate_; |
+ base::WeakPtrFactory<CastSelectDefaultView> weak_ptr_factory_; |
+ DISALLOW_COPY_AND_ASSIGN(CastSelectDefaultView); |
+}; |
+ |
+// This view displays a list of cast receivers that can be clicked on and casted |
+// to. It is activated by clicking on the chevron inside of |
+// |CastSelectDefaultView|. |
+class CastDetailedView : public TrayDetailsView, public ViewClickListener { |
+ public: |
+ CastDetailedView(SystemTrayItem* owner, |
+ CastConfigDelegate* cast_config_delegate, |
+ user::LoginStatus login); |
+ ~CastDetailedView() override; |
+ |
+ // Makes the detail view think the view associated with the given receiver_id |
+ // was clicked. This will start a cast. |
+ void SimulateViewClickedForTest(const std::string& receiver_id); |
+ |
+ private: |
+ void CreateItems(); |
+ |
+ void UpdateReceiverList(); |
+ void UpdateReceiverListCallback( |
+ const CastConfigDelegate::ReceiversAndActivites& |
+ new_receivers_and_activities); |
+ void UpdateReceiverListFromCachedData(); |
+ views::View* AddToReceiverList( |
+ const CastConfigDelegate::ReceiverAndActivity& receiverActivity); |
+ |
+ void AppendSettingsEntries(); |
+ void AppendHeaderEntry(); |
+ |
+ // Overridden from ViewClickListener. |
+ void OnViewClicked(views::View* sender) override; |
+ |
+ CastConfigDelegate* cast_config_delegate_; |
+ user::LoginStatus login_; |
+ views::View* options_ = nullptr; |
+ CastConfigDelegate::ReceiversAndActivites receivers_and_activities_; |
+ // A mapping from the view pointer to the associated activity id |
+ std::map<views::View*, std::string> receiver_activity_map_; |
+ base::WeakPtrFactory<CastDetailedView> weak_ptr_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CastDetailedView); |
+}; |
+ |
+// This view is displayed when the screen is actively being casted; it allows |
+// the user to easily stop casting. It fully replaces the |
+// |CastSelectDefaultView| view inside of the |CastDuplexView|. |
+class CastCastView : public views::View, public views::ButtonListener { |
+ public: |
+ explicit CastCastView(CastConfigDelegate* cast_config_delegate); |
+ ~CastCastView() override; |
+ |
+ void StopCasting(); |
+ |
+ // Updates the label for the stop view to include information about the |
+ // current device that is being casted. |
+ void UpdateLabel(); |
+ |
+ private: |
+ void UpdateLabelCallback( |
+ const CastConfigDelegate::ReceiversAndActivites& receivers_activities); |
+ |
+ // Overridden from views::View. |
+ int GetHeightForWidth(int width) const override; |
+ void Layout() override; |
+ |
+ // Overridden from views::ButtonListener. |
+ void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
+ |
+ CastConfigDelegate* cast_config_delegate_; |
+ views::ImageView* icon_; |
+ views::Label* label_; |
+ TrayPopupLabelButton* stop_button_; |
+ base::WeakPtrFactory<CastCastView> weak_ptr_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CastCastView); |
+}; |
+ |
+// This view by itself does very little. It acts as a front-end for managing |
+// which of the two child views (|CastSelectDefaultView| and |CastCastView|) |
+// is active. |
+class CastDuplexView : public views::View { |
+ public: |
+ CastDuplexView(SystemTrayItem* owner, |
+ CastConfigDelegate* config_delegate, |
+ bool show_more); |
+ ~CastDuplexView() override; |
+ |
+ // Activate either the casting or select view. |
+ void ActivateCastView(); |
+ void ActivateSelectView(); |
+ |
+ CastSelectDefaultView* select_view() { return select_view_; } |
+ CastCastView* cast_view() { return cast_view_; } |
+ |
+ // Only one of |select_view_| or |cast_view_| will be displayed at any given |
+ // time. This will return the view is being displayed. |
+ views::View* ActiveChildView(); |
+ |
+ private: |
+ // Overridden from views::View. |
+ void ChildPreferredSizeChanged(views::View* child) override; |
+ void Layout() override; |
+ |
+ CastSelectDefaultView* select_view_; |
+ CastCastView* cast_view_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CastDuplexView); |
+}; |
+ |
+} // namespace tray |
} // namespace ash |
#endif // ASH_SYSTEM_CAST_TRAY_CAST_H_ |