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