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

Unified Diff: chrome/browser/ui/webui/media_router/media_router_ui.cc

Issue 1173753003: [Media Router] Implement JoinRoute + update CreateRoute API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile fix again x2 Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/media_router/media_router_ui.cc
diff --git a/chrome/browser/ui/webui/media_router/media_router_ui.cc b/chrome/browser/ui/webui/media_router/media_router_ui.cc
index 9e6d529de8c5b50026b3a7ac3c90a1a9e15eddfb..752c006433b0d010f45367ce66ddf83da8d170d6 100644
--- a/chrome/browser/ui/webui/media_router/media_router_ui.cc
+++ b/chrome/browser/ui/webui/media_router/media_router_ui.cc
@@ -36,6 +36,8 @@ namespace media_router {
namespace {
std::string GetHostFromURL(const GURL& gurl) {
+ if (gurl.is_empty())
+ return std::string();
std::string host = gurl.host();
if (base::StartsWithASCII(host, "www.", false))
host = host.substr(4);
@@ -295,6 +297,7 @@ void MediaRouterUI::OnRouteResponseReceived(scoped_ptr<MediaRoute> route,
bool MediaRouterUI::DoCreateRoute(const MediaSink::Id& sink_id,
MediaCastMode cast_mode) {
DCHECK(query_result_manager_.get());
+ DCHECK(initiator_);
// Note that there is a rarely-encountered bug, where the MediaCastMode to
// MediaSource mapping could have been updated, between when the user
@@ -310,10 +313,27 @@ bool MediaRouterUI::DoCreateRoute(const MediaSink::Id& sink_id,
has_pending_route_request_ = true;
requesting_route_for_default_source_ = cast_mode == MediaCastMode::DEFAULT;
- router_->CreateRoute(source.id(), sink_id,
+ GURL origin;
+ // TODO(imcheng): What is the origin if not creating route in DEFAULT mode?
+ if (requesting_route_for_default_source_) {
+ origin = frame_url_.GetOrigin();
+ } else {
+ // Requesting route for mirroring. Use a placeholder URL as origin.
+ origin = GURL(chrome::kChromeUIMediaRouterURL);
+ }
+ DCHECK(origin.is_valid());
+
+ DVLOG(1) << "DoCreateRoute: origin: " << origin;
+
+ router_->CreateRoute(source.id(), sink_id, origin,
+ SessionTabHelper::IdForTab(initiator_),
base::Bind(&MediaRouterUI::OnRouteResponseReceived,
weak_factory_.GetWeakPtr()));
return true;
}
+std::string MediaRouterUI::GetFrameURLHost() const {
+ return GetHostFromURL(frame_url_);
+}
+
} // namespace media_router

Powered by Google App Engine
This is Rietveld 408576698