Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1596)

Unified Diff: chrome/common/resource_bundle_mac.mm

Issue 28185: properly initialize resource manager on mac for unittests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/unit/chrome_test_suite.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/resource_bundle_mac.mm
===================================================================
--- chrome/common/resource_bundle_mac.mm (revision 10462)
+++ chrome/common/resource_bundle_mac.mm (working copy)
@@ -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 @@
base::DataPack *LoadResourceDataPack(NSString *name) {
base::DataPack *resource_pack = NULL;
+ NSString * const pakExt = @"pak";
Mark Mentovai 2009/02/26 17:44:03 Never put space on both sides of the *.
+
+ // 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";
Mark Mentovai 2009/02/27 06:07:59 Shoulda caught this before, but this shouldn't har
+ 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 @@
} // 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");
« no previous file with comments | « no previous file | chrome/test/unit/chrome_test_suite.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698