Commit d9ee0c5b authored by Robert Sesek's avatar Robert Sesek Committed by Commit Bot

mac: Remove fullscreen support from BrowserWindowController.

A lot of c/b/u/cocoa/fullscreen is still used to implement views-mode
fullscreen.

Bug: 832676
Change-Id: I58ae4caff28d69c1be047c079b1ea95ae7a486e0
Reviewed-on: https://chromium-review.googlesource.com/1246601Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594444}
parent ddede7ee
...@@ -52,8 +52,6 @@ jumbo_split_static_library("ui") { ...@@ -52,8 +52,6 @@ jumbo_split_static_library("ui") {
"cocoa/animatable_view.mm", "cocoa/animatable_view.mm",
"cocoa/background_gradient_view.h", "cocoa/background_gradient_view.h",
"cocoa/background_gradient_view.mm", "cocoa/background_gradient_view.mm",
"cocoa/browser/exclusive_access_controller_views.h",
"cocoa/browser/exclusive_access_controller_views.mm",
"cocoa/browser_dialogs_views_mac.cc", "cocoa/browser_dialogs_views_mac.cc",
"cocoa/browser_dialogs_views_mac.h", "cocoa/browser_dialogs_views_mac.h",
"cocoa/browser_window_cocoa.h", "cocoa/browser_window_cocoa.h",
...@@ -64,8 +62,6 @@ jumbo_split_static_library("ui") { ...@@ -64,8 +62,6 @@ jumbo_split_static_library("ui") {
"cocoa/browser_window_controller_private.h", "cocoa/browser_window_controller_private.h",
"cocoa/browser_window_controller_private.mm", "cocoa/browser_window_controller_private.mm",
"cocoa/browser_window_factory_cocoa.mm", "cocoa/browser_window_factory_cocoa.mm",
"cocoa/browser_window_fullscreen_transition.h",
"cocoa/browser_window_fullscreen_transition.mm",
"cocoa/browser_window_layout.h", "cocoa/browser_window_layout.h",
"cocoa/browser_window_layout.mm", "cocoa/browser_window_layout.mm",
"cocoa/browser_window_utils.h", "cocoa/browser_window_utils.h",
...@@ -101,8 +97,6 @@ jumbo_split_static_library("ui") { ...@@ -101,8 +97,6 @@ jumbo_split_static_library("ui") {
"cocoa/extensions/extension_keybinding_registry_cocoa.mm", "cocoa/extensions/extension_keybinding_registry_cocoa.mm",
"cocoa/fast_resize_view.h", "cocoa/fast_resize_view.h",
"cocoa/fast_resize_view.mm", "cocoa/fast_resize_view.mm",
"cocoa/floating_bar_backing_view.h",
"cocoa/floating_bar_backing_view.mm",
"cocoa/framed_browser_window.h", "cocoa/framed_browser_window.h",
"cocoa/framed_browser_window.mm", "cocoa/framed_browser_window.mm",
"cocoa/fullscreen/fullscreen_menubar_tracker.h", "cocoa/fullscreen/fullscreen_menubar_tracker.h",
...@@ -111,8 +105,6 @@ jumbo_split_static_library("ui") { ...@@ -111,8 +105,6 @@ jumbo_split_static_library("ui") {
"cocoa/fullscreen/fullscreen_toolbar_animation_controller.mm", "cocoa/fullscreen/fullscreen_toolbar_animation_controller.mm",
"cocoa/fullscreen/fullscreen_toolbar_controller.h", "cocoa/fullscreen/fullscreen_toolbar_controller.h",
"cocoa/fullscreen/fullscreen_toolbar_controller.mm", "cocoa/fullscreen/fullscreen_toolbar_controller.mm",
"cocoa/fullscreen/fullscreen_toolbar_controller_cocoa.h",
"cocoa/fullscreen/fullscreen_toolbar_controller_cocoa.mm",
"cocoa/fullscreen/fullscreen_toolbar_controller_views.h", "cocoa/fullscreen/fullscreen_toolbar_controller_views.h",
"cocoa/fullscreen/fullscreen_toolbar_controller_views.mm", "cocoa/fullscreen/fullscreen_toolbar_controller_views.mm",
"cocoa/fullscreen/fullscreen_toolbar_mouse_tracker.h", "cocoa/fullscreen/fullscreen_toolbar_mouse_tracker.h",
...@@ -121,10 +113,6 @@ jumbo_split_static_library("ui") { ...@@ -121,10 +113,6 @@ jumbo_split_static_library("ui") {
"cocoa/fullscreen/fullscreen_toolbar_visibility_lock_controller.mm", "cocoa/fullscreen/fullscreen_toolbar_visibility_lock_controller.mm",
"cocoa/fullscreen/immersive_fullscreen_controller.h", "cocoa/fullscreen/immersive_fullscreen_controller.h",
"cocoa/fullscreen/immersive_fullscreen_controller.mm", "cocoa/fullscreen/immersive_fullscreen_controller.mm",
"cocoa/fullscreen_placeholder_view.h",
"cocoa/fullscreen_placeholder_view.mm",
"cocoa/fullscreen_window.h",
"cocoa/fullscreen_window.mm",
"cocoa/has_weak_browser_pointer.h", "cocoa/has_weak_browser_pointer.h",
"cocoa/javascript_app_modal_dialog_cocoa.h", "cocoa/javascript_app_modal_dialog_cocoa.h",
"cocoa/javascript_app_modal_dialog_cocoa.mm", "cocoa/javascript_app_modal_dialog_cocoa.mm",
...@@ -137,8 +125,6 @@ jumbo_split_static_library("ui") { ...@@ -137,8 +125,6 @@ jumbo_split_static_library("ui") {
"cocoa/rect_path_utils.mm", "cocoa/rect_path_utils.mm",
"cocoa/restart_browser.h", "cocoa/restart_browser.h",
"cocoa/restart_browser.mm", "cocoa/restart_browser.mm",
"cocoa/separate_fullscreen_window.h",
"cocoa/separate_fullscreen_window.mm",
"cocoa/simple_message_box_cocoa.h", "cocoa/simple_message_box_cocoa.h",
"cocoa/simple_message_box_cocoa.mm", "cocoa/simple_message_box_cocoa.mm",
"cocoa/single_web_contents_dialog_manager_cocoa.h", "cocoa/single_web_contents_dialog_manager_cocoa.h",
......
// Copyright 2016 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_COCOA_BROWSER_EXCLUSIVE_ACCESS_CONTROLLER_VIEWS_H_
#define CHROME_BROWSER_UI_COCOA_BROWSER_EXCLUSIVE_ACCESS_CONTROLLER_VIEWS_H_
// Note this file has a _views suffix so that it may have an optional runtime
// dependency on toolkit-views UI.
#import <CoreGraphics/CoreGraphics.h>
#include <memory>
#import "base/mac/scoped_nsobject.h"
#include "base/macros.h"
#include "base/time/time.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
#include "chrome/browser/ui/views/exclusive_access_bubble_views_context.h"
#include "components/prefs/pref_change_registrar.h"
#include "ui/base/accelerators/accelerator.h"
class Browser;
class BrowserWindow;
@class BrowserWindowController;
class ExclusiveAccessBubbleViews;
class FullscreenControlHost;
class GURL;
namespace views {
class EventMonitor;
}
// Component placed into a browser window controller to manage communication
// with subtle notification bubbles, which appear for events such as entering
// fullscreen.
class ExclusiveAccessController : public ExclusiveAccessContext,
public ui::AcceleratorProvider,
public ExclusiveAccessBubbleViewsContext {
public:
ExclusiveAccessController(BrowserWindowController* controller,
Browser* browser);
~ExclusiveAccessController() override;
const GURL& url() const { return url_; }
ExclusiveAccessBubbleType bubble_type() const { return bubble_type_; }
// Shows the bubble once the NSWindow has received -windowDidEnterFullScreen:.
void Show();
// Closes any open bubble.
void Destroy();
// ExclusiveAccessContext:
Profile* GetProfile() override;
bool IsFullscreen() const override;
void UpdateUIForTabFullscreen(TabFullscreenState state) override;
void UpdateFullscreenToolbar() override;
void EnterFullscreen(const GURL& url,
ExclusiveAccessBubbleType type) override;
void ExitFullscreen() override;
void UpdateExclusiveAccessExitBubbleContent(
const GURL& url,
ExclusiveAccessBubbleType bubble_type,
ExclusiveAccessBubbleHideCallback bubble_first_hide_callback,
bool force_update) override;
void OnExclusiveAccessUserInput() override;
content::WebContents* GetActiveWebContents() override;
void UnhideDownloadShelf() override;
void HideDownloadShelf() override;
bool ShouldHideUIForFullscreen() const override;
ExclusiveAccessBubbleViews* GetExclusiveAccessBubble() override;
// ui::AcceleratorProvider:
bool GetAcceleratorForCommandId(int command_id,
ui::Accelerator* accelerator) const override;
// ExclusiveAccessBubbleViewsContext:
ExclusiveAccessManager* GetExclusiveAccessManager() override;
views::Widget* GetBubbleAssociatedWidget() override;
ui::AcceleratorProvider* GetAcceleratorProvider() override;
gfx::NativeView GetBubbleParentView() const override;
gfx::Point GetCursorPointInParent() const override;
gfx::Rect GetClientAreaBoundsInScreen() const override;
bool IsImmersiveModeEnabled() const override;
gfx::Rect GetTopContainerBoundsInScreen() override;
void DestroyAnyExclusiveAccessBubble() override;
bool CanTriggerOnMouse() const override;
private:
BrowserWindow* GetBrowserWindow() const;
// Gets the FullscreenControlHost for this BrowserView, creating it if it does
// not yet exist.
FullscreenControlHost* GetFullscreenControlHost();
BrowserWindowController* controller_; // Weak. Owns |this|.
Browser* browser_; // Weak. Owned by controller.
// When going fullscreen for a tab, we need to store the URL and the
// fullscreen type, since we can't show the bubble until
// -windowDidEnterFullScreen: gets called.
GURL url_;
ExclusiveAccessBubbleType bubble_type_;
ExclusiveAccessBubbleHideCallback bubble_first_hide_callback_;
std::unique_ptr<ExclusiveAccessBubbleViews> views_bubble_;
std::unique_ptr<FullscreenControlHost> fullscreen_control_host_;
std::unique_ptr<views::EventMonitor> fullscreen_control_host_event_monitor_;
// Used to keep track of the kShowFullscreenToolbar preference.
PrefChangeRegistrar pref_registrar_;
DISALLOW_COPY_AND_ASSIGN(ExclusiveAccessController);
};
#endif // CHROME_BROWSER_UI_COCOA_BROWSER_EXCLUSIVE_ACCESS_CONTROLLER_VIEWS_H_
// Copyright 2016 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.
#import "chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.h"
#include "chrome/browser/download/download_shelf.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/cocoa/accelerators_cocoa.h"
#import "chrome/browser/ui/cocoa/browser_window_controller.h"
#import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_controller_cocoa.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
#include "chrome/browser/ui/status_bubble.h"
#include "chrome/browser/ui/views/exclusive_access_bubble_views.h"
#include "chrome/browser/ui/views/fullscreen_control/fullscreen_control_host.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "ui/base/cocoa/cocoa_base_utils.h"
#import "ui/gfx/mac/coordinate_conversion.h"
#include "ui/views/event_monitor.h"
namespace {
// If |callback| was never passed to |ExclusiveAccessBubbleViews|, calls it
// with |kNotShown|, otherwise does nothing.
void CallHideCallbackAsNotShownIfNecessary(
ExclusiveAccessBubbleHideCallback callback) {
if (callback)
std::move(callback).Run(ExclusiveAccessBubbleHideReason::kNotShown);
}
} // anonymous namespace
ExclusiveAccessController::ExclusiveAccessController(
BrowserWindowController* controller,
Browser* browser)
: controller_(controller),
browser_(browser),
bubble_type_(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE) {
pref_registrar_.Init(GetProfile()->GetPrefs());
pref_registrar_.Add(
prefs::kShowFullscreenToolbar,
base::Bind(&ExclusiveAccessController::UpdateFullscreenToolbar,
base::Unretained(this)));
}
ExclusiveAccessController::~ExclusiveAccessController() {
CallHideCallbackAsNotShownIfNecessary(std::move(bubble_first_hide_callback_));
}
void ExclusiveAccessController::Show() {
views_bubble_.reset(new ExclusiveAccessBubbleViews(
this, url_, bubble_type_, std::move(bubble_first_hide_callback_)));
}
void ExclusiveAccessController::Destroy() {
views_bubble_.reset();
url_ = GURL();
bubble_type_ = EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE;
CallHideCallbackAsNotShownIfNecessary(std::move(bubble_first_hide_callback_));
}
Profile* ExclusiveAccessController::GetProfile() {
return browser_->profile();
}
bool ExclusiveAccessController::IsFullscreen() const {
return [controller_ isInAnyFullscreenMode];
}
void ExclusiveAccessController::UpdateUIForTabFullscreen(
TabFullscreenState state) {
[controller_ updateUIForTabFullscreen:state];
}
void ExclusiveAccessController::UpdateFullscreenToolbar() {
[[controller_ fullscreenToolbarController]
layoutToolbarStyleIsExitingTabFullscreen:NO];
}
// See the Fullscreen terminology section and the (Fullscreen) interface
// category in browser_window_controller.h for a detailed explanation of the
// logic in this method.
void ExclusiveAccessController::EnterFullscreen(
const GURL& url,
ExclusiveAccessBubbleType bubble_type) {
url_ = url;
bubble_type_ = bubble_type;
CallHideCallbackAsNotShownIfNecessary(std::move(bubble_first_hide_callback_));
if (browser_->exclusive_access_manager()
->fullscreen_controller()
->IsWindowFullscreenForTabOrPending())
[controller_ enterWebContentFullscreen];
else
[controller_ enterBrowserFullscreen];
// This is not guarded by FullscreenControlHost::IsFullscreenExitUIEnabled()
// because ShouldHideUIForFullscreen() already guards that mouse and touch
// inputs will not trigger the exit UI, and we always need
// FullscreenControlHost whenever keyboard lock requires press-and-hold ESC.
fullscreen_control_host_event_monitor_ =
views::EventMonitor::CreateWindowMonitor(
GetFullscreenControlHost(),
GetActiveWebContents()->GetTopLevelNativeWindow());
}
void ExclusiveAccessController::ExitFullscreen() {
[controller_ exitAnyFullscreen];
if (fullscreen_control_host_) {
fullscreen_control_host_->Hide(false);
fullscreen_control_host_event_monitor_.reset();
}
}
void ExclusiveAccessController::UpdateExclusiveAccessExitBubbleContent(
const GURL& url,
ExclusiveAccessBubbleType bubble_type,
ExclusiveAccessBubbleHideCallback bubble_first_hide_callback,
bool force_update) {
url_ = url;
bubble_type_ = bubble_type;
CallHideCallbackAsNotShownIfNecessary(std::move(bubble_first_hide_callback_));
bubble_first_hide_callback_ = std::move(bubble_first_hide_callback);
[controller_ updateFullscreenExitBubble];
}
void ExclusiveAccessController::OnExclusiveAccessUserInput() {
if (views_bubble_)
views_bubble_->OnUserInput();
}
content::WebContents* ExclusiveAccessController::GetActiveWebContents() {
return browser_->tab_strip_model()->GetActiveWebContents();
}
void ExclusiveAccessController::UnhideDownloadShelf() {
}
void ExclusiveAccessController::HideDownloadShelf() {
StatusBubble* statusBubble = GetBrowserWindow()->GetStatusBubble();
if (statusBubble)
statusBubble->Hide();
}
bool ExclusiveAccessController::ShouldHideUIForFullscreen() const {
return false;
}
ExclusiveAccessBubbleViews*
ExclusiveAccessController::GetExclusiveAccessBubble() {
return views_bubble_.get();
}
bool ExclusiveAccessController::GetAcceleratorForCommandId(
int cmd_id,
ui::Accelerator* accelerator) const {
*accelerator =
*AcceleratorsCocoa::GetInstance()->GetAcceleratorForCommand(cmd_id);
return true;
}
ExclusiveAccessManager* ExclusiveAccessController::GetExclusiveAccessManager() {
return browser_->exclusive_access_manager();
}
views::Widget* ExclusiveAccessController::GetBubbleAssociatedWidget() {
NOTREACHED(); // Only used for non-simplified UI.
return nullptr;
}
ui::AcceleratorProvider* ExclusiveAccessController::GetAcceleratorProvider() {
return this;
}
gfx::NativeView ExclusiveAccessController::GetBubbleParentView() const {
return [[controller_ window] contentView];
}
gfx::Point ExclusiveAccessController::GetCursorPointInParent() const {
NSWindow* window = [controller_ window];
NSPoint location =
ui::ConvertPointFromScreenToWindow(window, [NSEvent mouseLocation]);
return gfx::Point(location.x,
NSHeight([[window contentView] frame]) - location.y);
}
gfx::Rect ExclusiveAccessController::GetClientAreaBoundsInScreen() const {
return gfx::ScreenRectFromNSRect([[controller_ window] frame]);
}
bool ExclusiveAccessController::IsImmersiveModeEnabled() const {
return false;
}
gfx::Rect ExclusiveAccessController::GetTopContainerBoundsInScreen() {
NOTREACHED(); // Only used for ImmersiveMode.
return gfx::Rect();
}
void ExclusiveAccessController::DestroyAnyExclusiveAccessBubble() {
Destroy();
}
bool ExclusiveAccessController::CanTriggerOnMouse() const {
return true;
}
BrowserWindow* ExclusiveAccessController::GetBrowserWindow() const {
return [controller_ browserWindow];
}
FullscreenControlHost* ExclusiveAccessController::GetFullscreenControlHost() {
if (!fullscreen_control_host_) {
fullscreen_control_host_ =
std::make_unique<FullscreenControlHost>(this, this);
}
return fullscreen_control_host_.get();
}
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window_state.h" #include "chrome/browser/ui/browser_window_state.h"
#import "chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.h"
#include "chrome/browser/ui/cocoa/browser_dialogs_views_mac.h" #include "chrome/browser/ui/cocoa/browser_dialogs_views_mac.h"
#import "chrome/browser/ui/cocoa/browser_window_controller.h" #import "chrome/browser/ui/cocoa/browser_window_controller.h"
#import "chrome/browser/ui/cocoa/browser_window_utils.h" #import "chrome/browser/ui/cocoa/browser_window_utils.h"
...@@ -153,7 +152,6 @@ bool BrowserWindowCocoa::IsVisible() const { ...@@ -153,7 +152,6 @@ bool BrowserWindowCocoa::IsVisible() const {
void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) { void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) {
gfx::Rect real_bounds = [controller_ enforceMinWindowSize:bounds]; gfx::Rect real_bounds = [controller_ enforceMinWindowSize:bounds];
GetExclusiveAccessContext()->ExitFullscreen();
NSRect cocoa_bounds = NSMakeRect(real_bounds.x(), 0, NSRect cocoa_bounds = NSMakeRect(real_bounds.x(), 0,
real_bounds.width(), real_bounds.width(),
real_bounds.height()); real_bounds.height());
...@@ -405,7 +403,7 @@ bool BrowserWindowCocoa::ShouldHideUIForFullscreen() const { ...@@ -405,7 +403,7 @@ bool BrowserWindowCocoa::ShouldHideUIForFullscreen() const {
} }
bool BrowserWindowCocoa::IsFullscreen() const { bool BrowserWindowCocoa::IsFullscreen() const {
return [controller_ isInAnyFullscreenMode]; return false;
} }
bool BrowserWindowCocoa::IsFullscreenBubbleVisible() const { bool BrowserWindowCocoa::IsFullscreenBubbleVisible() const {
...@@ -577,8 +575,6 @@ void BrowserWindowCocoa::HandleKeyboardEvent( ...@@ -577,8 +575,6 @@ void BrowserWindowCocoa::HandleKeyboardEvent(
// A priority system for exiting extension fullscreen when there is a // A priority system for exiting extension fullscreen when there is a
// conflict is being experimented. See Issue 536047. // conflict is being experimented. See Issue 536047.
if (event.windows_key_code == ui::VKEY_ESCAPE) { if (event.windows_key_code == ui::VKEY_ESCAPE) {
[controller_ exitExtensionFullscreenIfPossible];
// This is a press of an escape key with no modifiers except potentially // This is a press of an escape key with no modifiers except potentially
// shift. This will not be handled by the performKeyEquivalent: path, so // shift. This will not be handled by the performKeyEquivalent: path, so
// handle it directly here. // handle it directly here.
...@@ -666,7 +662,7 @@ void BrowserWindowCocoa::ExecuteExtensionCommand( ...@@ -666,7 +662,7 @@ void BrowserWindowCocoa::ExecuteExtensionCommand(
} }
ExclusiveAccessContext* BrowserWindowCocoa::GetExclusiveAccessContext() { ExclusiveAccessContext* BrowserWindowCocoa::GetExclusiveAccessContext() {
return [controller_ exclusiveAccessController]; return nullptr;
} }
void BrowserWindowCocoa::ShowImeWarningBubble( void BrowserWindowCocoa::ShowImeWarningBubble(
......
...@@ -103,15 +103,6 @@ NSString* GetTitleForViewsFullscreenMenuItem(Browser* browser) { ...@@ -103,15 +103,6 @@ NSString* GetTitleForViewsFullscreenMenuItem(Browser* browser) {
// Get the text for the "Enter/Exit Fullscreen" menu item. // Get the text for the "Enter/Exit Fullscreen" menu item.
// TODO(jackhou): Remove the dependency on BrowserWindowController(Private). // TODO(jackhou): Remove the dependency on BrowserWindowController(Private).
NSString* GetTitleForFullscreenMenuItem(Browser* browser) { NSString* GetTitleForFullscreenMenuItem(Browser* browser) {
NSWindow* ns_window = browser->window()->GetNativeWindow();
BrowserWindowController* controller =
BrowserWindowControllerForWindow(ns_window);
if (controller) {
return l10n_util::GetNSString([controller isInAppKitFullscreen]
? IDS_EXIT_FULLSCREEN_MAC
: IDS_ENTER_FULLSCREEN_MAC);
}
return GetTitleForViewsFullscreenMenuItem(browser); return GetTitleForViewsFullscreenMenuItem(browser);
} }
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#import "chrome/browser/ui/cocoa/browser_window_controller.h" #import "chrome/browser/ui/cocoa/browser_window_controller.h"
#import "chrome/browser/ui/cocoa/browser_window_layout.h" #import "chrome/browser/ui/cocoa/browser_window_layout.h"
#import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_controller.h"
@class BrowserWindowLayout; @class BrowserWindowLayout;
class PermissionRequestManager; class PermissionRequestManager;
...@@ -16,24 +15,6 @@ namespace content { ...@@ -16,24 +15,6 @@ namespace content {
class WebContents; class WebContents;
} // content. } // content.
// There are 2 mechanisms for invoking fullscreen: AppKit and Immersive.
// PRESENTATION_MODE = 1 had been removed, but the enums aren't renumbered
// since they are associated with a histogram.
enum FullscreenStyle {
IMMERSIVE_FULLSCREEN = 0,
CANONICAL_FULLSCREEN = 2,
FULLSCREEN_STYLE_COUNT = 3
};
// The source that triggered fullscreen. The enums should not be renumbered
// since they're ssociated with a histogram. Exposed for testing.
enum class FullscreenSource {
BROWSER = 0,
TAB,
EXTENSION,
FULLSCREEN_SOURCE_COUNT
};
// Private methods for the |BrowserWindowController|. This category should // Private methods for the |BrowserWindowController|. This category should
// contain the private methods used by different parts of the BWC; private // contain the private methods used by different parts of the BWC; private
// methods used only by single parts should be declared in their own file. // methods used only by single parts should be declared in their own file.
...@@ -42,10 +23,6 @@ enum class FullscreenSource { ...@@ -42,10 +23,6 @@ enum class FullscreenSource {
// "dependencies"). // "dependencies").
@interface BrowserWindowController(Private) @interface BrowserWindowController(Private)
// Sets the window's collection behavior to the appropriate
// fullscreen behavior.
- (void)updateFullscreenCollectionBehavior;
// Saves the window's position in the local state preferences. // Saves the window's position in the local state preferences.
- (void)saveWindowPositionIfNeeded; - (void)saveWindowPositionIfNeeded;
...@@ -60,9 +37,6 @@ enum class FullscreenSource { ...@@ -60,9 +37,6 @@ enum class FullscreenSource {
// content area, download shelf (if any). // content area, download shelf (if any).
- (void)layoutSubviews; - (void)layoutSubviews;
// Shows the informational "how to exit fullscreen" bubble.
- (void)showFullscreenExitBubbleIfNecessary;
// Lays out the tab strip and avatar button. // Lays out the tab strip and avatar button.
- (void)applyTabStripLayout:(const chrome::TabStripLayout&)layout; - (void)applyTabStripLayout:(const chrome::TabStripLayout&)layout;
...@@ -79,47 +53,6 @@ enum class FullscreenSource { ...@@ -79,47 +53,6 @@ enum class FullscreenSource {
// keep the total height of the two views constant. // keep the total height of the two views constant.
- (void)adjustToolbarAndBookmarkBarForCompression:(CGFloat)compression; - (void)adjustToolbarAndBookmarkBarForCompression:(CGFloat)compression;
// Moves views between windows in preparation for fullscreen mode when not using
// Cocoa's System Fullscreen API. (System Fullscreen reuses the original window
// for fullscreen mode, so there is no need to move views around.) This method
// does not position views; callers must also call |-layoutSubviews:|.
- (void)moveViewsForImmersiveFullscreen:(BOOL)fullscreen
regularWindow:(NSWindow*)regularWindow
fullscreenWindow:(NSWindow*)fullscreenWindow;
// Updates the anchor position of the permission bubble.
- (void)updatePermissionBubbleAnchor;
// Enter or exit fullscreen without using Cocoa's System Fullscreen API. These
// methods are internal implementations of |-setFullscreen:|.
- (void)enterImmersiveFullscreen;
- (void)exitImmersiveFullscreen;
// Register or deregister for content view resize notifications. These
// notifications are used while transitioning into fullscreen mode using Cocoa's
// System Fullscreen API.
- (void)registerForContentViewResizeNotifications;
- (void)deregisterForContentViewResizeNotifications;
// The opacity for the toolbar divider; 0 means that it shouldn't be shown.
- (CGFloat)toolbarDividerOpacity;
// Enter fullscreen by toggling the AppKit Fullscreen API.
- (void)enterAppKitFullscreen;
// Exit fullscreen by toggling the AppKit Fullscreen API. If |async| is true,
// call -toggleFullscreen: asynchronously.
- (void)exitAppKitFullscreenAsync:(BOOL)async;
// Returns where the fullscreen button should be positioned in the window.
// Returns NSZeroRect if there is no fullscreen button (if currently in
// fullscreen, or if running 10.6 or 10.10+).
- (NSRect)fullscreenButtonFrame;
// Updates |layout| with the full set of parameters required to statelessly
// determine the layout of the views managed by this controller.
- (void)updateLayoutParameters:(BrowserWindowLayout*)layout;
// Applies a layout to the views managed by this controller. // Applies a layout to the views managed by this controller.
- (void)applyLayout:(BrowserWindowLayout*)layout; - (void)applyLayout:(BrowserWindowLayout*)layout;
...@@ -130,43 +63,13 @@ enum class FullscreenSource { ...@@ -130,43 +63,13 @@ enum class FullscreenSource {
// Performs updateSubviewZOrder when this controller is not in fullscreen. // Performs updateSubviewZOrder when this controller is not in fullscreen.
- (void)updateSubviewZOrderNormal; - (void)updateSubviewZOrderNormal;
// Performs updateSubviewZOrder when this controller is in fullscreen.
- (void)updateSubviewZOrderFullscreen;
// Sets the content view's subviews. Attempts to not touch the tabContentArea // Sets the content view's subviews. Attempts to not touch the tabContentArea
// to prevent redraws. // to prevent redraws.
- (void)setContentViewSubviews:(NSArray*)subviews; - (void)setContentViewSubviews:(NSArray*)subviews;
// Whether the instance should use a custom transition when animating into and
// out of AppKit Fullscreen.
- (BOOL)shouldUseCustomAppKitFullscreenTransition:(BOOL)enterFullScreen;
// Resets the variables that were set from using custom AppKit fullscreen
// animation.
- (void)resetCustomAppKitFullscreenVariables;
- (content::WebContents*)webContents; - (content::WebContents*)webContents;
- (PermissionRequestManager*)permissionRequestManager; - (PermissionRequestManager*)permissionRequestManager;
// Hides or unhides any displayed modal sheet for fullscreen transition.
// Modal sheets should be hidden at the beginning and then shown at the end.
- (void)setSheetHiddenForFullscreenTransition:(BOOL)shoudHide;
// Adjusts the UI and destroys the exit bubble when we are exiting fullscreen.
- (void)adjustUIForExitingFullscreen;
// Determines the appropriate sliding fullscreen style and adjusts the UI to
// it when we are entering fullscreen.
- (void)adjustUIForEnteringFullscreen;
// Records fullscreen metrics when the browser enters fullscreen.
- (void)recordEnterFullscreenMetrics:(FullscreenStyle)style;
// Accessor for the controller managing the fullscreen toolbar visibility
// locks.
- (FullscreenToolbarVisibilityLockController*)
fullscreenToolbarVisibilityLockController;
@end // @interface BrowserWindowController(Private) @end // @interface BrowserWindowController(Private)
#endif // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_PRIVATE_H_ #endif // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_CONTROLLER_PRIVATE_H_
...@@ -85,12 +85,6 @@ TEST_F(BrowserWindowControllerTest, TestSaveWindowPosition) { ...@@ -85,12 +85,6 @@ TEST_F(BrowserWindowControllerTest, TestSaveWindowPosition) {
EXPECT_FALSE(browser_window_placement->empty()); EXPECT_FALSE(browser_window_placement->empty());
} }
TEST_F(BrowserWindowControllerTest, TestFullScreenWindow) {
// Confirm that |-createFullscreenWindow| doesn't return nil.
// See BrowserWindowFullScreenControllerTest for more fullscreen tests.
EXPECT_TRUE([controller_ createFullscreenWindow]);
}
TEST_F(BrowserWindowControllerTest, TestTheme) { TEST_F(BrowserWindowControllerTest, TestTheme) {
[controller_ userChangedTheme]; [controller_ userChangedTheme];
} }
...@@ -314,132 +308,3 @@ TEST_F(BrowserWindowControllerTest, UsesAutoLayout) { ...@@ -314,132 +308,3 @@ TEST_F(BrowserWindowControllerTest, UsesAutoLayout) {
// view's frame and autoresizing mask. // view's frame and autoresizing mask.
EXPECT_EQ(0u, [[[controller_ chromeContentView] constraints] count]); EXPECT_EQ(0u, [[[controller_ chromeContentView] constraints] count]);
} }
@interface BrowserWindowControllerFakeFullscreen : BrowserWindowController {
@private
// We release the window ourselves, so we don't have to rely on the unittest
// doing it for us.
base::scoped_nsobject<NSWindow> testFullscreenWindow_;
}
@end
class BrowserWindowFullScreenControllerTest : public CocoaProfileTest {
public:
void SetUp() override {
CocoaProfileTest::SetUp();
ASSERT_TRUE(browser());
controller_ =
[[BrowserWindowControllerFakeFullscreen alloc] initWithBrowser:browser()
takeOwnership:NO];
}
void TearDown() override {
[[controller_ nsWindowController] close];
CocoaProfileTest::TearDown();
}
public:
BrowserWindowController* controller_;
};
// Check if the window is front most or if one of its child windows (such
// as a status bubble) is front most.
static bool IsFrontWindow(NSWindow* window) {
NSWindow* frontmostWindow = [[NSApp orderedWindows] objectAtIndex:0];
return [frontmostWindow isEqual:window] ||
[[frontmostWindow parentWindow] isEqual:window];
}
void WaitForFullScreenTransition() {
content::WindowedNotificationObserver observer(
chrome::NOTIFICATION_FULLSCREEN_CHANGED,
content::NotificationService::AllSources());
observer.Wait();
}
// http://crbug.com/53586
TEST_F(BrowserWindowFullScreenControllerTest, TestFullscreen) {
ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen;
[[controller_ nsWindowController] showWindow:nil];
EXPECT_FALSE([controller_ isInAnyFullscreenMode]);
// The fix for http://crbug.com/447740 , where the omnibox would lose focus
// when switching between normal and fullscreen modes, makes some changes to
// -[BrowserWindowController setContentViewSubviews:]. Those changes appear
// to have extended the lifetime of the browser window during this test -
// specifically, the browser window is no longer visible, but it has not been
// fully freed (possibly being kept around by a reference from the
// autocompleteTextView). As a result the window still appears in
// -[NSApplication windows] and causes the test to fail. To get around this
// problem, I disable -[BrowserWindowController focusLocationBar:] and later
// force the window to clear its first responder.
base::mac::ScopedObjCClassSwizzler tmpSwizzler(
[BrowserWindowController class], @selector(focusLocationBar:),
@selector(dontFocusLocationBar:));
[controller_ enterBrowserFullscreen];
WaitForFullScreenTransition();
EXPECT_TRUE([controller_ isInAnyFullscreenMode]);
[controller_ exitAnyFullscreen];
WaitForFullScreenTransition();
EXPECT_FALSE([controller_ isInAnyFullscreenMode]);
[[controller_ window] makeFirstResponder:nil];
}
// If this test fails, it is usually a sign that the bots have some sort of
// problem (such as a modal dialog up). This tests is a very useful canary, so
// please do not mark it as flaky without first verifying that there are no bot
// problems.
// http://crbug.com/53586
TEST_F(BrowserWindowFullScreenControllerTest, TestActivate) {
ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen;
[[controller_ nsWindowController] showWindow:nil];
EXPECT_FALSE([controller_ isInAnyFullscreenMode]);
[controller_ activate];
chrome::testing::NSRunLoopRunAllPending();
EXPECT_TRUE(IsFrontWindow([controller_ window]));
// See the comment in TestFullscreen for an explanation of this
// swizzling and the makeFirstResponder:nil call below.
base::mac::ScopedObjCClassSwizzler tmpSwizzler(
[BrowserWindowController class], @selector(focusLocationBar:),
@selector(dontFocusLocationBar:));
[controller_ enterBrowserFullscreen];
WaitForFullScreenTransition();
[controller_ activate];
chrome::testing::NSRunLoopRunAllPending();
// We have to cleanup after ourselves by unfullscreening.
[controller_ exitAnyFullscreen];
WaitForFullScreenTransition();
[[controller_ window] makeFirstResponder:nil];
}
@implementation BrowserWindowControllerFakeFullscreen
// Override |-createFullscreenWindow| to return a dummy window. This isn't
// needed to pass the test, but because the dummy window is only 100x100, it
// prevents the real fullscreen window from flashing up and taking over the
// whole screen. We have to return an actual window because |-layoutSubviews|
// looks at the window's frame.
- (NSWindow*)createFullscreenWindow {
if (testFullscreenWindow_.get())
return testFullscreenWindow_.get();
testFullscreenWindow_.reset(
[[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,400,400)
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO]);
[[testFullscreenWindow_ contentView] setWantsLayer:YES];
return testFullscreenWindow_.get();
}
@end
/* TODO(???): test other methods of BrowserWindowController */
// Copyright 2015 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_COCOA_BROWSER_WINDOW_FULLSCREEN_TRANSITION_H_
#define CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_FULLSCREEN_TRANSITION_H_
#import <Cocoa/Cocoa.h>
@class BrowserWindowController;
// This class is responsible for managing the custom transition of a
// BrowserWindow from its normal state into an AppKit Fullscreen state
// and vice versa.
//
// By default, when AppKit Fullscreens a window, it creates a new virtual
// desktop and slides it in from the right of the screen. At the same time, the
// old virtual desktop slides off to the left. This animation takes one second,
// and the time is not customizable without elevated privileges or a
// self-modifying binary
// (https://code.google.com/p/chromium/issues/detail?id=414527). During that
// second, no user interaction is possible.
//
// The default implementation of the AppKit transition smoothly animates a
// window from its original size to the expected size. At the
// beginning of the animation, it takes a snapshot of the window's current
// state. Then it resizes the window, calls drawRect: (theorized, not tested),
// and takes a snapshot of the window's final state. The animation is a simple
// crossfade between the two snapshots. This has a flaw. Frequently, the
// renderer has not yet drawn content for the resized window by the time
// drawRect: is called. As a result, the animation is effectively a no-op. When
// the animation is finished, the new web content flashes in.
//
// The window's delegate can override four methods to customize the transition.
// -customWindowsToEnterFullScreenForWindow:
// The return of this method is an array of NSWindows. Each window that is
// returned will be added to the new virtual desktop after the animation is
// finished, but will not be a part of the animation itself.
// -window:startCustomAnimationToEnterFullScreenWithDuration:
// In this method, the window's delegate adds animations to the windows
// returned in the above method.
// -customWindowsToExitFullScreenForWindow:
// This method is similar to customWindowsToEnterFullScreenForWindow, but
// will be used for exiting full screen
// -window:startCustomAnimationToExitFullScreenWithDuration:
// In this method, the window's delegate adds animations to the windows
// returned in the above method.
//
// The goal of this class is to mimic the default animation, but instead of
// taking a snapshot of the final web content, it uses the live web content
// during the animation.
//
// See https://code.google.com/p/chromium/issues/detail?id=414527#c22 and its
// preceding comments for a more detailed description of the implementation,
// and the reasoning behind the decisions made.
//
// Recommended usage for entering full screen:
// (Override method on NSWindow's delegate):
// - (NSArray*)customWindowsToEnterFullScreenForWindow:(NSWindow*)window {
// self.transition = [[[BrowserWindowEnterFullscreenTransition alloc]
// initEnterWithWindow:window] autorelease];
// return [self.transition customWindowsForFullScreen];
// }
//
// (Override method on NSWindow's delegate)
// - (void)window:(NSWindow*)window
// startCustomAnimationToEnterFullScreenWithDuration:(NSTimeInterval)duration {
// [self.transition startCustomFullScreenAnimationWithDuration:duration];
// }
//
// (Override method on NSWindow's delegate)
// - (void)windowDidEnterFullScreen:(NSNotification*)notification {
// self.transition = nil;
// }
//
// (Override method on NSWindow)
// - (NSRect)constrainFrameRect:(NSRect)frame toScreen:(NSScreen*)screen {
// if (self.transition && ![self.transition shouldWindowBeConstrained])
// return frame;
// return [super constrainFrameRect:frame toScreen:screen];
// }
//
// For exiting fullscreen, you should do the same as above, but you must
// override following methods instead.
// -customWindowsToExitFullScreenForWindow:,
// -startCustomAnimationToEnterFullScreenWithDuration:
// -windowDidExitFullScreen:
// In addition, you should use initExitWithWindow:frame: instead of
// initEnterWithWindow:. For the frame parameter, you should pass the expected
// frame of the window at the end of the transition. If you want the window to
// resize and move to the frame it had before entering fullscreen, you will be
// responsible for saving the value of the frame and passing it to the
// parameter.
@interface BrowserWindowFullscreenTransition : NSObject
// Designated initializers. |controller| is the BrowserWindowController of the
// window that's going to be moved into a fullscreen Space.
- (instancetype)initEnterWithController:(BrowserWindowController*)controller;
- (instancetype)initExitWithController:(BrowserWindowController*)controller;
// Returns the windows to be used in the custom fullscreen transition.
- (NSArray*)customWindowsForFullScreenTransition;
// Returns true if the fullscreen transition is completed.
- (BOOL)isTransitionCompleted;
// This method begins animation for exit or enter fullscreen transition.
// In this method, the following happens:
// - Animates the snapshot to the expected final size of the window while
// fading it out.
// - Animates the current window from its original to final location and size
// while fading it in.
// If the transition is for exiting fullscreen, we would shrink the content view
// to the expected final size so that we can to avoid clipping from the
// window.
// Note: The two animations are added to different layers in different windows.
// There is no explicit logic to keep the two animations in sync. If this
// proves to be a problem, the relevant layers should attempt to sync up their
// time offsets with CACurrentMediaTime().
- (void)startCustomFullScreenAnimationWithDuration:(NSTimeInterval)duration;
// When this method returns true, the NSWindow method
// -constrainFrameRect:toScreen: must return the frame rect without
// constraining it. The owner of the instance of this class is responsible for
// hooking up this logic.
- (BOOL)shouldWindowBeUnconstrained;
// Returns the size of the window we expect the BrowserWindowLayout to have.
// During the exit fullscreen transition, the content size shrinks while the
// window frame stays the same. When that happens, we want to set the
// BrowserWindowLayout's window parameter to the content size instead of the
// actual window's size.
- (NSSize)desiredWindowLayoutSize;
// Called when the browser is destroyed.
- (void)browserWillBeDestroyed;
@end
#endif // CHROME_BROWSER_UI_COCOA_BROWSER_WINDOW_FULLSCREEN_TRANSITION_H_
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_controller.h"
namespace chrome { namespace chrome {
// The height of the tab strip. // The height of the tab strip.
...@@ -29,9 +27,6 @@ struct LayoutParameters { ...@@ -29,9 +27,6 @@ struct LayoutParameters {
// Whether the controller is in any fullscreen mode. This parameter should be // Whether the controller is in any fullscreen mode. This parameter should be
// NO if the controller is in the process of entering fullscreen. // NO if the controller is in the process of entering fullscreen.
BOOL inAnyFullscreen; BOOL inAnyFullscreen;
// The fullscreen toolbar style. See fullscreen_toolbar_controller.h for more
// details.
FullscreenToolbarStyle toolbarStyle;
// The minY of the AppKit Menu Bar, relative to the top of the screen. Ranges // The minY of the AppKit Menu Bar, relative to the top of the screen. Ranges
// from 0 to -22. Only relevant in fullscreen mode. // from 0 to -22. Only relevant in fullscreen mode.
CGFloat menubarOffset; CGFloat menubarOffset;
...@@ -148,7 +143,6 @@ struct LayoutOutput { ...@@ -148,7 +143,6 @@ struct LayoutOutput {
// Whether the controller is in any fullscreen mode. |inAnyFullscreen| should // Whether the controller is in any fullscreen mode. |inAnyFullscreen| should
// be NO if the controller is in the process of entering fullscreen. // be NO if the controller is in the process of entering fullscreen.
- (void)setInAnyFullscreen:(BOOL)inAnyFullscreen; - (void)setInAnyFullscreen:(BOOL)inAnyFullscreen;
- (void)setFullscreenToolbarStyle:(FullscreenToolbarStyle)toolbarStyle;
- (void)setFullscreenMenubarOffset:(CGFloat)menubarOffset; - (void)setFullscreenMenubarOffset:(CGFloat)menubarOffset;
- (void)setFullscreenToolbarFraction:(CGFloat)toolbarFraction; - (void)setFullscreenToolbarFraction:(CGFloat)toolbarFraction;
......
...@@ -91,10 +91,6 @@ const CGFloat kLocBarBottomInset = 1; ...@@ -91,10 +91,6 @@ const CGFloat kLocBarBottomInset = 1;
parameters_.inAnyFullscreen = inAnyFullscreen; parameters_.inAnyFullscreen = inAnyFullscreen;
} }
- (void)setFullscreenToolbarStyle:(FullscreenToolbarStyle)style {
parameters_.toolbarStyle = style;
}
- (void)setFullscreenMenubarOffset:(CGFloat)menubarOffset { - (void)setFullscreenMenubarOffset:(CGFloat)menubarOffset {
parameters_.menubarOffset = menubarOffset; parameters_.menubarOffset = menubarOffset;
} }
...@@ -193,11 +189,6 @@ const CGFloat kLocBarBottomInset = 1; ...@@ -193,11 +189,6 @@ const CGFloat kLocBarBottomInset = 1;
// Lay out the toolbar. // Lay out the toolbar.
if (parameters.hasToolbar) { if (parameters.hasToolbar) {
CGFloat toolbarY = maxY; CGFloat toolbarY = maxY;
if (parameters_.inAnyFullscreen &&
parameters_.toolbarStyle == FullscreenToolbarStyle::TOOLBAR_NONE) {
toolbarY = parameters_.windowSize.height + fullscreenYOffset_;
}
output_.toolbarFrame = NSMakeRect(0, toolbarY - parameters_.toolbarHeight, output_.toolbarFrame = NSMakeRect(0, toolbarY - parameters_.toolbarHeight,
width, parameters_.toolbarHeight); width, parameters_.toolbarHeight);
maxY = NSMinY(output_.toolbarFrame); maxY = NSMinY(output_.toolbarFrame);
...@@ -229,15 +220,6 @@ const CGFloat kLocBarBottomInset = 1; ...@@ -229,15 +220,6 @@ const CGFloat kLocBarBottomInset = 1;
// Place the find bar immediately below the toolbar/attached bookmark bar. // Place the find bar immediately below the toolbar/attached bookmark bar.
output_.findBarMaxY = maxY; output_.findBarMaxY = maxY;
if (parameters_.inAnyFullscreen &&
(parameters_.toolbarStyle == FullscreenToolbarStyle::TOOLBAR_HIDDEN ||
parameters_.toolbarStyle == FullscreenToolbarStyle::TOOLBAR_NONE)) {
// If the toolbar is hidden or missing, reset |maxY| to top of screen, so
// that the toolbar slides over the things which appear to be in the
// content area.
maxY = parameters_.windowSize.height;
}
// Lay out the info bar. It is never hidden. // Lay out the info bar. It is never hidden.
if (parameters_.infoBarHeight != 0) { if (parameters_.infoBarHeight != 0) {
CGFloat infoBarMaxY = maxY; CGFloat infoBarMaxY = maxY;
...@@ -270,18 +252,6 @@ const CGFloat kLocBarBottomInset = 1; ...@@ -270,18 +252,6 @@ const CGFloat kLocBarBottomInset = 1;
minY = NSMaxY(output_.downloadShelfFrame); minY = NSMaxY(output_.downloadShelfFrame);
} }
if (parameters_.inAnyFullscreen &&
parameters_.toolbarStyle == FullscreenToolbarStyle::TOOLBAR_PRESENT) {
// If in Canonical Fullscreen, content should be shifted down by an amount
// equal to all the widgets and views at the top of the window. It should
// not be further shifted by the appearance/disappearance of the AppKit
// menu bar.
maxY = parameters_.windowSize.height;
maxY -= NSHeight(output_.toolbarFrame) +
NSHeight(output_.tabStripLayout.frame) +
NSHeight(output_.bookmarkFrame) + parameters.infoBarHeight;
}
// All the remaining space becomes the frame of the content area. // All the remaining space becomes the frame of the content area.
output_.contentAreaFrame = NSMakeRect(0, minY, width, maxY - minY); output_.contentAreaFrame = NSMakeRect(0, minY, width, maxY - minY);
} }
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/bubble_anchor_util.h" #include "chrome/browser/ui/bubble_anchor_util.h"
#import "chrome/browser/ui/cocoa/browser_window_controller.h" #import "chrome/browser/ui/cocoa/browser_window_controller.h"
#import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_controller.h"
#import "chrome/browser/ui/cocoa/l10n_util.h" #import "chrome/browser/ui/cocoa/l10n_util.h"
#import "ui/base/cocoa/cocoa_base_utils.h" #import "ui/base/cocoa/cocoa_base_utils.h"
...@@ -22,8 +21,5 @@ bool HasVisibleLocationBarForBrowser(Browser* browser) { ...@@ -22,8 +21,5 @@ bool HasVisibleLocationBarForBrowser(Browser* browser) {
if (!browser->exclusive_access_manager()->context()->IsFullscreen()) if (!browser->exclusive_access_manager()->context()->IsFullscreen())
return true; return true;
// Return false only if the toolbar is fully hidden. return false;
BrowserWindowController* bwc = [BrowserWindowController
browserWindowControllerForWindow:browser->window()->GetNativeWindow()];
return [[bwc fullscreenToolbarController] toolbarFraction] != 0;
} }
// Copyright (c) 2010 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_COCOA_FLOATING_BAR_BACKING_VIEW_H_
#define CHROME_BROWSER_UI_COCOA_FLOATING_BAR_BACKING_VIEW_H_
#import <Cocoa/Cocoa.h>
#import "chrome/browser/ui/cocoa/themed_window.h"
// A custom view that draws the tab strip background for fullscreen windows.
@interface FloatingBarBackingView : NSView<ThemedWindowDrawing>
@end
#endif // CHROME_BROWSER_UI_COCOA_FLOATING_BAR_BACKING_VIEW_H_
// Copyright (c) 2012 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/cocoa/floating_bar_backing_view.h"
#import "chrome/browser/ui/cocoa/framed_browser_window.h"
#import "ui/base/cocoa/appkit_utils.h"
@implementation FloatingBarBackingView
- (void)drawRect:(NSRect)rect {
NSWindow* window = [self window];
BOOL isMainWindow = [window isMainWindow];
if (isMainWindow)
[[NSColor windowFrameColor] set];
else
[[NSColor windowBackgroundColor] set];
NSRectFill(rect);
[FramedBrowserWindow drawWindowThemeInDirtyRect:rect
forView:self
bounds:[self bounds]
forceBlackBackground:YES];
}
// Eat all mouse events (and do *not* pass them on to the next responder!).
- (void)mouseDown:(NSEvent*)event {}
- (void)rightMouseDown:(NSEvent*)event {}
- (void)otherMouseDown:(NSEvent*)event {}
- (void)rightMouseUp:(NSEvent*)event {}
- (void)otherMouseUp:(NSEvent*)event {}
- (void)mouseMoved:(NSEvent*)event {}
- (void)mouseDragged:(NSEvent*)event {}
- (void)rightMouseDragged:(NSEvent*)event {}
- (void)otherMouseDragged:(NSEvent*)event {}
// Eat this too, except that ...
- (void)mouseUp:(NSEvent*)event {
// a double-click in the blank area should try to minimize, to be consistent
// with double-clicks on the contiguous tab strip area. (It'll fail and beep.)
if ([event clickCount] == 2)
ui::WindowTitlebarReceivedDoubleClick([self window], self);
}
// ThemedWindowDrawing implementation.
- (void)windowDidChangeTheme {
[self setNeedsDisplay:YES];
}
- (void)windowDidChangeActive {
[self setNeedsDisplay:YES];
}
@end // @implementation FloatingBarBackingView
// Copyright (c) 2011 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.
#import "base/mac/scoped_nsobject.h"
#import "chrome/browser/ui/cocoa/floating_bar_backing_view.h"
#import "chrome/browser/ui/cocoa/test/cocoa_test_helper.h"
namespace {
class FloatingBarBackingViewTest : public CocoaTest {
public:
FloatingBarBackingViewTest() {
NSRect content_frame = [[test_window() contentView] frame];
base::scoped_nsobject<FloatingBarBackingView> view(
[[FloatingBarBackingView alloc] initWithFrame:content_frame]);
view_ = view.get();
[[test_window() contentView] addSubview:view_];
}
FloatingBarBackingView* view_; // Weak. Owned by the view hierarchy.
};
// Tests display, add/remove.
TEST_VIEW(FloatingBarBackingViewTest, view_);
} // namespace
// Copyright (c) 2017 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_COCOA_FULLSCREEN_PLACEHOLDER_VIEW_H_
#define CHROME_BROWSER_UI_COCOA_FULLSCREEN_PLACEHOLDER_VIEW_H_
#import <Cocoa/Cocoa.h>
#import <QuartzCore/CoreImage.h>
@class FullscreenPlaceholderView;
@interface FullscreenPlaceholderView : NSView
// Formats the screenshot displayed on the tab content area when on fullscreen
- (id)initWithFrame:(NSRect)frameRect image:(CGImageRef)screenshot;
@end // @interface FullscreenPlaceholderView : NSView
#endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_PLACEHOLDER_VIEW_H_
// Copyright 2017 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.
#import "chrome/browser/ui/cocoa/fullscreen_placeholder_view.h"
namespace {
NSImage* BlurImageWithRadius(CGImageRef image, NSNumber* radius) {
CIContext* context = [CIContext contextWithCGContext:nil options:nil];
CIImage* inputImage = [[[CIImage alloc] initWithCGImage:image] autorelease];
CIFilter* clampFilter = [CIFilter filterWithName:@"CIAffineClamp"];
[clampFilter setValue:inputImage forKey:kCIInputImageKey];
[clampFilter setValue:[NSValue valueWithBytes:&CGAffineTransformIdentity
objCType:@encode(CGAffineTransform)]
forKey:@"inputTransform"];
CIImage* extendedImage = [clampFilter valueForKey:kCIOutputImageKey];
CIFilter* blurFilter = [CIFilter filterWithName:@"CIGaussianBlur"];
[blurFilter setValue:extendedImage forKey:kCIInputImageKey];
[blurFilter setValue:radius forKey:@"inputRadius"];
CIImage* outputImage = [blurFilter valueForKey:kCIOutputImageKey];
CGImageRef cgImage =
(CGImageRef)[(id)[context createCGImage:outputImage
fromRect:[inputImage extent]] autorelease];
NSImage* resultImage =
[[[NSImage alloc] initWithCGImage:cgImage size:CGSizeZero] autorelease];
return resultImage;
}
}
@implementation FullscreenPlaceholderView {
NSTextField* textView_;
}
- (id)initWithFrame:(NSRect)frameRect image:(CGImageRef)screenshot {
if (self = [super initWithFrame:frameRect]) {
NSView* screenshotView =
[[[NSView alloc] initWithFrame:self.bounds] autorelease];
screenshotView.layer = [[[CALayer alloc] init] autorelease];
screenshotView.wantsLayer = YES;
screenshotView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
[self addSubview:screenshotView];
NSImage* screenshotImage = BlurImageWithRadius(screenshot, @15.0);
screenshotView.layer.contentsGravity = kCAGravityResizeAspectFill;
screenshotView.layer.contents = [screenshotImage
layerContentsForContentsScale:[screenshotView.layer contentsScale]];
textView_ = [[[NSTextField alloc] initWithFrame:frameRect] autorelease];
[textView_ setStringValue:@" Click to exit fullscreen "];
[textView_ setTextColor:[[NSColor whiteColor] colorWithAlphaComponent:0.6]];
[textView_.cell setWraps:NO];
[textView_.cell setScrollable:YES];
[textView_ setBezeled:NO];
[textView_ setEditable:NO];
[textView_ setDrawsBackground:NO];
[textView_ setWantsLayer:YES];
[self resizeLabel];
NSColor* color = [NSColor colorWithCalibratedWhite:0.3 alpha:0.5];
[textView_.layer setBackgroundColor:color.CGColor];
[textView_.layer setCornerRadius:12];
[self addSubview:textView_];
}
return self;
}
- (void)mouseDown:(NSEvent*)event {
// This function handles click events on FullscreenPlaceholderView and will be
// used to exit fullscreen
}
- (void)resizeSubviewsWithOldSize:(CGSize)oldSize {
[super resizeSubviewsWithOldSize:oldSize];
[self resizeLabel];
}
- (void)resizeLabel {
[textView_ setFont:[NSFont systemFontOfSize:0.023 * (NSWidth(self.frame))]];
[textView_ sizeToFit];
[textView_
setFrameOrigin:NSMakePoint(
NSMidX(self.bounds) - NSMidX(textView_.bounds),
NSMidY(self.bounds) - NSMidY(textView_.bounds))];
}
@end
// Copyright (c) 2010 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_COCOA_FULLSCREEN_WINDOW_H_
#define CHROME_BROWSER_UI_COCOA_FULLSCREEN_WINDOW_H_
#include <Cocoa/Cocoa.h>
#import "chrome/browser/ui/cocoa/chrome_browser_window.h"
// A FullscreenWindow is a borderless window suitable for going fullscreen. The
// returned window is NOT release when closed and is not initially visible.
// FullscreenWindow derives from ChromeBrowserWindow to inherit hole punching,
// theming methods, and special event handling
// (e.g. handleExtraKeyboardShortcut).
@interface FullscreenWindow : ChromeBrowserWindow
// Initialize a FullscreenWindow for the given screen.
// Designated initializer.
- (id)initForScreen:(NSScreen*)screen;
@end
#endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_WINDOW_H_
// Copyright (c) 2012 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.
#import "chrome/browser/ui/cocoa/fullscreen_window.h"
#import "chrome/browser/ui/cocoa/themed_window.h"
@implementation FullscreenWindow
// Make sure our designated initializer gets called.
- (id)init {
return [self initForScreen:[NSScreen mainScreen]];
}
- (id)initForScreen:(NSScreen*)screen {
NSRect contentRect;
contentRect.origin = NSZeroPoint;
contentRect.size = [screen frame].size;
if ((self = [super initWithContentRect:contentRect
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO
screen:screen])) {
[self setReleasedWhenClosed:NO];
// Borderless windows don't usually show up in the Windows menu so whine at
// Cocoa until it complies. See -dealloc and -setTitle: as well.
[NSApp addWindowsItem:self title:@"" filename:NO];
[[self contentView] setWantsLayer:YES];
}
return self;
}
- (void)dealloc {
// Paranoia; doesn't seem to be necessary but it doesn't hurt.
[NSApp removeWindowsItem:self];
[super dealloc];
}
- (void)setTitle:(NSString *)title {
[NSApp changeWindowsItem:self title:title filename:NO];
[super setTitle:title];
}
// According to
// http://www.cocoabuilder.com/archive/message/cocoa/2006/6/19/165953 ,
// NSBorderlessWindowMask windows cannot become key or main.
// In our case, however, we don't want that behavior, so we override
// canBecomeKeyWindow and canBecomeMainWindow.
- (BOOL)canBecomeKeyWindow {
return YES;
}
- (BOOL)canBecomeMainWindow {
return YES;
}
// When becoming/resigning main status, explicitly set the background color,
// which is required by |TabViewCocoa|.
- (void)becomeMainWindow {
[super becomeMainWindow];
[self setBackgroundColor:[NSColor windowFrameColor]];
}
- (void)resignMainWindow {
[super resignMainWindow];
[self setBackgroundColor:[NSColor windowBackgroundColor]];
}
// We need our own version, since the default one wants to flash the close
// button (and possibly other things), which results in nothing happening.
- (void)performClose:(id)sender {
BOOL shouldClose = YES;
// If applicable, check if this window should close.
id delegate = [self delegate];
if ([delegate respondsToSelector:@selector(windowShouldClose:)])
shouldClose = [delegate windowShouldClose:self];
if (shouldClose) {
[self close];
}
}
- (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item {
SEL action = [item action];
// Explicitly enable |-performClose:| (see above); otherwise the fact that
// this window does not have a close button results in it being disabled.
if (action == @selector(performClose:))
return YES;
return [super validateUserInterfaceItem:item];
}
@end
// Copyright (c) 2011 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 "base/mac/scoped_nsobject.h"
#include "chrome/browser/ui/cocoa/fullscreen_window.h"
#include "chrome/browser/ui/cocoa/test/cocoa_test_helper.h"
#include "testing/gtest/include/gtest/gtest.h"
#import "testing/gtest_mac.h"
#include "testing/platform_test.h"
@interface PerformCloseUIItem : NSObject<NSValidatedUserInterfaceItem>
@end
@implementation PerformCloseUIItem
- (SEL)action {
return @selector(performClose:);
}
- (NSInteger)tag {
return 0;
}
@end
class FullscreenWindowTest : public CocoaTest {
};
TEST_F(FullscreenWindowTest, Basics) {
base::scoped_nsobject<FullscreenWindow> window;
window.reset([[FullscreenWindow alloc] init]);
EXPECT_EQ([NSScreen mainScreen], [window screen]);
EXPECT_TRUE([window canBecomeKeyWindow]);
EXPECT_TRUE([window canBecomeMainWindow]);
EXPECT_EQ(NSBorderlessWindowMask, [window styleMask]);
EXPECT_NSEQ([[NSScreen mainScreen] frame], [window frame]);
EXPECT_FALSE([window isReleasedWhenClosed]);
}
TEST_F(FullscreenWindowTest, CanPerformClose) {
base::scoped_nsobject<FullscreenWindow> window;
window.reset([[FullscreenWindow alloc] init]);
base::scoped_nsobject<PerformCloseUIItem> item;
item.reset([[PerformCloseUIItem alloc] init]);
EXPECT_TRUE([window validateUserInterfaceItem:item.get()]);
}
...@@ -44,52 +44,6 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, HasLocationBarByDefault) { ...@@ -44,52 +44,6 @@ IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, HasLocationBarByDefault) {
HasVisibleLocationBarForBrowser(browser()); HasVisibleLocationBarForBrowser(browser());
} }
// Disabled. See https://crbug.com/845389 - this regressed somewhere between
// r545258 and r559030 (suspect: r549698), but it may be obsolete soon.
IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest,
DISABLED_BrowserFullscreenHasLocationBar) {
ui::test::ScopedFakeNSWindowFullscreen faker;
ShowBubble(browser());
// Toggling the toolbar in fullscreen may trigger an animation, but it also
// depends on the current mouse cursor position which is hard to manipulate in
// a browser_test. So toggle the toolbar style between PRESENT and NONE using
// the test API. Don't use HIDDEN, since that would cause flakes depending
// where the mouse cursor is on the test machine.
BrowserWindowController* browser_controller = [BrowserWindowController
browserWindowControllerForWindow:browser()->window()->GetNativeWindow()];
// Note that outside of fullscreen, there is no fullscreen toolbar controller.
EXPECT_FALSE([browser_controller fullscreenToolbarController]);
ExclusiveAccessManager* access_manager =
browser()->exclusive_access_manager();
FullscreenController* fullscreen_controller =
access_manager->fullscreen_controller();
EXPECT_FALSE(access_manager->context()->IsFullscreen());
fullscreen_controller->ToggleBrowserFullscreenMode();
faker.FinishTransition();
EXPECT_TRUE(access_manager->context()->IsFullscreen());
FullscreenToolbarControllerCocoa* toolbar_controller =
[browser_controller fullscreenToolbarController];
EXPECT_TRUE(toolbar_controller);
// In fullscreen, try removing the toolbar.
[toolbar_controller setToolbarStyle:FullscreenToolbarStyle::TOOLBAR_NONE];
EXPECT_FALSE(HasVisibleLocationBarForBrowser(browser()));
[toolbar_controller setToolbarStyle:FullscreenToolbarStyle::TOOLBAR_PRESENT];
EXPECT_TRUE(HasVisibleLocationBarForBrowser(browser()));
// Leave fullscreen. Toolbar should come back.
fullscreen_controller->ToggleBrowserFullscreenMode();
faker.FinishTransition();
EXPECT_FALSE(access_manager->context()->IsFullscreen());
EXPECT_FALSE([browser_controller fullscreenToolbarController]);
}
// Disabled. See https://crbug.com/845389 - this regressed somewhere between // Disabled. See https://crbug.com/845389 - this regressed somewhere between
// r545258 and r559030 (suspect: r549698), but it may be obsolete soon. // r545258 and r559030 (suspect: r549698), but it may be obsolete soon.
IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest, IN_PROC_BROWSER_TEST_F(PermissionBubbleBrowserTest,
......
// Copyright (c) 2017 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_COCOA_SEPARATE_FULLSCREEN_WINDOW_H_
#define CHROME_BROWSER_UI_COCOA_SEPARATE_FULLSCREEN_WINDOW_H_
#import <Cocoa/Cocoa.h>
#include "ui/base/cocoa/touch_bar_forward_declarations.h"
@interface SeparateFullscreenWindow : NSWindow
// This window class is instantiated to display a WebContentsViewCocoa as its
// subview in fullscreen mode as part of ContentFullscreen to enable users to
// interact with the main browser window and its tab when they're displaying
// content in this separate window. Related types include
// FullscreenLowPowerWindow.
@end
#endif // CHROME_BROWSER_UI_COCOA_SEPARATE_FULLSCREEN_WINDOW_H_
// Copyright (c) 2017 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.
#import "chrome/browser/ui/cocoa/separate_fullscreen_window.h"
@implementation SeparateFullscreenWindow
- (BOOL)canBecomeKeyWindow {
return YES;
}
- (BOOL)canBecomeMainWindow {
return YES;
}
@end
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
#include "base/mac/scoped_nsobject.h" #include "base/mac/scoped_nsobject.h"
class FullscreenObserver;
namespace content { namespace content {
class WebContents; class WebContents;
} }
...@@ -35,9 +33,6 @@ class WebContents; ...@@ -35,9 +33,6 @@ class WebContents;
@interface TabContentsController : NSViewController { @interface TabContentsController : NSViewController {
@private @private
content::WebContents* contents_; // weak content::WebContents* contents_; // weak
// When |fullscreenObserver_| is not-NULL, TabContentsController monitors for
// and auto-embeds fullscreen widgets as a subview.
std::unique_ptr<FullscreenObserver> fullscreenObserver_;
// Set to true while TabContentsController is embedding a fullscreen widget // Set to true while TabContentsController is embedding a fullscreen widget
// view as a subview instead of the normal WebContentsView render view. // view as a subview instead of the normal WebContentsView render view.
// Note: This will be false in the case of non-Flash fullscreen. // Note: This will be false in the case of non-Flash fullscreen.
...@@ -45,13 +40,6 @@ class WebContents; ...@@ -45,13 +40,6 @@ class WebContents;
// Set to true if the window is a popup. // Set to true if the window is a popup.
BOOL isPopup_; BOOL isPopup_;
// Reference to the FullscreenPlaceholderView displayed in the main window
// for the tab when our WebContentsView is in the SeparateFullscreenWindow.
NSView* fullscreenPlaceholderView_;
// Reference to the fullscreen window created to display the WebContents
// view separately.
NSWindow* separateFullscreenWindow_;
} }
@property(readonly, nonatomic) content::WebContents* webContents; @property(readonly, nonatomic) content::WebContents* webContents;
......
...@@ -1974,7 +1974,6 @@ test("browser_tests") { ...@@ -1974,7 +1974,6 @@ test("browser_tests") {
## TODO(crbug/845389): Re-Enable the following, which were temporarily ## TODO(crbug/845389): Re-Enable the following, which were temporarily
## omitted from the build, but still in use by the Cocoa browser. ## omitted from the build, but still in use by the Cocoa browser.
# "../browser/ui/cocoa/browser_window_controller_browsertest.mm",
# "../browser/ui/cocoa/task_manager_mac_browsertest.mm", # "../browser/ui/cocoa/task_manager_mac_browsertest.mm",
## The following lines are for obsolete secondary UI that currently do ## The following lines are for obsolete secondary UI that currently do
...@@ -4131,10 +4130,7 @@ test("unit_tests") { ...@@ -4131,10 +4130,7 @@ test("unit_tests") {
"../browser/ui/cocoa/constrained_window/constrained_window_sheet_controller_unittest.mm", "../browser/ui/cocoa/constrained_window/constrained_window_sheet_controller_unittest.mm",
"../browser/ui/cocoa/find_pasteboard_unittest.mm", "../browser/ui/cocoa/find_pasteboard_unittest.mm",
"../browser/ui/cocoa/first_run_dialog_controller_unittest.mm", "../browser/ui/cocoa/first_run_dialog_controller_unittest.mm",
"../browser/ui/cocoa/floating_bar_backing_view_unittest.mm",
"../browser/ui/cocoa/framed_browser_window_unittest.mm", "../browser/ui/cocoa/framed_browser_window_unittest.mm",
"../browser/ui/cocoa/fullscreen/fullscreen_toolbar_controller_unittest.mm",
"../browser/ui/cocoa/fullscreen_window_unittest.mm",
"../browser/ui/cocoa/history_menu_bridge_unittest.mm", "../browser/ui/cocoa/history_menu_bridge_unittest.mm",
"../browser/ui/cocoa/history_menu_cocoa_controller_unittest.mm", "../browser/ui/cocoa/history_menu_cocoa_controller_unittest.mm",
"../browser/ui/cocoa/history_overlay_controller_unittest.mm", "../browser/ui/cocoa/history_overlay_controller_unittest.mm",
......
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