diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-29 23:49:35 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-29 23:49:35 +0000 |
commit | 0167900145e8bb02885fa74df9887b452e9291be (patch) | |
tree | cd0d106ee404ece609dcffc00a75aa57675296c7 | |
parent | 84683f0a267ff5f9396321a546615a64566ff444 (diff) | |
download | chromium_src-0167900145e8bb02885fa74df9887b452e9291be.zip chromium_src-0167900145e8bb02885fa74df9887b452e9291be.tar.gz chromium_src-0167900145e8bb02885fa74df9887b452e9291be.tar.bz2 |
Fix AmIBundled for command-line executions. Again.
BUG=304860, 312196
TEST=run from the command line with dots
R=mark@chromium.org
Review URL: https://codereview.chromium.org/51023003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231672 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/mac/foundation_util.mm | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/base/mac/foundation_util.mm b/base/mac/foundation_util.mm index 1c75349..4e9b224 100644 --- a/base/mac/foundation_util.mm +++ b/base/mac/foundation_util.mm @@ -29,20 +29,6 @@ namespace { bool g_override_am_i_bundled = false; bool g_override_am_i_bundled_value = false; -int CheapPathNormalizedCount(NSString* path) { - int count = 0; - for (NSString* component in [path pathComponents]) { - if ([component isEqualToString:@"."]) - continue; - else if ([component isEqualToString:@".."]) - --count; - else - ++count; - } - - return count; -} - bool UncachedAmIBundled() { #if defined(OS_IOS) // All apps are bundled on iOS. @@ -51,16 +37,8 @@ bool UncachedAmIBundled() { if (g_override_am_i_bundled) return g_override_am_i_bundled_value; - NSBundle* bundle = base::mac::OuterBundle(); - int bundle_count = CheapPathNormalizedCount([bundle bundlePath]); - int executable_count = CheapPathNormalizedCount([bundle executablePath]); - - // 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. - int depth_difference = executable_count - bundle_count; - CHECK(depth_difference == 1 || depth_difference == 3); - return depth_difference == 3; + // Yes, this is cheap. + return [[base::mac::OuterBundle() bundlePath] hasSuffix:@".app"]; #endif } |