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

Side by Side Diff: chrome/browser/ui/webui/media_router/media_router_ui.cc

Issue 1294133002: [Presentation API, MediaRouter] Routing from media sink selection to route creation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@media-router-discovery-2
Patch Set: Fixed comments and naming and DCHECKs Created 5 years, 4 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
« no previous file with comments | « chrome/browser/ui/webui/media_router/media_router_dialog_controller_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_presentation_session_request.h" 10 #include "chrome/browser/media/router/create_presentation_session_request.h"
(...skipping 17 matching lines...) Expand all
28 #include "chrome/common/url_constants.h" 28 #include "chrome/common/url_constants.h"
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 void HandleRouteResponseForPresentationApi(
39 scoped_ptr<CreatePresentationSessionRequest> presentation_request,
40 const MediaRoute* route,
41 const std::string& presentation_id,
42 const std::string& error) {
43 DCHECK(presentation_request);
44 if (!route) {
45 presentation_request->MaybeInvokeErrorCallback(
46 content::PresentationError(content::PRESENTATION_ERROR_UNKNOWN, error));
47 } else {
48 presentation_request->MaybeInvokeSuccessCallback(presentation_id,
49 route->media_route_id());
50 }
51 }
52
53 std::string GetHostFromURL(const GURL& gurl) { 38 std::string GetHostFromURL(const GURL& gurl) {
54 if (gurl.is_empty()) 39 if (gurl.is_empty())
55 return std::string(); 40 return std::string();
56 std::string host = gurl.host(); 41 std::string host = gurl.host();
57 if (base::StartsWith(host, "www.", base::CompareCase::INSENSITIVE_ASCII)) 42 if (base::StartsWith(host, "www.", base::CompareCase::INSENSITIVE_ASCII))
58 host = host.substr(4); 43 host = host.substr(4);
59 return host; 44 return host;
60 } 45 }
61 46
62 } // namespace 47 } // namespace
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 // as browser-initiated. 328 // as browser-initiated.
344 std::vector<MediaRouteResponseCallback> route_response_callbacks; 329 std::vector<MediaRouteResponseCallback> route_response_callbacks;
345 route_response_callbacks.push_back( 330 route_response_callbacks.push_back(
346 base::Bind(&MediaRouterUI::OnRouteResponseReceived, 331 base::Bind(&MediaRouterUI::OnRouteResponseReceived,
347 weak_factory_.GetWeakPtr(), sink_id)); 332 weak_factory_.GetWeakPtr(), sink_id));
348 if (requesting_route_for_default_source_) { 333 if (requesting_route_for_default_source_) {
349 if (presentation_request_) { 334 if (presentation_request_) {
350 // |presentation_request_| will be nullptr after this call, as the 335 // |presentation_request_| will be nullptr after this call, as the
351 // object will be transferred to the callback. 336 // object will be transferred to the callback.
352 route_response_callbacks.push_back( 337 route_response_callbacks.push_back(
353 base::Bind(&HandleRouteResponseForPresentationApi, 338 base::Bind(&CreatePresentationSessionRequest::HandleRouteResponse,
354 base::Passed(&presentation_request_))); 339 base::Passed(&presentation_request_)));
355 } else if (presentation_service_delegate_) { 340 } else if (presentation_service_delegate_) {
356 route_response_callbacks.push_back( 341 route_response_callbacks.push_back(
357 base::Bind(&PresentationServiceDelegateImpl::OnRouteResponse, 342 base::Bind(&PresentationServiceDelegateImpl::OnRouteResponse,
358 presentation_service_delegate_)); 343 presentation_service_delegate_));
359 } 344 }
360 } 345 }
361 346
362 router_->CreateRoute(source.id(), sink_id, origin, 347 router_->CreateRoute(source.id(), sink_id, origin,
363 SessionTabHelper::IdForTab(initiator_), 348 SessionTabHelper::IdForTab(initiator_),
364 route_response_callbacks); 349 route_response_callbacks);
365 return true; 350 return true;
366 } 351 }
367 352
368 std::string MediaRouterUI::GetFrameURLHost() const { 353 std::string MediaRouterUI::GetFrameURLHost() const {
369 return GetHostFromURL(frame_url_); 354 return GetHostFromURL(frame_url_);
370 } 355 }
371 356
372 const std::string& MediaRouterUI::GetRouteProviderExtensionId() const { 357 const std::string& MediaRouterUI::GetRouteProviderExtensionId() const {
373 return router_->media_route_provider_extension_id(); 358 return router_->media_route_provider_extension_id();
374 } 359 }
375 360
376 } // namespace media_router 361 } // namespace media_router
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/media_router/media_router_dialog_controller_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698