| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/extension_icon_image.h" | 5 #include "extensions/browser/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" | |
| 11 #include "content/public/browser/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
| 12 #include "extensions/browser/image_loader.h" | 11 #include "extensions/browser/image_loader.h" |
| 12 #include "extensions/browser/notification_types.h" |
| 13 #include "extensions/common/extension.h" | 13 #include "extensions/common/extension.h" |
| 14 #include "ui/gfx/canvas.h" | 14 #include "ui/gfx/canvas.h" |
| 15 #include "ui/gfx/image/canvas_image_source.h" | 15 #include "ui/gfx/image/canvas_image_source.h" |
| 16 #include "ui/gfx/image/image.h" | 16 #include "ui/gfx/image/image.h" |
| 17 #include "ui/gfx/image/image_skia_operations.h" | 17 #include "ui/gfx/image/image_skia_operations.h" |
| 18 #include "ui/gfx/image/image_skia_source.h" | 18 #include "ui/gfx/image/image_skia_source.h" |
| 19 #include "ui/gfx/size.h" | 19 #include "ui/gfx/size.h" |
| 20 #include "ui/gfx/size_conversions.h" | 20 #include "ui/gfx/size_conversions.h" |
| 21 | 21 |
| 22 // The ImageSkia provided by extensions::IconImage contains ImageSkiaReps that | 22 // The ImageSkia provided by extensions::IconImage contains ImageSkiaReps that |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, | 152 registrar_.Add(this, |
| 153 chrome::NOTIFICATION_EXTENSION_REMOVED, | 153 extensions::NOTIFICATION_EXTENSION_REMOVED, |
| 154 content::NotificationService::AllSources()); | 154 content::NotificationService::AllSources()); |
| 155 } | 155 } |
| 156 | 156 |
| 157 IconImage::~IconImage() { | 157 IconImage::~IconImage() { |
| 158 source_->ResetHost(); | 158 source_->ResetHost(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 gfx::ImageSkiaRep IconImage::LoadImageForScaleFactor( | 161 gfx::ImageSkiaRep IconImage::LoadImageForScaleFactor( |
| 162 ui::ScaleFactor scale_factor) { | 162 ui::ScaleFactor scale_factor) { |
| 163 // Do nothing if extension is unloaded. | 163 // Do nothing if extension is unloaded. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 image_skia_.RemoveRepresentation(scale); | 221 image_skia_.RemoveRepresentation(scale); |
| 222 image_skia_.AddRepresentation(rep); | 222 image_skia_.AddRepresentation(rep); |
| 223 | 223 |
| 224 if (observer_) | 224 if (observer_) |
| 225 observer_->OnExtensionIconImageChanged(this); | 225 observer_->OnExtensionIconImageChanged(this); |
| 226 } | 226 } |
| 227 | 227 |
| 228 void IconImage::Observe(int type, | 228 void IconImage::Observe(int type, |
| 229 const content::NotificationSource& source, | 229 const content::NotificationSource& source, |
| 230 const content::NotificationDetails& details) { | 230 const content::NotificationDetails& details) { |
| 231 DCHECK_EQ(type, chrome::NOTIFICATION_EXTENSION_REMOVED); | 231 DCHECK_EQ(type, extensions::NOTIFICATION_EXTENSION_REMOVED); |
| 232 | 232 |
| 233 const Extension* extension = content::Details<const Extension>(details).ptr(); | 233 const Extension* extension = content::Details<const Extension>(details).ptr(); |
| 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 |