Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / chrome / browser / ui / webui / media_router / media_cast_mode.cc
blobdd9a4309c02c0810cd9cacde3f370cc09758513b
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/webui/media_router/media_cast_mode.h"
7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/grit/generated_resources.h"
10 #include "ui/base/l10n/l10n_util.h"
12 namespace media_router {
14 std::string MediaCastModeToTitle(MediaCastMode mode, const std::string& host) {
15 switch (mode) {
16 case MediaCastMode::DEFAULT:
17 return l10n_util::GetStringFUTF8(
18 IDS_MEDIA_ROUTER_DEFAULT_CAST_MODE_TITLE, base::UTF8ToUTF16(host));
19 case MediaCastMode::TAB_MIRROR:
20 return l10n_util::GetStringUTF8(
21 IDS_MEDIA_ROUTER_TAB_MIRROR_CAST_MODE_TITLE);
22 case MediaCastMode::DESKTOP_OR_WINDOW_MIRROR:
23 return l10n_util::GetStringUTF8(
24 IDS_MEDIA_ROUTER_DESKTOP_OR_WINDOW_MIRROR_CAST_MODE_TITLE);
25 case MediaCastMode::SOUND_OPTIMIZED_TAB_MIRROR:
26 return l10n_util::GetStringUTF8(
27 IDS_MEDIA_ROUTER_SOUND_OPTIMIZED_TAB_MIRROR_CAST_MODE_TITLE);
28 default:
29 NOTREACHED();
30 return "";
34 std::string MediaCastModeToDescription(
35 MediaCastMode mode, const std::string& host) {
36 switch (mode) {
37 case MediaCastMode::DEFAULT:
38 return l10n_util::GetStringFUTF8(
39 IDS_MEDIA_ROUTER_DEFAULT_CAST_MODE, base::UTF8ToUTF16(host));
40 case MediaCastMode::TAB_MIRROR:
41 return l10n_util::GetStringUTF8(
42 IDS_MEDIA_ROUTER_TAB_MIRROR_CAST_MODE);
43 case MediaCastMode::DESKTOP_OR_WINDOW_MIRROR:
44 return l10n_util::GetStringUTF8(
45 IDS_MEDIA_ROUTER_DESKTOP_OR_WINDOW_MIRROR_CAST_MODE);
46 case MediaCastMode::SOUND_OPTIMIZED_TAB_MIRROR:
47 return l10n_util::GetStringUTF8(
48 IDS_MEDIA_ROUTER_SOUND_OPTIMIZED_TAB_MIRROR_CAST_MODE);
49 default:
50 NOTREACHED();
51 return "";
55 bool IsValidCastModeNum(int cast_mode_num) {
56 return cast_mode_num >= MediaCastMode::DEFAULT &&
57 cast_mode_num < MediaCastMode::NUM_CAST_MODES;
60 MediaCastMode GetPreferredCastMode(const CastModeSet& cast_modes) {
61 if (cast_modes.empty()) {
62 LOG(ERROR) << "Called with empty cast_modes!";
63 return MediaCastMode::DEFAULT;
65 return *cast_modes.begin();
68 } // namespace media_router