| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 const gfx::ImageSkia* image = | 209 const gfx::ImageSkia* image = |
| 210 image_in.IsEmpty() ? &default_icon_ : image_in.ToImageSkia(); | 210 image_in.IsEmpty() ? &default_icon_ : image_in.ToImageSkia(); |
| 211 | 211 |
| 212 // Maybe default icon was not set. | 212 // Maybe default icon was not set. |
| 213 if (image->isNull()) | 213 if (image->isNull()) |
| 214 return; | 214 return; |
| 215 | 215 |
| 216 gfx::ImageSkiaRep rep = image->GetRepresentation(scale); | 216 gfx::ImageSkiaRep rep = image->GetRepresentation(scale); |
| 217 DCHECK(!rep.is_null()); | 217 DCHECK(!rep.is_null()); |
| 218 DCHECK_EQ(scale, rep.scale()); | 218 DCHECK_EQ(scale, rep.scale()); |
| 219 | |
| 220 // Remove old representation if there is one. | 219 // Remove old representation if there is one. |
| 221 image_skia_.RemoveRepresentation(scale); | 220 image_skia_.RemoveRepresentation(scale); |
| 222 image_skia_.AddRepresentation(rep); | 221 image_skia_.AddRepresentation(rep); |
| 223 | 222 |
| 224 if (observer_) | 223 if (observer_) |
| 225 observer_->OnExtensionIconImageChanged(this); | 224 observer_->OnExtensionIconImageChanged(this); |
| 226 } | 225 } |
| 227 | 226 |
| 228 void IconImage::Observe(int type, | 227 void IconImage::Observe(int type, |
| 229 const content::NotificationSource& source, | 228 const content::NotificationSource& source, |
| 230 const content::NotificationDetails& details) { | 229 const content::NotificationDetails& details) { |
| 231 DCHECK_EQ(type, chrome::NOTIFICATION_EXTENSION_REMOVED); | 230 DCHECK_EQ(type, chrome::NOTIFICATION_EXTENSION_REMOVED); |
| 232 | 231 |
| 233 const Extension* extension = content::Details<const Extension>(details).ptr(); | 232 const Extension* extension = content::Details<const Extension>(details).ptr(); |
| 234 | 233 |
| 235 if (extension_ == extension) | 234 if (extension_ == extension) |
| 236 extension_ = NULL; | 235 extension_ = NULL; |
| 237 } | 236 } |
| 238 | 237 |
| 239 } // namespace extensions | 238 } // namespace extensions |
| OLD | NEW |