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

Unified Diff: ui/base/resource/resource_bundle_gtk.cc

Issue 10270023: Add new ResourceBundle::Delegate interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 | « ui/base/resource/resource_bundle_aurax11.cc ('k') | ui/base/resource/resource_bundle_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/resource/resource_bundle_gtk.cc
===================================================================
--- ui/base/resource/resource_bundle_gtk.cc (revision 135347)
+++ ui/base/resource/resource_bundle_gtk.cc (working copy)
@@ -56,7 +56,9 @@
FilePath path;
if (PathService::Get(base::DIR_MODULE, &path))
return path.AppendASCII(pak_name.c_str());
- return FilePath();
+
+ // Return just the name of the pack file.
+ return FilePath(pak_name.c_str());
}
} // namespace
@@ -77,33 +79,36 @@
// Check to see if the image is already in the cache.
{
base::AutoLock lock_scope(*images_and_fonts_lock_);
- ImageMap::const_iterator found = images_.find(key);
- if (found != images_.end())
- return *found->second;
+ if (images_.count(key))
+ return images_[key];
}
- scoped_refptr<base::RefCountedStaticMemory> data(
- LoadDataResourceBytes(resource_id));
- GdkPixbuf* pixbuf = LoadPixbuf(data.get(), rtl == RTL_ENABLED);
+ gfx::Image image;
+ if (delegate_)
+ image = delegate_->GetNativeImageNamed(resource_id, rtl);
- // The load was successful, so cache the image.
- if (pixbuf) {
- base::AutoLock lock_scope(*images_and_fonts_lock_);
+ if (image.IsEmpty()) {
+ scoped_refptr<base::RefCountedStaticMemory> data(
+ LoadDataResourceBytes(resource_id));
+ GdkPixbuf* pixbuf = LoadPixbuf(data.get(), rtl == RTL_ENABLED);
- // Another thread raced the load and has already cached the image.
- if (images_.count(key)) {
- g_object_unref(pixbuf);
- return *images_[key];
+ if (!pixbuf) {
+ LOG(WARNING) << "Unable to load pixbuf with id " << resource_id;
+ NOTREACHED(); // Want to assert in debug mode.
+ return GetEmptyImage();
}
- gfx::Image* image = new gfx::Image(pixbuf); // Takes ownership.
- images_[key] = image;
- return *image;
+ image = gfx::Image(pixbuf); // Takes ownership.
}
- LOG(WARNING) << "Unable to pixbuf with id " << resource_id;
- NOTREACHED(); // Want to assert in debug mode.
- return *GetEmptyImage();
+ base::AutoLock lock_scope(*images_and_fonts_lock_);
+
+ // Another thread raced the load and has already cached the image.
+ if (images_.count(key))
+ return images_[key];
+
+ images_[key] = image;
+ return images_[key];
}
} // namespace ui
« no previous file with comments | « ui/base/resource/resource_bundle_aurax11.cc ('k') | ui/base/resource/resource_bundle_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698