| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/mac/scoped_cftyperef.h" | 11 #include "base/mac/scoped_cftyperef.h" |
| 12 #include "base/memory/scoped_nsobject.h" | 12 #include "base/memory/scoped_nsobject.h" |
| 13 #include "base/sys_string_conversions.h" | 13 #include "base/sys_string_conversions.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 namespace mac { | 16 namespace mac { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 // a count of currently outstanding requests for full screen mode from browser | 20 // A count of currently outstanding requests for full screen mode from browser |
| 21 // windows, plugins, etc. | 21 // windows, plugins, etc. |
| 22 int g_full_screen_requests[kNumFullScreenModes] = { 0, 0, 0}; | 22 int g_full_screen_requests[kNumFullScreenModes] = { 0, 0, 0}; |
| 23 | 23 |
| 24 // Sets the appropriate SystemUIMode based on the current full screen requests. | 24 // Sets the appropriate SystemUIMode based on the current full screen requests. |
| 25 // Since only one SystemUIMode can be active at a given time, full screen | 25 // Since only one SystemUIMode can be active at a given time, full screen |
| 26 // requests are ordered by priority. If there are no outstanding full screen | 26 // requests are ordered by priority. If there are no outstanding full screen |
| 27 // requests, reverts to normal mode. If the correct SystemUIMode is already | 27 // requests, reverts to normal mode. If the correct SystemUIMode is already |
| 28 // set, does nothing. | 28 // set, does nothing. |
| 29 void SetUIMode() { | 29 void SetUIMode() { |
| 30 // Get the current UI mode. | 30 // Get the current UI mode. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 kProcessDictionaryIncludeAllInformationMask))); | 68 kProcessDictionaryIncludeAllInformationMask))); |
| 69 | 69 |
| 70 // Check that creator process code is that of loginwindow. | 70 // Check that creator process code is that of loginwindow. |
| 71 BOOL result = | 71 BOOL result = |
| 72 [[parent_info objectForKey:@"FileCreator"] isEqualToString:@"lgnw"]; | 72 [[parent_info objectForKey:@"FileCreator"] isEqualToString:@"lgnw"]; |
| 73 | 73 |
| 74 return result == YES; | 74 return result == YES; |
| 75 } | 75 } |
| 76 | 76 |
| 77 // Looks into Shared File Lists corresponding to Login Items for the item | 77 // Looks into Shared File Lists corresponding to Login Items for the item |
| 78 // representing the current application. If such an item is found, returns | 78 // representing the current application. If such an item is found, returns a |
| 79 // retained reference to it. Caller is responsible for releasing the reference. | 79 // retained reference to it. Caller is responsible for releasing the reference. |
| 80 LSSharedFileListItemRef GetLoginItemForApp() { | 80 LSSharedFileListItemRef GetLoginItemForApp() { |
| 81 ScopedCFTypeRef<LSSharedFileListRef> login_items(LSSharedFileListCreate( | 81 ScopedCFTypeRef<LSSharedFileListRef> login_items(LSSharedFileListCreate( |
| 82 NULL, kLSSharedFileListSessionLoginItems, NULL)); | 82 NULL, kLSSharedFileListSessionLoginItems, NULL)); |
| 83 | 83 |
| 84 if (!login_items.get()) { | 84 if (!login_items.get()) { |
| 85 LOG(ERROR) << "Couldn't get a Login Items list."; | 85 LOG(ERROR) << "Couldn't get a Login Items list."; |
| 86 return NULL; | 86 return NULL; |
| 87 } | 87 } |
| 88 | 88 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 | 269 |
| 270 NSURL* url = [NSURL fileURLWithPath:filePath]; | 270 NSURL* url = [NSURL fileURLWithPath:filePath]; |
| 271 // Note that we always set CSBackupSetItemExcluded's excludeByPath param | 271 // Note that we always set CSBackupSetItemExcluded's excludeByPath param |
| 272 // to true. This prevents a problem with toggling the setting: if the file | 272 // to true. This prevents a problem with toggling the setting: if the file |
| 273 // is excluded with excludeByPath set to true then excludeByPath must | 273 // is excluded with excludeByPath set to true then excludeByPath must |
| 274 // also be true when un-excluding the file, otherwise the un-excluding | 274 // also be true when un-excluding the file, otherwise the un-excluding |
| 275 // will be ignored. | 275 // will be ignored. |
| 276 bool success = | 276 bool success = |
| 277 CSBackupSetItemExcluded((CFURLRef)url, exclude, true) == noErr; | 277 CSBackupSetItemExcluded((CFURLRef)url, exclude, true) == noErr; |
| 278 if (!success) | 278 if (!success) |
| 279 LOG(WARNING) << "Failed to set backup excluson for file '" | 279 LOG(WARNING) << "Failed to set backup exclusion for file '" |
| 280 << file_path.value().c_str() << "'. Continuing."; | 280 << file_path.value().c_str() << "'. Continuing."; |
| 281 return success; | 281 return success; |
| 282 } | 282 } |
| 283 | 283 |
| 284 void SetProcessName(CFStringRef process_name) { | 284 void SetProcessName(CFStringRef process_name) { |
| 285 if (!process_name || CFStringGetLength(process_name) == 0) { | 285 if (!process_name || CFStringGetLength(process_name) == 0) { |
| 286 NOTREACHED() << "SetProcessName given bad name."; | 286 NOTREACHED() << "SetProcessName given bad name."; |
| 287 return; | 287 return; |
| 288 } | 288 } |
| 289 | 289 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 CFDictionaryGetValue(user_info.get(), kCFErrorDescriptionKey)); | 547 CFDictionaryGetValue(user_info.get(), kCFErrorDescriptionKey)); |
| 548 } | 548 } |
| 549 o << "Code: " << CFErrorGetCode(err) | 549 o << "Code: " << CFErrorGetCode(err) |
| 550 << " Domain: " << CFErrorGetDomain(err) | 550 << " Domain: " << CFErrorGetDomain(err) |
| 551 << " Desc: " << desc.get(); | 551 << " Desc: " << desc.get(); |
| 552 if(errorDesc) { | 552 if(errorDesc) { |
| 553 o << "(" << errorDesc << ")"; | 553 o << "(" << errorDesc << ")"; |
| 554 } | 554 } |
| 555 return o; | 555 return o; |
| 556 } | 556 } |
| OLD | NEW |