| Index: chrome/browser/ui/fullscreen/fullscreen_controller.cc
|
| ===================================================================
|
| --- chrome/browser/ui/fullscreen/fullscreen_controller.cc (revision 179614)
|
| +++ chrome/browser/ui/fullscreen/fullscreen_controller.cc (working copy)
|
| @@ -57,7 +57,7 @@
|
|
|
| void FullscreenController::ToggleFullscreenMode() {
|
| extension_caused_fullscreen_ = GURL();
|
| - ToggleFullscreenModeInternal(BROWSER);
|
| + ToggleFullscreenModeInternal(false);
|
| }
|
|
|
| bool FullscreenController::IsFullscreenForTabOrPending() const {
|
| @@ -92,7 +92,11 @@
|
| 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 @@
|
| } 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 @@
|
| // |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 @@
|
| #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 @@
|
| }
|
|
|
| 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 @@
|
| }
|
|
|
| // 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
|
| - {
|
| + window_->EnterFullscreen(url, GetFullscreenExitBubbleType());
|
| #endif
|
| - window_->EnterFullscreen(url, GetFullscreenExitBubbleType());
|
| + } 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 @@
|
| // 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::ExitTabFullscreenOrMouseLockIfNecessary() {
|
| if (tab_caused_fullscreen_)
|
| - ToggleFullscreenModeInternal(TAB);
|
| + ToggleFullscreenModeInternal(true);
|
| else
|
| NotifyTabOfExitIfNecessary();
|
| }
|
|
|