| Index: ui/base/resource/resource_bundle_mac.mm
|
| ===================================================================
|
| --- ui/base/resource/resource_bundle_mac.mm (revision 134688)
|
| +++ ui/base/resource/resource_bundle_mac.mm (working copy)
|
| @@ -36,8 +36,12 @@
|
| resource_path = [base::mac::FrameworkBundle() pathForResource:name
|
| ofType:@"pak"];
|
| }
|
| - if (!resource_path)
|
| - return FilePath();
|
| +
|
| + if (!resource_path) {
|
| + // Return just the name of the pack file.
|
| + return FilePath(base::SysNSStringToUTF8(name) + ".pak");
|
| + }
|
| +
|
| return FilePath([resource_path fileSystemRepresentation]);
|
| }
|
|
|
| @@ -56,11 +60,11 @@
|
| #if defined(ENABLE_HIDPI)
|
| if (base::mac::IsOSLionOrLater()) {
|
| AddDataPack(GetResourcesPakFilePath(@"theme_resources_2x", nil),
|
| - ResourceHandle::kScaleFactor200x);
|
| + ResourceHandle::kScaleFactor200x);
|
| AddDataPack(GetResourcesPakFilePath(@"theme_resources_standard_2x", nil),
|
| - ResourceHandle::kScaleFactor200x);
|
| + ResourceHandle::kScaleFactor200x);
|
| AddDataPack(GetResourcesPakFilePath(@"ui_resources_standard_2x", nil),
|
| - ResourceHandle::kScaleFactor200x);
|
| + ResourceHandle::kScaleFactor200x);
|
| }
|
| #endif
|
| }
|
| @@ -77,10 +81,18 @@
|
| if ([mac_locale isEqual:@"en_US"])
|
| mac_locale = @"en";
|
|
|
| - return GetResourcesPakFilePath(@"locale", mac_locale);
|
| + FilePath locale_file_path = GetResourcesPakFilePath(@"locale", mac_locale);
|
| +
|
| + if (delegate_) {
|
| + locale_file_path =
|
| + delegate_->GetPathForLocalePack(locale_file_path, app_locale);
|
| + }
|
| +
|
| + return locale_file_path;
|
| }
|
|
|
| -gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) {
|
| +const gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id,
|
| + ImageRTL rtl) {
|
| // Flipped images are not used on Mac.
|
| DCHECK_EQ(rtl, RTL_DISABLED);
|
|
|
| @@ -99,41 +111,47 @@
|
| }
|
| }
|
|
|
| - scoped_nsobject<NSImage> ns_image;
|
| - for (size_t i = 0; i < data_packs_.size(); ++i) {
|
| - scoped_refptr<base::RefCountedStaticMemory> data(
|
| - data_packs_[i]->GetStaticMemory(resource_id));
|
| - if (!data.get())
|
| - continue;
|
| + gfx::Image image;
|
| + if (delegate_)
|
| + image = delegate_->GetNativeImageNamed(resource_id, rtl);
|
|
|
| - scoped_nsobject<NSData> ns_data(
|
| - [[NSData alloc] initWithBytes:data->front()
|
| - length:data->size()]);
|
| + if (image.IsEmpty()) {
|
| + scoped_nsobject<NSImage> ns_image;
|
| + for (size_t i = 0; i < data_packs_.size(); ++i) {
|
| + scoped_refptr<base::RefCountedStaticMemory> data(
|
| + data_packs_[i]->GetStaticMemory(resource_id));
|
| + if (!data.get())
|
| + continue;
|
| +
|
| + scoped_nsobject<NSData> ns_data(
|
| + [[NSData alloc] initWithBytes:data->front()
|
| + length:data->size()]);
|
| + if (!ns_image.get()) {
|
| + ns_image.reset([[NSImage alloc] initWithData:ns_data]);
|
| + } else {
|
| + NSImageRep* image_rep = [NSBitmapImageRep imageRepWithData:ns_data];
|
| + if (image_rep)
|
| + [ns_image addRepresentation:image_rep];
|
| + }
|
| + }
|
| +
|
| if (!ns_image.get()) {
|
| - ns_image.reset([[NSImage alloc] initWithData:ns_data]);
|
| - } else {
|
| - NSImageRep* image_rep = [NSBitmapImageRep imageRepWithData:ns_data];
|
| - if (image_rep)
|
| - [ns_image addRepresentation:image_rep];
|
| + LOG(WARNING) << "Unable to load image with id " << resource_id;
|
| + NOTREACHED(); // Want to assert in debug mode.
|
| + return GetEmptyImage();
|
| }
|
| - }
|
|
|
| - if (!ns_image.get()) {
|
| - LOG(WARNING) << "Unable to load image with id " << resource_id;
|
| - NOTREACHED(); // Want to assert in debug mode.
|
| - return *GetEmptyImage();
|
| + image = gfx::Image(ns_image.release());
|
| }
|
|
|
| base::AutoLock lock(*images_and_fonts_lock_);
|
|
|
| // Another thread raced the load and has already cached the image.
|
| - if (images_.count(resource_id)) {
|
| - return *images_[resource_id];
|
| - }
|
| + if (images_.count(resource_id))
|
| + return images_[resource_id];
|
|
|
| - gfx::Image* image = new gfx::Image(ns_image.release());
|
| images_[resource_id] = image;
|
| - return *image;
|
| + return images_[resource_id];
|
| }
|
|
|
| } // namespace ui
|
|
|