Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: ash/common/system/chromeos/cast/tray_cast.cc

Issue 2761063002: Move more from WmShell to Shell (Closed)
Patch Set: merge Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 nullptr, 121 nullptr,
122 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_CAST_CAST_UNKNOWN), 122 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_CAST_CAST_UNKNOWN),
123 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_CAST_STOP)) { 123 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_CAST_STOP)) {
124 icon()->SetImage( 124 icon()->SetImage(
125 gfx::CreateVectorIcon(kSystemMenuCastEnabledIcon, kMenuIconColor)); 125 gfx::CreateVectorIcon(kSystemMenuCastEnabledIcon, kMenuIconColor));
126 } 126 }
127 127
128 CastCastView::~CastCastView() {} 128 CastCastView::~CastCastView() {}
129 129
130 void CastCastView::StopCasting() { 130 void CastCastView::StopCasting() {
131 WmShell::Get()->cast_config()->StopCasting(displayed_route_.Clone()); 131 Shell::Get()->cast_config()->StopCasting(displayed_route_.Clone());
132 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_CAST_STOP_CAST); 132 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_CAST_STOP_CAST);
133 } 133 }
134 134
135 void CastCastView::UpdateLabel( 135 void CastCastView::UpdateLabel(
136 const std::vector<mojom::SinkAndRoutePtr>& sinks_routes) { 136 const std::vector<mojom::SinkAndRoutePtr>& sinks_routes) {
137 for (auto& i : sinks_routes) { 137 for (auto& i : sinks_routes) {
138 const mojom::CastSinkPtr& sink = i->sink; 138 const mojom::CastSinkPtr& sink = i->sink;
139 const mojom::CastRoutePtr& route = i->route; 139 const mojom::CastRoutePtr& route = i->route;
140 140
141 // We only want to display casts that came from this machine, since on a 141 // We only want to display casts that came from this machine, since on a
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 kTrayPopupPaddingBetweenItems); 408 kTrayPopupPaddingBetweenItems);
409 409
410 scroll_content()->AddChildView(container); 410 scroll_content()->AddChildView(container);
411 return container; 411 return container;
412 } 412 }
413 413
414 void CastDetailedView::HandleViewClicked(views::View* view) { 414 void CastDetailedView::HandleViewClicked(views::View* view) {
415 // Find the receiver we are going to cast to. 415 // Find the receiver we are going to cast to.
416 auto it = view_to_sink_map_.find(view); 416 auto it = view_to_sink_map_.find(view);
417 if (it != view_to_sink_map_.end()) { 417 if (it != view_to_sink_map_.end()) {
418 WmShell::Get()->cast_config()->CastToSink(it->second.Clone()); 418 Shell::Get()->cast_config()->CastToSink(it->second.Clone());
419 WmShell::Get()->RecordUserMetricsAction( 419 WmShell::Get()->RecordUserMetricsAction(
420 UMA_STATUS_AREA_DETAILED_CAST_VIEW_LAUNCH_CAST); 420 UMA_STATUS_AREA_DETAILED_CAST_VIEW_LAUNCH_CAST);
421 } 421 }
422 } 422 }
423 423
424 } // namespace tray 424 } // namespace tray
425 425
426 TrayCast::TrayCast(SystemTray* system_tray) 426 TrayCast::TrayCast(SystemTray* system_tray)
427 : SystemTrayItem(system_tray, UMA_CAST) { 427 : SystemTrayItem(system_tray, UMA_CAST) {
428 Shell::GetInstance()->AddShellObserver(this); 428 Shell::GetInstance()->AddShellObserver(this);
429 WmShell::Get()->cast_config()->AddObserver(this); 429 Shell::Get()->cast_config()->AddObserver(this);
430 WmShell::Get()->cast_config()->RequestDeviceRefresh(); 430 Shell::Get()->cast_config()->RequestDeviceRefresh();
431 } 431 }
432 432
433 TrayCast::~TrayCast() { 433 TrayCast::~TrayCast() {
434 WmShell::Get()->cast_config()->RemoveObserver(this); 434 Shell::Get()->cast_config()->RemoveObserver(this);
435 Shell::GetInstance()->RemoveShellObserver(this); 435 Shell::GetInstance()->RemoveShellObserver(this);
436 } 436 }
437 437
438 void TrayCast::StartCastForTest(const std::string& receiver_id) { 438 void TrayCast::StartCastForTest(const std::string& receiver_id) {
439 if (detailed_ != nullptr) 439 if (detailed_ != nullptr)
440 detailed_->SimulateViewClickedForTest(receiver_id); 440 detailed_->SimulateViewClickedForTest(receiver_id);
441 } 441 }
442 442
443 void TrayCast::StopCastForTest() { 443 void TrayCast::StopCastForTest() {
444 default_->cast_view()->StopCasting(); 444 default_->cast_view()->StopCasting();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 if (default_) { 498 if (default_) {
499 bool has_receivers = !sinks_and_routes_.empty(); 499 bool has_receivers = !sinks_and_routes_.empty();
500 default_->SetVisible(has_receivers); 500 default_->SetVisible(has_receivers);
501 default_->cast_view()->UpdateLabel(sinks_and_routes_); 501 default_->cast_view()->UpdateLabel(sinks_and_routes_);
502 } 502 }
503 if (detailed_) 503 if (detailed_)
504 detailed_->UpdateReceiverList(sinks_and_routes_); 504 detailed_->UpdateReceiverList(sinks_and_routes_);
505 } 505 }
506 506
507 void TrayCast::UpdatePrimaryView() { 507 void TrayCast::UpdatePrimaryView() {
508 if (WmShell::Get()->cast_config()->Connected() && 508 if (Shell::Get()->cast_config()->Connected() && !sinks_and_routes_.empty()) {
509 !sinks_and_routes_.empty()) {
510 if (default_) { 509 if (default_) {
511 if (HasActiveRoute()) 510 if (HasActiveRoute())
512 default_->ActivateCastView(); 511 default_->ActivateCastView();
513 else 512 else
514 default_->ActivateSelectView(); 513 default_->ActivateSelectView();
515 } 514 }
516 515
517 if (tray_) 516 if (tray_)
518 tray_->SetVisible(is_mirror_casting_); 517 tray_->SetVisible(is_mirror_casting_);
519 } else { 518 } else {
(...skipping 12 matching lines...) Expand all
532 531
533 return false; 532 return false;
534 } 533 }
535 534
536 void TrayCast::OnCastingSessionStartedOrStopped(bool started) { 535 void TrayCast::OnCastingSessionStartedOrStopped(bool started) {
537 is_mirror_casting_ = started; 536 is_mirror_casting_ = started;
538 UpdatePrimaryView(); 537 UpdatePrimaryView();
539 } 538 }
540 539
541 } // namespace ash 540 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/brightness/tray_brightness.cc ('k') | ash/common/system/chromeos/enterprise/tray_enterprise.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698