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. |
213 DCHECK_EQ(scale, rep.scale()); | 216 DCHECK_EQ(scale, rep.scale()); |
| 217 #endif |
214 | 218 |
215 // Remove old representation if there is one. | 219 // Remove old representation if there is one. |
216 image_skia_.RemoveRepresentation(scale); | 220 image_skia_.RemoveRepresentation(scale); |
217 image_skia_.AddRepresentation(rep); | 221 image_skia_.AddRepresentation(rep); |
218 | 222 |
219 if (observer_) | 223 if (observer_) |
220 observer_->OnExtensionIconImageChanged(this); | 224 observer_->OnExtensionIconImageChanged(this); |
221 } | 225 } |
222 | 226 |
223 void IconImage::Observe(int type, | 227 void IconImage::Observe(int type, |
224 const content::NotificationSource& source, | 228 const content::NotificationSource& source, |
225 const content::NotificationDetails& details) { | 229 const content::NotificationDetails& details) { |
226 DCHECK_EQ(type, extensions::NOTIFICATION_EXTENSION_REMOVED); | 230 DCHECK_EQ(type, extensions::NOTIFICATION_EXTENSION_REMOVED); |
227 | 231 |
228 const Extension* extension = content::Details<const Extension>(details).ptr(); | 232 const Extension* extension = content::Details<const Extension>(details).ptr(); |
229 | 233 |
230 if (extension_ == extension) | 234 if (extension_ == extension) |
231 extension_ = NULL; | 235 extension_ = NULL; |
232 } | 236 } |
233 | 237 |
234 } // namespace extensions | 238 } // namespace extensions |
OLD | NEW |