summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/cocoa
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/ui/cocoa')
-rw-r--r--chrome/browser/ui/cocoa/accelerators_cocoa_browsertest.mm6
-rw-r--r--chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.mm7
-rw-r--r--chrome/browser/ui/cocoa/browser_window_command_handler.mm21
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller.h5
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller.mm16
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm48
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller_private.mm1
7 files changed, 90 insertions, 14 deletions
diff --git a/chrome/browser/ui/cocoa/accelerators_cocoa_browsertest.mm b/chrome/browser/ui/cocoa/accelerators_cocoa_browsertest.mm
index dff475c..9191a67 100644
--- a/chrome/browser/ui/cocoa/accelerators_cocoa_browsertest.mm
+++ b/chrome/browser/ui/cocoa/accelerators_cocoa_browsertest.mm
@@ -5,6 +5,7 @@
#import <Cocoa/Cocoa.h>
#include "base/logging.h"
+#include "chrome/app/chrome_command_ids.h"
#import "chrome/browser/ui/cocoa/accelerators_cocoa.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "testing/gtest_mac.h"
@@ -127,7 +128,10 @@ IN_PROC_BROWSER_TEST_F(AcceleratorsCocoaBrowserTest,
EXPECT_TRUE(item);
// If the menu uses a commandDispatch:, the tag must match the command id!
- if (item.action == @selector(commandDispatch:))
+ // Added an exception for IDC_TOGGLE_FULLSCREEN_TOOLBAR, which conflicts
+ // with IDC_PRESENTATION_MODE.
+ if (item.action == @selector(commandDispatch:)
+ && item.tag != IDC_TOGGLE_FULLSCREEN_TOOLBAR)
EXPECT_EQ(item.tag, it->first);
}
}
diff --git a/chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.mm b/chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.mm
index 7026b32..e2a8ed0 100644
--- a/chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.mm
+++ b/chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.mm
@@ -13,6 +13,8 @@
#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/common/pref_names.h"
+#include "components/prefs/pref_service.h"
#import "ui/gfx/mac/coordinate_conversion.h"
ExclusiveAccessController::ExclusiveAccessController(
@@ -72,7 +74,10 @@ void ExclusiveAccessController::UpdateFullscreenWithToolbar(bool with_toolbar) {
}
void ExclusiveAccessController::ToggleFullscreenToolbar() {
- [controller_ toggleFullscreenToolbar];
+ PrefService* prefs = browser_->profile()->GetPrefs();
+ bool hideToolbar = !prefs->GetBoolean(prefs::kHideFullscreenToolbar);
+ [controller_ setFullscreenToolbarHidden:hideToolbar];
+ prefs->SetBoolean(prefs::kHideFullscreenToolbar, hideToolbar);
}
bool ExclusiveAccessController::IsFullscreenWithToolbar() const {
diff --git a/chrome/browser/ui/cocoa/browser_window_command_handler.mm b/chrome/browser/ui/cocoa/browser_window_command_handler.mm
index 8697e32..4f88b46e4 100644
--- a/chrome/browser/ui/cocoa/browser_window_command_handler.mm
+++ b/chrome/browser/ui/cocoa/browser_window_command_handler.mm
@@ -16,6 +16,7 @@
#include "chrome/browser/ui/browser_window.h"
#import "chrome/browser/ui/cocoa/browser_window_controller_private.h"
#include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
+#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
@@ -53,9 +54,8 @@ void UpdateToggleStateWithTag(NSInteger tag, id item, NSWindow* window) {
}
if (tag == IDC_TOGGLE_FULLSCREEN_TOOLBAR) {
- BrowserWindowController* controller =
- [browser->window()->GetNativeWindow() windowController];
- SetToggleState([controller shouldHideFullscreenToolbar], item);
+ PrefService* prefs = browser->profile()->GetPrefs();
+ SetToggleState(prefs->GetBoolean(prefs::kHideFullscreenToolbar), item);
return;
}
@@ -173,7 +173,12 @@ Browser* FindBrowserForSender(id sender, NSWindow* window) {
}
case IDC_PRESENTATION_MODE: {
if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) {
- [menuItem setTitle:GetTitleForPresentationModeMenuItem(browser)];
+ if (chrome::mac::SupportsSystemFullscreen()) {
+ [menuItem setHidden:YES];
+ enable = NO;
+ } else {
+ [menuItem setTitle:GetTitleForPresentationModeMenuItem(browser)];
+ }
}
break;
}
@@ -209,13 +214,11 @@ Browser* FindBrowserForSender(id sender, NSWindow* window) {
break;
}
case IDC_TOGGLE_FULLSCREEN_TOOLBAR: {
- // TODO(spqchan): Implement a preferences for this command and replace
- // the Presentation Mode menu item with item.
- if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) {
+ if (!chrome::mac::SupportsSystemFullscreen()) {
+ NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item);
[menuItem setHidden:YES];
- enable = false;
+ enable = NO;
}
- break;
}
default:
// Special handling for the contents of the Text Encoding submenu. On
diff --git a/chrome/browser/ui/cocoa/browser_window_controller.h b/chrome/browser/ui/cocoa/browser_window_controller.h
index d4b1938..f6943fd 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller.h
+++ b/chrome/browser/ui/cocoa/browser_window_controller.h
@@ -531,7 +531,7 @@ class Command;
// Toggles and updates the toolbar's visibility in fullscreen mode. This
// function toggles between the sliding styles: OMNIBOX_TABS_PRESENT and
// OMNIBOX_TABS_HIDDEN.
-- (void)toggleFullscreenToolbar;
+- (void)setFullscreenToolbarHidden:(BOOL)isHidden;
// Returns YES if the browser window is in or entering any fullscreen mode.
- (BOOL)isInAnyFullscreenMode;
@@ -635,6 +635,9 @@ class Command;
// Returns the active tab contents controller's |blockFullscreenResize_| flag.
- (BOOL)isActiveTabContentsControllerResizeBlocked;
+// Returns the presentation mode controller.
+- (PresentationModeController*)presentationModeController;
+
@end // @interface BrowserWindowController (TestingAPI)
diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm
index 7575a48..e6616ac 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller.mm
@@ -81,6 +81,7 @@
#include "chrome/browser/ui/window_sizer/window_sizer.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/command.h"
+#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/locale_settings.h"
@@ -435,6 +436,10 @@ void SetUpBrowserWindowCommandHandler(NSWindow* window) {
extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS,
windowShim_.get()));
+ PrefService* prefs = browser_->profile()->GetPrefs();
+ shouldHideFullscreenToolbar_ =
+ prefs->GetBoolean(prefs::kHideFullscreenToolbar);
+
blockLayoutSubviews_ = NO;
// We are done initializing now.
@@ -1916,6 +1921,10 @@ willAnimateFromState:(BookmarkBar::State)oldState
[sheet orderOut:self];
}
+- (PresentationModeController*)presentationModeController {
+ return presentationModeController_.get();
+}
+
- (void)executeExtensionCommand:(const std::string&)extension_id
command:(const extensions::Command&)command {
// Global commands are handled by the ExtensionCommandsGlobalRegistry
@@ -1971,9 +1980,12 @@ willAnimateFromState:(BookmarkBar::State)oldState
[self showFullscreenExitBubbleIfNecessary];
}
-- (void)toggleFullscreenToolbar {
- shouldHideFullscreenToolbar_ = !shouldHideFullscreenToolbar_;
+- (void)setFullscreenToolbarHidden:(BOOL)shouldHide {
+ if (shouldHideFullscreenToolbar_ == shouldHide)
+ return;
+ [presentationModeController_ setToolbarFraction:0.0];
+ shouldHideFullscreenToolbar_ = shouldHide;
if ([self isInAppKitFullscreen])
[self updateFullscreenWithToolbar:!shouldHideFullscreenToolbar_];
}
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm b/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
index df6e2cd..7865cef 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
@@ -14,6 +14,7 @@
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/devtools/devtools_window_testing.h"
+#include "chrome/browser/fullscreen.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
@@ -30,6 +31,7 @@
#import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
#import "chrome/browser/ui/cocoa/infobars/infobar_controller.h"
#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
+#import "chrome/browser/ui/cocoa/presentation_mode_controller.h"
#import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h"
#import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h"
#import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
@@ -40,6 +42,7 @@
#include "chrome/browser/ui/find_bar/find_bar_controller.h"
#include "chrome/browser/ui/infobar_container_delegate.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/common/pref_names.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/testing_profile.h"
#include "components/infobars/core/infobar_delegate.h"
@@ -316,6 +319,17 @@ class BrowserWindowControllerTest : public InProcessBrowserTest {
runner->Run();
}
+ void VerifyFullscreenToolbarVisibility(fullscreen_mac::SlidingStyle style) {
+ EXPECT_EQ([[controller() presentationModeController] slidingStyle], style);
+
+ NSRect toolbarFrame = [[[controller() toolbarController] view] frame];
+ NSRect screenFrame = [[[controller() window] screen] frame];
+ if (style == fullscreen_mac::OMNIBOX_TABS_PRESENT)
+ EXPECT_LE(NSMaxY(toolbarFrame), NSMaxY(screenFrame));
+ else
+ EXPECT_GE(NSMinY(toolbarFrame), NSMaxY(screenFrame));
+ }
+
NSInteger GetExpectedTopInfoBarTipHeight() {
InfoBarContainerController* info_bar_container_controller =
[controller() infoBarContainerController];
@@ -673,3 +687,37 @@ IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, FullscreenResizeFlags) {
ToggleFullscreenAndWaitForNotification();
VerifyFullscreenResizeFlagsAfterTransition();
}
+
+// Tests that the omnibox and tabs are hidden/visible in fullscreen mode.
+// Ensure that when the user toggles this setting, the omnibox, tabs and
+// preferences are updated correctly.
+IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest,
+ FullscreenToolbarIsVisibleAccordingToPrefs) {
+ // This feature is only available on SystemFullscreen.
+ if (!chrome::mac::SupportsSystemFullscreen())
+ return;
+
+ // Tests that the preference is set to false by default.
+ PrefService* prefs = browser()->profile()->GetPrefs();
+ EXPECT_FALSE(prefs->GetBoolean(prefs::kHideFullscreenToolbar));
+
+ // Toggle fullscreen and check if the toolbar is shown.
+ ToggleFullscreenAndWaitForNotification();
+ VerifyFullscreenToolbarVisibility(fullscreen_mac::OMNIBOX_TABS_PRESENT);
+
+ // Toggle the visibility of the fullscreen toolbar. Verify that the toolbar
+ // is hidden and the preference is correctly updated.
+ [[controller() presentationModeController] setToolbarFraction:0.0];
+ chrome::ExecuteCommand(browser(), IDC_TOGGLE_FULLSCREEN_TOOLBAR);
+ EXPECT_TRUE(prefs->GetBoolean(prefs::kHideFullscreenToolbar));
+ VerifyFullscreenToolbarVisibility(fullscreen_mac::OMNIBOX_TABS_HIDDEN);
+
+ // Toggle out and back into fullscreen and verify that the toolbar is still
+ // hidden.
+ ToggleFullscreenAndWaitForNotification();
+ ToggleFullscreenAndWaitForNotification();
+ VerifyFullscreenToolbarVisibility(fullscreen_mac::OMNIBOX_TABS_HIDDEN);
+
+ chrome::ExecuteCommand(browser(), IDC_TOGGLE_FULLSCREEN_TOOLBAR);
+ EXPECT_FALSE(prefs->GetBoolean(prefs::kHideFullscreenToolbar));
+}
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_private.mm b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
index cfc3f59..539a9c2 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_private.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
@@ -782,6 +782,7 @@ willPositionSheet:(NSWindow*)sheet
[self deregisterForContentViewResizeNotifications];
browser_->WindowFullscreenStateChanged();
+ [self.chromeContentView setAutoresizesSubviews:YES];
[self resetCustomAppKitFullscreenVariables];