OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_HELPER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_HELPER_H_ |
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_HELPER_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_HELPER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "chrome/browser/media/router/media_source.h" | 10 #include "chrome/browser/media/router/media_source.h" |
11 | 11 |
12 namespace media_router { | 12 namespace media_router { |
13 | 13 |
14 // Helper library for protocol-specific media source object creation. | 14 // Helper library for protocol-specific media source object creation. |
15 | |
16 // TODO(kmarshall): Should these creation methods be moved to the WebUI, which | |
17 // (excluding Presentation API) is their only caller? The MR base code can be | |
18 // Also, consider generating an is_mirroring state boolean at the time of URN | |
19 // creation so that the mirroring status does not have to be determined from a | |
20 // string prefix check. | |
21 // These changes would allow the MR to handle MediaSource objects in the same | |
22 // type agnostic fashion vs. having to format and parse URNs and track which | |
23 // MediaSource types are mirroring-enabled. | |
24 | |
25 // Returns MediaSource URI depending on the type of source. | 15 // Returns MediaSource URI depending on the type of source. |
26 MediaSource ForTabMediaSource(int tab_id); | 16 MediaSource MediaSourceForTab(int tab_id); |
27 MediaSource ForDesktopMediaSource(); | 17 MediaSource MediaSourceForDesktop(); |
28 MediaSource ForCastAppMediaSource(const std::string& app_id); | 18 MediaSource MediaSourceForCastApp(const std::string& app_id); |
29 MediaSource ForPresentationUrl(const std::string& presentation_url); | 19 MediaSource MediaSourceForPresentationUrl(const std::string& presentation_url); |
30 | 20 |
31 // Returns true if |source| outputs its content via mirroring. | 21 // Returns true if |source| outputs its content via mirroring. |
32 bool IsMirroringMediaSource(const MediaSource& source); | 22 bool IsMirroringMediaSource(const MediaSource& source); |
33 | 23 |
34 // Checks that |source| is a parseable URN and is of a known type. | 24 // Checks that |source| is a parseable URN and is of a known type. |
35 // Does not deeper protocol-level syntax checks. | 25 // Does not deeper protocol-level syntax checks. |
36 bool IsValidMediaSource(const MediaSource& source); | 26 bool IsValidMediaSource(const MediaSource& source); |
37 | 27 |
| 28 // Extracts the presentation URL from |source|. |
| 29 // If |source| is invalid, an empty string is returned. |
| 30 std::string PresentationUrlFromMediaSource(const MediaSource& source); |
| 31 |
| 32 // Returns true if |source| is a valid presentation URL. |
| 33 bool IsValidPresentationUrl(const std::string& url); |
| 34 |
38 } // namespace media_router | 35 } // namespace media_router |
39 | 36 |
40 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_HELPER_H_ | 37 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SOURCE_HELPER_H_ |
OLD | NEW |