| 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 "content/public/browser/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 void IconImage::OnImageLoaded(float scale, const gfx::Image& image_in) { | 203 void IconImage::OnImageLoaded(float scale, const gfx::Image& image_in) { |
| 204 const gfx::ImageSkia* image = | 204 const gfx::ImageSkia* image = |
| 205 image_in.IsEmpty() ? &default_icon_ : image_in.ToImageSkia(); | 205 image_in.IsEmpty() ? &default_icon_ : image_in.ToImageSkia(); |
| 206 | 206 |
| 207 // Maybe default icon was not set. | 207 // Maybe default icon was not set. |
| 208 if (image->isNull()) | 208 if (image->isNull()) |
| 209 return; | 209 return; |
| 210 | 210 |
| 211 gfx::ImageSkiaRep rep = image->GetRepresentation(scale); | 211 gfx::ImageSkiaRep rep = image->GetRepresentation(scale); |
| 212 DCHECK(!rep.is_null()); | 212 DCHECK(!rep.is_null()); |
| 213 #if !defined(USE_ATHENA) | |
| 214 // TODO(oshima): It someshow gets 2x image for 1x for some extensions. Fix | |
| 215 // this. | |
| 216 DCHECK_EQ(scale, rep.scale()); | 213 DCHECK_EQ(scale, rep.scale()); |
| 217 #endif | |
| 218 | 214 |
| 219 // Remove old representation if there is one. | 215 // Remove old representation if there is one. |
| 220 image_skia_.RemoveRepresentation(scale); | 216 image_skia_.RemoveRepresentation(scale); |
| 221 image_skia_.AddRepresentation(rep); | 217 image_skia_.AddRepresentation(rep); |
| 222 | 218 |
| 223 if (observer_) | 219 if (observer_) |
| 224 observer_->OnExtensionIconImageChanged(this); | 220 observer_->OnExtensionIconImageChanged(this); |
| 225 } | 221 } |
| 226 | 222 |
| 227 void IconImage::Observe(int type, | 223 void IconImage::Observe(int type, |
| 228 const content::NotificationSource& source, | 224 const content::NotificationSource& source, |
| 229 const content::NotificationDetails& details) { | 225 const content::NotificationDetails& details) { |
| 230 DCHECK_EQ(type, extensions::NOTIFICATION_EXTENSION_REMOVED); | 226 DCHECK_EQ(type, extensions::NOTIFICATION_EXTENSION_REMOVED); |
| 231 | 227 |
| 232 const Extension* extension = content::Details<const Extension>(details).ptr(); | 228 const Extension* extension = content::Details<const Extension>(details).ptr(); |
| 233 | 229 |
| 234 if (extension_ == extension) | 230 if (extension_ == extension) |
| 235 extension_ = NULL; | 231 extension_ = NULL; |
| 236 } | 232 } |
| 237 | 233 |
| 238 } // namespace extensions | 234 } // namespace extensions |
| OLD | NEW |