Chromium Code Reviews| 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/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/web_contents_sizer.h" | 14 #include "chrome/browser/ui/web_contents_sizer.h" |
| 15 #include "content/public/browser/render_widget_host_view.h" | 15 #include "content/public/browser/render_widget_host_view.h" |
| 16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 17 #include "extensions/browser/extension_host.h" | 17 #include "extensions/browser/extension_host.h" |
| 18 #include "extensions/browser/process_manager.h" | 18 #include "extensions/browser/process_manager.h" |
| 19 | 19 |
| 20 #if defined(ENABLE_MEDIA_ROUTER) | |
|
imcheng
2016/09/19 23:01:17
No need for the ENABLE_MEDIA_ROUTER check. We shou
zhaobin
2016/09/23 17:18:18
Done.
| |
| 21 #include "chrome/browser/media/router/media_router_feature.h" | |
|
imcheng
2016/09/19 23:01:17
this include not needed?
zhaobin
2016/09/23 17:18:18
Done.
| |
| 22 #include "chrome/browser/media/router/receiver_presentation_service_delegate_imp l.h" | |
| 23 #endif | |
| 24 | |
| 20 using content::WebContents; | 25 using content::WebContents; |
| 21 | 26 |
| 22 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::OffscreenTabsOwner); | 27 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::OffscreenTabsOwner); |
| 23 | 28 |
| 24 namespace { | 29 namespace { |
| 25 | 30 |
| 26 // Upper limit on the number of simultaneous off-screen tabs per extension | 31 // Upper limit on the number of simultaneous off-screen tabs per extension |
| 27 // instance. | 32 // instance. |
| 28 const int kMaxOffscreenTabsPerExtension = 3; | 33 const int kMaxOffscreenTabsPerExtension = 3; |
| 29 | 34 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 ResizeWebContents(offscreen_tab_web_contents_.get(), | 116 ResizeWebContents(offscreen_tab_web_contents_.get(), |
| 112 gfx::Rect(initial_size)); | 117 gfx::Rect(initial_size)); |
| 113 | 118 |
| 114 // Mute audio output. When tab capture starts, the audio will be | 119 // Mute audio output. When tab capture starts, the audio will be |
| 115 // automatically unmuted, but will be captured into the MediaStream. | 120 // automatically unmuted, but will be captured into the MediaStream. |
| 116 offscreen_tab_web_contents_->SetAudioMuted(true); | 121 offscreen_tab_web_contents_->SetAudioMuted(true); |
| 117 | 122 |
| 118 // TODO(imcheng): If |optional_presentation_id| is not empty, register it with | 123 // TODO(imcheng): If |optional_presentation_id| is not empty, register it with |
| 119 // the PresentationRouter. http://crbug.com/513859 | 124 // the PresentationRouter. http://crbug.com/513859 |
| 120 if (!optional_presentation_id.empty()) { | 125 if (!optional_presentation_id.empty()) { |
| 121 NOTIMPLEMENTED() | 126 #if defined(ENABLE_MEDIA_ROUTER) |
| 122 << "Register with PresentationRouter, id=" << optional_presentation_id; | 127 DVLOG(1) << "Register with PresentationRouter, id=" |
|
imcheng
2016/09/19 23:01:17
I suggest just combining this log statement with t
zhaobin
2016/09/23 17:18:18
Done.
| |
| 128 << optional_presentation_id; | |
| 129 // Register the offscreen tab as the receiver of the offscreen presentation. | |
| 130 media_router::ReceiverPresentationServiceDelegateImpl::CreateForWebContents( | |
| 131 offscreen_tab_web_contents_.get(), optional_presentation_id); | |
| 132 #endif // defined(ENABLE_MEDIA_ROUTER) | |
| 123 } | 133 } |
| 124 | 134 |
| 125 // Navigate to the initial URL. | 135 // Navigate to the initial URL. |
| 126 content::NavigationController::LoadURLParams load_params(start_url_); | 136 content::NavigationController::LoadURLParams load_params(start_url_); |
| 127 load_params.should_replace_current_entry = true; | 137 load_params.should_replace_current_entry = true; |
| 128 load_params.should_clear_history_list = true; | 138 load_params.should_clear_history_list = true; |
| 129 offscreen_tab_web_contents_->GetController().LoadURLWithParams(load_params); | 139 offscreen_tab_web_contents_->GetController().LoadURLWithParams(load_params); |
| 130 | 140 |
| 131 start_time_ = base::TimeTicks::Now(); | 141 start_time_ = base::TimeTicks::Now(); |
| 132 DieIfContentCaptureEnded(); | 142 DieIfContentCaptureEnded(); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 362 | 372 |
| 363 // Schedule the timer to check again in a second. | 373 // Schedule the timer to check again in a second. |
| 364 capture_poll_timer_.Start( | 374 capture_poll_timer_.Start( |
| 365 FROM_HERE, | 375 FROM_HERE, |
| 366 base::TimeDelta::FromSeconds(kPollIntervalInSeconds), | 376 base::TimeDelta::FromSeconds(kPollIntervalInSeconds), |
| 367 base::Bind(&OffscreenTab::DieIfContentCaptureEnded, | 377 base::Bind(&OffscreenTab::DieIfContentCaptureEnded, |
| 368 base::Unretained(this))); | 378 base::Unretained(this))); |
| 369 } | 379 } |
| 370 | 380 |
| 371 } // namespace extensions | 381 } // namespace extensions |
| OLD | NEW |