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

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

Issue 1259073004: [Presentation API] Change ListenForSessionMessages API to client-style. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile fix 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
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 21 matching lines...) Expand all
32 #include "content/public/browser/web_ui_data_source.h" 32 #include "content/public/browser/web_ui_data_source.h"
33 #include "ui/web_dialogs/web_dialog_delegate.h" 33 #include "ui/web_dialogs/web_dialog_delegate.h"
34 34
35 namespace media_router { 35 namespace media_router {
36 36
37 namespace { 37 namespace {
38 38
39 void HandleRouteResponseForPresentationApi( 39 void HandleRouteResponseForPresentationApi(
40 scoped_ptr<CreatePresentationSessionRequest> presentation_request, 40 scoped_ptr<CreatePresentationSessionRequest> presentation_request,
41 const MediaRoute* route, 41 const MediaRoute* route,
42 const std::string& presentation_id,
42 const std::string& error) { 43 const std::string& error) {
43 DCHECK(presentation_request); 44 DCHECK(presentation_request);
44 if (!route) { 45 if (!route) {
45 presentation_request->MaybeInvokeErrorCallback( 46 presentation_request->MaybeInvokeErrorCallback(
46 content::PresentationError(content::PRESENTATION_ERROR_UNKNOWN, error)); 47 content::PresentationError(content::PRESENTATION_ERROR_UNKNOWN, error));
47 } else { 48 } else {
49 // Presentation ID should not have changed.
50 DCHECK_EQ(presentation_request->presentation_info().presentation_id,
51 presentation_id);
48 presentation_request->MaybeInvokeSuccessCallback(route->media_route_id()); 52 presentation_request->MaybeInvokeSuccessCallback(route->media_route_id());
49 } 53 }
50 } 54 }
51 55
52 std::string GetHostFromURL(const GURL& gurl) { 56 std::string GetHostFromURL(const GURL& gurl) {
53 if (gurl.is_empty()) 57 if (gurl.is_empty())
54 return std::string(); 58 return std::string();
55 std::string host = gurl.host(); 59 std::string host = gurl.host();
56 if (base::StartsWith(host, "www.", base::CompareCase::INSENSITIVE_ASCII)) 60 if (base::StartsWith(host, "www.", base::CompareCase::INSENSITIVE_ASCII))
57 host = host.substr(4); 61 host = host.substr(4);
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 handler_->UpdateIssue(issue); 275 handler_->UpdateIssue(issue);
272 } 276 }
273 277
274 void MediaRouterUI::OnRoutesUpdated(const std::vector<MediaRoute>& routes) { 278 void MediaRouterUI::OnRoutesUpdated(const std::vector<MediaRoute>& routes) {
275 routes_ = routes; 279 routes_ = routes;
276 if (ui_initialized_) 280 if (ui_initialized_)
277 handler_->UpdateRoutes(routes_); 281 handler_->UpdateRoutes(routes_);
278 } 282 }
279 283
280 void MediaRouterUI::OnRouteResponseReceived(const MediaRoute* route, 284 void MediaRouterUI::OnRouteResponseReceived(const MediaRoute* route,
285 const std::string& presentation_id,
281 const std::string& error) { 286 const std::string& error) {
282 DVLOG(1) << "OnRouteResponseReceived"; 287 DVLOG(1) << "OnRouteResponseReceived";
283 // TODO(imcheng): Display error in UI. (crbug.com/490372) 288 // TODO(imcheng): Display error in UI. (crbug.com/490372)
284 if (!route) 289 if (!route)
285 LOG(ERROR) << "MediaRouteResponse returned error: " << error; 290 LOG(ERROR) << "MediaRouteResponse returned error: " << error;
286 else 291 else
287 handler_->AddRoute(*route); 292 handler_->AddRoute(*route);
288 293
289 has_pending_route_request_ = false; 294 has_pending_route_request_ = false;
290 requesting_route_for_default_source_ = false; 295 requesting_route_for_default_source_ = false;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 360
356 std::string MediaRouterUI::GetFrameURLHost() const { 361 std::string MediaRouterUI::GetFrameURLHost() const {
357 return GetHostFromURL(frame_url_); 362 return GetHostFromURL(frame_url_);
358 } 363 }
359 364
360 const std::string& MediaRouterUI::GetRouteProviderExtensionId() const { 365 const std::string& MediaRouterUI::GetRouteProviderExtensionId() const {
361 return router_->media_route_provider_extension_id(); 366 return router_->media_route_provider_extension_id();
362 } 367 }
363 368
364 } // namespace media_router 369 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698