| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "ash/common/system/chromeos/cast/tray_cast.h" | 5 #include "ash/common/system/chromeos/cast/tray_cast.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } // namespace | 73 } // namespace |
| 74 | 74 |
| 75 namespace tray { | 75 namespace tray { |
| 76 | 76 |
| 77 // This view is displayed in the system tray when the cast extension is active. | 77 // This view is displayed in the system tray when the cast extension is active. |
| 78 // It asks the user if they want to cast the desktop. If they click on the | 78 // It asks the user if they want to cast the desktop. If they click on the |
| 79 // chevron, then a detail view will replace this view where the user will | 79 // chevron, then a detail view will replace this view where the user will |
| 80 // actually pick the cast receiver. | 80 // actually pick the cast receiver. |
| 81 class CastSelectDefaultView : public TrayItemMore { | 81 class CastSelectDefaultView : public TrayItemMore { |
| 82 public: | 82 public: |
| 83 CastSelectDefaultView(SystemTrayItem* owner, bool show_more); | 83 explicit CastSelectDefaultView(SystemTrayItem* owner); |
| 84 ~CastSelectDefaultView() override; | 84 ~CastSelectDefaultView() override; |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 DISALLOW_COPY_AND_ASSIGN(CastSelectDefaultView); | 87 DISALLOW_COPY_AND_ASSIGN(CastSelectDefaultView); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 CastSelectDefaultView::CastSelectDefaultView(SystemTrayItem* owner, | 90 CastSelectDefaultView::CastSelectDefaultView(SystemTrayItem* owner) |
| 91 bool show_more) | 91 : TrayItemMore(owner) { |
| 92 : TrayItemMore(owner, show_more) { | |
| 93 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 92 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 94 | 93 |
| 95 // Update the image and label. | 94 // Update the image and label. |
| 96 if (MaterialDesignController::IsSystemTrayMenuMaterial()) | 95 if (MaterialDesignController::IsSystemTrayMenuMaterial()) |
| 97 SetImage(GetCastIconForSystemMenu(false)); | 96 SetImage(GetCastIconForSystemMenu(false)); |
| 98 else | 97 else |
| 99 SetImage(*rb.GetImageNamed(IDR_AURA_UBER_TRAY_CAST).ToImageSkia()); | 98 SetImage(*rb.GetImageNamed(IDR_AURA_UBER_TRAY_CAST).ToImageSkia()); |
| 100 | 99 |
| 101 base::string16 label = | 100 base::string16 label = |
| 102 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_CAST_DESKTOP); | 101 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_CAST_DESKTOP); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 const ui::Event& event) { | 207 const ui::Event& event) { |
| 209 StopCasting(); | 208 StopCasting(); |
| 210 } | 209 } |
| 211 | 210 |
| 212 // This view by itself does very little. It acts as a front-end for managing | 211 // This view by itself does very little. It acts as a front-end for managing |
| 213 // which of the two child views (|CastSelectDefaultView| and |CastCastView|) | 212 // which of the two child views (|CastSelectDefaultView| and |CastCastView|) |
| 214 // is active. | 213 // is active. |
| 215 class CastDuplexView : public views::View { | 214 class CastDuplexView : public views::View { |
| 216 public: | 215 public: |
| 217 CastDuplexView(SystemTrayItem* owner, | 216 CastDuplexView(SystemTrayItem* owner, |
| 218 bool show_more, | 217 bool enabled, |
| 219 const std::vector<mojom::SinkAndRoutePtr>& sinks_routes); | 218 const std::vector<mojom::SinkAndRoutePtr>& sinks_routes); |
| 220 ~CastDuplexView() override; | 219 ~CastDuplexView() override; |
| 221 | 220 |
| 222 // Activate either the casting or select view. | 221 // Activate either the casting or select view. |
| 223 void ActivateCastView(); | 222 void ActivateCastView(); |
| 224 void ActivateSelectView(); | 223 void ActivateSelectView(); |
| 225 | 224 |
| 226 CastSelectDefaultView* select_view() { return select_view_; } | 225 CastSelectDefaultView* select_view() { return select_view_; } |
| 227 CastCastView* cast_view() { return cast_view_; } | 226 CastCastView* cast_view() { return cast_view_; } |
| 228 | 227 |
| 229 private: | 228 private: |
| 230 // Overridden from views::View. | 229 // Overridden from views::View. |
| 231 void ChildPreferredSizeChanged(views::View* child) override; | 230 void ChildPreferredSizeChanged(views::View* child) override; |
| 232 void Layout() override; | 231 void Layout() override; |
| 233 | 232 |
| 234 // Only one of |select_view_| or |cast_view_| will be displayed at any given | 233 // Only one of |select_view_| or |cast_view_| will be displayed at any given |
| 235 // time. This will return the view is being displayed. | 234 // time. This will return the view is being displayed. |
| 236 views::View* ActiveChildView(); | 235 views::View* ActiveChildView(); |
| 237 | 236 |
| 238 CastSelectDefaultView* select_view_; | 237 CastSelectDefaultView* select_view_; |
| 239 CastCastView* cast_view_; | 238 CastCastView* cast_view_; |
| 240 | 239 |
| 241 DISALLOW_COPY_AND_ASSIGN(CastDuplexView); | 240 DISALLOW_COPY_AND_ASSIGN(CastDuplexView); |
| 242 }; | 241 }; |
| 243 | 242 |
| 244 CastDuplexView::CastDuplexView( | 243 CastDuplexView::CastDuplexView( |
| 245 SystemTrayItem* owner, | 244 SystemTrayItem* owner, |
| 246 bool show_more, | 245 bool enabled, |
| 247 const std::vector<mojom::SinkAndRoutePtr>& sinks_routes) { | 246 const std::vector<mojom::SinkAndRoutePtr>& sinks_routes) { |
| 248 select_view_ = new CastSelectDefaultView(owner, show_more); | 247 select_view_ = new CastSelectDefaultView(owner); |
| 248 select_view_->SetEnabled(enabled); |
| 249 cast_view_ = new CastCastView(); | 249 cast_view_ = new CastCastView(); |
| 250 cast_view_->UpdateLabel(sinks_routes); | 250 cast_view_->UpdateLabel(sinks_routes); |
| 251 SetLayoutManager(new views::FillLayout()); | 251 SetLayoutManager(new views::FillLayout()); |
| 252 | 252 |
| 253 ActivateSelectView(); | 253 ActivateSelectView(); |
| 254 } | 254 } |
| 255 | 255 |
| 256 CastDuplexView::~CastDuplexView() { | 256 CastDuplexView::~CastDuplexView() { |
| 257 RemoveChildView(ActiveChildView()); | 257 RemoveChildView(ActiveChildView()); |
| 258 delete select_view_; | 258 delete select_view_; |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 | 563 |
| 564 return false; | 564 return false; |
| 565 } | 565 } |
| 566 | 566 |
| 567 void TrayCast::OnCastingSessionStartedOrStopped(bool started) { | 567 void TrayCast::OnCastingSessionStartedOrStopped(bool started) { |
| 568 is_mirror_casting_ = started; | 568 is_mirror_casting_ = started; |
| 569 UpdatePrimaryView(); | 569 UpdatePrimaryView(); |
| 570 } | 570 } |
| 571 | 571 |
| 572 } // namespace ash | 572 } // namespace ash |
| OLD | NEW |