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/ui/webui/extensions/extension_icon_source.h" | 5 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/memory/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 #include "base/string_split.h" | 12 #include "base/string_split.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
16 #include "chrome/browser/extensions/extension_prefs.h" | 16 #include "chrome/browser/extensions/extension_prefs.h" |
17 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
20 #include "chrome/common/extensions/extension_resource.h" | 20 #include "chrome/common/extensions/extension_resource.h" |
21 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| 22 #include "googleurl/src/gurl.h" |
22 #include "grit/component_extension_resources_map.h" | 23 #include "grit/component_extension_resources_map.h" |
23 #include "grit/theme_resources.h" | 24 #include "grit/theme_resources.h" |
24 #include "googleurl/src/gurl.h" | |
25 #include "skia/ext/image_operations.h" | 25 #include "skia/ext/image_operations.h" |
| 26 #include "ui/base/layout.h" |
26 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
27 #include "ui/gfx/codec/png_codec.h" | 28 #include "ui/gfx/codec/png_codec.h" |
28 #include "ui/gfx/color_utils.h" | 29 #include "ui/gfx/color_utils.h" |
29 #include "ui/gfx/skbitmap_operations.h" | 30 #include "ui/gfx/skbitmap_operations.h" |
30 #include "webkit/glue/image_decoder.h" | 31 #include "webkit/glue/image_decoder.h" |
31 | 32 |
32 namespace { | 33 namespace { |
33 | 34 |
34 scoped_refptr<base::RefCountedMemory> BitmapToMemory(const SkBitmap* image) { | 35 scoped_refptr<base::RefCountedMemory> BitmapToMemory(const SkBitmap* image) { |
35 base::RefCountedBytes* image_bytes = new base::RefCountedBytes; | 36 base::RefCountedBytes* image_bytes = new base::RefCountedBytes; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 icon_size, | 84 icon_size, |
84 match, | 85 match, |
85 grayscale ? "?grayscale=true" : "")); | 86 grayscale ? "?grayscale=true" : "")); |
86 CHECK(icon_url.is_valid()); | 87 CHECK(icon_url.is_valid()); |
87 return icon_url; | 88 return icon_url; |
88 } | 89 } |
89 | 90 |
90 // static | 91 // static |
91 SkBitmap* ExtensionIconSource::LoadImageByResourceId(int resource_id) { | 92 SkBitmap* ExtensionIconSource::LoadImageByResourceId(int resource_id) { |
92 std::string contents = ResourceBundle::GetSharedInstance() | 93 std::string contents = ResourceBundle::GetSharedInstance() |
93 .GetRawDataResource(resource_id).as_string(); | 94 .GetRawDataResource(resource_id, |
| 95 ui::SCALE_FACTOR_100P).as_string(); |
94 | 96 |
95 // Convert and return it. | 97 // Convert and return it. |
96 const unsigned char* data = | 98 const unsigned char* data = |
97 reinterpret_cast<const unsigned char*>(contents.data()); | 99 reinterpret_cast<const unsigned char*>(contents.data()); |
98 return ToBitmap(data, contents.length()); | 100 return ToBitmap(data, contents.length()); |
99 } | 101 } |
100 | 102 |
101 std::string ExtensionIconSource::GetMimeType(const std::string&) const { | 103 std::string ExtensionIconSource::GetMimeType(const std::string&) const { |
102 // We need to explicitly return a mime type, otherwise if the user tries to | 104 // We need to explicitly return a mime type, otherwise if the user tries to |
103 // drag the image they get no extension. | 105 // drag the image they get no extension. |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 | 338 |
337 void ExtensionIconSource::ClearData(int request_id) { | 339 void ExtensionIconSource::ClearData(int request_id) { |
338 std::map<int, ExtensionIconRequest*>::iterator i = | 340 std::map<int, ExtensionIconRequest*>::iterator i = |
339 request_map_.find(request_id); | 341 request_map_.find(request_id); |
340 if (i == request_map_.end()) | 342 if (i == request_map_.end()) |
341 return; | 343 return; |
342 | 344 |
343 delete i->second; | 345 delete i->second; |
344 request_map_.erase(i); | 346 request_map_.erase(i); |
345 } | 347 } |
OLD | NEW |