| 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/fileicon_source.h" | 5 #include "chrome/browser/ui/webui/fileicon_source.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 FileIconSource::FileIconSource() {} | 99 FileIconSource::FileIconSource() {} |
| 100 | 100 |
| 101 FileIconSource::~FileIconSource() {} | 101 FileIconSource::~FileIconSource() {} |
| 102 | 102 |
| 103 void FileIconSource::FetchFileIcon( | 103 void FileIconSource::FetchFileIcon( |
| 104 const base::FilePath& path, | 104 const base::FilePath& path, |
| 105 ui::ScaleFactor scale_factor, | 105 ui::ScaleFactor scale_factor, |
| 106 IconLoader::IconSize icon_size, | 106 IconLoader::IconSize icon_size, |
| 107 const content::URLDataSource::GotDataCallback& callback) { | 107 const content::URLDataSource::GotDataCallback& callback) { |
| 108 IconManager* im = g_browser_process->icon_manager(); | 108 IconManager* im = g_browser_process->icon_manager(); |
| 109 gfx::Image* icon = im->LookupIcon(path, icon_size); | 109 gfx::Image* icon = im->LookupIconFromFilepath(path, icon_size); |
| 110 | 110 |
| 111 if (icon) { | 111 if (icon) { |
| 112 scoped_refptr<base::RefCountedBytes> icon_data(new base::RefCountedBytes); | 112 scoped_refptr<base::RefCountedBytes> icon_data(new base::RefCountedBytes); |
| 113 gfx::PNGCodec::EncodeBGRASkBitmap( | 113 gfx::PNGCodec::EncodeBGRASkBitmap( |
| 114 icon->ToImageSkia()->GetRepresentation(scale_factor).sk_bitmap(), | 114 icon->ToImageSkia()->GetRepresentation(scale_factor).sk_bitmap(), |
| 115 false, &icon_data->data()); | 115 false, &icon_data->data()); |
| 116 | 116 |
| 117 callback.Run(icon_data); | 117 callback.Run(icon_data); |
| 118 } else { | 118 } else { |
| 119 // Attach the ChromeURLDataManager request ID to the history request. | 119 // Attach the ChromeURLDataManager request ID to the history request. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 .sk_bitmap(), | 161 .sk_bitmap(), |
| 162 false, | 162 false, |
| 163 &icon_data->data()); | 163 &icon_data->data()); |
| 164 | 164 |
| 165 details.callback.Run(icon_data); | 165 details.callback.Run(icon_data); |
| 166 } else { | 166 } else { |
| 167 // TODO(glen): send a dummy icon. | 167 // TODO(glen): send a dummy icon. |
| 168 details.callback.Run(NULL); | 168 details.callback.Run(NULL); |
| 169 } | 169 } |
| 170 } | 170 } |
| OLD | NEW |