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/icon_loader.h" | 5 #include "chrome/browser/icon_loader.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 } | 33 } |
34 | 34 |
35 FilePath filename = base::nix::GetMimeIcon(group_, size_pixels); | 35 FilePath filename = base::nix::GetMimeIcon(group_, size_pixels); |
36 // We don't support SVG icons; this just spams the terminal so fail quickly | 36 // We don't support SVG icons; this just spams the terminal so fail quickly |
37 // and don't try to read the file from disk first. | 37 // and don't try to read the file from disk first. |
38 if (filename.Extension() != ".svg") { | 38 if (filename.Extension() != ".svg") { |
39 string icon_data; | 39 string icon_data; |
40 file_util::ReadFileToString(filename, &icon_data); | 40 file_util::ReadFileToString(filename, &icon_data); |
41 | 41 |
42 webkit_glue::ImageDecoder decoder; | 42 webkit_glue::ImageDecoder decoder; |
43 scoped_ptr<SkBitmap> bitmap(new SkBitmap()); | 43 SkBitmap bitmap; |
44 *bitmap = decoder.Decode( | 44 bitmap = decoder.Decode( |
45 reinterpret_cast<const unsigned char*>(icon_data.data()), | 45 reinterpret_cast<const unsigned char*>(icon_data.data()), |
46 icon_data.length()); | 46 icon_data.length()); |
47 if (!bitmap->empty()) { | 47 if (!bitmap.empty()) { |
48 DCHECK_EQ(size_pixels, bitmap->width()); | 48 DCHECK_EQ(size_pixels, bitmap.width()); |
49 DCHECK_EQ(size_pixels, bitmap->height()); | 49 DCHECK_EQ(size_pixels, bitmap.height()); |
50 image_.reset(new gfx::Image(bitmap.release())); | 50 image_.reset(new gfx::Image(bitmap)); |
51 } else { | 51 } else { |
52 LOG(WARNING) << "Unsupported file type or load error: " | 52 LOG(WARNING) << "Unsupported file type or load error: " |
53 << filename.value(); | 53 << filename.value(); |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 target_message_loop_->PostTask( | 57 target_message_loop_->PostTask( |
58 FROM_HERE, base::Bind(&IconLoader::NotifyDelegate, this)); | 58 FROM_HERE, base::Bind(&IconLoader::NotifyDelegate, this)); |
59 } | 59 } |
OLD | NEW |