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/foundation_util.h" | 5 #include "base/mac/foundation_util.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/mac/bundle_locations.h" | 12 #include "base/mac/bundle_locations.h" |
| 13 #include "base/mac/mac_logging.h" |
13 #include "base/sys_string_conversions.h" | 14 #include "base/sys_string_conversions.h" |
14 | 15 |
15 namespace base { | 16 namespace base { |
16 namespace mac { | 17 namespace mac { |
17 | 18 |
18 static bool g_override_am_i_bundled = false; | 19 static bool g_override_am_i_bundled = false; |
19 static bool g_override_am_i_bundled_value = false; | 20 static bool g_override_am_i_bundled_value = false; |
20 | 21 |
21 // Adapted from http://developer.apple.com/carbon/tipsandtricks.html#AmIBundled | 22 // Adapted from http://developer.apple.com/carbon/tipsandtricks.html#AmIBundled |
22 static bool UncachedAmIBundled() { | 23 static bool UncachedAmIBundled() { |
23 if (g_override_am_i_bundled) | 24 if (g_override_am_i_bundled) |
24 return g_override_am_i_bundled_value; | 25 return g_override_am_i_bundled_value; |
25 | 26 |
26 ProcessSerialNumber psn = {0, kCurrentProcess}; | 27 ProcessSerialNumber psn = {0, kCurrentProcess}; |
27 | 28 |
28 FSRef fsref; | 29 FSRef fsref; |
29 OSStatus pbErr; | 30 OSStatus pbErr; |
30 if ((pbErr = GetProcessBundleLocation(&psn, &fsref)) != noErr) { | 31 if ((pbErr = GetProcessBundleLocation(&psn, &fsref)) != noErr) { |
31 DLOG(ERROR) << "GetProcessBundleLocation failed: error " << pbErr; | 32 OSSTATUS_DLOG(ERROR, pbErr) << "GetProcessBundleLocation failed"; |
32 return false; | 33 return false; |
33 } | 34 } |
34 | 35 |
35 FSCatalogInfo info; | 36 FSCatalogInfo info; |
36 OSErr fsErr; | 37 OSErr fsErr; |
37 if ((fsErr = FSGetCatalogInfo(&fsref, kFSCatInfoNodeFlags, &info, | 38 if ((fsErr = FSGetCatalogInfo(&fsref, kFSCatInfoNodeFlags, &info, |
38 NULL, NULL, NULL)) != noErr) { | 39 NULL, NULL, NULL)) != noErr) { |
39 DLOG(ERROR) << "FSGetCatalogInfo failed: error " << fsErr; | 40 OSSTATUS_DLOG(ERROR, fsErr) << "FSGetCatalogInfo failed"; |
40 return false; | 41 return false; |
41 } | 42 } |
42 | 43 |
43 return info.nodeFlags & kFSNodeIsDirectoryMask; | 44 return info.nodeFlags & kFSNodeIsDirectoryMask; |
44 } | 45 } |
45 | 46 |
46 bool AmIBundled() { | 47 bool AmIBundled() { |
47 // If the return value is not cached, this function will return different | 48 // If the return value is not cached, this function will return different |
48 // values depending on when it's called. This confuses some client code, see | 49 // values depending on when it's called. This confuses some client code, see |
49 // http://crbug.com/63183 . | 50 // http://crbug.com/63183 . |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 CFDictionaryGetValue(user_info.get(), kCFErrorDescriptionKey)); | 347 CFDictionaryGetValue(user_info.get(), kCFErrorDescriptionKey)); |
347 } | 348 } |
348 o << "Code: " << CFErrorGetCode(err) | 349 o << "Code: " << CFErrorGetCode(err) |
349 << " Domain: " << CFErrorGetDomain(err) | 350 << " Domain: " << CFErrorGetDomain(err) |
350 << " Desc: " << desc.get(); | 351 << " Desc: " << desc.get(); |
351 if(errorDesc) { | 352 if(errorDesc) { |
352 o << "(" << errorDesc << ")"; | 353 o << "(" << errorDesc << ")"; |
353 } | 354 } |
354 return o; | 355 return o; |
355 } | 356 } |
OLD | NEW |