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

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: Make changes in response to review comments & sync. 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
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | content/browser/renderer_host/render_view_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser.cc
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 00baca8d266a850da7e56963054d3026b381d28f..4031888828360151daa5144a6c0887d86bf192cd 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -3769,25 +3769,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;
+ }
+
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);
}
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | content/browser/renderer_host/render_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698