summaryrefslogtreecommitdiffstats
path: root/extensions/browser/extension_icon_image.cc
diff options
context:
space:
mode:
authorrdevlin.cronin <rdevlin.cronin@chromium.org>2015-01-29 08:57:35 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-29 16:58:38 +0000
commitf19c7663b819419271996f47be3f2be55db95fb7 (patch)
tree0d8a7b0aacf37902a6d5672b7931f1d190309d44 /extensions/browser/extension_icon_image.cc
parent758bbd8cae9aec18563d30fac961230c8a90d73a (diff)
downloadchromium_src-f19c7663b819419271996f47be3f2be55db95fb7.zip
chromium_src-f19c7663b819419271996f47be3f2be55db95fb7.tar.gz
chromium_src-f19c7663b819419271996f47be3f2be55db95fb7.tar.bz2
[Extensions] Cache extension action icons
Cache extension action icons so that they don't have to be reloaded each time a new view is created (i.e., each time a new browser or the new overflow menu is opened). BUG=452958 Review URL: https://codereview.chromium.org/885443004 Cr-Commit-Position: refs/heads/master@{#313724}
Diffstat (limited to 'extensions/browser/extension_icon_image.cc')
-rw-r--r--extensions/browser/extension_icon_image.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/extensions/browser/extension_icon_image.cc b/extensions/browser/extension_icon_image.cc
index 8e3f957..5f237ff 100644
--- a/extensions/browser/extension_icon_image.cc
+++ b/extensions/browser/extension_icon_image.cc
@@ -134,13 +134,14 @@ IconImage::IconImage(
extension_(extension),
icon_set_(icon_set),
resource_size_in_dip_(resource_size_in_dip),
- observer_(observer),
source_(NULL),
default_icon_(gfx::ImageSkiaOperations::CreateResizedImage(
default_icon,
skia::ImageOperations::RESIZE_BEST,
gfx::Size(resource_size_in_dip, resource_size_in_dip))),
weak_ptr_factory_(this) {
+ if (observer)
+ AddObserver(observer);
gfx::Size resource_size(resource_size_in_dip, resource_size_in_dip);
source_ = new Source(this, resource_size);
image_skia_ = gfx::ImageSkia(source_, resource_size);
@@ -150,7 +151,16 @@ IconImage::IconImage(
content::NotificationService::AllSources());
}
+void IconImage::AddObserver(Observer* observer) {
+ observers_.AddObserver(observer);
+}
+
+void IconImage::RemoveObserver(Observer* observer) {
+ observers_.RemoveObserver(observer);
+}
+
IconImage::~IconImage() {
+ FOR_EACH_OBSERVER(Observer, observers_, OnExtensionIconImageDestroyed(this));
source_->ResetHost();
}
@@ -216,8 +226,7 @@ void IconImage::OnImageLoaded(float scale, const gfx::Image& image_in) {
image_skia_.RemoveRepresentation(scale);
image_skia_.AddRepresentation(rep);
- if (observer_)
- observer_->OnExtensionIconImageChanged(this);
+ FOR_EACH_OBSERVER(Observer, observers_, OnExtensionIconImageChanged(this));
}
void IconImage::Observe(int type,