Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
| OLD | NEW |