Commit 33318204 authored by spqchan's avatar spqchan Committed by Commit bot

Refactored FullscreenController

Removed the toggle between Presentation Mode and Fullscreen.
Renamed UpdateFullscreenWithToolbar to UpdateUIForTabFullscreen.
Fixed the fullscreen toolbar logic in BWC so that the toolbar state is
correct when we exit tab fullscreen.

BUG=579259

Review-Url: https://codereview.chromium.org/2089323002
Cr-Commit-Position: refs/heads/master@{#402677}
parent 956d75c9
...@@ -57,7 +57,7 @@ class ExclusiveAccessController : public ExclusiveAccessContext, ...@@ -57,7 +57,7 @@ class ExclusiveAccessController : public ExclusiveAccessContext,
// ExclusiveAccessContext: // ExclusiveAccessContext:
Profile* GetProfile() override; Profile* GetProfile() override;
bool IsFullscreen() const override; bool IsFullscreen() const override;
void UpdateFullscreenWithToolbar(bool with_toolbar) override; void UpdateUIForTabFullscreen(TabFullscreenState state) override;
void UpdateFullscreenToolbar() override; void UpdateFullscreenToolbar() override;
void EnterFullscreen(const GURL& url, void EnterFullscreen(const GURL& url,
ExclusiveAccessBubbleType type) override; ExclusiveAccessBubbleType type) override;
......
...@@ -93,8 +93,9 @@ bool ExclusiveAccessController::IsFullscreen() const { ...@@ -93,8 +93,9 @@ bool ExclusiveAccessController::IsFullscreen() const {
return [controller_ isInAnyFullscreenMode]; return [controller_ isInAnyFullscreenMode];
} }
void ExclusiveAccessController::UpdateFullscreenWithToolbar(bool with_toolbar) { void ExclusiveAccessController::UpdateUIForTabFullscreen(
[controller_ updateFullscreenWithToolbar:with_toolbar]; TabFullscreenState state) {
[controller_ updateUIForTabFullscreen:state];
} }
void ExclusiveAccessController::UpdateFullscreenToolbar() { void ExclusiveAccessController::UpdateFullscreenToolbar() {
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#import "chrome/browser/ui/cocoa/themed_window.h" #import "chrome/browser/ui/cocoa/themed_window.h"
#import "chrome/browser/ui/cocoa/url_drop_target.h" #import "chrome/browser/ui/cocoa/url_drop_target.h"
#import "chrome/browser/ui/cocoa/view_resizer.h" #import "chrome/browser/ui/cocoa/view_resizer.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
#include "chrome/browser/ui/tabs/tab_utils.h" #include "chrome/browser/ui/tabs/tab_utils.h"
#include "components/translate/core/common/translate_errors.h" #include "components/translate/core/common/translate_errors.h"
#include "ui/base/accelerators/accelerator_manager.h" #include "ui/base/accelerators/accelerator_manager.h"
...@@ -536,9 +537,10 @@ class Command; ...@@ -536,9 +537,10 @@ class Command;
// Enters Browser AppKit Fullscreen. // Enters Browser AppKit Fullscreen.
- (void)enterBrowserFullscreen; - (void)enterBrowserFullscreen;
// Adds or removes the tab strip and toolbar from the current window. The // Updates the UI for tab fullscreen by adding or removing the tab strip and
// window must be in immersive or AppKit Fullscreen. // toolbar from the current window. The window must already be in fullscreen.
- (void)updateFullscreenWithToolbar:(BOOL)withToolbar; - (void)updateUIForTabFullscreen:
(ExclusiveAccessContext::TabFullscreenState)state;
// Exits extension fullscreen if we're currently in the mode. Returns YES // Exits extension fullscreen if we're currently in the mode. Returns YES
// if we exited fullscreen. // if we exited fullscreen.
......
...@@ -1854,10 +1854,17 @@ willAnimateFromState:(BookmarkBar::State)oldState ...@@ -1854,10 +1854,17 @@ willAnimateFromState:(BookmarkBar::State)oldState
[self enterAppKitFullscreen]; [self enterAppKitFullscreen];
} }
- (void)updateFullscreenWithToolbar:(BOOL)withToolbar { - (void)updateUIForTabFullscreen:
(ExclusiveAccessContext::TabFullscreenState)state {
DCHECK([self isInAnyFullscreenMode]);
if (state == ExclusiveAccessContext::STATE_ENTER_TAB_FULLSCREEN) {
[self adjustUIForSlidingFullscreenStyle:fullscreen_mac::OMNIBOX_TABS_NONE];
return;
}
[self adjustUIForSlidingFullscreenStyle: [self adjustUIForSlidingFullscreenStyle:
withToolbar ? fullscreen_mac::OMNIBOX_TABS_PRESENT shouldShowFullscreenToolbar_ ? fullscreen_mac::OMNIBOX_TABS_PRESENT
: fullscreen_mac::OMNIBOX_TABS_HIDDEN]; : fullscreen_mac::OMNIBOX_TABS_HIDDEN];
} }
- (void)updateFullscreenExitBubble { - (void)updateFullscreenExitBubble {
...@@ -1881,8 +1888,9 @@ willAnimateFromState:(BookmarkBar::State)oldState ...@@ -1881,8 +1888,9 @@ willAnimateFromState:(BookmarkBar::State)oldState
[presentationModeController_ setToolbarFraction:0.0]; [presentationModeController_ setToolbarFraction:0.0];
shouldShowFullscreenToolbar_ = visible; shouldShowFullscreenToolbar_ = visible;
if ([self isInAppKitFullscreen]) [self adjustUIForSlidingFullscreenStyle:
[self updateFullscreenWithToolbar:shouldShowFullscreenToolbar_]; shouldShowFullscreenToolbar_ ? fullscreen_mac::OMNIBOX_TABS_PRESENT
: fullscreen_mac::OMNIBOX_TABS_HIDDEN];
} }
- (BOOL)isInAnyFullscreenMode { - (BOOL)isInAnyFullscreenMode {
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
// This file provides default implementations for the ExclusiveAccessContext // This file provides default implementations for the ExclusiveAccessContext
// methods that only some platforms care about. // methods that only some platforms care about.
void ExclusiveAccessContext::UpdateFullscreenWithToolbar(bool with_toolbar) { void ExclusiveAccessContext::UpdateUIForTabFullscreen(
TabFullscreenState state) {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
......
...@@ -20,6 +20,11 @@ class WebContents; ...@@ -20,6 +20,11 @@ class WebContents;
// context. // context.
class ExclusiveAccessContext { class ExclusiveAccessContext {
public: public:
enum TabFullscreenState {
STATE_ENTER_TAB_FULLSCREEN,
STATE_EXIT_TAB_FULLSCREEN,
};
virtual ~ExclusiveAccessContext() {} virtual ~ExclusiveAccessContext() {}
// Returns the current profile associated with the window. // Returns the current profile associated with the window.
...@@ -29,11 +34,10 @@ class ExclusiveAccessContext { ...@@ -29,11 +34,10 @@ class ExclusiveAccessContext {
// fullscreen. // fullscreen.
virtual bool IsFullscreen() const = 0; virtual bool IsFullscreen() const = 0;
// Shows or hides the tab strip, toolbar and bookmark bar with in browser // Called when we transition between tab and browser fullscreen. This method
// fullscreen. // updates the UI by showing/hiding the tab strip, toolbar and bookmark bar
// Currently only supported on Mac. // in the browser fullscreen. Currently only supported on Mac.
// TODO (spqchan): Deprecate this method. crbug.com/579259 virtual void UpdateUIForTabFullscreen(TabFullscreenState state);
virtual void UpdateFullscreenWithToolbar(bool with_toolbar);
// Updates the toolbar state to be hidden or shown in fullscreen according to // Updates the toolbar state to be hidden or shown in fullscreen according to
// the preference's state. Only supported on Mac. // the preference's state. Only supported on Mac.
......
...@@ -140,13 +140,11 @@ void FullscreenController::EnterFullscreenModeForTab(WebContents* web_contents, ...@@ -140,13 +140,11 @@ void FullscreenController::EnterFullscreenModeForTab(WebContents* web_contents,
return; return;
} }
// Browser Fullscreen -> Tab Fullscreen.
if (exclusive_access_context->IsFullscreen()) { if (exclusive_access_context->IsFullscreen()) {
// Browser Fullscreen with Toolbar -> Tab Fullscreen (no toolbar). exclusive_access_context->UpdateUIForTabFullscreen(
exclusive_access_context->UpdateFullscreenWithToolbar(false); ExclusiveAccessContext::STATE_ENTER_TAB_FULLSCREEN);
state_prior_to_tab_fullscreen_ = STATE_BROWSER_FULLSCREEN_WITH_TOOLBAR; state_prior_to_tab_fullscreen_ = STATE_BROWSER_FULLSCREEN;
} else {
// Browser Fullscreen without Toolbar -> Tab Fullscreen.
state_prior_to_tab_fullscreen_ = STATE_BROWSER_FULLSCREEN_NO_TOOLBAR;
} }
// We need to update the fullscreen exit bubble, e.g., going from browser // We need to update the fullscreen exit bubble, e.g., going from browser
...@@ -183,11 +181,10 @@ void FullscreenController::ExitFullscreenModeForTab(WebContents* web_contents) { ...@@ -183,11 +181,10 @@ void FullscreenController::ExitFullscreenModeForTab(WebContents* web_contents) {
return; return;
} }
// Tab Fullscreen -> Browser Fullscreen (with or without toolbar). // Tab Fullscreen -> Browser Fullscreen.
if (state_prior_to_tab_fullscreen_ == STATE_BROWSER_FULLSCREEN_WITH_TOOLBAR) { if (state_prior_to_tab_fullscreen_ == STATE_BROWSER_FULLSCREEN)
// Tab Fullscreen (no toolbar) -> Browser Fullscreen with Toolbar. exclusive_access_context->UpdateUIForTabFullscreen(
exclusive_access_context->UpdateFullscreenWithToolbar(true); ExclusiveAccessContext::STATE_EXIT_TAB_FULLSCREEN);
}
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
// Clear the bubble URL, which forces the Mac UI to redraw. // Clear the bubble URL, which forces the Mac UI to redraw.
...@@ -337,19 +334,6 @@ void FullscreenController::ToggleFullscreenModeInternal( ...@@ -337,19 +334,6 @@ void FullscreenController::ToggleFullscreenModeInternal(
exclusive_access_manager()->context(); exclusive_access_manager()->context();
bool enter_fullscreen = !exclusive_access_context->IsFullscreen(); bool enter_fullscreen = !exclusive_access_context->IsFullscreen();
#if defined(OS_MACOSX)
// When a Mac user requests a toggle they may be toggling between
// FullscreenWithoutChrome and FullscreenWithToolbar.
// TODO(spqchan): Refactor toolbar related code since most of it should be
// deprecated.
if (exclusive_access_context->IsFullscreen() &&
!IsWindowFullscreenForTabOrPending() &&
IsExtensionFullscreenOrPending()) {
enter_fullscreen = enter_fullscreen ||
exclusive_access_context->IsFullscreen();
}
#endif
// In kiosk mode, we always want to be fullscreen. When the browser first // 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. // starts we're not yet fullscreen, so let the initial toggle go through.
if (chrome::IsRunningInAppMode() && exclusive_access_context->IsFullscreen()) if (chrome::IsRunningInAppMode() && exclusive_access_context->IsFullscreen())
......
...@@ -175,8 +175,7 @@ class FullscreenController : public ExclusiveAccessControllerBase { ...@@ -175,8 +175,7 @@ class FullscreenController : public ExclusiveAccessControllerBase {
enum PriorFullscreenState { enum PriorFullscreenState {
STATE_INVALID, STATE_INVALID,
STATE_NORMAL, STATE_NORMAL,
STATE_BROWSER_FULLSCREEN_NO_TOOLBAR, STATE_BROWSER_FULLSCREEN,
STATE_BROWSER_FULLSCREEN_WITH_TOOLBAR,
}; };
// The state before entering tab fullscreen mode via webkitRequestFullScreen. // The state before entering tab fullscreen mode via webkitRequestFullScreen.
// When not in tab fullscreen, it is STATE_INVALID. // When not in tab fullscreen, it is STATE_INVALID.
......
...@@ -48,7 +48,6 @@ class FullscreenControllerTestWindow : public TestBrowserWindow, ...@@ -48,7 +48,6 @@ class FullscreenControllerTestWindow : public TestBrowserWindow,
// BrowserWindow Interface: // BrowserWindow Interface:
bool ShouldHideUIForFullscreen() const override; bool ShouldHideUIForFullscreen() const override;
bool IsFullscreen() const override; bool IsFullscreen() const override;
void UpdateFullscreenWithToolbar(bool with_toolbar) override;
static const char* GetWindowStateString(WindowState state); static const char* GetWindowStateString(WindowState state);
WindowState state() const { return state_; } WindowState state() const { return state_; }
void set_browser(Browser* browser) { browser_ = browser; } void set_browser(Browser* browser) { browser_ = browser; }
...@@ -113,11 +112,6 @@ bool FullscreenControllerTestWindow::IsFullscreen() const { ...@@ -113,11 +112,6 @@ bool FullscreenControllerTestWindow::IsFullscreen() const {
#endif #endif
} }
void FullscreenControllerTestWindow::UpdateFullscreenWithToolbar(
bool with_toolbar) {
EnterFullscreen();
}
// static // static
const char* FullscreenControllerTestWindow::GetWindowStateString( const char* FullscreenControllerTestWindow::GetWindowStateString(
WindowState state) { WindowState state) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment