| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/extension_icon_image.h" | 5 #include "chrome/browser/extensions/extension_icon_image.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 source_(NULL), | 142 source_(NULL), |
| 143 default_icon_(gfx::ImageSkiaOperations::CreateResizedImage( | 143 default_icon_(gfx::ImageSkiaOperations::CreateResizedImage( |
| 144 default_icon, | 144 default_icon, |
| 145 skia::ImageOperations::RESIZE_BEST, | 145 skia::ImageOperations::RESIZE_BEST, |
| 146 gfx::Size(resource_size_in_dip, resource_size_in_dip))), | 146 gfx::Size(resource_size_in_dip, resource_size_in_dip))), |
| 147 weak_ptr_factory_(this) { | 147 weak_ptr_factory_(this) { |
| 148 gfx::Size resource_size(resource_size_in_dip, resource_size_in_dip); | 148 gfx::Size resource_size(resource_size_in_dip, resource_size_in_dip); |
| 149 source_ = new Source(this, resource_size); | 149 source_ = new Source(this, resource_size); |
| 150 image_skia_ = gfx::ImageSkia(source_, resource_size); | 150 image_skia_ = gfx::ImageSkia(source_, resource_size); |
| 151 | 151 |
| 152 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 152 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
| 153 content::NotificationService::AllSources()); | 153 content::NotificationService::AllSources()); |
| 154 } | 154 } |
| 155 | 155 |
| 156 IconImage::~IconImage() { | 156 IconImage::~IconImage() { |
| 157 source_->ResetHost(); | 157 source_->ResetHost(); |
| 158 } | 158 } |
| 159 | 159 |
| 160 gfx::ImageSkiaRep IconImage::LoadImageForScaleFactor( | 160 gfx::ImageSkiaRep IconImage::LoadImageForScaleFactor( |
| 161 ui::ScaleFactor scale_factor) { | 161 ui::ScaleFactor scale_factor) { |
| 162 // Do nothing if extension is unloaded. | 162 // Do nothing if extension is unloaded. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 image_skia_.RemoveRepresentation(scale); | 220 image_skia_.RemoveRepresentation(scale); |
| 221 image_skia_.AddRepresentation(rep); | 221 image_skia_.AddRepresentation(rep); |
| 222 | 222 |
| 223 if (observer_) | 223 if (observer_) |
| 224 observer_->OnExtensionIconImageChanged(this); | 224 observer_->OnExtensionIconImageChanged(this); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void IconImage::Observe(int type, | 227 void IconImage::Observe(int type, |
| 228 const content::NotificationSource& source, | 228 const content::NotificationSource& source, |
| 229 const content::NotificationDetails& details) { | 229 const content::NotificationDetails& details) { |
| 230 DCHECK_EQ(type, chrome::NOTIFICATION_EXTENSION_UNLOADED); | 230 DCHECK_EQ(type, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED); |
| 231 | 231 |
| 232 const Extension* extension = | 232 const Extension* extension = |
| 233 content::Details<extensions::UnloadedExtensionInfo>(details)->extension; | 233 content::Details<extensions::UnloadedExtensionInfo>(details)->extension; |
| 234 | 234 |
| 235 if (extension_ == extension) | 235 if (extension_ == extension) |
| 236 extension_ = NULL; | 236 extension_ = NULL; |
| 237 } | 237 } |
| 238 | 238 |
| 239 } // namespace extensions | 239 } // namespace extensions |
| OLD | NEW |