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 // static | 19 // static |
20 IconGroupID IconLoader::ReadGroupIDFromFilepath( | 20 IconLoader::IconGroup IconLoader::GroupForFilepath( |
21 const base::FilePath& filepath) { | 21 const base::FilePath& file_path) { |
22 if (!IsIconMutableFromFilepath(filepath)) | 22 if (file_path.MatchesExtension(L".exe") || |
23 return filepath.Extension(); | 23 file_path.MatchesExtension(L".dll") || |
24 return filepath.value(); | 24 file_path.MatchesExtension(L".ico")) { |
| 25 return file_path.value(); |
| 26 } |
| 27 |
| 28 return file_path.Extension(); |
25 } | 29 } |
26 | 30 |
27 // static | 31 // 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() { | 32 content::BrowserThread::ID IconLoader::ReadIconThreadID() { |
36 return content::BrowserThread::FILE; | 33 return content::BrowserThread::FILE; |
37 } | 34 } |
38 | 35 |
39 void IconLoader::ReadIcon() { | 36 void IconLoader::ReadIcon() { |
40 int size = 0; | 37 int size = 0; |
41 switch (icon_size_) { | 38 switch (icon_size_) { |
42 case IconLoader::SMALL: | 39 case IconLoader::SMALL: |
43 size = SHGFI_SMALLICON; | 40 size = SHGFI_SMALLICON; |
44 break; | 41 break; |
(...skipping 21 matching lines...) Expand all Loading... |
66 image_skia.MakeThreadSafe(); | 63 image_skia.MakeThreadSafe(); |
67 image_.reset(new gfx::Image(image_skia)); | 64 image_.reset(new gfx::Image(image_skia)); |
68 DestroyIcon(file_info.hIcon); | 65 DestroyIcon(file_info.hIcon); |
69 } | 66 } |
70 } | 67 } |
71 | 68 |
72 // Always notify the delegate, regardless of success. | 69 // Always notify the delegate, regardless of success. |
73 target_task_runner_->PostTask(FROM_HERE, | 70 target_task_runner_->PostTask(FROM_HERE, |
74 base::Bind(&IconLoader::NotifyDelegate, this)); | 71 base::Bind(&IconLoader::NotifyDelegate, this)); |
75 } | 72 } |
OLD | NEW |