| OLD | NEW |
| 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 20 matching lines...) Expand all Loading... |
| 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( | 38 void HandleRouteResponseForPresentationApi( |
| 39 scoped_ptr<CreatePresentationSessionRequest> presentation_request, | 39 scoped_ptr<CreatePresentationSessionRequest> presentation_request, |
| 40 const MediaRoute* route, | 40 const MediaRoute* route, |
| 41 const std::string& presentation_id, |
| 41 const std::string& error) { | 42 const std::string& error) { |
| 42 DCHECK(presentation_request); | 43 DCHECK(presentation_request); |
| 43 if (!route) { | 44 if (!route) { |
| 44 presentation_request->MaybeInvokeErrorCallback( | 45 presentation_request->MaybeInvokeErrorCallback( |
| 45 content::PresentationError(content::PRESENTATION_ERROR_UNKNOWN, error)); | 46 content::PresentationError(content::PRESENTATION_ERROR_UNKNOWN, error)); |
| 46 } else { | 47 } else { |
| 47 presentation_request->MaybeInvokeSuccessCallback(route->media_route_id()); | 48 presentation_request->MaybeInvokeSuccessCallback(presentation_id, |
| 49 route->media_route_id()); |
| 48 } | 50 } |
| 49 } | 51 } |
| 50 | 52 |
| 51 std::string GetHostFromURL(const GURL& gurl) { | 53 std::string GetHostFromURL(const GURL& gurl) { |
| 52 if (gurl.is_empty()) | 54 if (gurl.is_empty()) |
| 53 return std::string(); | 55 return std::string(); |
| 54 std::string host = gurl.host(); | 56 std::string host = gurl.host(); |
| 55 if (base::StartsWith(host, "www.", base::CompareCase::INSENSITIVE_ASCII)) | 57 if (base::StartsWith(host, "www.", base::CompareCase::INSENSITIVE_ASCII)) |
| 56 host = host.substr(4); | 58 host = host.substr(4); |
| 57 return host; | 59 return host; |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 handler_->UpdateIssue(issue); | 277 handler_->UpdateIssue(issue); |
| 276 } | 278 } |
| 277 | 279 |
| 278 void MediaRouterUI::OnRoutesUpdated(const std::vector<MediaRoute>& routes) { | 280 void MediaRouterUI::OnRoutesUpdated(const std::vector<MediaRoute>& routes) { |
| 279 routes_ = routes; | 281 routes_ = routes; |
| 280 if (ui_initialized_) | 282 if (ui_initialized_) |
| 281 handler_->UpdateRoutes(routes_); | 283 handler_->UpdateRoutes(routes_); |
| 282 } | 284 } |
| 283 | 285 |
| 284 void MediaRouterUI::OnRouteResponseReceived(const MediaRoute* route, | 286 void MediaRouterUI::OnRouteResponseReceived(const MediaRoute* route, |
| 287 const std::string& presentation_id, |
| 285 const std::string& error) { | 288 const std::string& error) { |
| 286 DVLOG(1) << "OnRouteResponseReceived"; | 289 DVLOG(1) << "OnRouteResponseReceived"; |
| 287 // TODO(imcheng): Display error in UI. (crbug.com/490372) | 290 // TODO(imcheng): Display error in UI. (crbug.com/490372) |
| 288 if (!route) | 291 if (!route) |
| 289 LOG(ERROR) << "MediaRouteResponse returned error: " << error; | 292 LOG(ERROR) << "MediaRouteResponse returned error: " << error; |
| 290 else | 293 else |
| 291 handler_->AddRoute(*route); | 294 handler_->AddRoute(*route); |
| 292 | 295 |
| 293 has_pending_route_request_ = false; | 296 has_pending_route_request_ = false; |
| 294 requesting_route_for_default_source_ = false; | 297 requesting_route_for_default_source_ = false; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 | 362 |
| 360 std::string MediaRouterUI::GetFrameURLHost() const { | 363 std::string MediaRouterUI::GetFrameURLHost() const { |
| 361 return GetHostFromURL(frame_url_); | 364 return GetHostFromURL(frame_url_); |
| 362 } | 365 } |
| 363 | 366 |
| 364 const std::string& MediaRouterUI::GetRouteProviderExtensionId() const { | 367 const std::string& MediaRouterUI::GetRouteProviderExtensionId() const { |
| 365 return router_->media_route_provider_extension_id(); | 368 return router_->media_route_provider_extension_id(); |
| 366 } | 369 } |
| 367 | 370 |
| 368 } // namespace media_router | 371 } // namespace media_router |
| OLD | NEW |