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