| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/memory/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 : DataSource(kFileIconPath, MessageLoop::current()) {} | 23 : DataSource(kFileIconPath, MessageLoop::current()) {} |
| 24 | 24 |
| 25 FileIconSource::~FileIconSource() { | 25 FileIconSource::~FileIconSource() { |
| 26 cancelable_consumer_.CancelAllRequests(); | 26 cancelable_consumer_.CancelAllRequests(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void FileIconSource::StartDataRequest(const std::string& path, | 29 void FileIconSource::StartDataRequest(const std::string& path, |
| 30 bool is_incognito, | 30 bool is_incognito, |
| 31 int request_id) { | 31 int request_id) { |
| 32 std::string escaped_path = net::UnescapeURLComponent(path, | 32 std::string escaped_path = net::UnescapeURLComponent(path, |
| 33 UnescapeRule::SPACES); | 33 net::UnescapeRule::SPACES); |
| 34 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
| 35 // The path we receive has the wrong slashes and escaping for what we need; | 35 // The path we receive has the wrong slashes and escaping for what we need; |
| 36 // this only appears to matter for getting icons from .exe files. | 36 // this only appears to matter for getting icons from .exe files. |
| 37 std::replace(escaped_path.begin(), escaped_path.end(), '/', '\\'); | 37 std::replace(escaped_path.begin(), escaped_path.end(), '/', '\\'); |
| 38 FilePath escaped_filepath(UTF8ToWide(escaped_path)); | 38 FilePath escaped_filepath(UTF8ToWide(escaped_path)); |
| 39 #elif defined(OS_POSIX) | 39 #elif defined(OS_POSIX) |
| 40 // The correct encoding on Linux may not actually be UTF8. | 40 // The correct encoding on Linux may not actually be UTF8. |
| 41 FilePath escaped_filepath(escaped_path); | 41 FilePath escaped_filepath(escaped_path); |
| 42 #endif | 42 #endif |
| 43 | 43 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 if (icon) { | 75 if (icon) { |
| 76 scoped_refptr<RefCountedBytes> icon_data(new RefCountedBytes); | 76 scoped_refptr<RefCountedBytes> icon_data(new RefCountedBytes); |
| 77 gfx::PNGCodec::EncodeBGRASkBitmap(*icon, false, &icon_data->data()); | 77 gfx::PNGCodec::EncodeBGRASkBitmap(*icon, false, &icon_data->data()); |
| 78 | 78 |
| 79 SendResponse(request_id, icon_data); | 79 SendResponse(request_id, icon_data); |
| 80 } else { | 80 } else { |
| 81 // TODO(glen): send a dummy icon. | 81 // TODO(glen): send a dummy icon. |
| 82 SendResponse(request_id, NULL); | 82 SendResponse(request_id, NULL); |
| 83 } | 83 } |
| 84 } | 84 } |
| OLD | NEW |