[email protected] | 3c64537 | 2011-01-25 20:54:06 | [diff] [blame] | 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. | ||||
4 | |||||
5 | #import "chrome/browser/fullscreen.h" | ||||
6 | |||||
[email protected] | 3c64537 | 2011-01-25 20:54:06 | [diff] [blame] | 7 | #import <Cocoa/Cocoa.h> |
8 | |||||
[email protected] | ee6a527 | 2013-07-15 21:14:01 | [diff] [blame] | 9 | #include "base/command_line.h" |
10 | #include "base/mac/mac_util.h" | ||||
11 | #include "chrome/common/chrome_switches.h" | ||||
12 | |||||
[email protected] | d621e70 | 2013-01-24 01:43:00 | [diff] [blame] | 13 | // Replicate specific 10.7 SDK declarations for building with prior SDKs. |
14 | #if !defined(MAC_OS_X_VERSION_10_7) || \ | ||||
15 | MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 | ||||
[email protected] | abd4d9a | 2012-12-29 01:01:15 | [diff] [blame] | 16 | |
[email protected] | d621e70 | 2013-01-24 01:43:00 | [diff] [blame] | 17 | enum { |
18 | NSApplicationPresentationFullScreen = 1 << 10 | ||||
19 | }; | ||||
[email protected] | 3c64537 | 2011-01-25 20:54:06 | [diff] [blame] | 20 | |
[email protected] | d621e70 | 2013-01-24 01:43:00 | [diff] [blame] | 21 | #endif // MAC_OS_X_VERSION_10_7 |
[email protected] | 3c64537 | 2011-01-25 20:54:06 | [diff] [blame] | 22 | |
23 | bool IsFullScreenMode() { | ||||
[email protected] | d621e70 | 2013-01-24 01:43:00 | [diff] [blame] | 24 | // Check if the main display has been captured (by games in particular). |
[email protected] | 3c64537 | 2011-01-25 20:54:06 | [diff] [blame] | 25 | if (CGDisplayIsCaptured(CGMainDisplayID())) |
26 | return true; | ||||
27 | |||||
[email protected] | d621e70 | 2013-01-24 01:43:00 | [diff] [blame] | 28 | NSApplicationPresentationOptions options = |
29 | [NSApp currentSystemPresentationOptions]; | ||||
30 | |||||
31 | bool dock_hidden = (options & NSApplicationPresentationHideDock) || | ||||
32 | (options & NSApplicationPresentationAutoHideDock); | ||||
33 | |||||
34 | bool menu_hidden = (options & NSApplicationPresentationHideMenuBar) || | ||||
35 | (options & NSApplicationPresentationAutoHideMenuBar); | ||||
36 | |||||
37 | // If both dock and menu bar are hidden, that is the equivalent of the Carbon | ||||
38 | // SystemUIMode (or Info.plist's LSUIPresentationMode) kUIModeAllHidden. | ||||
39 | if (dock_hidden && menu_hidden) | ||||
40 | return true; | ||||
41 | |||||
42 | if (options & NSApplicationPresentationFullScreen) | ||||
43 | return true; | ||||
44 | |||||
45 | return false; | ||||
[email protected] | 3c64537 | 2011-01-25 20:54:06 | [diff] [blame] | 46 | } |
[email protected] | ee6a527 | 2013-07-15 21:14:01 | [diff] [blame] | 47 | |
48 | namespace chrome { | ||||
49 | namespace mac { | ||||
50 | |||||
51 | bool SupportsSystemFullscreen() { | ||||
52 | const CommandLine* command_line = CommandLine::ForCurrentProcess(); | ||||
53 | if (command_line->HasSwitch(switches::kDisableSystemFullscreenForTesting)) | ||||
54 | return false; | ||||
55 | |||||
56 | return base::mac::IsOSLionOrLater(); | ||||
57 | } | ||||
58 | |||||
59 | } // namespace mac | ||||
60 | } // namespace chrome |