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

Side by Side Diff: chrome/browser/ui/webui/media_router/media_cast_mode.cc

Issue 1100763002: Inject CanAddURLToHistory into TopSitesImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@prefs
Patch Set: Fix error introduced during rebase Created 5 years, 7 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
(Empty)
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.
4
5 #include "chrome/browser/ui/webui/media_router/media_cast_mode.h"
6
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"
11
12 namespace media_router {
13
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 "";
31 }
32 }
33
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 "";
52 }
53 }
54
55 bool IsValidCastModeNum(int cast_mode_num) {
56 return cast_mode_num >= MediaCastMode::DEFAULT &&
57 cast_mode_num < MediaCastMode::NUM_CAST_MODES;
58 }
59
60 MediaCastMode GetPreferredCastMode(const CastModeSet& cast_modes) {
61 if (cast_modes.empty()) {
62 LOG(ERROR) << "Called with empty cast_modes!";
63 return MediaCastMode::DEFAULT;
64 }
65 return *cast_modes.begin();
66 }
67
68 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698