| 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 "chrome/common/chrome_notification_types.h" | 9 #include "chrome/common/chrome_notification_types.h" |
| 10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 if (!extension_) | 161 if (!extension_) |
| 162 return gfx::ImageSkiaRep(); | 162 return gfx::ImageSkiaRep(); |
| 163 | 163 |
| 164 const float scale = ui::GetScaleFactorScale(scale_factor); | 164 const float scale = ui::GetScaleFactorScale(scale_factor); |
| 165 const int resource_size_in_pixel = | 165 const int resource_size_in_pixel = |
| 166 static_cast<int>(resource_size_in_dip_ * scale); | 166 static_cast<int>(resource_size_in_dip_ * scale); |
| 167 | 167 |
| 168 ExtensionResource resource; | 168 ExtensionResource resource; |
| 169 | 169 |
| 170 // Find extension resource for non bundled component extensions. | 170 // Find extension resource for non bundled component extensions. |
| 171 if (!ImageLoadingTracker::IsSpecialBundledExtensionId(extension_->id())) { | 171 // We try loading bigger image only if resource size is >= 32. |
| 172 // We try loading bigger image only if resource size is >= 32. | 172 if (resource_size_in_pixel >= kMatchBiggerTreshold) { |
| 173 if (resource_size_in_pixel >= kMatchBiggerTreshold) { | 173 resource = GetExtensionIconResource(extension_, icon_set_, |
| 174 resource = GetExtensionIconResource(extension_, icon_set_, | 174 resource_size_in_pixel, ExtensionIconSet::MATCH_BIGGER); |
| 175 resource_size_in_pixel, ExtensionIconSet::MATCH_BIGGER); | 175 } |
| 176 } | |
| 177 | 176 |
| 178 // If resource is not found by now, try matching smaller one. | 177 // If resource is not found by now, try matching smaller one. |
| 179 if (resource.empty()) { | 178 if (resource.empty()) { |
| 180 resource = GetExtensionIconResource(extension_, icon_set_, | 179 resource = GetExtensionIconResource(extension_, icon_set_, |
| 181 resource_size_in_pixel, ExtensionIconSet::MATCH_SMALLER); | 180 resource_size_in_pixel, ExtensionIconSet::MATCH_SMALLER); |
| 182 } | 181 } |
| 183 | 182 |
| 184 // If there is no resource found, return default icon. | 183 // If there is no resource found, return default icon. |
| 185 if (resource.empty()) | 184 if (resource.empty()) |
| 186 return default_icon_.GetRepresentation(scale_factor); | 185 return default_icon_.GetRepresentation(scale_factor); |
| 187 } | |
| 188 | 186 |
| 189 int id = tracker_.next_id(); | 187 int id = tracker_.next_id(); |
| 190 load_map_[id].scale_factor = scale_factor; | 188 load_map_[id].scale_factor = scale_factor; |
| 191 load_map_[id].is_async = false; | 189 load_map_[id].is_async = false; |
| 192 | 190 |
| 193 std::vector<ImageLoadingTracker::ImageRepresentation> info_list; | 191 std::vector<ImageLoadingTracker::ImageRepresentation> info_list; |
| 194 info_list.push_back(ImageLoadingTracker::ImageRepresentation( | 192 info_list.push_back(ImageLoadingTracker::ImageRepresentation( |
| 195 resource, | 193 resource, |
| 196 ImageLoadingTracker::ImageRepresentation::ALWAYS_RESIZE, | 194 ImageLoadingTracker::ImageRepresentation::ALWAYS_RESIZE, |
| 197 gfx::Size(resource_size_in_dip_, resource_size_in_dip_).Scale(scale), | 195 gfx::Size(resource_size_in_dip_, resource_size_in_dip_).Scale(scale), |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 DCHECK_EQ(type, chrome::NOTIFICATION_EXTENSION_UNLOADED); | 248 DCHECK_EQ(type, chrome::NOTIFICATION_EXTENSION_UNLOADED); |
| 251 | 249 |
| 252 const Extension* extension = | 250 const Extension* extension = |
| 253 content::Details<extensions::UnloadedExtensionInfo>(details)->extension; | 251 content::Details<extensions::UnloadedExtensionInfo>(details)->extension; |
| 254 | 252 |
| 255 if (extension_ == extension) | 253 if (extension_ == extension) |
| 256 extension_ = NULL; | 254 extension_ = NULL; |
| 257 } | 255 } |
| 258 | 256 |
| 259 } // namespace extensions | 257 } // namespace extensions |
| OLD | NEW |