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

Side by Side Diff: chrome/browser/media/router/media_source.cc

Issue 949293004: Add media router common classes and unittests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resync with latest changes Created 5 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
(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/media/router/media_source.h"
6
7 #include "base/strings/string_util.h"
8 #include "base/strings/stringprintf.h"
9 #include "url/gurl.h"
10
11 namespace media_router {
12
13 namespace {
14
15 // See: https://www.ietf.org/rfc/rfc3406.txt
16 const char* kTabMediaUrnPrefix = "urn:x-org.chromium.media:source:tab";
17 const char* kDesktopMediaUrnPrefix = "urn:x-org.chromium.media:source:desktop";
18 const char* kDialUrnPrefix = "urn:dial-multiscreen-org:dial:application:";
19 const char* kCastUrnPrefix = "urn:x-com.google.cast:application:";
20
21 } // namespace
22
23 MediaSource ForTabMediaSource(int tab_id) {
24 return base::StringPrintf("%s:%d", kTabMediaUrnPrefix, tab_id);
25 }
26
27 MediaSource ForDesktopMediaSource() {
28 return std::string(kDesktopMediaUrnPrefix);
29 }
30
31 // TODO(mfoltz): Remove? This is only used for tests.
mark a. foltz 2015/03/02 21:40:10 This is probably a good time as ever to do this.
Kevin M 2015/03/03 21:53:20 Done.
32 MediaSource ForDialAppMediaSource(const std::string& app_name) {
33 return kDialUrnPrefix + app_name;
34 }
35
36 // TODO(mfoltz): Remove when the TODO in
37 // MediaSourceManager::GetDefaultMediaSource is resolved.
mark a. foltz 2015/03/02 21:40:10 IIRC this will need to be retained until more Pres
Kevin M 2015/03/03 21:53:20 Acknowledged.
38 MediaSource ForCastAppMediaSource(const std::string& app_id) {
39 return kCastUrnPrefix + app_id;
40 }
41
42 MediaSource ForPresentationUrl(const std::string& presentation_url) {
43 return presentation_url;
44 }
45
46 bool IsMirroringMediaSource(const MediaSource& source) {
47 return StartsWithASCII(source, kDesktopMediaUrnPrefix, true) ||
48 StartsWithASCII(source, kTabMediaUrnPrefix, true);
49 }
50
51 bool IsValidMediaSource(const MediaSource& source) {
52 if (IsMirroringMediaSource(source) ||
53 StartsWithASCII(source, kDialUrnPrefix, true) ||
54 StartsWithASCII(source, kCastUrnPrefix, true)) {
55 return true;
56 }
57 GURL url(source);
58 return url.is_valid() && url.SchemeIsHTTPOrHTTPS();
59 }
60
61 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698