summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscheib@chromium.org <scheib@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-07 05:21:29 +0000
committerscheib@chromium.org <scheib@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-07 05:21:29 +0000
commit299c0ac7aa93b6562a1c6a8e3536185b96a30f95 (patch)
treec7850d64b0bef996c9a43b99526d30d21291a864
parentb8f1d48cde7936b0de0ddd73393beea9cce6c353 (diff)
downloadchromium_src-299c0ac7aa93b6562a1c6a8e3536185b96a30f95.zip
chromium_src-299c0ac7aa93b6562a1c6a8e3536185b96a30f95.tar.gz
chromium_src-299c0ac7aa93b6562a1c6a8e3536185b96a30f95.tar.bz2
Fix regression on mac: HTML5 fullscreen now hides browser chrome.
r175045 caused this regression on Mac 10.8 and upwards: - Enter browser fullscreen with omnibox showing (Enter Fullscreen). - Enter HTML5 fullscreen. Incorrectly, the omnibox was still showing. This change corrects that. BUG=168513 Review URL: https://chromiumcodereview.appspot.com/12211050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181213 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/fullscreen/fullscreen_controller.cc55
-rw-r--r--chrome/browser/ui/fullscreen/fullscreen_controller.h16
-rw-r--r--chrome/browser/ui/fullscreen/fullscreen_controller_state_test.cc8
3 files changed, 61 insertions, 18 deletions
diff --git a/chrome/browser/ui/fullscreen/fullscreen_controller.cc b/chrome/browser/ui/fullscreen/fullscreen_controller.cc
index 8b703a9..cb40844 100644
--- a/chrome/browser/ui/fullscreen/fullscreen_controller.cc
+++ b/chrome/browser/ui/fullscreen/fullscreen_controller.cc
@@ -39,7 +39,7 @@ FullscreenController::FullscreenController(Browser* browser)
window_(browser->window()),
profile_(browser->profile()),
fullscreened_tab_(NULL),
- tab_caused_fullscreen_(false),
+ state_prior_to_tab_fullscreen_(STATE_INVALID),
tab_fullscreen_accepted_(false),
toggled_into_fullscreen_(false),
mouse_lock_tab_(NULL),
@@ -53,7 +53,7 @@ FullscreenController::~FullscreenController() {
}
bool FullscreenController::IsFullscreenForBrowser() const {
- return window_->IsFullscreen() && !tab_caused_fullscreen_;
+ return window_->IsFullscreen() && !IsFullscreenCausedByTab();
}
void FullscreenController::ToggleFullscreenMode() {
@@ -73,10 +73,16 @@ bool FullscreenController::IsFullscreenForTabOrPending(
return true;
}
+bool FullscreenController::IsFullscreenCausedByTab() const {
+ return state_prior_to_tab_fullscreen_ == STATE_NORMAL;
+}
+
void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents,
bool enter_fullscreen) {
if (web_contents != browser_->tab_strip_model()->GetActiveWebContents())
return;
+ if (IsFullscreenForTabOrPending() == enter_fullscreen)
+ return;
#if defined(OS_WIN)
// For now, avoid breaking when initiating full screen tab mode while in
@@ -88,13 +94,26 @@ void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents,
#endif
bool in_browser_or_tab_fullscreen_mode = window_->IsFullscreen();
+ bool window_is_fullscreen_with_chrome = false;
+#if defined(OS_MACOSX)
+ window_is_fullscreen_with_chrome = window_->IsFullscreenWithChrome();
+#endif
if (enter_fullscreen) {
SetFullscreenedTab(web_contents);
if (!in_browser_or_tab_fullscreen_mode) {
- tab_caused_fullscreen_ = true;
+ state_prior_to_tab_fullscreen_ = STATE_NORMAL;
ToggleFullscreenModeInternal(TAB);
+ } else if (window_is_fullscreen_with_chrome) {
+#if defined(OS_MACOSX)
+ state_prior_to_tab_fullscreen_ = STATE_BROWSER_FULLSCREEN_WITH_CHROME;
+ EnterFullscreenModeInternal(TAB);
+#else
+ NOTREACHED();
+#endif
} else {
+ state_prior_to_tab_fullscreen_ = STATE_BROWSER_FULLSCREEN_NO_CHROME;
+
// We need to update the fullscreen exit bubble, e.g., going from browser
// fullscreen to tab fullscreen will need to show different content.
const GURL& url = web_contents->GetURL();
@@ -110,9 +129,15 @@ void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents,
}
} else {
if (in_browser_or_tab_fullscreen_mode) {
- if (tab_caused_fullscreen_) {
+ if (IsFullscreenCausedByTab()) {
ToggleFullscreenModeInternal(TAB);
} else {
+#if defined(OS_MACOSX)
+ if (state_prior_to_tab_fullscreen_ ==
+ STATE_BROWSER_FULLSCREEN_WITH_CHROME) {
+ EnterFullscreenModeInternal(BROWSER_WITH_CHROME);
+ }
+#endif
// 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
@@ -456,7 +481,7 @@ void FullscreenController::NotifyTabOfExitIfNecessary() {
if (fullscreened_tab_) {
RenderViewHost* rvh = fullscreened_tab_->GetRenderViewHost();
SetFullscreenedTab(NULL);
- tab_caused_fullscreen_ = false;
+ state_prior_to_tab_fullscreen_ = STATE_INVALID;
tab_fullscreen_accepted_ = false;
if (rvh)
rvh->ExitFullscreen();
@@ -527,9 +552,13 @@ void FullscreenController::EnterFullscreenModeInternal(
} else {
if (!extension_caused_fullscreen_.is_empty())
url = extension_caused_fullscreen_;
- content::RecordAction(UserMetricsAction("ToggleFullscreen"));
}
+ if (option == BROWSER)
+ content::RecordAction(UserMetricsAction("ToggleFullscreen"));
+ // TODO(scheib): Record metrics for WITH_CHROME, without counting transitions
+ // from tab fullscreen out to browser with chrome.
+
#if defined(OS_MACOSX)
if (option == BROWSER_WITH_CHROME) {
CHECK(base::mac::IsOSLionOrLater());
@@ -553,8 +582,8 @@ void FullscreenController::ExitFullscreenModeInternal() {
toggled_into_fullscreen_ = false;
#if defined(OS_MACOSX)
// Mac windows report a state change instantly, and so we must also clear
- // tab_caused_fullscreen_ to match them else other logic using
- // tab_caused_fullscreen_ will be incorrect.
+ // state_prior_to_tab_fullscreen_ to match them else other logic using
+ // state_prior_to_tab_fullscreen_ will be incorrect.
NotifyTabOfExitIfNecessary();
#endif
window_->ExitFullscreen();
@@ -574,8 +603,14 @@ void FullscreenController::SetMouseLockTab(WebContents* tab) {
}
void FullscreenController::ExitTabFullscreenOrMouseLockIfNecessary() {
- if (tab_caused_fullscreen_)
- ToggleFullscreenModeInternal(TAB);
+ bool exit_tab_fullscreen = IsFullscreenCausedByTab();
+#if defined(OS_MACOSX)
+ if (state_prior_to_tab_fullscreen_ == STATE_BROWSER_FULLSCREEN_WITH_CHROME)
+ exit_tab_fullscreen = true;
+#endif
+
+ if (exit_tab_fullscreen)
+ ToggleFullscreenModeForTab(fullscreened_tab_, false);
else
NotifyTabOfExitIfNecessary();
}
diff --git a/chrome/browser/ui/fullscreen/fullscreen_controller.h b/chrome/browser/ui/fullscreen/fullscreen_controller.h
index 8da996e..b7ff113 100644
--- a/chrome/browser/ui/fullscreen/fullscreen_controller.h
+++ b/chrome/browser/ui/fullscreen/fullscreen_controller.h
@@ -53,6 +53,9 @@ class FullscreenController : public content::NotificationObserver {
bool IsFullscreenForTabOrPending() const;
bool IsFullscreenForTabOrPending(
const content::WebContents* web_contents) const;
+ // True if fullscreen was entered because of tab fullscreen (was not
+ // previously in browser fullscreen).
+ bool IsFullscreenCausedByTab() const;
void ToggleFullscreenModeForTab(content::WebContents* web_contents,
bool enter_fullscreen);
@@ -176,8 +179,17 @@ class FullscreenController : public content::NotificationObserver {
// The URL of the extension which trigerred "browser fullscreen" mode.
GURL extension_caused_fullscreen_;
- // True if the current tab entered fullscreen mode via webkitRequestFullScreen
- bool tab_caused_fullscreen_;
+ enum PriorFullscreenState {
+ STATE_INVALID,
+ STATE_NORMAL,
+ STATE_BROWSER_FULLSCREEN_NO_CHROME,
+#if defined(OS_MACOSX)
+ STATE_BROWSER_FULLSCREEN_WITH_CHROME,
+#endif
+ };
+ // The state before entering tab fullscreen mode via webkitRequestFullScreen.
+ // When not in tab fullscreen, it is STATE_INVALID.
+ PriorFullscreenState state_prior_to_tab_fullscreen_;
// True if tab fullscreen has been allowed, either by settings or by user
// clicking the allow button on the fullscreen infobar.
bool tab_fullscreen_accepted_;
diff --git a/chrome/browser/ui/fullscreen/fullscreen_controller_state_test.cc b/chrome/browser/ui/fullscreen/fullscreen_controller_state_test.cc
index f2d7636..34bb7f0 100644
--- a/chrome/browser/ui/fullscreen/fullscreen_controller_state_test.cc
+++ b/chrome/browser/ui/fullscreen/fullscreen_controller_state_test.cc
@@ -502,13 +502,9 @@ void FullscreenControllerStateTest::VerifyWindowState() {
break;
case STATE_TAB_BROWSER_FULLSCREEN_CHROME:
#if defined(OS_MACOSX)
- // http://crbug.com/168513
- // Tab fullscreen does not remove the chrome when previously in
- // 'with chrome' browser fullscreen. The following two With and Without
- // expectations should be swapped so there is no chrome in this state.
- EXPECT_TRUE(GetBrowser()->window()->IsFullscreenWithChrome())
+ EXPECT_FALSE(GetBrowser()->window()->IsFullscreenWithChrome())
<< GetAndClearDebugLog();
- EXPECT_FALSE(GetBrowser()->window()->IsFullscreenWithoutChrome())
+ EXPECT_TRUE(GetBrowser()->window()->IsFullscreenWithoutChrome())
<< GetAndClearDebugLog();
#endif
EXPECT_TRUE(GetFullscreenController()->IsFullscreenForBrowser())