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 #include <memory> | |
9 #include <utility> | |
mark a. foltz
2016/10/04 00:32:20
These #includes don't seem to be used in your patc
| |
8 | 10 |
9 #include "base/bind.h" | 11 #include "base/bind.h" |
10 #include "base/macros.h" | 12 #include "base/macros.h" |
11 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
12 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" | 14 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" |
15 #include "chrome/browser/media/router/receiver_presentation_service_delegate_imp l.h" | |
13 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/web_contents_sizer.h" | 17 #include "chrome/browser/ui/web_contents_sizer.h" |
15 #include "content/public/browser/render_widget_host_view.h" | 18 #include "content/public/browser/render_widget_host_view.h" |
16 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
17 #include "extensions/browser/extension_host.h" | 20 #include "extensions/browser/extension_host.h" |
18 #include "extensions/browser/process_manager.h" | 21 #include "extensions/browser/process_manager.h" |
19 | 22 |
20 using content::WebContents; | 23 using content::WebContents; |
21 | 24 |
22 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::OffscreenTabsOwner); | 25 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::OffscreenTabsOwner); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 OffscreenTab::~OffscreenTab() { | 94 OffscreenTab::~OffscreenTab() { |
92 DVLOG(1) << "Destroying OffscreenTab for start_url=" << start_url_.spec(); | 95 DVLOG(1) << "Destroying OffscreenTab for start_url=" << start_url_.spec(); |
93 } | 96 } |
94 | 97 |
95 void OffscreenTab::Start(const GURL& start_url, | 98 void OffscreenTab::Start(const GURL& start_url, |
96 const gfx::Size& initial_size, | 99 const gfx::Size& initial_size, |
97 const std::string& optional_presentation_id) { | 100 const std::string& optional_presentation_id) { |
98 DCHECK(start_time_.is_null()); | 101 DCHECK(start_time_.is_null()); |
99 start_url_ = start_url; | 102 start_url_ = start_url; |
100 DVLOG(1) << "Starting OffscreenTab with initial size of " | 103 DVLOG(1) << "Starting OffscreenTab with initial size of " |
101 << initial_size.ToString() << " for start_url=" << start_url_.spec(); | 104 << initial_size.ToString() << " for start_url=" << start_url_.spec() |
102 | 105 << " Register with PresentationRouter, id=" |
mark a. foltz
2016/10/04 00:32:20
Did you mean ReceiverPresentationServiceDelegateIm
zhaobin
2016/10/04 02:43:00
Done.
| |
106 << optional_presentation_id; | |
103 // Create the WebContents to contain the off-screen tab's page. | 107 // Create the WebContents to contain the off-screen tab's page. |
104 offscreen_tab_web_contents_.reset( | 108 offscreen_tab_web_contents_.reset( |
105 WebContents::Create(WebContents::CreateParams(profile_.get()))); | 109 WebContents::Create(WebContents::CreateParams(profile_.get()))); |
106 offscreen_tab_web_contents_->SetDelegate(this); | 110 offscreen_tab_web_contents_->SetDelegate(this); |
107 WebContentsObserver::Observe(offscreen_tab_web_contents_.get()); | 111 WebContentsObserver::Observe(offscreen_tab_web_contents_.get()); |
108 | 112 |
109 // Set initial size, if specified. | 113 // Set initial size, if specified. |
110 if (!initial_size.IsEmpty()) | 114 if (!initial_size.IsEmpty()) |
111 ResizeWebContents(offscreen_tab_web_contents_.get(), | 115 ResizeWebContents(offscreen_tab_web_contents_.get(), |
112 gfx::Rect(initial_size)); | 116 gfx::Rect(initial_size)); |
113 | 117 |
114 // Mute audio output. When tab capture starts, the audio will be | 118 // Mute audio output. When tab capture starts, the audio will be |
115 // automatically unmuted, but will be captured into the MediaStream. | 119 // automatically unmuted, but will be captured into the MediaStream. |
116 offscreen_tab_web_contents_->SetAudioMuted(true); | 120 offscreen_tab_web_contents_->SetAudioMuted(true); |
117 | 121 |
118 // TODO(imcheng): If |optional_presentation_id| is not empty, register it with | 122 // TODO(imcheng): If |optional_presentation_id| is not empty, register it with |
119 // the PresentationRouter. http://crbug.com/513859 | 123 // the PresentationRouter. http://crbug.com/513859 |
mark a. foltz
2016/10/04 00:32:20
s/PresentationRouter/ReceiverPresentationServiceDe
zhaobin
2016/10/04 02:43:00
Done.
| |
120 if (!optional_presentation_id.empty()) { | 124 if (!optional_presentation_id.empty()) { |
121 NOTIMPLEMENTED() | 125 #if defined(ENABLE_MEDIA_ROUTER) |
imcheng
2016/09/28 07:28:35
nit: Remove the #if
zhaobin
2016/09/29 17:20:42
Done.
mark a. foltz
2016/10/04 00:32:20
Still not done (did you upload the most recent pat
| |
122 << "Register with PresentationRouter, id=" << optional_presentation_id; | 126 // Register the offscreen tab as the receiver of the offscreen presentation. |
127 media_router::ReceiverPresentationServiceDelegateImpl::CreateForWebContents( | |
128 offscreen_tab_web_contents_.get(), optional_presentation_id); | |
129 #endif // defined(ENABLE_MEDIA_ROUTER) | |
123 } | 130 } |
124 | 131 |
125 // Navigate to the initial URL. | 132 // Navigate to the initial URL. |
126 content::NavigationController::LoadURLParams load_params(start_url_); | 133 content::NavigationController::LoadURLParams load_params(start_url_); |
127 load_params.should_replace_current_entry = true; | 134 load_params.should_replace_current_entry = true; |
128 load_params.should_clear_history_list = true; | 135 load_params.should_clear_history_list = true; |
129 offscreen_tab_web_contents_->GetController().LoadURLWithParams(load_params); | 136 offscreen_tab_web_contents_->GetController().LoadURLWithParams(load_params); |
130 | 137 |
131 start_time_ = base::TimeTicks::Now(); | 138 start_time_ = base::TimeTicks::Now(); |
132 DieIfContentCaptureEnded(); | 139 DieIfContentCaptureEnded(); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
362 | 369 |
363 // Schedule the timer to check again in a second. | 370 // Schedule the timer to check again in a second. |
364 capture_poll_timer_.Start( | 371 capture_poll_timer_.Start( |
365 FROM_HERE, | 372 FROM_HERE, |
366 base::TimeDelta::FromSeconds(kPollIntervalInSeconds), | 373 base::TimeDelta::FromSeconds(kPollIntervalInSeconds), |
367 base::Bind(&OffscreenTab::DieIfContentCaptureEnded, | 374 base::Bind(&OffscreenTab::DieIfContentCaptureEnded, |
368 base::Unretained(this))); | 375 base::Unretained(this))); |
369 } | 376 } |
370 | 377 |
371 } // namespace extensions | 378 } // namespace extensions |
OLD | NEW |