summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-15 19:52:52 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-15 19:52:52 +0000
commit7fac888e97750567424c1ededd1c6c3957dddaa6 (patch)
tree194dd4c1cc4520775b42e56b619c414782049a3f /base
parent490348b9600fd16e8ae14b32b78a9b9f3613fd6c (diff)
downloadchromium_src-7fac888e97750567424c1ededd1c6c3957dddaa6.zip
chromium_src-7fac888e97750567424c1ededd1c6c3957dddaa6.tar.gz
chromium_src-7fac888e97750567424c1ededd1c6c3957dddaa6.tar.bz2
Mac: Let out-of-process tests run in bundled mode for their whole lifetime.
Since out-of-process tests override the EXE path to look like the bundled app, it makes sense to override AmIBundled() as well. This is important because the renderer process started from browser_tests runs as bundled, and if browser and renderer process don't agree on bundled-ness, the "load plugin" requests for internal plugins from the renderer have the wrong plugin path, causing the plugin load to fail. Also add a DCHECK that makes sure that AmIBundled() doesn't flip-flop. This makes PDFBrowserTest work on mac, so enable it. It looks like even unit_tests uses the out-of-process test runner, so this change is a bit hairy :-/ BUG=61258,63183 TEST=all existing tests still pass, PDFBrowserTest.* passes. Review URL: http://codereview.chromium.org/4947002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66156 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/base_paths_mac.mm3
-rw-r--r--base/mac_util.h1
-rw-r--r--base/mac_util.mm25
3 files changed, 27 insertions, 2 deletions
diff --git a/base/base_paths_mac.mm b/base/base_paths_mac.mm
index 793bece..34a3d23 100644
--- a/base/base_paths_mac.mm
+++ b/base/base_paths_mac.mm
@@ -52,7 +52,8 @@ bool PathProviderMac(int key, FilePath* result) {
case base::DIR_APP_DATA:
return mac_util::GetUserDirectory(NSApplicationSupportDirectory, result);
case base::DIR_SOURCE_ROOT: {
- if (GetNSExecutablePath(result)) {
+ // Go through PathService to catch overrides.
+ if (PathService::Get(base::FILE_EXE, result)) {
// Start with the executable's directory.
*result = result->DirName();
if (mac_util::AmIBundled()) {
diff --git a/base/mac_util.h b/base/mac_util.h
index 182fcc8..d31bf82 100644
--- a/base/mac_util.h
+++ b/base/mac_util.h
@@ -50,6 +50,7 @@ bool FSRefFromPath(const std::string& path, FSRef* ref);
// Returns true if the application is running from a bundle
bool AmIBundled();
+void SetOverrideAmIBundled(bool value);
// Returns true if this process is marked as a "Background only process".
bool IsBackgroundOnlyProcess();
diff --git a/base/mac_util.mm b/base/mac_util.mm
index 4e6b105..9610d37 100644
--- a/base/mac_util.mm
+++ b/base/mac_util.mm
@@ -145,8 +145,14 @@ bool FSRefFromPath(const std::string& path, FSRef* ref) {
return status == noErr;
}
+static bool g_override_am_i_bundled = false;
+static bool g_override_am_i_bundled_value = false;
+
// Adapted from http://developer.apple.com/carbon/tipsandtricks.html#AmIBundled
-bool AmIBundled() {
+static bool UncachedAmIBundled() {
+ if (g_override_am_i_bundled)
+ return g_override_am_i_bundled_value;
+
ProcessSerialNumber psn = {0, kCurrentProcess};
FSRef fsref;
@@ -167,6 +173,23 @@ bool AmIBundled() {
return info.nodeFlags & kFSNodeIsDirectoryMask;
}
+bool AmIBundled() {
+ // If the return value is not cached, this function will return different
+ // values depending on when it's called. This confuses some client code, see
+ // http://crbug.com/63183 .
+ static bool result = UncachedAmIBundled();
+ DCHECK_EQ(result, UncachedAmIBundled())
+ << "The return value of AmIBundled() changed. This will confuse tests. "
+ << "Call SetAmIBundled() override manually if your test binary "
+ << "delay-loads the framework.";
+ return result;
+}
+
+void SetOverrideAmIBundled(bool value) {
+ g_override_am_i_bundled = true;
+ g_override_am_i_bundled_value = value;
+}
+
bool IsBackgroundOnlyProcess() {
// This function really does want to examine NSBundle's idea of the main
// bundle dictionary, and not the overriden MainAppBundle. It needs to look