| 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" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 << initial_size.ToString() << " for start_url=" << start_url_.spec(); | 91 << initial_size.ToString() << " for start_url=" << start_url_.spec(); |
| 92 | 92 |
| 93 // Create the WebContents to contain the off-screen tab's page. | 93 // Create the WebContents to contain the off-screen tab's page. |
| 94 offscreen_tab_web_contents_.reset( | 94 offscreen_tab_web_contents_.reset( |
| 95 WebContents::Create(WebContents::CreateParams(profile_.get()))); | 95 WebContents::Create(WebContents::CreateParams(profile_.get()))); |
| 96 offscreen_tab_web_contents_->SetDelegate(this); | 96 offscreen_tab_web_contents_->SetDelegate(this); |
| 97 WebContentsObserver::Observe(offscreen_tab_web_contents_.get()); | 97 WebContentsObserver::Observe(offscreen_tab_web_contents_.get()); |
| 98 | 98 |
| 99 // Set initial size, if specified. | 99 // Set initial size, if specified. |
| 100 if (!initial_size.IsEmpty()) | 100 if (!initial_size.IsEmpty()) |
| 101 ResizeWebContents(offscreen_tab_web_contents_.get(), initial_size); | 101 ResizeWebContents(offscreen_tab_web_contents_.get(), |
| 102 gfx::Rect(initial_size)); |
| 102 | 103 |
| 103 // Mute audio output. When tab capture starts, the audio will be | 104 // Mute audio output. When tab capture starts, the audio will be |
| 104 // automatically unmuted, but will be captured into the MediaStream. | 105 // automatically unmuted, but will be captured into the MediaStream. |
| 105 offscreen_tab_web_contents_->SetAudioMuted(true); | 106 offscreen_tab_web_contents_->SetAudioMuted(true); |
| 106 | 107 |
| 107 // TODO(imcheng): If |optional_presentation_id| is not empty, register it with | 108 // TODO(imcheng): If |optional_presentation_id| is not empty, register it with |
| 108 // the PresentationRouter. http://crbug.com/513859 | 109 // the PresentationRouter. http://crbug.com/513859 |
| 109 if (!optional_presentation_id.empty()) { | 110 if (!optional_presentation_id.empty()) { |
| 110 NOTIMPLEMENTED() | 111 NOTIMPLEMENTED() |
| 111 << "Register with PresentationRouter, id=" << optional_presentation_id; | 112 << "Register with PresentationRouter, id=" << optional_presentation_id; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 const GURL& origin) { | 221 const GURL& origin) { |
| 221 DCHECK_EQ(offscreen_tab_web_contents_.get(), contents); | 222 DCHECK_EQ(offscreen_tab_web_contents_.get(), contents); |
| 222 | 223 |
| 223 if (in_fullscreen_mode()) | 224 if (in_fullscreen_mode()) |
| 224 return; | 225 return; |
| 225 | 226 |
| 226 non_fullscreen_size_ = | 227 non_fullscreen_size_ = |
| 227 contents->GetRenderWidgetHostView()->GetViewBounds().size(); | 228 contents->GetRenderWidgetHostView()->GetViewBounds().size(); |
| 228 if (contents->GetCapturerCount() >= 0 && | 229 if (contents->GetCapturerCount() >= 0 && |
| 229 !contents->GetPreferredSize().IsEmpty()) { | 230 !contents->GetPreferredSize().IsEmpty()) { |
| 230 ResizeWebContents(contents, contents->GetPreferredSize()); | 231 ResizeWebContents(contents, gfx::Rect(contents->GetPreferredSize())); |
| 231 } | 232 } |
| 232 } | 233 } |
| 233 | 234 |
| 234 void OffscreenTab::ExitFullscreenModeForTab(WebContents* contents) { | 235 void OffscreenTab::ExitFullscreenModeForTab(WebContents* contents) { |
| 235 DCHECK_EQ(offscreen_tab_web_contents_.get(), contents); | 236 DCHECK_EQ(offscreen_tab_web_contents_.get(), contents); |
| 236 | 237 |
| 237 if (!in_fullscreen_mode()) | 238 if (!in_fullscreen_mode()) |
| 238 return; | 239 return; |
| 239 | 240 |
| 240 ResizeWebContents(contents, non_fullscreen_size_); | 241 ResizeWebContents(contents, gfx::Rect(non_fullscreen_size_)); |
| 241 non_fullscreen_size_ = gfx::Size(); | 242 non_fullscreen_size_ = gfx::Size(); |
| 242 } | 243 } |
| 243 | 244 |
| 244 bool OffscreenTab::IsFullscreenForTabOrPending( | 245 bool OffscreenTab::IsFullscreenForTabOrPending( |
| 245 const WebContents* contents) const { | 246 const WebContents* contents) const { |
| 246 DCHECK_EQ(offscreen_tab_web_contents_.get(), contents); | 247 DCHECK_EQ(offscreen_tab_web_contents_.get(), contents); |
| 247 return in_fullscreen_mode(); | 248 return in_fullscreen_mode(); |
| 248 } | 249 } |
| 249 | 250 |
| 250 blink::WebDisplayMode OffscreenTab::GetDisplayMode( | 251 blink::WebDisplayMode OffscreenTab::GetDisplayMode( |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 | 352 |
| 352 // Schedule the timer to check again in a second. | 353 // Schedule the timer to check again in a second. |
| 353 capture_poll_timer_.Start( | 354 capture_poll_timer_.Start( |
| 354 FROM_HERE, | 355 FROM_HERE, |
| 355 base::TimeDelta::FromSeconds(kPollIntervalInSeconds), | 356 base::TimeDelta::FromSeconds(kPollIntervalInSeconds), |
| 356 base::Bind(&OffscreenTab::DieIfContentCaptureEnded, | 357 base::Bind(&OffscreenTab::DieIfContentCaptureEnded, |
| 357 base::Unretained(this))); | 358 base::Unretained(this))); |
| 358 } | 359 } |
| 359 | 360 |
| 360 } // namespace extensions | 361 } // namespace extensions |
| OLD | NEW |