Index: chrome/browser/ui/fullscreen/fullscreen_controller.cc |
diff --git a/chrome/browser/ui/fullscreen/fullscreen_controller.cc b/chrome/browser/ui/fullscreen/fullscreen_controller.cc |
index 3754c80dfb6bebe366c7a228c5228c410e55fe26..8b28ca0f10611708f825fd178c2f059fdd7a2dc5 100644 |
--- a/chrome/browser/ui/fullscreen/fullscreen_controller.cc |
+++ b/chrome/browser/ui/fullscreen/fullscreen_controller.cc |
@@ -25,6 +25,7 @@ |
#include "content/public/browser/render_widget_host_view.h" |
#include "content/public/browser/user_metrics.h" |
#include "content/public/browser/web_contents.h" |
+#include "content/public/browser/web_contents_view.h" |
#include "extensions/common/extension.h" |
#if defined(OS_MACOSX) |
@@ -73,10 +74,8 @@ bool FullscreenController::IsFullscreenForTabOrPending() const { |
bool FullscreenController::IsFullscreenForTabOrPending( |
const WebContents* web_contents) const { |
- if (web_contents != fullscreened_tab_) |
- return false; |
- DCHECK(web_contents == browser_->tab_strip_model()->GetActiveWebContents()); |
- return true; |
+ return web_contents == fullscreened_tab_ || |
scheib
2014/02/12 01:41:16
Why drop the DCHECK when !IsCapturedFullscreenTab?
miu
2014/02/12 08:25:19
Good point. I rearranged this to put it back.
|
+ IsCapturedFullscreenTab(web_contents); |
} |
bool FullscreenController::IsFullscreenCausedByTab() const { |
@@ -85,6 +84,11 @@ bool FullscreenController::IsFullscreenCausedByTab() const { |
void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents, |
bool enter_fullscreen) { |
+ if (MaybeToggleAsFullscreenWithinTab(web_contents, enter_fullscreen)) { |
+ // During tab capture of embedded fullscreen views, browser window |
+ // fullscreen state is unchanged, so return now. |
+ return; |
+ } |
if (fullscreened_tab_) { |
if (web_contents != fullscreened_tab_) |
return; |
@@ -218,6 +222,11 @@ bool FullscreenController::IsMouseLocked() const { |
void FullscreenController::RequestToLockMouse(WebContents* web_contents, |
bool user_gesture, |
bool last_unlocked_by_target) { |
+ if (IsCapturedFullscreenTab(web_contents)) { |
scheib
2014/02/12 01:41:16
Won't this break the use case of casting play of f
miu
2014/02/12 08:25:19
Resolved. I took this code out and mouse lock wor
|
+ web_contents->GotResponseToLockMouseRequest(false); |
+ return; |
+ } |
+ |
DCHECK(!IsMouseLocked()); |
NotifyMouseLockChange(); |
@@ -273,8 +282,34 @@ void FullscreenController::OnTabDeactivated(WebContents* web_contents) { |
ExitTabFullscreenOrMouseLockIfNecessary(); |
} |
+void FullscreenController::OnTabDetachedFromView(WebContents* old_contents) { |
scheib
2014/02/12 01:41:16
So far I haven't noticed when we resize content ba
miu
2014/02/12 08:25:19
Done. (Reworked this into the comment a few lines
|
+ if (!IsCapturedFullscreenTab(old_contents)) |
+ return; |
+ |
+ // After detaching an embedded fullscreen view undergoing screen capture, set |
+ // it to exactly the WebContents' preferred size. This will allow it to be |
+ // rendered and captured at the ideal resolution while the tab is being |
+ // backgroundend by the user. |
+ if (old_contents->GetCapturerCount() == 0 || |
+ old_contents->GetPreferredSize().IsEmpty()) { |
+ // Do nothing if tab capture ended after toggling fullscreen, or a preferred |
+ // size was never specified by the capturer. |
+ return; |
+ } |
+ content::RenderWidgetHostView* const current_fs_view = |
+ old_contents->GetFullscreenRenderWidgetHostView(); |
+ if (current_fs_view) |
+ current_fs_view->SetSize(old_contents->GetPreferredSize()); |
+ old_contents->GetView()->SizeContents(old_contents->GetPreferredSize()); |
+} |
+ |
void FullscreenController::OnTabClosing(WebContents* web_contents) { |
- if (web_contents == fullscreened_tab_ || web_contents == mouse_lock_tab_) { |
+ if (IsCapturedFullscreenTab(web_contents)) { |
+ RenderViewHost* const rvh = web_contents->GetRenderViewHost(); |
+ if (rvh) |
+ rvh->ExitFullscreen(); |
+ } else if (web_contents == fullscreened_tab_ || |
+ web_contents == mouse_lock_tab_) { |
ExitTabFullscreenOrMouseLockIfNecessary(); |
// The call to exit fullscreen may result in asynchronous notification of |
// fullscreen state change (e.g., on Linux). We don't want to rely on it |
@@ -306,8 +341,15 @@ void FullscreenController::WindowFullscreenStateChanged() { |
} |
bool FullscreenController::HandleUserPressedEscape() { |
- if (IsFullscreenForTabOrPending() || |
- IsMouseLocked() || IsMouseLockRequested()) { |
+ WebContents* const active_web_contents = |
+ browser_->tab_strip_model()->GetActiveWebContents(); |
+ if (IsCapturedFullscreenTab(active_web_contents)) { |
+ RenderViewHost* const rvh = active_web_contents->GetRenderViewHost(); |
+ if (rvh) |
+ rvh->ExitFullscreen(); |
+ return true; |
+ } else if (IsFullscreenForTabOrPending() || |
+ IsMouseLocked() || IsMouseLockRequested()) { |
ExitTabFullscreenOrMouseLockIfNecessary(); |
return true; |
} |
@@ -679,8 +721,7 @@ bool FullscreenController::IsPrivilegedFullscreenForTab() const { |
const bool embedded_widget_present = |
fullscreened_tab_ && |
fullscreened_tab_->GetFullscreenRenderWidgetHostView() && |
- implicit_cast<const content::WebContentsDelegate*>(browser_)-> |
- EmbedsFullscreenWidget(); |
+ IsEmbeddedFullscreenEnabled(); |
return embedded_widget_present || is_privileged_fullscreen_for_testing_; |
} |
@@ -689,6 +730,48 @@ void FullscreenController::SetPrivilegedFullscreenForTesting( |
is_privileged_fullscreen_for_testing_ = is_privileged; |
} |
+bool FullscreenController::IsEmbeddedFullscreenEnabled() const { |
+ return implicit_cast<const content::WebContentsDelegate*>(browser_)-> |
+ EmbedsFullscreenWidget(); |
+} |
+ |
+bool FullscreenController::MaybeToggleAsFullscreenWithinTab( |
+ WebContents* web_contents, bool enter_fullscreen) { |
+ if (!IsEmbeddedFullscreenEnabled()) |
+ return false; |
+ |
+ if (enter_fullscreen) { |
+ if (web_contents->GetCapturerCount() > 0) { |
+ if (std::find(captured_tabs_.begin(), captured_tabs_.end(), |
scheib
2014/02/12 01:41:16
why not just std::set::insert()?
miu
2014/02/12 08:25:19
Done.
|
+ web_contents) == captured_tabs_.end()) { |
+ captured_tabs_.push_back(web_contents); |
+ } |
+ return true; |
+ } |
+ } else { |
+ const std::vector<const WebContents*>::iterator it = |
+ std::find(captured_tabs_.begin(), captured_tabs_.end(), web_contents); |
+ if (it != captured_tabs_.end()) { |
scheib
2014/02/12 01:41:16
captured_tabs_.find(web_contents) != captured_tabs
miu
2014/02/12 08:25:19
Done.
|
+ captured_tabs_.erase(it); |
+ return true; |
+ } |
+ } |
+ |
+ return false; |
+} |
+ |
+bool FullscreenController::IsCapturedFullscreenTab( |
+ const WebContents* web_contents) const { |
+ if (std::find(captured_tabs_.begin(), captured_tabs_.end(), web_contents) != |
+ captured_tabs_.end()) { |
+ DCHECK(IsEmbeddedFullscreenEnabled()); |
+ DCHECK_NE(fullscreened_tab_, web_contents); |
+ DCHECK_NE(mouse_lock_tab_, web_contents); |
miu
2014/02/12 08:25:19
I removed this since it was wrong (i.e., mouse loc
|
+ return true; |
+ } |
+ return false; |
+} |
+ |
void FullscreenController::UnlockMouse() { |
if (!mouse_lock_tab_) |
return; |