| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dom_ui/fileicon_source.h" | 5 #include "chrome/browser/dom_ui/fileicon_source.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/ref_counted_memory.h" | 9 #include "base/ref_counted_memory.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 IconManager::Handle h = im->LoadIcon(escaped_filepath, | 52 IconManager::Handle h = im->LoadIcon(escaped_filepath, |
| 53 IconLoader::NORMAL, | 53 IconLoader::NORMAL, |
| 54 &cancelable_consumer_, | 54 &cancelable_consumer_, |
| 55 NewCallback(this, &FileIconSource::OnFileIconDataAvailable)); | 55 NewCallback(this, &FileIconSource::OnFileIconDataAvailable)); |
| 56 | 56 |
| 57 // Attach the ChromeURLDataManager request ID to the history request. | 57 // Attach the ChromeURLDataManager request ID to the history request. |
| 58 cancelable_consumer_.SetClientData(im, h, request_id); | 58 cancelable_consumer_.SetClientData(im, h, request_id); |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 std::string FileIconSource::GetMimeType(const std::string&) const { |
| 63 // Rely on image decoder inferring the correct type. |
| 64 return std::string(); |
| 65 } |
| 66 |
| 62 void FileIconSource::OnFileIconDataAvailable(IconManager::Handle handle, | 67 void FileIconSource::OnFileIconDataAvailable(IconManager::Handle handle, |
| 63 SkBitmap* icon) { | 68 SkBitmap* icon) { |
| 64 IconManager* im = g_browser_process->icon_manager(); | 69 IconManager* im = g_browser_process->icon_manager(); |
| 65 int request_id = cancelable_consumer_.GetClientData(im, handle); | 70 int request_id = cancelable_consumer_.GetClientData(im, handle); |
| 66 | 71 |
| 67 if (icon) { | 72 if (icon) { |
| 68 scoped_refptr<RefCountedBytes> icon_data(new RefCountedBytes); | 73 scoped_refptr<RefCountedBytes> icon_data(new RefCountedBytes); |
| 69 gfx::PNGCodec::EncodeBGRASkBitmap(*icon, false, &icon_data->data); | 74 gfx::PNGCodec::EncodeBGRASkBitmap(*icon, false, &icon_data->data); |
| 70 | 75 |
| 71 SendResponse(request_id, icon_data); | 76 SendResponse(request_id, icon_data); |
| 72 } else { | 77 } else { |
| 73 // TODO(glen): send a dummy icon. | 78 // TODO(glen): send a dummy icon. |
| 74 SendResponse(request_id, NULL); | 79 SendResponse(request_id, NULL); |
| 75 } | 80 } |
| 76 } | 81 } |
| OLD | NEW |