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/extensions/api/tab_capture/offscreen_presentation.h" | 5 #include "chrome/browser/extensions/api/tab_capture/offscreen_presentation.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" | 10 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" |
| 11 #include "chrome/browser/media/router/receiver_presentation_service_delegate_imp
l.h" |
11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/ui/web_contents_sizer.h" | 13 #include "chrome/browser/ui/web_contents_sizer.h" |
13 #include "content/public/browser/render_widget_host_view.h" | 14 #include "content/public/browser/render_widget_host_view.h" |
14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
15 #include "extensions/browser/extension_host.h" | 16 #include "extensions/browser/extension_host.h" |
16 #include "extensions/browser/process_manager.h" | 17 #include "extensions/browser/process_manager.h" |
17 | 18 |
18 #if defined(USE_AURA) | 19 #if defined(USE_AURA) |
19 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
20 #include "base/thread_task_runner_handle.h" | 21 #include "base/thread_task_runner_handle.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 #endif | 213 #endif |
213 | 214 |
214 // Set initial size, if specified. | 215 // Set initial size, if specified. |
215 if (!initial_size.IsEmpty()) | 216 if (!initial_size.IsEmpty()) |
216 ResizeWebContents(presentation_web_contents_.get(), initial_size); | 217 ResizeWebContents(presentation_web_contents_.get(), initial_size); |
217 | 218 |
218 // Mute audio output. When tab capture starts, the audio will be | 219 // Mute audio output. When tab capture starts, the audio will be |
219 // automatically unmuted, but will be captured into the MediaStream. | 220 // automatically unmuted, but will be captured into the MediaStream. |
220 presentation_web_contents_->SetAudioMuted(true); | 221 presentation_web_contents_->SetAudioMuted(true); |
221 | 222 |
| 223 // Register the offscreen tab as the receiver of the offscreen presentation. |
| 224 media_router::ReceiverPresentationServiceDelegateImpl::CreateForWebContents( |
| 225 presentation_web_contents_.get(), presentation_id()); |
| 226 |
222 // Navigate to the initial URL of the presentation. | 227 // Navigate to the initial URL of the presentation. |
223 content::NavigationController::LoadURLParams load_params(start_url_); | 228 content::NavigationController::LoadURLParams load_params(start_url_); |
224 load_params.should_replace_current_entry = true; | 229 load_params.should_replace_current_entry = true; |
225 load_params.should_clear_history_list = true; | 230 load_params.should_clear_history_list = true; |
226 presentation_web_contents_->GetController().LoadURLWithParams(load_params); | 231 presentation_web_contents_->GetController().LoadURLWithParams(load_params); |
227 | 232 |
228 start_time_ = base::TimeTicks::Now(); | 233 start_time_ = base::TimeTicks::Now(); |
229 DieIfContentCaptureEnded(); | 234 DieIfContentCaptureEnded(); |
230 } | 235 } |
231 | 236 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 | 473 |
469 // Schedule the timer to check again in a second. | 474 // Schedule the timer to check again in a second. |
470 capture_poll_timer_.Start( | 475 capture_poll_timer_.Start( |
471 FROM_HERE, | 476 FROM_HERE, |
472 base::TimeDelta::FromSeconds(kPollIntervalInSeconds), | 477 base::TimeDelta::FromSeconds(kPollIntervalInSeconds), |
473 base::Bind(&OffscreenPresentation::DieIfContentCaptureEnded, | 478 base::Bind(&OffscreenPresentation::DieIfContentCaptureEnded, |
474 base::Unretained(this))); | 479 base::Unretained(this))); |
475 } | 480 } |
476 | 481 |
477 } // namespace extensions | 482 } // namespace extensions |
OLD | NEW |