Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4583)

Unified Diff: chrome/browser/ui/browser.cc

Issue 8072011: Only allow to lock the mouse when the tab is in fullscreen mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/browser.cc
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 9a24b1b696ae61b6a5d43deb79c67a8b0dcb21fc..08b6b3c2d0627f9150e61983de2292261302b71d 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -3797,25 +3797,48 @@ void Browser::ToggleFullscreenModeForTab(TabContents* tab,
bool enter_fullscreen) {
if (tab != GetSelectedTabContents())
return;
- fullscreened_tab_ = enter_fullscreen ?
- TabContentsWrapper::GetCurrentWrapperForContents(tab) : NULL;
- bool in_correct_mode_for_tab_fullscreen;
+
+ if (enter_fullscreen) {
+ fullscreened_tab_ = TabContentsWrapper::GetCurrentWrapperForContents(tab);
+ bool in_correct_mode_for_tab_fullscreen;
#if defined(OS_MACOSX)
- in_correct_mode_for_tab_fullscreen = window_->InPresentationMode();
+ in_correct_mode_for_tab_fullscreen = window_->InPresentationMode();
#else
- in_correct_mode_for_tab_fullscreen = window_->IsFullscreen();
+ in_correct_mode_for_tab_fullscreen = window_->IsFullscreen();
#endif
- if (enter_fullscreen && !in_correct_mode_for_tab_fullscreen)
- tab_caused_fullscreen_ = true;
+ if (!in_correct_mode_for_tab_fullscreen)
+ tab_caused_fullscreen_ = true;
sky 2011/09/28 22:58:04 Does this need to be reset for the if (!enter_full
koz (OOO until 15th September) 2011/09/29 04:13:07 It should get reset by the call to Toggle{Presenta
yzshen1 2011/09/29 20:41:04 Yes. If currently fullscreen mode is on, Toggle{Pr
+ }
+
if (tab_caused_fullscreen_) {
#if defined(OS_MACOSX)
TogglePresentationMode();
#else
ToggleFullscreenMode();
#endif
+ } else if (!enter_fullscreen) {
+ // If currently there is a tab in "tab fullscreen" mode and fullscreen was
+ // not caused by it (i.e., previously it was in "browser fullscreen" mode),
+ // we need to switch back to "browser fullscreen" mode. In this case, all we
+ // have to do is notifying the tab that it has exited "tab fullscreen" mode.
+ NotifyTabOfFullscreenExitIfNecessary();
}
}
+bool Browser::IsFullscreenForTab(const TabContents* tab) const {
+ const TabContentsWrapper* wrapper =
+ TabContentsWrapper::GetCurrentWrapperForContents(tab);
+ bool result = wrapper && wrapper == fullscreened_tab_;
+ DCHECK(!result || tab == GetSelectedTabContents());
+#if defined(OS_MACOSX)
+ DCHECK(!result || window_->InPresentationMode());
+#else
+ DCHECK(!result || window_->IsFullscreen());
+#endif
+
+ return result;
+}
+
void Browser::JSOutOfMemory(TabContents* tab) {
JSOutOfMemoryHelper(tab);
}

Powered by Google App Engine
This is Rietveld 408576698