| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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( |
| 119 const std::string& path, | 119 const std::string& path, |
| 120 bool is_incognito, | 120 const content::URLDataSource::ExtraRequestInfo& info, |
| 121 const content::URLDataSource::GotDataCallback& callback) { | 121 const content::URLDataSource::GotDataCallback& callback) { |
| 122 // This is where everything gets started. First, parse the request and make | 122 // This is where everything gets started. First, parse the request and make |
| 123 // the request data available for later. | 123 // the request data available for later. |
| 124 static int next_id = 0; | 124 static int next_id = 0; |
| 125 if (!ParseData(path, ++next_id, callback)) { | 125 if (!ParseData(path, ++next_id, callback)) { |
| 126 // If the request data cannot be parsed, request parameters will not be | 126 // If the request data cannot be parsed, request parameters will not be |
| 127 // added to |request_map_|. | 127 // added to |request_map_|. |
| 128 // Send back the default application icon (not resized or desaturated) as | 128 // Send back the default application icon (not resized or desaturated) as |
| 129 // the default response. | 129 // the default response. |
| 130 callback.Run(BitmapToMemory(GetDefaultAppImage())); | 130 callback.Run(BitmapToMemory(GetDefaultAppImage())); |
| (...skipping 206 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 |