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

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

Issue 2697363002: cros: Fix various small issues with cast tray entry. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « ash/ash_strings.grd ('k') | ash/common/system/chromeos/screen_security/screen_tray_item.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 WmShell::Get()->cast_config()->StopCasting(displayed_route_.Clone()); 153 WmShell::Get()->cast_config()->StopCasting(displayed_route_.Clone());
154 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_CAST_STOP_CAST); 154 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_CAST_STOP_CAST);
155 } 155 }
156 156
157 void CastCastView::UpdateLabel( 157 void CastCastView::UpdateLabel(
158 const std::vector<mojom::SinkAndRoutePtr>& sinks_routes) { 158 const std::vector<mojom::SinkAndRoutePtr>& sinks_routes) {
159 for (auto& i : sinks_routes) { 159 for (auto& i : sinks_routes) {
160 const mojom::CastSinkPtr& sink = i->sink; 160 const mojom::CastSinkPtr& sink = i->sink;
161 const mojom::CastRoutePtr& route = i->route; 161 const mojom::CastRoutePtr& route = i->route;
162 162
163 if (!route->id.empty()) { 163 // We only want to display casts that came from this machine, since on a
164 // busy network many other people could be casting.
165 if (!route->id.empty() && route->is_local_source) {
164 displayed_route_ = route.Clone(); 166 displayed_route_ = route.Clone();
165 167
166 // We want to display different labels inside of the title depending on 168 // We want to display different labels inside of the title depending on
167 // what we are actually casting - either the desktop, a tab, or a fallback 169 // what we are actually casting - either the desktop, a tab, or a fallback
168 // that catches everything else (ie, an extension tab). 170 // that catches everything else (ie, an extension tab).
169 switch (route->content_source) { 171 switch (route->content_source) {
170 case ash::mojom::ContentSource::UNKNOWN: 172 case ash::mojom::ContentSource::UNKNOWN:
171 label()->SetText( 173 label()->SetText(
172 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_CAST_CAST_UNKNOWN)); 174 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_CAST_CAST_UNKNOWN));
175 stop_button()->SetAccessibleName(l10n_util::GetStringUTF16(
176 IDS_ASH_STATUS_TRAY_CAST_CAST_UNKNOWN_ACCESSIBILITY_STOP));
173 break; 177 break;
174 case ash::mojom::ContentSource::TAB: 178 case ash::mojom::ContentSource::TAB:
175 label()->SetText(ElideString(l10n_util::GetStringFUTF16( 179 label()->SetText(ElideString(l10n_util::GetStringFUTF16(
176 IDS_ASH_STATUS_TRAY_CAST_CAST_TAB, 180 IDS_ASH_STATUS_TRAY_CAST_CAST_TAB,
177 base::UTF8ToUTF16(route->title), base::UTF8ToUTF16(sink->name)))); 181 base::UTF8ToUTF16(route->title), base::UTF8ToUTF16(sink->name))));
182 stop_button()->SetAccessibleName(
183 ElideString(l10n_util::GetStringFUTF16(
184 IDS_ASH_STATUS_TRAY_CAST_CAST_TAB_ACCESSIBILITY_STOP,
185 base::UTF8ToUTF16(route->title),
186 base::UTF8ToUTF16(sink->name))));
178 break; 187 break;
179 case ash::mojom::ContentSource::DESKTOP: 188 case ash::mojom::ContentSource::DESKTOP:
180 label()->SetText(ElideString( 189 label()->SetText(ElideString(
181 l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_CAST_CAST_DESKTOP, 190 l10n_util::GetStringFUTF16(IDS_ASH_STATUS_TRAY_CAST_CAST_DESKTOP,
182 base::UTF8ToUTF16(sink->name)))); 191 base::UTF8ToUTF16(sink->name))));
192 stop_button()->SetAccessibleName(
193 ElideString(l10n_util::GetStringFUTF16(
194 IDS_ASH_STATUS_TRAY_CAST_CAST_DESKTOP_ACCESSIBILITY_STOP,
195 base::UTF8ToUTF16(sink->name))));
183 break; 196 break;
184 } 197 }
185 198
186 PreferredSizeChanged(); 199 PreferredSizeChanged();
187 Layout(); 200 Layout();
188 201 // Only need to update labels once.
189 // If this machine is the source of the activity, then we want to display 202 break;
190 // it over any other activity. There can be multiple activities if other
191 // devices on the network are casting at the same time.
192 if (route->is_local_source)
193 break;
194 } 203 }
195 } 204 }
196 } 205 }
197 206
198 void CastCastView::ButtonPressed(views::Button* sender, 207 void CastCastView::ButtonPressed(views::Button* sender,
199 const ui::Event& event) { 208 const ui::Event& event) {
200 StopCasting(); 209 StopCasting();
201 } 210 }
202 211
203 // This view by itself does very little. It acts as a front-end for managing 212 // This view by itself does very little. It acts as a front-end for managing
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 tray_->SetVisible(is_mirror_casting_); 549 tray_->SetVisible(is_mirror_casting_);
541 } else { 550 } else {
542 if (default_) 551 if (default_)
543 default_->SetVisible(false); 552 default_->SetVisible(false);
544 if (tray_) 553 if (tray_)
545 tray_->SetVisible(false); 554 tray_->SetVisible(false);
546 } 555 }
547 } 556 }
548 557
549 bool TrayCast::HasActiveRoute() { 558 bool TrayCast::HasActiveRoute() {
550 if (is_mirror_casting_)
551 return true;
552
553 for (const auto& sr : sinks_and_routes_) { 559 for (const auto& sr : sinks_and_routes_) {
554 if (!sr->route->title.empty()) 560 if (!sr->route->title.empty() && sr->route->is_local_source)
555 return true; 561 return true;
556 } 562 }
557 563
558 return false; 564 return false;
559 } 565 }
560 566
561 void TrayCast::OnCastingSessionStartedOrStopped(bool started) { 567 void TrayCast::OnCastingSessionStartedOrStopped(bool started) {
562 is_mirror_casting_ = started; 568 is_mirror_casting_ = started;
563 UpdatePrimaryView(); 569 UpdatePrimaryView();
564 } 570 }
565 571
566 } // namespace ash 572 } // namespace ash
OLDNEW
« no previous file with comments | « ash/ash_strings.grd ('k') | ash/common/system/chromeos/screen_security/screen_tray_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698