OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_util.h" | 5 #include "base/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" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 bool AmIBundled() { | 70 bool AmIBundled() { |
71 ProcessSerialNumber psn = {0, kCurrentProcess}; | 71 ProcessSerialNumber psn = {0, kCurrentProcess}; |
72 | 72 |
73 FSRef fsref; | 73 FSRef fsref; |
74 if (GetProcessBundleLocation(&psn, &fsref) != noErr) { | 74 if (GetProcessBundleLocation(&psn, &fsref) != noErr) { |
75 LOG(ERROR) << "GetProcessBundleLocation failed, returning false"; | 75 LOG(ERROR) << "GetProcessBundleLocation failed, returning false"; |
76 return false; | 76 return false; |
77 } | 77 } |
78 | 78 |
79 FSCatalogInfo info; | 79 FSCatalogInfo info; |
80 HFSUniStr255 hfsname; | |
81 if (FSGetCatalogInfo(&fsref, kFSCatInfoNodeFlags, &info, | 80 if (FSGetCatalogInfo(&fsref, kFSCatInfoNodeFlags, &info, |
82 &hfsname, NULL, NULL) != noErr) { | 81 NULL, NULL, NULL) != noErr) { |
83 LOG(ERROR) << "FSGetCatalogInfo failed, returning false"; | 82 LOG(ERROR) << "FSGetCatalogInfo failed, returning false"; |
84 return false; | 83 return false; |
85 } | 84 } |
86 | 85 |
87 scoped_cftyperef<CFStringRef> cfname( | 86 return info.nodeFlags & kFSNodeIsDirectoryMask; |
88 CFStringCreateWithCharacters(kCFAllocatorDefault, | |
89 hfsname.unicode, | |
90 hfsname.length)); | |
91 std::string filename = base::SysCFStringRefToUTF8(cfname); | |
92 bool bundled = info.nodeFlags & kFSNodeIsDirectoryMask; | |
93 LOG(ERROR) << "AmIBundled() filename is: " << filename | |
94 << ", returning " << (bundled ? "true" : "false"); | |
95 | |
96 return bundled; | |
97 } | 87 } |
98 | 88 |
99 bool IsBackgroundOnlyProcess() { | 89 bool IsBackgroundOnlyProcess() { |
100 // This function really does want to examine NSBundle's idea of the main | 90 // This function really does want to examine NSBundle's idea of the main |
101 // bundle dictionary, and not the overriden MainAppBundle. It needs to look | 91 // bundle dictionary, and not the overriden MainAppBundle. It needs to look |
102 // at the actual running .app's Info.plist to access its LSUIElement | 92 // at the actual running .app's Info.plist to access its LSUIElement |
103 // property. | 93 // property. |
104 NSDictionary* info_dictionary = [[NSBundle mainBundle] infoDictionary]; | 94 NSDictionary* info_dictionary = [[NSBundle mainBundle] infoDictionary]; |
105 return [[info_dictionary objectForKey:@"LSUIElement"] boolValue] != NO; | 95 return [[info_dictionary objectForKey:@"LSUIElement"] boolValue] != NO; |
106 } | 96 } |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 [image drawInRect:NSMakeRect(0,0, size.width, size.height) | 509 [image drawInRect:NSMakeRect(0,0, size.width, size.height) |
520 fromRect:NSZeroRect | 510 fromRect:NSZeroRect |
521 operation:NSCompositeCopy | 511 operation:NSCompositeCopy |
522 fraction:1.0]; | 512 fraction:1.0]; |
523 [NSGraphicsContext restoreGraphicsState]; | 513 [NSGraphicsContext restoreGraphicsState]; |
524 | 514 |
525 return CGBitmapContextCreateImage(context); | 515 return CGBitmapContextCreateImage(context); |
526 } | 516 } |
527 | 517 |
528 } // namespace mac_util | 518 } // namespace mac_util |
OLD | NEW |