| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 GetFilePathAndQuery(url_path, &file_path, &query); | 139 GetFilePathAndQuery(url_path, &file_path, &query); |
| 140 ParseQueryParams(query, &scale_factor, &icon_size); | 140 ParseQueryParams(query, &scale_factor, &icon_size); |
| 141 FetchFileIcon(file_path, scale_factor, icon_size, callback); | 141 FetchFileIcon(file_path, scale_factor, icon_size, callback); |
| 142 } | 142 } |
| 143 | 143 |
| 144 std::string FileIconSource::GetMimeType(const std::string&) const { | 144 std::string FileIconSource::GetMimeType(const std::string&) const { |
| 145 // Rely on image decoder inferring the correct type. | 145 // Rely on image decoder inferring the correct type. |
| 146 return std::string(); | 146 return std::string(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 bool FileIconSource::AllowCaching() const { |
| 150 return false; |
| 151 } |
| 152 |
| 149 void FileIconSource::OnFileIconDataAvailable(const IconRequestDetails& details, | 153 void FileIconSource::OnFileIconDataAvailable(const IconRequestDetails& details, |
| 150 gfx::Image* icon) { | 154 gfx::Image* icon) { |
| 151 if (icon) { | 155 if (icon) { |
| 152 scoped_refptr<base::RefCountedBytes> icon_data(new base::RefCountedBytes); | 156 scoped_refptr<base::RefCountedBytes> icon_data(new base::RefCountedBytes); |
| 153 gfx::PNGCodec::EncodeBGRASkBitmap( | 157 gfx::PNGCodec::EncodeBGRASkBitmap( |
| 154 icon->ToImageSkia()->GetRepresentation( | 158 icon->ToImageSkia()->GetRepresentation( |
| 155 details.scale_factor).sk_bitmap(), | 159 details.scale_factor).sk_bitmap(), |
| 156 false, | 160 false, |
| 157 &icon_data->data()); | 161 &icon_data->data()); |
| 158 | 162 |
| 159 details.callback.Run(icon_data.get()); | 163 details.callback.Run(icon_data.get()); |
| 160 } else { | 164 } else { |
| 161 // TODO(glen): send a dummy icon. | 165 // TODO(glen): send a dummy icon. |
| 162 details.callback.Run(NULL); | 166 details.callback.Run(NULL); |
| 163 } | 167 } |
| 164 } | 168 } |
| OLD | NEW |