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/icon_loader.h" | 5 #include "chrome/browser/icon_loader.h" |
6 | 6 |
7 #include <gdk-pixbuf/gdk-pixbuf.h> | 7 #include <gdk-pixbuf/gdk-pixbuf.h> |
8 #include <gio/gio.h> | 8 #include <gio/gio.h> |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 | 10 |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "base/mime_util.h" | 14 #include "base/mime_util.h" |
15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
17 | 17 |
18 static int SizeToInt(IconLoader::IconSize size) { | 18 static int SizeToInt(IconLoader::IconSize size) { |
19 int pixels = 48; | 19 int pixels = 0; |
20 if (size == IconLoader::NORMAL) | 20 switch (size) { |
21 pixels = 32; | 21 case IconLoader::SMALL: |
22 else if (size == IconLoader::SMALL) | 22 pixels = 16; |
23 pixels = 16; | 23 break; |
24 | 24 case IconLoader::NORMAL: |
| 25 pixels = 32; |
| 26 break; |
| 27 case IconLoader::LARGE: |
| 28 pixels = 48; |
| 29 break; |
| 30 default: |
| 31 NOTREACHED(); |
| 32 } |
25 return pixels; | 33 return pixels; |
26 } | 34 } |
27 | 35 |
28 void IconLoader::ReadIcon() { | 36 void IconLoader::ReadIcon() { |
29 filename_ = mime_util::GetMimeIcon(group_, SizeToInt(icon_size_)); | 37 filename_ = mime_util::GetMimeIcon(group_, SizeToInt(icon_size_)); |
30 file_util::ReadFileToString(filename_, &icon_data_); | 38 file_util::ReadFileToString(filename_, &icon_data_); |
31 target_message_loop_->PostTask(FROM_HERE, | 39 target_message_loop_->PostTask(FROM_HERE, |
32 NewRunnableMethod(this, &IconLoader::ParseIcon)); | 40 NewRunnableMethod(this, &IconLoader::ParseIcon)); |
33 } | 41 } |
34 | 42 |
(...skipping 19 matching lines...) Expand all Loading... |
54 image_.reset(new gfx::Image(pixbuf)); | 62 image_.reset(new gfx::Image(pixbuf)); |
55 } else { | 63 } else { |
56 LOG(WARNING) << "Unsupported file type or load error: " << | 64 LOG(WARNING) << "Unsupported file type or load error: " << |
57 filename_.value(); | 65 filename_.value(); |
58 } | 66 } |
59 | 67 |
60 g_object_unref(loader); | 68 g_object_unref(loader); |
61 | 69 |
62 NotifyDelegate(); | 70 NotifyDelegate(); |
63 } | 71 } |
OLD | NEW |