Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(469)

Side by Side Diff: base/mac/mac_util.mm

Issue 13583005: Work around bug coming back from hiding menu bar with fullscreen. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/mac/mac_util.h" 5 #include "base/mac/mac_util.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 #import <IOKit/IOKitLib.h> 8 #import <IOKit/IOKitLib.h>
9 9
10 #include <errno.h> 10 #include <errno.h>
11 #include <string.h> 11 #include <string.h>
12 #include <sys/utsname.h> 12 #include <sys/utsname.h>
13 #include <sys/xattr.h> 13 #include <sys/xattr.h>
14 14
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/mac/bundle_locations.h" 17 #include "base/mac/bundle_locations.h"
18 #include "base/mac/foundation_util.h" 18 #include "base/mac/foundation_util.h"
19 #include "base/mac/mac_logging.h" 19 #include "base/mac/mac_logging.h"
20 #include "base/mac/scoped_cftyperef.h" 20 #include "base/mac/scoped_cftyperef.h"
21 #include "base/memory/scoped_generic_obj.h" 21 #include "base/memory/scoped_generic_obj.h"
22 #include "base/memory/scoped_nsobject.h" 22 #include "base/memory/scoped_nsobject.h"
23 #include "base/strings/string_number_conversions.h" 23 #include "base/strings/string_number_conversions.h"
24 #include "base/strings/string_piece.h" 24 #include "base/strings/string_piece.h"
25 #include "base/strings/sys_string_conversions.h" 25 #include "base/strings/sys_string_conversions.h"
26 26
27 namespace base { 27 namespace base {
28 namespace mac { 28 namespace mac {
29 29
30 // Replicate specific 10.7 SDK declarations for building with prior SDKs.
31 #if !defined(MAC_OS_X_VERSION_10_7) || \
32 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
33
34 enum {
35 NSApplicationPresentationFullScreen = 1 << 10
36 };
37
38 #endif // MAC_OS_X_VERSION_10_7
39
30 namespace { 40 namespace {
31 41
32 // The current count of outstanding requests for full screen mode from browser 42 // The current count of outstanding requests for full screen mode from browser
33 // windows, plugins, etc. 43 // windows, plugins, etc.
34 int g_full_screen_requests[kNumFullScreenModes] = { 0 }; 44 int g_full_screen_requests[kNumFullScreenModes] = { 0 };
35 45
36 // Sets the appropriate application presentation option based on the current 46 // Sets the appropriate application presentation option based on the current
37 // full screen requests. Since only one presentation option can be active at a 47 // full screen requests. Since only one presentation option can be active at a
38 // given time, full screen requests are ordered by priority. If there are no 48 // given time, full screen requests are ordered by priority. If there are no
39 // outstanding full screen requests, reverts to normal mode. If the correct 49 // outstanding full screen requests, reverts to normal mode. If the correct
(...skipping 13 matching lines...) Expand all
53 if (g_full_screen_requests[kFullScreenModeAutoHideAll] > 0) { 63 if (g_full_screen_requests[kFullScreenModeAutoHideAll] > 0) {
54 desired_options = NSApplicationPresentationHideDock | 64 desired_options = NSApplicationPresentationHideDock |
55 NSApplicationPresentationAutoHideMenuBar; 65 NSApplicationPresentationAutoHideMenuBar;
56 } else if (g_full_screen_requests[kFullScreenModeHideDock] > 0) { 66 } else if (g_full_screen_requests[kFullScreenModeHideDock] > 0) {
57 desired_options = NSApplicationPresentationHideDock; 67 desired_options = NSApplicationPresentationHideDock;
58 } else if (g_full_screen_requests[kFullScreenModeHideAll] > 0) { 68 } else if (g_full_screen_requests[kFullScreenModeHideAll] > 0) {
59 desired_options = NSApplicationPresentationHideDock | 69 desired_options = NSApplicationPresentationHideDock |
60 NSApplicationPresentationHideMenuBar; 70 NSApplicationPresentationHideMenuBar;
61 } 71 }
62 72
73 // Bug-fix: if the window is fullscreened (Lion-style) and
74 // NSApplicationPresentationDefault is requested, the result is that the menu
75 // bar doesn't auto-hide. In that case, explicitly set the presentation
76 // options to the ones that are set by the system as it fullscreens a window.
Nico 2013/04/03 22:16:07 file rdar
77 if (desired_options == NSApplicationPresentationDefault &&
78 current_options & NSApplicationPresentationFullScreen) {
79 desired_options |= NSApplicationPresentationFullScreen |
80 NSApplicationPresentationAutoHideMenuBar |
81 NSApplicationPresentationAutoHideDock;
82 }
83
63 if (current_options != desired_options) 84 if (current_options != desired_options)
64 [NSApp setPresentationOptions:desired_options]; 85 [NSApp setPresentationOptions:desired_options];
65 } 86 }
66 87
67 // Looks into Shared File Lists corresponding to Login Items for the item 88 // Looks into Shared File Lists corresponding to Login Items for the item
68 // representing the current application. If such an item is found, returns a 89 // representing the current application. If such an item is found, returns a
69 // retained reference to it. Caller is responsible for releasing the reference. 90 // retained reference to it. Caller is responsible for releasing the reference.
70 LSSharedFileListItemRef GetLoginItemForApp() { 91 LSSharedFileListItemRef GetLoginItemForApp() {
71 ScopedCFTypeRef<LSSharedFileListRef> login_items(LSSharedFileListCreate( 92 ScopedCFTypeRef<LSSharedFileListRef> login_items(LSSharedFileListCreate(
72 NULL, kLSSharedFileListSessionLoginItems, NULL)); 93 NULL, kLSSharedFileListSessionLoginItems, NULL));
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) 687 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp))
667 return false; 688 return false;
668 *type = ident.substr(0, number_loc); 689 *type = ident.substr(0, number_loc);
669 *major = major_tmp; 690 *major = major_tmp;
670 *minor = minor_tmp; 691 *minor = minor_tmp;
671 return true; 692 return true;
672 } 693 }
673 694
674 } // namespace mac 695 } // namespace mac
675 } // namespace base 696 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698