Chromium Code Reviews| 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.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 | 68 |
| 69 ExtensionIconSource::~ExtensionIconSource() { | 69 ExtensionIconSource::~ExtensionIconSource() { |
| 70 // Clean up all the temporary data we're holding for requests. | 70 // Clean up all the temporary data we're holding for requests. |
| 71 STLDeleteValues(&request_map_); | 71 STLDeleteValues(&request_map_); |
| 72 } | 72 } |
| 73 | 73 |
| 74 // static | 74 // static |
| 75 GURL ExtensionIconSource::GetIconURL(const Extension* extension, | 75 GURL ExtensionIconSource::GetIconURL(const Extension* extension, |
| 76 Extension::Icons icon_size, | 76 Extension::Icons icon_size, |
| 77 ExtensionIconSet::MatchType match, | 77 ExtensionIconSet::MatchType match, |
| 78 bool grayscale) { | 78 bool grayscale, |
| 79 if (extension->id() == extension_misc::kWebStoreAppId) | 79 bool* exists) { |
|
Evan Stade
2011/07/27 16:31:45
nit: set exists to true at the start of the functi
Greg Billock
2011/07/27 19:52:24
Done.
| |
| 80 if (extension->id() == extension_misc::kWebStoreAppId) { | |
| 81 if (exists) *exists = true; | |
| 80 return GURL("chrome://theme/IDR_WEBSTORE_ICON"); | 82 return GURL("chrome://theme/IDR_WEBSTORE_ICON"); |
| 83 } | |
| 84 | |
| 85 if (exists) { | |
| 86 if (extension->GetIconURL(icon_size, match) == GURL()) | |
| 87 *exists = false; | |
| 88 else | |
| 89 *exists = true; | |
| 90 } | |
| 81 | 91 |
| 82 GURL icon_url(base::StringPrintf("%s%s/%d/%d%s", | 92 GURL icon_url(base::StringPrintf("%s%s/%d/%d%s", |
| 83 chrome::kChromeUIExtensionIconURL, | 93 chrome::kChromeUIExtensionIconURL, |
| 84 extension->id().c_str(), | 94 extension->id().c_str(), |
| 85 icon_size, | 95 icon_size, |
| 86 match, | 96 match, |
| 87 grayscale ? "?grayscale=true" : "")); | 97 grayscale ? "?grayscale=true" : "")); |
| 88 CHECK(icon_url.is_valid()); | 98 CHECK(icon_url.is_valid()); |
| 89 return icon_url; | 99 return icon_url; |
| 90 } | 100 } |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 | 327 |
| 318 void ExtensionIconSource::ClearData(int request_id) { | 328 void ExtensionIconSource::ClearData(int request_id) { |
| 319 std::map<int, ExtensionIconRequest*>::iterator i = | 329 std::map<int, ExtensionIconRequest*>::iterator i = |
| 320 request_map_.find(request_id); | 330 request_map_.find(request_id); |
| 321 if (i == request_map_.end()) | 331 if (i == request_map_.end()) |
| 322 return; | 332 return; |
| 323 | 333 |
| 324 delete i->second; | 334 delete i->second; |
| 325 request_map_.erase(i); | 335 request_map_.erase(i); |
| 326 } | 336 } |
| OLD | NEW |