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

Side by Side 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: 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 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/ui/webui/media_router/media_router_ui.h" 5 #include "chrome/browser/ui/webui/media_router/media_router_ui.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "chrome/browser/media/router/create_session_request.h" 10 #include "chrome/browser/media/router/create_session_request.h"
(...skipping 18 matching lines...) Expand all
29 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
30 #include "content/public/browser/web_ui.h" 30 #include "content/public/browser/web_ui.h"
31 #include "content/public/browser/web_ui_data_source.h" 31 #include "content/public/browser/web_ui_data_source.h"
32 #include "ui/web_dialogs/web_dialog_delegate.h" 32 #include "ui/web_dialogs/web_dialog_delegate.h"
33 33
34 namespace media_router { 34 namespace media_router {
35 35
36 namespace { 36 namespace {
37 37
38 std::string GetHostFromURL(const GURL& gurl) { 38 std::string GetHostFromURL(const GURL& gurl) {
39 if (gurl.is_empty())
40 return std::string();
39 std::string host = gurl.host(); 41 std::string host = gurl.host();
40 if (StartsWithASCII(host, "www.", false)) 42 if (StartsWithASCII(host, "www.", false))
41 host = host.substr(4); 43 host = host.substr(4);
42 return host; 44 return host;
43 } 45 }
44 46
45 } // namespace 47 } // namespace
46 48
47 // This class calls to refresh the UI when the highest priority issue is 49 // This class calls to refresh the UI when the highest priority issue is
48 // updated. 50 // updated.
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 290 }
289 } 291 }
290 292
291 has_pending_route_request_ = false; 293 has_pending_route_request_ = false;
292 requesting_route_for_default_source_ = false; 294 requesting_route_for_default_source_ = false;
293 } 295 }
294 296
295 bool MediaRouterUI::DoCreateRoute(const MediaSink::Id& sink_id, 297 bool MediaRouterUI::DoCreateRoute(const MediaSink::Id& sink_id,
296 MediaCastMode cast_mode) { 298 MediaCastMode cast_mode) {
297 DCHECK(query_result_manager_.get()); 299 DCHECK(query_result_manager_.get());
300 DCHECK(initiator_);
298 301
299 // Note that there is a rarely-encountered bug, where the MediaCastMode to 302 // Note that there is a rarely-encountered bug, where the MediaCastMode to
300 // MediaSource mapping could have been updated, between when the user 303 // MediaSource mapping could have been updated, between when the user
301 // clicked on the UI to start a create route request, 304 // clicked on the UI to start a create route request,
302 // and when this function is called. 305 // and when this function is called.
303 // However, since the user does not have visibility into the MediaSource, and 306 // However, since the user does not have visibility into the MediaSource, and
304 // that it occurs very rarely in practice, we leave it as-is for now. 307 // that it occurs very rarely in practice, we leave it as-is for now.
305 MediaSource source = query_result_manager_->GetSourceForCastMode(cast_mode); 308 MediaSource source = query_result_manager_->GetSourceForCastMode(cast_mode);
306 if (source.Empty()) { 309 if (source.Empty()) {
307 LOG(ERROR) << "No corresponding MediaSource for cast mode " << cast_mode; 310 LOG(ERROR) << "No corresponding MediaSource for cast mode " << cast_mode;
308 return false; 311 return false;
309 } 312 }
310 313
311 has_pending_route_request_ = true; 314 has_pending_route_request_ = true;
312 requesting_route_for_default_source_ = cast_mode == MediaCastMode::DEFAULT; 315 requesting_route_for_default_source_ = cast_mode == MediaCastMode::DEFAULT;
313 router_->CreateRoute(source.id(), sink_id, 316 GURL origin;
317 // TODO(imcheng): What is the origin if not creating route in DEFAULT mode?
mark a. foltz 2015/06/10 23:18:51 If the user is e.g. initiating tab mirroring it sh
imcheng (use chromium acct) 2015/06/11 22:49:12 Done.
318 if (requesting_route_for_default_source_) {
319 origin = frame_url_.GetOrigin();
320 DCHECK(origin.is_valid());
321 }
322 DVLOG(1) << "DoCreateRoute: origin: " << origin;
323
324 router_->CreateRoute(source.id(), sink_id, origin,
325 SessionTabHelper::IdForTab(initiator_),
314 base::Bind(&MediaRouterUI::OnRouteResponseReceived, 326 base::Bind(&MediaRouterUI::OnRouteResponseReceived,
315 weak_factory_.GetWeakPtr())); 327 weak_factory_.GetWeakPtr()));
316 return true; 328 return true;
317 } 329 }
318 330
331 std::string MediaRouterUI::GetFrameURLHost() const {
332 return GetHostFromURL(frame_url_);
333 }
334
319 } // namespace media_router 335 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698