| 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 "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 void IconImage::AddObserver(Observer* observer) { | 157 void IconImage::AddObserver(Observer* observer) { |
| 158 observers_.AddObserver(observer); | 158 observers_.AddObserver(observer); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void IconImage::RemoveObserver(Observer* observer) { | 161 void IconImage::RemoveObserver(Observer* observer) { |
| 162 observers_.RemoveObserver(observer); | 162 observers_.RemoveObserver(observer); |
| 163 } | 163 } |
| 164 | 164 |
| 165 IconImage::~IconImage() { | 165 IconImage::~IconImage() { |
| 166 FOR_EACH_OBSERVER(Observer, observers_, OnExtensionIconImageDestroyed(this)); | 166 for (auto& observer : observers_) |
| 167 observer.OnExtensionIconImageDestroyed(this); |
| 167 source_->ResetHost(); | 168 source_->ResetHost(); |
| 168 } | 169 } |
| 169 | 170 |
| 170 gfx::ImageSkiaRep IconImage::LoadImageForScaleFactor( | 171 gfx::ImageSkiaRep IconImage::LoadImageForScaleFactor( |
| 171 ui::ScaleFactor scale_factor) { | 172 ui::ScaleFactor scale_factor) { |
| 172 // Do nothing if extension is unloaded. | 173 // Do nothing if extension is unloaded. |
| 173 if (!extension_) | 174 if (!extension_) |
| 174 return gfx::ImageSkiaRep(); | 175 return gfx::ImageSkiaRep(); |
| 175 | 176 |
| 176 const float scale = ui::GetScaleForScaleFactor(scale_factor); | 177 const float scale = ui::GetScaleForScaleFactor(scale_factor); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 241 |
| 241 image_skia_.RemoveRepresentation(scale); | 242 image_skia_.RemoveRepresentation(scale); |
| 242 image_skia_.AddRepresentation(rep); | 243 image_skia_.AddRepresentation(rep); |
| 243 | 244 |
| 244 // Update the image to use the updated image skia. | 245 // Update the image to use the updated image skia. |
| 245 // It's a shame we have to do this because it means that all the other | 246 // It's a shame we have to do this because it means that all the other |
| 246 // representations stored on |image_| will be deleted, but unfortunately | 247 // representations stored on |image_| will be deleted, but unfortunately |
| 247 // there's no way to combine the storage of two images. | 248 // there's no way to combine the storage of two images. |
| 248 image_ = gfx::Image(image_skia_); | 249 image_ = gfx::Image(image_skia_); |
| 249 | 250 |
| 250 FOR_EACH_OBSERVER(Observer, observers_, OnExtensionIconImageChanged(this)); | 251 for (auto& observer : observers_) |
| 252 observer.OnExtensionIconImageChanged(this); |
| 251 } | 253 } |
| 252 | 254 |
| 253 void IconImage::Observe(int type, | 255 void IconImage::Observe(int type, |
| 254 const content::NotificationSource& source, | 256 const content::NotificationSource& source, |
| 255 const content::NotificationDetails& details) { | 257 const content::NotificationDetails& details) { |
| 256 DCHECK_EQ(type, extensions::NOTIFICATION_EXTENSION_REMOVED); | 258 DCHECK_EQ(type, extensions::NOTIFICATION_EXTENSION_REMOVED); |
| 257 | 259 |
| 258 const Extension* extension = content::Details<const Extension>(details).ptr(); | 260 const Extension* extension = content::Details<const Extension>(details).ptr(); |
| 259 | 261 |
| 260 if (extension_.get() == extension) | 262 if (extension_.get() == extension) |
| 261 extension_ = nullptr; | 263 extension_ = nullptr; |
| 262 } | 264 } |
| 263 | 265 |
| 264 } // namespace extensions | 266 } // namespace extensions |
| OLD | NEW |