| 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/ui/webui/extensions/extension_icon_source.h" | 5 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/memory/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 std::string contents = ResourceBundle::GetSharedInstance() | 98 std::string contents = ResourceBundle::GetSharedInstance() |
| 99 .GetRawDataResourceForScale(resource_id, | 99 .GetRawDataResourceForScale(resource_id, |
| 100 ui::SCALE_FACTOR_100P).as_string(); | 100 ui::SCALE_FACTOR_100P).as_string(); |
| 101 | 101 |
| 102 // Convert and return it. | 102 // Convert and return it. |
| 103 const unsigned char* data = | 103 const unsigned char* data = |
| 104 reinterpret_cast<const unsigned char*>(contents.data()); | 104 reinterpret_cast<const unsigned char*>(contents.data()); |
| 105 return ToBitmap(data, contents.length()); | 105 return ToBitmap(data, contents.length()); |
| 106 } | 106 } |
| 107 | 107 |
| 108 std::string ExtensionIconSource::GetSource() { | 108 std::string ExtensionIconSource::GetSource() const { |
| 109 return chrome::kChromeUIExtensionIconHost; | 109 return chrome::kChromeUIExtensionIconHost; |
| 110 } | 110 } |
| 111 | 111 |
| 112 std::string ExtensionIconSource::GetMimeType(const std::string&) const { | 112 std::string ExtensionIconSource::GetMimeType(const std::string&) const { |
| 113 // We need to explicitly return a mime type, otherwise if the user tries to | 113 // We need to explicitly return a mime type, otherwise if the user tries to |
| 114 // drag the image they get no extension. | 114 // drag the image they get no extension. |
| 115 return "image/png"; | 115 return "image/png"; |
| 116 } | 116 } |
| 117 | 117 |
| 118 void ExtensionIconSource::StartDataRequest( | 118 void ExtensionIconSource::StartDataRequest( |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 | 337 |
| 338 void ExtensionIconSource::ClearData(int request_id) { | 338 void ExtensionIconSource::ClearData(int request_id) { |
| 339 std::map<int, ExtensionIconRequest*>::iterator i = | 339 std::map<int, ExtensionIconRequest*>::iterator i = |
| 340 request_map_.find(request_id); | 340 request_map_.find(request_id); |
| 341 if (i == request_map_.end()) | 341 if (i == request_map_.end()) |
| 342 return; | 342 return; |
| 343 | 343 |
| 344 delete i->second; | 344 delete i->second; |
| 345 request_map_.erase(i); | 345 request_map_.erase(i); |
| 346 } | 346 } |
| OLD | NEW |