• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
7#import <Cocoa/Cocoa.h>
8
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"
13
14bool IsFullScreenMode() {
15  // Check if the main display has been captured (by games in particular).
16  if (CGDisplayIsCaptured(CGMainDisplayID()))
17    return true;
18
19  NSApplicationPresentationOptions options =
20      [NSApp currentSystemPresentationOptions];
21
22  bool dock_hidden = (options & NSApplicationPresentationHideDock) ||
23                     (options & NSApplicationPresentationAutoHideDock);
24
25  bool menu_hidden = (options & NSApplicationPresentationHideMenuBar) ||
26                     (options & NSApplicationPresentationAutoHideMenuBar);
27
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)
31    return true;
32
33  if (options & NSApplicationPresentationFullScreen)
34    return true;
35
36  return false;
37}
38
39namespace chrome {
40namespace mac {
41
42bool SupportsSystemFullscreen() {
43  const CommandLine* command_line = CommandLine::ForCurrentProcess();
44  if (command_line->HasSwitch(switches::kDisableSystemFullscreenForTesting))
45    return false;
46
47  return base::mac::IsOSLionOrLater();
48}
49
50}  // namespace mac
51}  // namespace chrome
52