diff options
author | thomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-26 17:52:49 +0000 |
---|---|---|
committer | thomasvl@chromium.org <thomasvl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-26 17:52:49 +0000 |
commit | 09c428d53f174b3a3f64155a76b2a9e860e066da (patch) | |
tree | 18e909fdb0b9998baddab8aefa6574f042c79495 /chrome/common/resource_bundle_mac.mm | |
parent | 0972da02b5c92fcaa3b52343f76663aa622ffa69 (diff) | |
download | chromium_src-09c428d53f174b3a3f64155a76b2a9e860e066da.zip chromium_src-09c428d53f174b3a3f64155a76b2a9e860e066da.tar.gz chromium_src-09c428d53f174b3a3f64155a76b2a9e860e066da.tar.bz2 |
properly initialize resource manager on mac for unittests.
Review URL: http://codereview.chromium.org/28185
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10479 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/resource_bundle_mac.mm')
-rw-r--r-- | chrome/common/resource_bundle_mac.mm | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/chrome/common/resource_bundle_mac.mm b/chrome/common/resource_bundle_mac.mm index 36187ec..7515ed7 100644 --- a/chrome/common/resource_bundle_mac.mm +++ b/chrome/common/resource_bundle_mac.mm @@ -11,6 +11,7 @@ #include "base/file_path.h" #include "base/file_util.h" #include "base/logging.h" +#include "base/mac_util.h" #include "base/path_service.h" #include "base/string_piece.h" #include "base/string_util.h" @@ -18,6 +19,7 @@ #include "chrome/common/gfx/chrome_font.h" #include "chrome/common/l10n_util.h" + ResourceBundle::~ResourceBundle() { FreeImages(); @@ -34,8 +36,33 @@ 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("English.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:@"pak"]; + ofType:pakExt]; if (resource_path) { FilePath resources_pak_path([resource_path fileSystemRepresentation]); resource_pack = new base::DataPack; @@ -53,8 +80,8 @@ base::DataPack *LoadResourceDataPack(NSString *name) { } // namespace void ResourceBundle::LoadResources(const std::wstring& pref_locale) { - DCHECK(pref_locale.size() == 0) - << "ignoring requested locale in favore of NSBundle's selection"; + DLOG_IF(WARNING, pref_locale.size() != 0) + << "ignoring requested locale in favor of NSBundle's selection"; DCHECK(resources_data_ == NULL) << "resource data already loaded!"; resources_data_ = LoadResourceDataPack(@"chrome"); |