OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/nix/mime_util_xdg.h" | 9 #include "base/nix/mime_util_xdg.h" |
10 #include "ui/views/linux_ui/linux_ui.h" | 10 #include "ui/views/linux_ui/linux_ui.h" |
11 | 11 |
12 // static | 12 // static |
13 IconGroupID IconLoader::ReadGroupIDFromFilepath( | 13 IconGroupID IconLoader::ReadGroupIDFromFilepath( |
14 const base::FilePath& filepath) { | 14 const base::FilePath& filepath) { |
15 return base::nix::GetFileMimeType(filepath); | 15 return base::nix::GetFileMimeType(filepath); |
16 } | 16 } |
17 | 17 |
| 18 // static |
18 bool IconLoader::IsIconMutableFromFilepath(const base::FilePath&) { | 19 bool IconLoader::IsIconMutableFromFilepath(const base::FilePath&) { |
19 return false; | 20 return false; |
20 } | 21 } |
21 | 22 |
| 23 // static |
| 24 content::BrowserThread::ID IconLoader::ReadIconThreadID() { |
| 25 // ReadIcon() calls into views::LinuxUI and GTK2 code, so it must be on the UI |
| 26 // thread. |
| 27 return content::BrowserThread::UI; |
| 28 } |
| 29 |
22 void IconLoader::ReadIcon() { | 30 void IconLoader::ReadIcon() { |
23 int size_pixels = 0; | 31 int size_pixels = 0; |
24 switch (icon_size_) { | 32 switch (icon_size_) { |
25 case IconLoader::SMALL: | 33 case IconLoader::SMALL: |
26 size_pixels = 16; | 34 size_pixels = 16; |
27 break; | 35 break; |
28 case IconLoader::NORMAL: | 36 case IconLoader::NORMAL: |
29 size_pixels = 32; | 37 size_pixels = 32; |
30 break; | 38 break; |
31 case IconLoader::LARGE: | 39 case IconLoader::LARGE: |
32 size_pixels = 48; | 40 size_pixels = 48; |
33 break; | 41 break; |
34 default: | 42 default: |
35 NOTREACHED(); | 43 NOTREACHED(); |
36 } | 44 } |
37 | 45 |
38 views::LinuxUI* ui = views::LinuxUI::instance(); | 46 views::LinuxUI* ui = views::LinuxUI::instance(); |
39 if (ui) { | 47 if (ui) { |
40 gfx::Image image = ui->GetIconForContentType(group_, size_pixels); | 48 gfx::Image image = ui->GetIconForContentType(group_, size_pixels); |
41 if (!image.IsEmpty()) | 49 if (!image.IsEmpty()) |
42 image_.reset(new gfx::Image(image)); | 50 image_.reset(new gfx::Image(image)); |
43 } | 51 } |
44 | 52 |
45 target_message_loop_->PostTask( | 53 target_message_loop_->PostTask( |
46 FROM_HERE, base::Bind(&IconLoader::NotifyDelegate, this)); | 54 FROM_HERE, base::Bind(&IconLoader::NotifyDelegate, this)); |
47 } | 55 } |
OLD | NEW |