summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-30 12:30:19 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-30 12:30:19 +0000
commit640bab89449adfefe55aa43101b970bc2961824e (patch)
treec2860e6b4411fddc9aef6baed6b8097b1d2fb6a6
parentd2ba7cb98cae3cb0b4337c4ac2393617577178ab (diff)
downloadchromium_src-640bab89449adfefe55aa43101b970bc2961824e.zip
chromium_src-640bab89449adfefe55aa43101b970bc2961824e.tar.gz
chromium_src-640bab89449adfefe55aa43101b970bc2961824e.tar.bz2
Revert 179554 - suspected to break browser_tests on Mac 10.6
> Refactor FullscreenController removing TogglePresentationMode & adding ToggleFullscreenWithChrome. > > Part of a series of refactoring changes that will enable simpler code in FullscreenController as well as correcting behavior there. This change attempts to make the minimal modifications required in order to have FullscreenController::ToggleFullscreenMode consistently mean fullscreen with no browser chrome on all platforms. > > Depends on https://codereview.chromium.org/12018007/ > > BUG=169138 > > Review URL: https://chromiumcodereview.appspot.com/11896104 TBR=scheib@chromium.org Review URL: https://codereview.chromium.org/12089068 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179615 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/browser.cc6
-rw-r--r--chrome/browser/ui/browser.h3
-rw-r--r--chrome/browser/ui/browser_command_controller.cc10
-rw-r--r--chrome/browser/ui/browser_commands_mac.cc16
-rw-r--r--chrome/browser/ui/browser_commands_mac.h16
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm7
-rw-r--r--chrome/browser/ui/fullscreen/fullscreen_controller.cc113
-rw-r--r--chrome/browser/ui/fullscreen/fullscreen_controller.h18
-rw-r--r--chrome/browser/ui/fullscreen/fullscreen_controller_interactive_browsertest.cc2
-rw-r--r--chrome/browser/ui/fullscreen/fullscreen_controller_state_test.cc4
-rw-r--r--chrome/chrome_browser_ui.gypi2
11 files changed, 89 insertions, 108 deletions
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 23fdd51..cbd53a9 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -767,6 +767,12 @@ void Browser::ToggleFullscreenModeWithExtension(const GURL& extension_url) {
fullscreen_controller_->ToggleFullscreenModeWithExtension(extension_url);
}
+#if defined(OS_MACOSX)
+void Browser::TogglePresentationMode() {
+ fullscreen_controller_->TogglePresentationMode();
+}
+#endif
+
bool Browser::SupportsWindowFeature(WindowFeature feature) const {
return SupportsWindowFeatureImpl(feature, true);
}
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index 9f86dd5..ec797fc 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -346,6 +346,9 @@ class Browser : public TabStripModelObserver,
// See the description of FullscreenController::ToggleMetroSnapMode.
void SetMetroSnapMode(bool enable);
#endif
+#if defined(OS_MACOSX)
+ void TogglePresentationMode();
+#endif
// Returns true if the Browser supports the specified feature. The value of
// this varies during the lifetime of the browser. For example, if the window
diff --git a/chrome/browser/ui/browser_command_controller.cc b/chrome/browser/ui/browser_command_controller.cc
index 60f0fe9..72ce592 100644
--- a/chrome/browser/ui/browser_command_controller.cc
+++ b/chrome/browser/ui/browser_command_controller.cc
@@ -39,10 +39,6 @@
#include "content/public/common/url_constants.h"
#include "ui/base/keycodes/keyboard_codes.h"
-#if defined(OS_MACOSX)
-#include "chrome/browser/ui/browser_commands_mac.h"
-#endif
-
#if defined(OS_WIN)
#include "base/win/metro.h"
#endif
@@ -425,11 +421,7 @@ void BrowserCommandController::ExecuteCommandWithDisposition(
ConvertPopupToTabbedBrowser(browser_);
break;
case IDC_FULLSCREEN:
-#if defined(OS_MACOSX)
- chrome::ToggleFullscreenWithChrome(browser_);
-#else
chrome::ToggleFullscreenMode(browser_);
-#endif
break;
#if defined(USE_ASH)
@@ -458,7 +450,7 @@ void BrowserCommandController::ExecuteCommandWithDisposition(
#if defined(OS_MACOSX)
case IDC_PRESENTATION_MODE:
- chrome::ToggleFullscreenMode(browser_);
+ browser_->TogglePresentationMode();
break;
#endif
case IDC_EXIT:
diff --git a/chrome/browser/ui/browser_commands_mac.cc b/chrome/browser/ui/browser_commands_mac.cc
deleted file mode 100644
index bde0b5a..0000000
--- a/chrome/browser/ui/browser_commands_mac.cc
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/browser_commands_mac.h"
-
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
-
-namespace chrome {
-
-void ToggleFullscreenWithChrome(Browser* browser) {
- browser->fullscreen_controller()->ToggleFullscreenWithChrome();
-}
-
-} // namespace chrome
diff --git a/chrome/browser/ui/browser_commands_mac.h b/chrome/browser/ui/browser_commands_mac.h
deleted file mode 100644
index 730be67..0000000
--- a/chrome/browser/ui/browser_commands_mac.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_BROWSER_COMMANDS_MAC_H_
-#define CHROME_BROWSER_UI_BROWSER_COMMANDS_MAC_H_
-
-class Browser;
-
-namespace chrome {
-
-void ToggleFullscreenWithChrome(Browser* browser);
-
-} // namespace chrome
-
-#endif // CHROME_BROWSER_UI_BROWSER_COMMANDS_MAC_H_
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm b/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
index 5ca760f..5800a80 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
@@ -13,7 +13,6 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/cocoa/browser_window_cocoa.h"
#import "chrome/browser/ui/cocoa/browser_window_controller_private.h"
@@ -272,7 +271,7 @@ IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, ZOrderNormal) {
// Verify that in non-instant presentation mode that the info bar is below the
// content are and everything else is above it.
IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, ZOrderPresentationMode) {
- chrome::ToggleFullscreenMode(browser());
+ browser()->TogglePresentationMode();
browser()->GetFindBarController(); // add find bar
std::vector<ViewID> view_list;
@@ -306,7 +305,7 @@ IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, ZOrderNormalInstant) {
// non-instant presentation mode.
IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest,
ZOrderInstantPresentationMode) {
- chrome::ToggleFullscreenMode(browser());
+ browser()->TogglePresentationMode();
ShowInstantResults();
browser()->GetFindBarController(); // add find bar
@@ -354,7 +353,7 @@ IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, ContentOffset) {
// the info bar.
IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest,
ContentOffsetPresentationMode) {
- chrome::ToggleFullscreenMode(browser());
+ browser()->TogglePresentationMode();
PreviewableContentsController* preview =
[controller() previewableContentsController];
diff --git a/chrome/browser/ui/fullscreen/fullscreen_controller.cc b/chrome/browser/ui/fullscreen/fullscreen_controller.cc
index 6a6cf44..519adcc 100644
--- a/chrome/browser/ui/fullscreen/fullscreen_controller.cc
+++ b/chrome/browser/ui/fullscreen/fullscreen_controller.cc
@@ -57,7 +57,7 @@ bool FullscreenController::IsFullscreenForBrowser() const {
void FullscreenController::ToggleFullscreenMode() {
extension_caused_fullscreen_ = GURL();
- ToggleFullscreenModeInternal(BROWSER);
+ ToggleFullscreenModeInternal(false);
}
bool FullscreenController::IsFullscreenForTabOrPending() const {
@@ -92,7 +92,11 @@ void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents,
SetFullscreenedTab(web_contents);
if (!in_browser_or_tab_fullscreen_mode) {
tab_caused_fullscreen_ = true;
- ToggleFullscreenModeInternal(TAB);
+#if defined(OS_MACOSX)
+ TogglePresentationModeInternal(true);
+#else
+ ToggleFullscreenModeInternal(true);
+#endif
} else {
// We need to update the fullscreen exit bubble, e.g., going from browser
// fullscreen to tab fullscreen will need to show different content.
@@ -110,7 +114,11 @@ void FullscreenController::ToggleFullscreenModeForTab(WebContents* web_contents,
} else {
if (in_browser_or_tab_fullscreen_mode) {
if (tab_caused_fullscreen_) {
- ToggleFullscreenModeInternal(TAB);
+#if defined(OS_MACOSX)
+ TogglePresentationModeInternal(true);
+#else
+ ToggleFullscreenModeInternal(true);
+#endif
} else {
// 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"
@@ -132,7 +140,7 @@ void FullscreenController::ToggleFullscreenModeWithExtension(
// |extension_caused_fullscreen_| will be reset if this causes fullscreen to
// exit.
extension_caused_fullscreen_ = extension_url;
- ToggleFullscreenModeInternal(BROWSER);
+ ToggleFullscreenModeInternal(false);
}
bool FullscreenController::IsInMetroSnapMode() {
@@ -158,8 +166,8 @@ void FullscreenController::SetMetroSnapMode(bool enable) {
#endif // defined(OS_WIN)
#if defined(OS_MACOSX)
-void FullscreenController::ToggleFullscreenWithChrome() {
- ToggleFullscreenModeInternal(BROWSER_WITH_CHROME);
+void FullscreenController::TogglePresentationMode() {
+ TogglePresentationModeInternal(false);
}
#endif
@@ -266,10 +274,15 @@ bool FullscreenController::HandleUserPressedEscape() {
}
void FullscreenController::ExitTabOrBrowserFullscreenToPreviousState() {
- if (IsFullscreenForTabOrPending())
+ if (IsFullscreenForTabOrPending()) {
ExitTabFullscreenOrMouseLockIfNecessary();
- else if (IsFullscreenForBrowser())
- ExitFullscreenModeInternal();
+ } else if (IsFullscreenForBrowser()) {
+#if defined(OS_MACOSX)
+ TogglePresentationMode();
+#else
+ ToggleFullscreenMode();
+#endif
+ }
}
void FullscreenController::OnAcceptFullscreenPermission() {
@@ -484,63 +497,55 @@ void FullscreenController::NotifyMouseLockChange() {
}
// TODO(koz): Change |for_tab| to an enum.
-void FullscreenController::ToggleFullscreenModeInternal(
- FullscreenInternalOption option) {
+void FullscreenController::ToggleFullscreenModeInternal(bool for_tab) {
#if defined(OS_WIN)
// When in Metro snap mode, toggling in and out of fullscreen is prevented.
if (IsInMetroSnapMode())
return;
#endif
- bool enter_fullscreen = !window_->IsFullscreen();
+ toggled_into_fullscreen_ = !window_->IsFullscreen();
#if defined(OS_MACOSX)
- // When a Mac user requests a toggle they may be toggling between
- // FullscreenWithoutChrome and FullscreenWithChrome.
- if (!IsFullscreenForTabOrPending()) {
- if (option == BROWSER_WITH_CHROME)
- enter_fullscreen |= window_->IsFullscreenWithoutChrome();
- else
- enter_fullscreen |= window_->IsFullscreenWithChrome();
- }
+ // When a Mac user requests a toggle they may be transitioning from
+ // FullscreenWithoutChrome to FullscreenWithChrome.
+ if (!IsFullscreenForTabOrPending())
+ toggled_into_fullscreen_ |= window_->IsFullscreenWithoutChrome();
#endif
// In kiosk mode, we always want to be fullscreen. When the browser first
// starts we're not yet fullscreen, so let the initial toggle go through.
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode) &&
- window_->IsFullscreen())
+ !toggled_into_fullscreen_)
return;
- if (enter_fullscreen)
- EnterFullscreenModeInternal(option);
- else
- ExitFullscreenModeInternal();
-}
-
-void FullscreenController::EnterFullscreenModeInternal(
- FullscreenInternalOption option) {
- toggled_into_fullscreen_ = true;
GURL url;
- if (option == TAB) {
+ if (for_tab) {
url = browser_->tab_strip_model()->GetActiveWebContents()->GetURL();
- tab_fullscreen_accepted_ =
+ tab_fullscreen_accepted_ = toggled_into_fullscreen_ &&
GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW;
} else {
if (!extension_caused_fullscreen_.is_empty())
url = extension_caused_fullscreen_;
content::RecordAction(UserMetricsAction("ToggleFullscreen"));
}
-
+ if (toggled_into_fullscreen_) {
#if defined(OS_MACOSX)
- if (option == BROWSER_WITH_CHROME) {
+ CHECK(!for_tab); // EnterFullscreenWithChrome invalid for tab fullscreen.
CHECK(base::mac::IsOSLionOrLater());
window_->EnterFullscreenWithChrome();
- } else {
#else
- {
-#endif
window_->EnterFullscreen(url, GetFullscreenExitBubbleType());
+#endif
+ } else {
+#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.
+ NotifyTabOfExitIfNecessary();
+#endif
+ window_->ExitFullscreen();
+ extension_caused_fullscreen_ = GURL();
}
-
UpdateFullscreenExitBubbleContent();
// Once the window has become fullscreen it'll call back to
@@ -549,19 +554,31 @@ void FullscreenController::EnterFullscreenModeInternal(
// the BrowserWindow invoke WindowFullscreenStateChanged when appropriate.
}
-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.
- NotifyTabOfExitIfNecessary();
-#endif
- window_->ExitFullscreen();
- extension_caused_fullscreen_ = GURL();
+void FullscreenController::TogglePresentationModeInternal(bool for_tab) {
+ toggled_into_fullscreen_ = !window_->IsFullscreenWithoutChrome();
+ GURL url;
+ if (for_tab) {
+ url = browser_->tab_strip_model()->GetActiveWebContents()->GetURL();
+ tab_fullscreen_accepted_ = toggled_into_fullscreen_ &&
+ GetFullscreenSetting(url) == CONTENT_SETTING_ALLOW;
+ }
+ if (!window_->IsFullscreenWithoutChrome()) {
+ window_->EnterFullscreen(url, GetFullscreenExitBubbleType());
+ } else {
+ window_->ExitFullscreen();
+ // 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.
+ NotifyTabOfExitIfNecessary();
+ }
UpdateFullscreenExitBubbleContent();
+
+ // WindowFullscreenStateChanged will be called by BrowserWindowController
+ // when the transition completes.
}
+#endif
void FullscreenController::SetFullscreenedTab(WebContents* tab) {
fullscreened_tab_ = tab;
@@ -575,7 +592,7 @@ void FullscreenController::SetMouseLockTab(WebContents* tab) {
void FullscreenController::ExitTabFullscreenOrMouseLockIfNecessary() {
if (tab_caused_fullscreen_)
- ToggleFullscreenModeInternal(TAB);
+ ToggleFullscreenModeInternal(true);
else
NotifyTabOfExitIfNecessary();
}
diff --git a/chrome/browser/ui/fullscreen/fullscreen_controller.h b/chrome/browser/ui/fullscreen/fullscreen_controller.h
index 8da996e..6b094f0 100644
--- a/chrome/browser/ui/fullscreen/fullscreen_controller.h
+++ b/chrome/browser/ui/fullscreen/fullscreen_controller.h
@@ -74,7 +74,7 @@ class FullscreenController : public content::NotificationObserver {
#endif
#if defined(OS_MACOSX)
- void ToggleFullscreenWithChrome();
+ void TogglePresentationMode();
#endif
// Mouse Lock ////////////////////////////////////////////////////////////////
@@ -130,14 +130,6 @@ class FullscreenController : public content::NotificationObserver {
MOUSELOCK_ACCEPTED_SILENTLY
};
- enum FullscreenInternalOption {
- BROWSER,
-#if defined(OS_MACOSX)
- BROWSER_WITH_CHROME,
-#endif
- TAB
- };
-
void UpdateNotificationRegistrations();
// Posts a task to call NotifyFullscreenChange.
@@ -149,9 +141,11 @@ class FullscreenController : public content::NotificationObserver {
void NotifyTabOfExitIfNecessary();
void NotifyMouseLockChange();
- void ToggleFullscreenModeInternal(FullscreenInternalOption option);
- void EnterFullscreenModeInternal(FullscreenInternalOption option);
- void ExitFullscreenModeInternal();
+ // TODO(koz): Change |for_tab| to an enum.
+ void ToggleFullscreenModeInternal(bool for_tab);
+#if defined(OS_MACOSX)
+ void TogglePresentationModeInternal(bool for_tab);
+#endif
void SetFullscreenedTab(content::WebContents* tab);
void SetMouseLockTab(content::WebContents* tab);
diff --git a/chrome/browser/ui/fullscreen/fullscreen_controller_interactive_browsertest.cc b/chrome/browser/ui/fullscreen/fullscreen_controller_interactive_browsertest.cc
index d312f82..7fa124a 100644
--- a/chrome/browser/ui/fullscreen/fullscreen_controller_interactive_browsertest.cc
+++ b/chrome/browser/ui/fullscreen/fullscreen_controller_interactive_browsertest.cc
@@ -379,7 +379,7 @@ IN_PROC_BROWSER_TEST_F(
{
FullscreenNotificationObserver fullscreen_observer;
- chrome::ToggleFullscreenMode(browser());
+ browser()->TogglePresentationMode();
fullscreen_observer.Wait();
EXPECT_FALSE(browser()->window()->IsFullscreen());
EXPECT_FALSE(browser()->window()->IsFullscreenWithChrome());
diff --git a/chrome/browser/ui/fullscreen/fullscreen_controller_state_test.cc b/chrome/browser/ui/fullscreen/fullscreen_controller_state_test.cc
index fad0d0d..473aad8 100644
--- a/chrome/browser/ui/fullscreen/fullscreen_controller_state_test.cc
+++ b/chrome/browser/ui/fullscreen/fullscreen_controller_state_test.cc
@@ -277,7 +277,11 @@ bool FullscreenControllerStateTest::InvokeEvent(Event event) {
switch (event) {
case TOGGLE_FULLSCREEN:
+#if defined(OS_MACOSX)
+ GetFullscreenController()->TogglePresentationMode();
+#else
GetFullscreenController()->ToggleFullscreenMode();
+#endif
break;
case TAB_FULLSCREEN_TRUE:
GetFullscreenController()->ToggleFullscreenModeForTab(
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index ba3fcbf..b455d94 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -245,8 +245,6 @@
'browser/ui/browser.h',
'browser/ui/browser_commands.cc',
'browser/ui/browser_commands.h',
- 'browser/ui/browser_commands_mac.cc',
- 'browser/ui/browser_commands_mac.h',
'browser/ui/browser_command_controller.cc',
'browser/ui/browser_command_controller.h',
'browser/ui/browser_content_setting_bubble_model_delegate.cc',