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

Side by Side Diff: base/mac_util.mm

Issue 3197012: [Mac] Add diagnostic logging to AmIBundled() to help with bot failures.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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) 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 OSStatus status = FSPathMakeRef((const UInt8*)path.c_str(), 64 OSStatus status = FSPathMakeRef((const UInt8*)path.c_str(),
65 ref, nil); 65 ref, nil);
66 return status == noErr; 66 return status == noErr;
67 } 67 }
68 68
69 // Adapted from http://developer.apple.com/carbon/tipsandtricks.html#AmIBundled 69 // Adapted from http://developer.apple.com/carbon/tipsandtricks.html#AmIBundled
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 return false; 75 LOG(ERROR) << "GetProcessBundleLocation failed, returning false";
76
77 FSCatalogInfo info;
78 if (FSGetCatalogInfo(&fsref, kFSCatInfoNodeFlags, &info,
79 NULL, NULL, NULL) != noErr) {
80 return false; 76 return false;
81 } 77 }
82 78
83 return info.nodeFlags & kFSNodeIsDirectoryMask; 79 FSCatalogInfo info;
80 HFSUniStr255 hfsname;
81 if (FSGetCatalogInfo(&fsref, kFSCatInfoNodeFlags, &info,
82 &hfsname, NULL, NULL) != noErr) {
83 LOG(ERROR) << "FSGetCatalogInfo failed, returning false";
84 return false;
85 }
86
87 scoped_cftyperef<CFStringRef> cfname(
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;
84 } 97 }
85 98
86 bool IsBackgroundOnlyProcess() { 99 bool IsBackgroundOnlyProcess() {
87 // This function really does want to examine NSBundle's idea of the main 100 // This function really does want to examine NSBundle's idea of the main
88 // bundle dictionary, and not the overriden MainAppBundle. It needs to look 101 // bundle dictionary, and not the overriden MainAppBundle. It needs to look
89 // at the actual running .app's Info.plist to access its LSUIElement 102 // at the actual running .app's Info.plist to access its LSUIElement
90 // property. 103 // property.
91 NSDictionary* info_dictionary = [[NSBundle mainBundle] infoDictionary]; 104 NSDictionary* info_dictionary = [[NSBundle mainBundle] infoDictionary];
92 return [[info_dictionary objectForKey:@"LSUIElement"] boolValue] != NO; 105 return [[info_dictionary objectForKey:@"LSUIElement"] boolValue] != NO;
93 } 106 }
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 [image drawInRect:NSMakeRect(0,0, size.width, size.height) 519 [image drawInRect:NSMakeRect(0,0, size.width, size.height)
507 fromRect:NSZeroRect 520 fromRect:NSZeroRect
508 operation:NSCompositeCopy 521 operation:NSCompositeCopy
509 fraction:1.0]; 522 fraction:1.0];
510 [NSGraphicsContext restoreGraphicsState]; 523 [NSGraphicsContext restoreGraphicsState];
511 524
512 return CGBitmapContextCreateImage(context); 525 return CGBitmapContextCreateImage(context);
513 } 526 }
514 527
515 } // namespace mac_util 528 } // namespace mac_util
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