diff options
Diffstat (limited to 'app/resource_bundle_mac.mm')
-rw-r--r-- | app/resource_bundle_mac.mm | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/app/resource_bundle_mac.mm b/app/resource_bundle_mac.mm index 9d14440..1388932 100644 --- a/app/resource_bundle_mac.mm +++ b/app/resource_bundle_mac.mm @@ -9,13 +9,26 @@ #include "base/file_path.h" #include "base/logging.h" #include "base/mac_util.h" +#include "base/sys_string_conversions.h" #include "skia/ext/skia_utils_mac.h" namespace { -FilePath GetResourcesPakFilePath(NSString* name) { - NSString *resource_path = [mac_util::MainAppBundle() pathForResource:name - ofType:@"pak"]; +FilePath GetResourcesPakFilePath(NSString* name, NSString* mac_locale) { + NSString *resource_path; + // Some of the helper processes need to be able to fetch resources + // (chrome_dll_main.cc SubprocessNeedsResourceBundle()). Fetch the same locale + // as the already-running browser instead of using what NSBundle might pick + // based on values at helper launch time. + if ([mac_locale length]) { + resource_path = [mac_util::MainAppBundle() pathForResource:name + ofType:@"pak" + inDirectory:@"" + forLocalization:mac_locale]; + } else { + resource_path = [mac_util::MainAppBundle() pathForResource:name + ofType:@"pak"]; + } if (!resource_path) return FilePath(); return FilePath([resource_path fileSystemRepresentation]); @@ -25,14 +38,22 @@ FilePath GetResourcesPakFilePath(NSString* name) { // static FilePath ResourceBundle::GetResourcesFilePath() { - return GetResourcesPakFilePath(@"chrome"); + return GetResourcesPakFilePath(@"chrome", nil); } // static FilePath ResourceBundle::GetLocaleFilePath(const std::string& app_locale) { - DLOG_IF(WARNING, !app_locale.empty()) - << "ignoring requested locale in favor of NSBundle's selection"; - return GetResourcesPakFilePath(@"locale"); + NSString* mac_locale = base::SysUTF8ToNSString(app_locale); + + // Mac OS X uses "_" instead of "-", so swap to get a Mac-style value. + mac_locale = [mac_locale stringByReplacingOccurrencesOfString:@"-" + withString:@"_"]; + + // On disk, the "en_US" resources are just "en" (http://crbug.com/25578). + if ([mac_locale isEqual:@"en_US"]) + mac_locale = @"en"; + + return GetResourcesPakFilePath(@"locale", mac_locale); } NSImage* ResourceBundle::GetNSImageNamed(int resource_id) { |