| 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/media/router/presentation_service_delegate_impl.h" | 5 #include "chrome/browser/media/router/presentation_service_delegate_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/containers/scoped_ptr_hash_map.h" | 9 #include "base/containers/scoped_ptr_hash_map.h" |
| 10 #include "base/containers/small_map.h" | 10 #include "base/containers/small_map.h" |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 frame_manager_->OnPresentationSessionStarted( | 541 frame_manager_->OnPresentationSessionStarted( |
| 542 RenderFrameHostId(render_process_id, render_frame_id), false, new_session, | 542 RenderFrameHostId(render_process_id, render_frame_id), false, new_session, |
| 543 route_id); | 543 route_id); |
| 544 success_cb.Run(new_session); | 544 success_cb.Run(new_session); |
| 545 } | 545 } |
| 546 | 546 |
| 547 void PresentationServiceDelegateImpl::StartSession( | 547 void PresentationServiceDelegateImpl::StartSession( |
| 548 int render_process_id, | 548 int render_process_id, |
| 549 int render_frame_id, | 549 int render_frame_id, |
| 550 const std::string& presentation_url, | 550 const std::string& presentation_url, |
| 551 const std::string& presentation_id, | |
| 552 const PresentationSessionSuccessCallback& success_cb, | 551 const PresentationSessionSuccessCallback& success_cb, |
| 553 const PresentationSessionErrorCallback& error_cb) { | 552 const PresentationSessionErrorCallback& error_cb) { |
| 554 if (presentation_url.empty() || !IsValidPresentationUrl(presentation_url)) { | 553 if (presentation_url.empty() || !IsValidPresentationUrl(presentation_url)) { |
| 555 error_cb.Run(content::PresentationError(content::PRESENTATION_ERROR_UNKNOWN, | 554 error_cb.Run(content::PresentationError(content::PRESENTATION_ERROR_UNKNOWN, |
| 556 "Invalid presentation arguments.")); | 555 "Invalid presentation arguments.")); |
| 557 return; | 556 return; |
| 558 } | 557 } |
| 559 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); | 558 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); |
| 560 std::string final_presentation_id = | 559 |
| 561 presentation_id.empty() | 560 // TODO(mlamouri,avayvod): don't use the default presentation id provided by |
| 562 ? frame_manager_->GetDefaultPresentationId(render_frame_host_id) | 561 // the frame when we implement the new default presentation model. |
| 563 : presentation_id; | 562 std::string presentation_id = |
| 564 if (final_presentation_id.empty()) | 563 frame_manager_->GetDefaultPresentationId(render_frame_host_id); |
| 565 // TODO(imcheng): Remove presentation_id argument entirely if required | 564 if (presentation_id.empty()) |
| 566 // by Presentation API spec. | 565 presentation_id = base::GenerateGUID(); |
| 567 final_presentation_id = base::GenerateGUID(); | 566 |
| 568 scoped_ptr<CreateSessionRequest> context(new CreateSessionRequest( | 567 scoped_ptr<CreateSessionRequest> context(new CreateSessionRequest( |
| 569 presentation_url, final_presentation_id, | 568 presentation_url, presentation_id, |
| 570 GetLastCommittedURLForFrame(render_frame_host_id), | 569 GetLastCommittedURLForFrame(render_frame_host_id), |
| 571 base::Bind(&PresentationServiceDelegateImpl::OnStartSessionSucceeded, | 570 base::Bind(&PresentationServiceDelegateImpl::OnStartSessionSucceeded, |
| 572 weak_factory_.GetWeakPtr(), render_process_id, render_frame_id, | 571 weak_factory_.GetWeakPtr(), render_process_id, render_frame_id, |
| 573 success_cb), | 572 success_cb), |
| 574 error_cb)); | 573 error_cb)); |
| 575 // NOTE: Currently this request is ignored if a dialog is already open, e.g. | 574 // NOTE: Currently this request is ignored if a dialog is already open, e.g. |
| 576 // via browser action. In practice, this should rarely happen, but log | 575 // via browser action. In practice, this should rarely happen, but log |
| 577 // an error message in case it does. | 576 // an error message in case it does. |
| 578 MediaRouterDialogController::CreateForWebContents(web_contents_); | 577 MediaRouterDialogController::CreateForWebContents(web_contents_); |
| 579 MediaRouterDialogController* controller = | 578 MediaRouterDialogController* controller = |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest( | 698 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest( |
| 700 int render_process_id, | 699 int render_process_id, |
| 701 int render_frame_id, | 700 int render_frame_id, |
| 702 const MediaSource::Id& source_id) const { | 701 const MediaSource::Id& source_id) const { |
| 703 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); | 702 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); |
| 704 return frame_manager_->HasScreenAvailabilityListenerForTest( | 703 return frame_manager_->HasScreenAvailabilityListenerForTest( |
| 705 render_frame_host_id, source_id); | 704 render_frame_host_id, source_id); |
| 706 } | 705 } |
| 707 | 706 |
| 708 } // namespace media_router | 707 } // namespace media_router |
| OLD | NEW |