summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorthomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-03 16:26:03 +0000
committerthomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-03 16:26:03 +0000
commit6f33add36219e1faadea9d295b35d43841ebd508 (patch)
treebc5561b8d3cedeb13e504c971a7992a34e6d2353 /chrome
parentabf6c7a76bc68d0a01c1665e97972b0056654a26 (diff)
downloadchromium_src-6f33add36219e1faadea9d295b35d43841ebd508.zip
chromium_src-6f33add36219e1faadea9d295b35d43841ebd508.tar.gz
chromium_src-6f33add36219e1faadea9d295b35d43841ebd508.tar.bz2
Add a macutil for the main app bundle and override
- provide apis to get and override the app bundle - w/in the core code, use this api for fetching the bundle - render sandbox config - resource bundles - test shell font - w/in the unittest boot straps, use the mac util to override the bundle so resources can be found. Review URL: http://codereview.chromium.org/28214 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10798 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/common/resource_bundle_mac.mm29
-rw-r--r--chrome/renderer/renderer_main_platform_delegate_mac.mm30
-rw-r--r--chrome/test/unit/chrome_test_suite.h14
3 files changed, 28 insertions, 45 deletions
diff --git a/chrome/common/resource_bundle_mac.mm b/chrome/common/resource_bundle_mac.mm
index e739855..3757fc89 100644
--- a/chrome/common/resource_bundle_mac.mm
+++ b/chrome/common/resource_bundle_mac.mm
@@ -36,33 +36,8 @@ namespace {
base::DataPack *LoadResourceDataPack(NSString *name) {
base::DataPack *resource_pack = NULL;
- NSString *const pakExt = @"pak";
-
- // TODO(thomasvl): THIS SUCKS! We need to remove this gate. It's here
- // because of the unittests, but we have no other way to find our resources.
- if (!mac_util::AmIBundled()) {
- FilePath path;
- PathService::Get(base::DIR_EXE, &path);
- path = path.AppendASCII("Chromium.app");
- path = path.AppendASCII("Contents");
- path = path.AppendASCII("Resources");
- if ([name isEqual:@"locale"]) {
- path = path.AppendASCII("en.lproj");
- }
- NSString *pakName = [name stringByAppendingPathExtension:pakExt];
- path = path.Append([pakName fileSystemRepresentation]);
- resource_pack = new base::DataPack;
- bool success = resource_pack->Load(path);
- DCHECK(success) << "failed to load chrome.pak";
- if (!success) {
- delete resource_pack;
- resource_pack = NULL;
- }
- return resource_pack;
- }
-
- NSString *resource_path = [[NSBundle mainBundle] pathForResource:name
- ofType:pakExt];
+ NSString *resource_path = [mac_util::MainAppBundle() pathForResource:name
+ ofType:@"pak"];
if (resource_path) {
FilePath resources_pak_path([resource_path fileSystemRepresentation]);
resource_pack = new base::DataPack;
diff --git a/chrome/renderer/renderer_main_platform_delegate_mac.mm b/chrome/renderer/renderer_main_platform_delegate_mac.mm
index 70ce7f4..2b3a3d5 100644
--- a/chrome/renderer/renderer_main_platform_delegate_mac.mm
+++ b/chrome/renderer/renderer_main_platform_delegate_mac.mm
@@ -14,6 +14,7 @@ extern "C" {
}
#include "base/sys_info.h"
+#include "base/mac_util.h"
#include "chrome/common/chrome_switches.h"
#include "third_party/WebKit/WebKit/mac/WebCoreSupport/WebSystemInterface.h"
@@ -98,27 +99,20 @@ bool RendererMainPlatformDelegate::EnableSandbox() {
base::SysInfo::CacheSysInfo();
// For the renderer, we give it a custom sandbox to lock down as tight as
- // possible, but still be able to draw. If we're not a renderer process, it
- // usually means we're a unittest, so we use a pure compute sandbox instead.
-
- const char *sandbox_profile = kSBXProfilePureComputation;
- uint64_t sandbox_flags = SANDBOX_NAMED;
-
- if (parameters_.sandbox_info_.ProcessType() == switches::kRendererProcess) {
- NSString* sandbox_profile_path =
- [[NSBundle mainBundle] pathForResource:@"renderer" ofType:@"sb"];
- BOOL is_dir = NO;
- if (![[NSFileManager defaultManager] fileExistsAtPath:sandbox_profile_path
- isDirectory:&is_dir] || is_dir) {
- LOG(ERROR) << "Failed to find the sandbox profile on disk";
- return false;
- }
- sandbox_profile = [sandbox_profile_path fileSystemRepresentation];
- sandbox_flags = SANDBOX_NAMED_EXTERNAL;
+ // possible, but still be able to draw.
+
+ NSString* sandbox_profile_path =
+ [mac_util::MainAppBundle() pathForResource:@"renderer" ofType:@"sb"];
+ BOOL is_dir = NO;
+ if (![[NSFileManager defaultManager] fileExistsAtPath:sandbox_profile_path
+ isDirectory:&is_dir] || is_dir) {
+ LOG(ERROR) << "Failed to find the sandbox profile on disk";
+ return false;
}
+ const char *sandbox_profile = [sandbox_profile_path fileSystemRepresentation];
char* error_buff = NULL;
- int error = sandbox_init(sandbox_profile, sandbox_flags,
+ int error = sandbox_init(sandbox_profile, SANDBOX_NAMED_EXTERNAL,
&error_buff);
bool success = (error == 0 && error_buff == NULL);
if (error == -1) {
diff --git a/chrome/test/unit/chrome_test_suite.h b/chrome/test/unit/chrome_test_suite.h
index f89030c..8dcdbf6 100644
--- a/chrome/test/unit/chrome_test_suite.h
+++ b/chrome/test/unit/chrome_test_suite.h
@@ -9,6 +9,9 @@
#include "base/stats_table.h"
#include "base/file_util.h"
+#if defined(OS_MACOSX)
+#include "base/mac_util.h"
+#endif
#include "base/path_service.h"
#include "base/scoped_nsautorelease_pool.h"
#include "base/test_suite.h"
@@ -47,6 +50,13 @@ protected:
if (!user_data_dir.empty())
PathService::Override(chrome::DIR_USER_DATA, user_data_dir);
+#if defined(OS_MACOSX)
+ FilePath path;
+ PathService::Get(base::DIR_EXE, &path);
+ path = path.AppendASCII("Chromium.app");
+ mac_util::SetOverrideAppBundlePath(path);
+#endif
+
// Force unittests to run using en-us so if we test against string
// output, it'll pass regardless of the system language.
ResourceBundle::InitSharedInstance(L"en-us");
@@ -64,6 +74,10 @@ protected:
// TODO(port): Remove the #ifdef when ResourceBundle is ported.
ResourceBundle::CleanupSharedInstance();
+#if defined(OS_MACOSX)
+ mac_util::SetOverrideAppBundle(NULL);
+#endif
+
delete g_browser_process;
g_browser_process = NULL;