OLD | NEW |
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 #include <string.h> | 9 #include <string.h> |
10 #include <sys/utsname.h> | 10 #include <sys/utsname.h> |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "base/string_piece.h" | 21 #include "base/string_piece.h" |
22 #include "base/sys_string_conversions.h" | 22 #include "base/sys_string_conversions.h" |
23 | 23 |
24 namespace base { | 24 namespace base { |
25 namespace mac { | 25 namespace mac { |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 // The current count of outstanding requests for full screen mode from browser | 29 // The current count of outstanding requests for full screen mode from browser |
30 // windows, plugins, etc. | 30 // windows, plugins, etc. |
31 int g_full_screen_requests[kNumFullScreenModes] = { 0, 0, 0}; | 31 int g_full_screen_requests[kNumFullScreenModes] = { 0 }; |
32 | 32 |
33 // Sets the appropriate SystemUIMode based on the current full screen requests. | 33 // Sets the appropriate application presentation option based on the current |
34 // Since only one SystemUIMode can be active at a given time, full screen | 34 // full screen requests. Since only one presentation option can be active at a |
35 // requests are ordered by priority. If there are no outstanding full screen | 35 // given time, full screen requests are ordered by priority. If there are no |
36 // requests, reverts to normal mode. If the correct SystemUIMode is already | 36 // outstanding full screen requests, reverts to normal mode. If the correct |
37 // set, does nothing. | 37 // presentation option is already set, does nothing. |
38 void SetUIMode() { | 38 void SetUIMode() { |
39 // Get the current UI mode. | 39 NSApplicationPresentationOptions current_options = |
40 SystemUIMode current_mode; | 40 [NSApp presentationOptions]; |
41 GetSystemUIMode(¤t_mode, NULL); | |
42 | 41 |
43 // Determine which mode should be active, based on which requests are | 42 // Determine which mode should be active, based on which requests are |
44 // currently outstanding. More permissive requests take precedence. For | 43 // currently outstanding. More permissive requests take precedence. For |
45 // example, plugins request |kFullScreenModeAutoHideAll|, while browser | 44 // example, plugins request |kFullScreenModeAutoHideAll|, while browser |
46 // windows request |kFullScreenModeHideDock| when the fullscreen overlay is | 45 // windows request |kFullScreenModeHideDock| when the fullscreen overlay is |
47 // down. Precedence goes to plugins in this case, so AutoHideAll wins over | 46 // down. Precedence goes to plugins in this case, so AutoHideAll wins over |
48 // HideDock. | 47 // HideDock. |
49 SystemUIMode desired_mode = kUIModeNormal; | 48 NSApplicationPresentationOptions desired_options = |
50 SystemUIOptions desired_options = 0; | 49 NSApplicationPresentationDefault; |
51 if (g_full_screen_requests[kFullScreenModeAutoHideAll] > 0) { | 50 if (g_full_screen_requests[kFullScreenModeAutoHideAll] > 0) { |
52 desired_mode = kUIModeAllHidden; | 51 desired_options = NSApplicationPresentationHideDock | |
53 desired_options = kUIOptionAutoShowMenuBar; | 52 NSApplicationPresentationAutoHideMenuBar; |
54 } else if (g_full_screen_requests[kFullScreenModeHideDock] > 0) { | 53 } else if (g_full_screen_requests[kFullScreenModeHideDock] > 0) { |
55 desired_mode = kUIModeContentHidden; | 54 desired_options = NSApplicationPresentationHideDock; |
56 } else if (g_full_screen_requests[kFullScreenModeHideAll] > 0) { | 55 } else if (g_full_screen_requests[kFullScreenModeHideAll] > 0) { |
57 desired_mode = kUIModeAllHidden; | 56 desired_options = NSApplicationPresentationHideDock | |
| 57 NSApplicationPresentationHideMenuBar; |
58 } | 58 } |
59 | 59 |
60 if (current_mode != desired_mode) | 60 if (current_options != desired_options) |
61 SetSystemUIMode(desired_mode, desired_options); | 61 [NSApp setPresentationOptions:desired_options]; |
62 } | 62 } |
63 | 63 |
64 // Looks into Shared File Lists corresponding to Login Items for the item | 64 // Looks into Shared File Lists corresponding to Login Items for the item |
65 // representing the current application. If such an item is found, returns a | 65 // representing the current application. If such an item is found, returns a |
66 // retained reference to it. Caller is responsible for releasing the reference. | 66 // retained reference to it. Caller is responsible for releasing the reference. |
67 LSSharedFileListItemRef GetLoginItemForApp() { | 67 LSSharedFileListItemRef GetLoginItemForApp() { |
68 ScopedCFTypeRef<LSSharedFileListRef> login_items(LSSharedFileListCreate( | 68 ScopedCFTypeRef<LSSharedFileListRef> login_items(LSSharedFileListCreate( |
69 NULL, kLSSharedFileListSessionLoginItems, NULL)); | 69 NULL, kLSSharedFileListSessionLoginItems, NULL)); |
70 | 70 |
71 if (!login_items.get()) { | 71 if (!login_items.get()) { |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) | 657 StringPiece(begin + comma_loc + 1, ident.end()), &minor_tmp)) |
658 return false; | 658 return false; |
659 *type = ident.substr(0, number_loc); | 659 *type = ident.substr(0, number_loc); |
660 *major = major_tmp; | 660 *major = major_tmp; |
661 *minor = minor_tmp; | 661 *minor = minor_tmp; |
662 return true; | 662 return true; |
663 } | 663 } |
664 | 664 |
665 } // namespace mac | 665 } // namespace mac |
666 } // namespace base | 666 } // namespace base |
OLD | NEW |