| 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_dialog_controller.h" | 5 #include "chrome/browser/ui/webui/media_router/media_router_dialog_controller.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "chrome/browser/media/router/presentation_service_delegate_impl.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" | 12 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" |
| 12 #include "chrome/browser/ui/webui/media_router/media_router_ui.h" | 13 #include "chrome/browser/ui/webui/media_router/media_router_ui.h" |
| 13 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 14 #include "components/web_modal/web_contents_modal_dialog_host.h" | 15 #include "components/web_modal/web_contents_modal_dialog_host.h" |
| 15 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/navigation_controller.h" | 17 #include "content/public/browser/navigation_controller.h" |
| 17 #include "content/public/browser/navigation_details.h" | 18 #include "content/public/browser/navigation_details.h" |
| 18 #include "content/public/browser/navigation_entry.h" | 19 #include "content/public/browser/navigation_entry.h" |
| 19 #include "content/public/browser/render_frame_host.h" | 20 #include "content/public/browser/render_frame_host.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 CreateMediaRouterDialog(); | 201 CreateMediaRouterDialog(); |
| 201 return GetMediaRouterDialog(); | 202 return GetMediaRouterDialog(); |
| 202 } | 203 } |
| 203 | 204 |
| 204 // Show the initiator holding the existing media router dialog. | 205 // Show the initiator holding the existing media router dialog. |
| 205 initiator_->GetDelegate()->ActivateContents(initiator_); | 206 initiator_->GetDelegate()->ActivateContents(initiator_); |
| 206 return media_router_dialog; | 207 return media_router_dialog; |
| 207 } | 208 } |
| 208 | 209 |
| 209 WebContents* MediaRouterDialogController::ShowMediaRouterDialogForPresentation( | 210 WebContents* MediaRouterDialogController::ShowMediaRouterDialogForPresentation( |
| 210 scoped_ptr<CreateSessionRequest> request) { | 211 scoped_ptr<CreatePresentationSessionRequest> request) { |
| 211 DCHECK(thread_checker_.CalledOnValidThread()); | 212 DCHECK(thread_checker_.CalledOnValidThread()); |
| 212 | 213 |
| 213 // Get the media router dialog for |initiator|, or create a new dialog | 214 // Get the media router dialog for |initiator|, or create a new dialog |
| 214 // if not found. | 215 // if not found. |
| 215 WebContents* media_router_dialog = GetMediaRouterDialog(); | 216 WebContents* media_router_dialog = GetMediaRouterDialog(); |
| 216 if (!media_router_dialog) { | 217 if (!media_router_dialog) { |
| 217 CreateMediaRouterDialog(); | 218 CreateMediaRouterDialog(); |
| 218 media_router_dialog = GetMediaRouterDialog(); | 219 media_router_dialog = GetMediaRouterDialog(); |
| 219 presentation_request_ = request.Pass(); | 220 presentation_request_ = request.Pass(); |
| 220 return media_router_dialog; | 221 return media_router_dialog; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 335 |
| 335 MediaRouterUI* media_router_ui = static_cast<MediaRouterUI*>( | 336 MediaRouterUI* media_router_ui = static_cast<MediaRouterUI*>( |
| 336 media_router_dialog->GetWebUI()->GetController()); | 337 media_router_dialog->GetWebUI()->GetController()); |
| 337 DCHECK(media_router_ui); | 338 DCHECK(media_router_ui); |
| 338 if (!media_router_ui) { | 339 if (!media_router_ui) { |
| 339 Reset(); | 340 Reset(); |
| 340 return; | 341 return; |
| 341 } | 342 } |
| 342 | 343 |
| 343 if (!presentation_request_.get()) { | 344 if (!presentation_request_.get()) { |
| 344 PresentationServiceDelegateImpl::CreateForWebContents(initiator); | 345 // TODO(imcheng): Don't create PresentationServiceDelegateImpl if it doesn't |
| 345 PresentationServiceDelegateImpl* delegate = | 346 // exist (crbug.com/508695). |
| 346 PresentationServiceDelegateImpl::FromWebContents(initiator); | 347 base::WeakPtr<PresentationServiceDelegateImpl> delegate = |
| 347 CHECK(delegate); | 348 PresentationServiceDelegateImpl::GetOrCreateForWebContents(initiator) |
| 349 ->GetWeakPtr(); |
| 348 media_router_ui->InitWithDefaultMediaSource(delegate); | 350 media_router_ui->InitWithDefaultMediaSource(delegate); |
| 349 } else { | 351 } else { |
| 350 media_router_ui->InitWithPresentationSessionRequest( | 352 media_router_ui->InitWithPresentationSessionRequest( |
| 351 initiator, presentation_request_.Pass()); | 353 initiator, presentation_request_.Pass()); |
| 352 } | 354 } |
| 353 } | 355 } |
| 354 | 356 |
| 355 } // namespace media_router | 357 } // namespace media_router |
| 356 | 358 |
| OLD | NEW |