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 <windows.h> | 7 #include <windows.h> |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
13 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
14 #include "ui/display/win/dpi.h" | 14 #include "ui/display/win/dpi.h" |
15 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
16 #include "ui/gfx/icon_util.h" | 16 #include "ui/gfx/icon_util.h" |
17 #include "ui/gfx/image/image_skia.h" | 17 #include "ui/gfx/image/image_skia.h" |
18 | 18 |
| 19 namespace { |
| 20 |
| 21 bool IsInstanceIconForFilepath(const base::FilePath& filepath) { |
| 22 return filepath.MatchesExtension(L".exe") || |
| 23 filepath.MatchesExtension(L".dll") || |
| 24 filepath.MatchesExtension(L".ico"); |
| 25 } |
| 26 |
| 27 } // namespace |
| 28 |
19 // static | 29 // static |
20 IconGroupID IconLoader::ReadGroupIDFromFilepath( | 30 IconLoader::IconGroup IconLoader::GroupForFilepath( |
21 const base::FilePath& filepath) { | 31 const base::FilePath& filepath) { |
22 if (!IsIconMutableFromFilepath(filepath)) | 32 if (!IsInstanceIconForFilepath(filepath)) |
23 return filepath.Extension(); | 33 return filepath.Extension(); |
24 return filepath.value(); | 34 return filepath.value(); |
25 } | 35 } |
26 | 36 |
27 // static | 37 // static |
28 bool IconLoader::IsIconMutableFromFilepath(const base::FilePath& filepath) { | |
29 return filepath.MatchesExtension(L".exe") || | |
30 filepath.MatchesExtension(L".dll") || | |
31 filepath.MatchesExtension(L".ico"); | |
32 } | |
33 | |
34 // static | |
35 content::BrowserThread::ID IconLoader::ReadIconThreadID() { | 38 content::BrowserThread::ID IconLoader::ReadIconThreadID() { |
36 return content::BrowserThread::FILE; | 39 return content::BrowserThread::FILE; |
37 } | 40 } |
38 | 41 |
39 void IconLoader::ReadIcon() { | 42 void IconLoader::ReadIcon() { |
40 int size = 0; | 43 int size = 0; |
41 switch (icon_size_) { | 44 switch (icon_size_) { |
42 case IconLoader::SMALL: | 45 case IconLoader::SMALL: |
43 size = SHGFI_SMALLICON; | 46 size = SHGFI_SMALLICON; |
44 break; | 47 break; |
(...skipping 21 matching lines...) Expand all Loading... |
66 image_skia.MakeThreadSafe(); | 69 image_skia.MakeThreadSafe(); |
67 image_.reset(new gfx::Image(image_skia)); | 70 image_.reset(new gfx::Image(image_skia)); |
68 DestroyIcon(file_info.hIcon); | 71 DestroyIcon(file_info.hIcon); |
69 } | 72 } |
70 } | 73 } |
71 | 74 |
72 // Always notify the delegate, regardless of success. | 75 // Always notify the delegate, regardless of success. |
73 target_task_runner_->PostTask(FROM_HERE, | 76 target_task_runner_->PostTask(FROM_HERE, |
74 base::Bind(&IconLoader::NotifyDelegate, this)); | 77 base::Bind(&IconLoader::NotifyDelegate, this)); |
75 } | 78 } |
OLD | NEW |