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

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

Issue 2517833004: [MR] Cancel auto-switching from tab mirroring to Cast SDK at page navigation based on user pref (Closed)
Patch Set: Add checks for OS_ANDROID Created 4 years 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
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 #include "chrome/browser/media/router/media_source_helper.h" 5 #include "chrome/browser/media/router/media_source_helper.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "chrome/browser/media/router/media_source.h" 11 #include "chrome/browser/media/router/media_source.h"
12 #include "chrome/browser/sessions/session_tab_helper.h" 12 #include "chrome/browser/sessions/session_tab_helper.h"
13 #include "url/gurl.h" 13 #include "url/gurl.h"
14 14
15 namespace media_router { 15 namespace media_router {
16 16
17 namespace { 17 namespace {
18 18
19 // Prefixes used to format and detect various protocols' media source URNs. 19 // Prefixes used to format and detect various protocols' media source URNs.
20 // See: https://www.ietf.org/rfc/rfc3406.txt 20 // See: https://www.ietf.org/rfc/rfc3406.txt
21 constexpr char kTabMediaUrnFormat[] = "urn:x-org.chromium.media:source:tab:%d"; 21 constexpr char kTabMediaUrnFormat[] = "urn:x-org.chromium.media:source:tab:%d";
22 constexpr char kDesktopMediaUrn[] = "urn:x-org.chromium.media:source:desktop"; 22 constexpr char kDesktopMediaUrn[] = "urn:x-org.chromium.media:source:desktop";
23 constexpr char kTabRemotingUrnFormat[] = 23 constexpr char kTabRemotingUrnFormat[] =
24 "urn:x-org.chromium.media:source:tab_content_remoting:%d"; 24 "urn:x-org.chromium.media:source:tab_content_remoting:%d";
25 25
26 // This value must be the same as |chrome.cast.AUTO_JOIN_PRESENTATION_ID| in the
27 // component extension.
28 constexpr char kAutoJoinPresentationId[] = "auto-join";
29
26 } // namespace 30 } // namespace
27 31
28 MediaSource MediaSourceForTab(int tab_id) { 32 MediaSource MediaSourceForTab(int tab_id) {
29 return MediaSource(base::StringPrintf(kTabMediaUrnFormat, tab_id)); 33 return MediaSource(base::StringPrintf(kTabMediaUrnFormat, tab_id));
30 } 34 }
31 35
32 MediaSource MediaSourceForTabContentRemoting(content::WebContents* contents) { 36 MediaSource MediaSourceForTabContentRemoting(content::WebContents* contents) {
33 DCHECK(contents); 37 DCHECK(contents);
34 return MediaSource(base::StringPrintf(kTabRemotingUrnFormat, 38 return MediaSource(base::StringPrintf(kTabRemotingUrnFormat,
35 SessionTabHelper::IdForTab(contents))); 39 SessionTabHelper::IdForTab(contents)));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 bool IsValidMediaSource(const MediaSource& source) { 76 bool IsValidMediaSource(const MediaSource& source) {
73 return TabIdFromMediaSource(source) > 0 || 77 return TabIdFromMediaSource(source) > 0 ||
74 IsDesktopMirroringMediaSource(source) || 78 IsDesktopMirroringMediaSource(source) ||
75 IsValidPresentationUrl(GURL(source.id())); 79 IsValidPresentationUrl(GURL(source.id()));
76 } 80 }
77 81
78 bool IsValidPresentationUrl(const GURL& url) { 82 bool IsValidPresentationUrl(const GURL& url) {
79 return url.is_valid() && url.SchemeIsHTTPOrHTTPS(); 83 return url.is_valid() && url.SchemeIsHTTPOrHTTPS();
80 } 84 }
81 85
86 bool IsAutoJoinPresentationId(const std::string& presentation_id) {
87 return presentation_id == kAutoJoinPresentationId;
88 }
89
82 } // namespace media_router 90 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698