1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #import "chrome/browser/fullscreen.h"
7 #import <Cocoa/Cocoa.h>
9 #include "base/command_line.h"
10 #include "base/mac/mac_util.h"
11 #include "base/mac/sdk_forward_declarations.h"
12 #include "chrome/common/chrome_switches.h"
14 bool IsFullScreenMode() {
15 // Check if the main display has been captured (by games in particular).
16 if (CGDisplayIsCaptured(CGMainDisplayID()))
19 NSApplicationPresentationOptions options =
20 [NSApp currentSystemPresentationOptions];
22 bool dock_hidden = (options & NSApplicationPresentationHideDock) ||
23 (options & NSApplicationPresentationAutoHideDock);
25 bool menu_hidden = (options & NSApplicationPresentationHideMenuBar) ||
26 (options & NSApplicationPresentationAutoHideMenuBar);
28 // If both dock and menu bar are hidden, that is the equivalent of the Carbon
29 // SystemUIMode (or Info.plist's LSUIPresentationMode) kUIModeAllHidden.
30 if (dock_hidden && menu_hidden)
33 if (options & NSApplicationPresentationFullScreen)
42 bool SupportsSystemFullscreen() {
43 const base::CommandLine* command_line =
44 base::CommandLine::ForCurrentProcess();
45 if (command_line->HasSwitch(switches::kDisableSystemFullscreenForTesting))
48 return base::mac::IsOSLionOrLater();