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_tab.h" | 5 #include "chrome/browser/extensions/api/tab_capture/offscreen_tab.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" | 12 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" |
| 13 #include "chrome/browser/media/router/receiver_presentation_service_delegate_imp
l.h" |
13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/web_contents_sizer.h" | 15 #include "chrome/browser/ui/web_contents_sizer.h" |
15 #include "content/public/browser/render_view_host.h" | 16 #include "content/public/browser/render_view_host.h" |
16 #include "content/public/browser/render_widget_host_view.h" | 17 #include "content/public/browser/render_widget_host_view.h" |
17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
18 #include "content/public/common/web_preferences.h" | 19 #include "content/public/common/web_preferences.h" |
19 #include "extensions/browser/extension_host.h" | 20 #include "extensions/browser/extension_host.h" |
20 #include "extensions/browser/process_manager.h" | 21 #include "extensions/browser/process_manager.h" |
21 | 22 |
22 using content::WebContents; | 23 using content::WebContents; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 111 |
111 // Set initial size, if specified. | 112 // Set initial size, if specified. |
112 if (!initial_size.IsEmpty()) | 113 if (!initial_size.IsEmpty()) |
113 ResizeWebContents(offscreen_tab_web_contents_.get(), | 114 ResizeWebContents(offscreen_tab_web_contents_.get(), |
114 gfx::Rect(initial_size)); | 115 gfx::Rect(initial_size)); |
115 | 116 |
116 // Mute audio output. When tab capture starts, the audio will be | 117 // Mute audio output. When tab capture starts, the audio will be |
117 // automatically unmuted, but will be captured into the MediaStream. | 118 // automatically unmuted, but will be captured into the MediaStream. |
118 offscreen_tab_web_contents_->SetAudioMuted(true); | 119 offscreen_tab_web_contents_->SetAudioMuted(true); |
119 | 120 |
120 // TODO(imcheng): If |optional_presentation_id| is not empty, register it with | |
121 // the PresentationRouter. http://crbug.com/513859 | |
122 if (!optional_presentation_id.empty()) { | 121 if (!optional_presentation_id.empty()) { |
123 NOTIMPLEMENTED() | 122 DVLOG(1) << " Register with ReceiverPresentationServiceDelegateImpl, " |
124 << "Register with PresentationRouter, id=" << optional_presentation_id; | 123 << "[presentation_id]: " << optional_presentation_id; |
| 124 // Register the offscreen tab as the receiver of the offscreen presentation. |
| 125 media_router::ReceiverPresentationServiceDelegateImpl::CreateForWebContents( |
| 126 offscreen_tab_web_contents_.get(), optional_presentation_id); |
125 | 127 |
126 if (auto* render_view_host = | 128 if (auto* render_view_host = |
127 offscreen_tab_web_contents_->GetRenderViewHost()) { | 129 offscreen_tab_web_contents_->GetRenderViewHost()) { |
128 auto web_prefs = render_view_host->GetWebkitPreferences(); | 130 auto web_prefs = render_view_host->GetWebkitPreferences(); |
129 web_prefs.presentation_receiver = true; | 131 web_prefs.presentation_receiver = true; |
130 render_view_host->UpdateWebkitPreferences(web_prefs); | 132 render_view_host->UpdateWebkitPreferences(web_prefs); |
131 } | 133 } |
132 } | 134 } |
133 | 135 |
134 // Navigate to the initial URL. | 136 // Navigate to the initial URL. |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 | 375 |
374 // Schedule the timer to check again in a second. | 376 // Schedule the timer to check again in a second. |
375 capture_poll_timer_.Start( | 377 capture_poll_timer_.Start( |
376 FROM_HERE, | 378 FROM_HERE, |
377 base::TimeDelta::FromSeconds(kPollIntervalInSeconds), | 379 base::TimeDelta::FromSeconds(kPollIntervalInSeconds), |
378 base::Bind(&OffscreenTab::DieIfContentCaptureEnded, | 380 base::Bind(&OffscreenTab::DieIfContentCaptureEnded, |
379 base::Unretained(this))); | 381 base::Unretained(this))); |
380 } | 382 } |
381 | 383 |
382 } // namespace extensions | 384 } // namespace extensions |
OLD | NEW |