diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-25 19:56:47 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-25 19:56:47 +0000 |
commit | a9a882490f8617fa87834777d8edbbe044fa6837 (patch) | |
tree | 5a8d86a1a1476ebf2f719db4b11da81b7bf026af /base/mac | |
parent | 0bba7b2af8d43109664a8acb454a4a069b99d374 (diff) | |
download | chromium_src-a9a882490f8617fa87834777d8edbbe044fa6837.zip chromium_src-a9a882490f8617fa87834777d8edbbe044fa6837.tar.gz chromium_src-a9a882490f8617fa87834777d8edbbe044fa6837.tar.bz2 |
Do not use Process Manager functions for determining bundledness.
BUG=304860
TEST=GPU process on Mavericks shouldn't have an app icon to its left, shouldn't be "not responding"
R=thakis@chromium.org
Review URL: https://codereview.chromium.org/41493002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231093 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/mac')
-rw-r--r-- | base/mac/foundation_util.mm | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/base/mac/foundation_util.mm b/base/mac/foundation_util.mm index 1897b6f..1d33391 100644 --- a/base/mac/foundation_util.mm +++ b/base/mac/foundation_util.mm @@ -29,30 +29,22 @@ static bool g_override_am_i_bundled_value = false; // Adapted from http://developer.apple.com/carbon/tipsandtricks.html#AmIBundled static bool UncachedAmIBundled() { #if defined(OS_IOS) - // All apps are bundled on iOS + // All apps are bundled on iOS. return true; #else if (g_override_am_i_bundled) return g_override_am_i_bundled_value; - ProcessSerialNumber psn = {0, kCurrentProcess}; + NSBundle* bundle = base::mac::OuterBundle(); + NSArray* bundle_parts = [[bundle bundlePath] pathComponents]; + NSArray* executable_parts = [[bundle executablePath] pathComponents]; - FSRef fsref; - OSStatus pbErr; - if ((pbErr = GetProcessBundleLocation(&psn, &fsref)) != noErr) { - OSSTATUS_DLOG(ERROR, pbErr) << "GetProcessBundleLocation failed"; - return false; - } - - FSCatalogInfo info; - OSErr fsErr; - if ((fsErr = FSGetCatalogInfo(&fsref, kFSCatInfoNodeFlags, &info, - NULL, NULL, NULL)) != noErr) { - OSSTATUS_DLOG(ERROR, fsErr) << "FSGetCatalogInfo failed"; - return false; - } - - return info.nodeFlags & kFSNodeIsDirectoryMask; + // Bundled executables are exactly three levels deeper than their bundle. + // Non-bundled executables have a fake bundle with a bundle path of their + // parent directory. + NSUInteger depth_difference = [executable_parts count] - [bundle_parts count]; + CHECK(depth_difference == 1 || depth_difference == 3); + return depth_difference == 3; #endif } |