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

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: Code review feedback. 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:";
mark a. foltz 2015/03/05 16:58:41 This can be removed.
Kevin M 2015/03/05 18:34:18 Done.
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 when the TODO in
32 // MediaSourceManager::GetDefaultMediaSource is resolved.
33 MediaSource ForCastAppMediaSource(const std::string& app_id) {
34 return kCastUrnPrefix + app_id;
35 }
36
37 MediaSource ForPresentationUrl(const std::string& presentation_url) {
38 return presentation_url;
39 }
40
41 bool IsMirroringMediaSource(const MediaSource& source) {
42 return StartsWithASCII(source, kDesktopMediaUrnPrefix, true) ||
43 StartsWithASCII(source, kTabMediaUrnPrefix, true);
44 }
45
46 bool IsValidMediaSource(const MediaSource& source) {
47 if (IsMirroringMediaSource(source) ||
48 StartsWithASCII(source, kDialUrnPrefix, true) ||
mark a. foltz 2015/03/05 16:58:41 As can this line.
Kevin M 2015/03/05 18:34:18 Done.
49 StartsWithASCII(source, kCastUrnPrefix, true)) {
50 return true;
51 }
52 GURL url(source);
53 return url.is_valid() && url.SchemeIsHTTPOrHTTPS();
54 }
55
56 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698