| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/webui/extension_icon_source.h" | 5 #include "chrome/browser/ui/webui/extension_icon_source.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
| 9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 match_param = match_param.substr(0, match_param.find('?')); | 257 match_param = match_param.substr(0, match_param.find('?')); |
| 258 | 258 |
| 259 // The icon size and match types are encoded as string representations of | 259 // The icon size and match types are encoded as string representations of |
| 260 // their enum values, so to get the enum back, we read the string as an int | 260 // their enum values, so to get the enum back, we read the string as an int |
| 261 // and then cast to the enum. | 261 // and then cast to the enum. |
| 262 Extension::Icons size; | 262 Extension::Icons size; |
| 263 int size_num; | 263 int size_num; |
| 264 if (!base::StringToInt(size_param, &size_num)) | 264 if (!base::StringToInt(size_param, &size_num)) |
| 265 return false; | 265 return false; |
| 266 size = static_cast<Extension::Icons>(size_num); | 266 size = static_cast<Extension::Icons>(size_num); |
| 267 if (size <= 0) |
| 268 return false; |
| 267 | 269 |
| 268 ExtensionIconSet::MatchType match_type; | 270 ExtensionIconSet::MatchType match_type; |
| 269 int match_num; | 271 int match_num; |
| 270 if (!base::StringToInt(match_param, &match_num)) | 272 if (!base::StringToInt(match_param, &match_num)) |
| 271 return false; | 273 return false; |
| 272 match_type = static_cast<ExtensionIconSet::MatchType>(match_num); | 274 match_type = static_cast<ExtensionIconSet::MatchType>(match_num); |
| 275 if (!(match_type == ExtensionIconSet::MATCH_EXACTLY || |
| 276 match_type == ExtensionIconSet::MATCH_SMALLER || |
| 277 match_type == ExtensionIconSet::MATCH_BIGGER)) |
| 278 match_type = ExtensionIconSet::MATCH_EXACTLY; |
| 273 | 279 |
| 274 std::string extension_id = path_parts.at(0); | 280 std::string extension_id = path_parts.at(0); |
| 275 const Extension* extension = | 281 const Extension* extension = |
| 276 profile_->GetExtensionService()->GetExtensionById(extension_id, true); | 282 profile_->GetExtensionService()->GetExtensionById(extension_id, true); |
| 277 if (!extension) | 283 if (!extension) |
| 278 return false; | 284 return false; |
| 279 | 285 |
| 280 bool grayscale = path_lower.find("grayscale=true") != std::string::npos; | 286 bool grayscale = path_lower.find("grayscale=true") != std::string::npos; |
| 281 | 287 |
| 282 SetData(request_id, extension, grayscale, size, match_type); | 288 SetData(request_id, extension, grayscale, size, match_type); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 312 | 318 |
| 313 void ExtensionIconSource::ClearData(int request_id) { | 319 void ExtensionIconSource::ClearData(int request_id) { |
| 314 std::map<int, ExtensionIconRequest*>::iterator i = | 320 std::map<int, ExtensionIconRequest*>::iterator i = |
| 315 request_map_.find(request_id); | 321 request_map_.find(request_id); |
| 316 if (i == request_map_.end()) | 322 if (i == request_map_.end()) |
| 317 return; | 323 return; |
| 318 | 324 |
| 319 delete i->second; | 325 delete i->second; |
| 320 request_map_.erase(i); | 326 request_map_.erase(i); |
| 321 } | 327 } |
| OLD | NEW |