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/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/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/extensions/extension_system.h" | 18 #include "chrome/browser/extensions/extension_system.h" |
19 #include "chrome/browser/extensions/image_loader.h" | 19 #include "chrome/browser/extensions/image_loader.h" |
20 #include "chrome/browser/favicon/favicon_service_factory.h" | 20 #include "chrome/browser/favicon/favicon_service_factory.h" |
21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/common/extensions/extension.h" | 22 #include "chrome/common/extensions/extension.h" |
23 #include "chrome/common/extensions/extension_constants.h" | 23 #include "chrome/common/extensions/extension_constants.h" |
24 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 24 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
25 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" | 25 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" |
26 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
| 27 #include "content/public/child/image_decoder_utils.h" |
27 #include "extensions/common/extension_resource.h" | 28 #include "extensions/common/extension_resource.h" |
28 #include "googleurl/src/gurl.h" | 29 #include "googleurl/src/gurl.h" |
29 #include "grit/component_extension_resources_map.h" | 30 #include "grit/component_extension_resources_map.h" |
30 #include "grit/theme_resources.h" | 31 #include "grit/theme_resources.h" |
31 #include "skia/ext/image_operations.h" | 32 #include "skia/ext/image_operations.h" |
32 #include "ui/base/layout.h" | 33 #include "ui/base/layout.h" |
33 #include "ui/base/resource/resource_bundle.h" | 34 #include "ui/base/resource/resource_bundle.h" |
34 #include "ui/gfx/codec/png_codec.h" | 35 #include "ui/gfx/codec/png_codec.h" |
35 #include "ui/gfx/color_utils.h" | 36 #include "ui/gfx/color_utils.h" |
36 #include "ui/gfx/favicon_size.h" | 37 #include "ui/gfx/favicon_size.h" |
| 38 #include "ui/gfx/size.h" |
37 #include "ui/gfx/skbitmap_operations.h" | 39 #include "ui/gfx/skbitmap_operations.h" |
38 #include "webkit/glue/image_decoder.h" | |
39 | 40 |
40 namespace { | 41 namespace { |
41 | 42 |
42 scoped_refptr<base::RefCountedMemory> BitmapToMemory(const SkBitmap* image) { | 43 scoped_refptr<base::RefCountedMemory> BitmapToMemory(const SkBitmap* image) { |
43 base::RefCountedBytes* image_bytes = new base::RefCountedBytes; | 44 base::RefCountedBytes* image_bytes = new base::RefCountedBytes; |
44 gfx::PNGCodec::EncodeBGRASkBitmap(*image, false, &image_bytes->data()); | 45 gfx::PNGCodec::EncodeBGRASkBitmap(*image, false, &image_bytes->data()); |
45 return image_bytes; | 46 return image_bytes; |
46 } | 47 } |
47 | 48 |
48 SkBitmap DesaturateImage(const SkBitmap* image) { | 49 SkBitmap DesaturateImage(const SkBitmap* image) { |
49 color_utils::HSL shift = {-1, 0, 0.6}; | 50 color_utils::HSL shift = {-1, 0, 0.6}; |
50 return SkBitmapOperations::CreateHSLShiftedBitmap(*image, shift); | 51 return SkBitmapOperations::CreateHSLShiftedBitmap(*image, shift); |
51 } | 52 } |
52 | 53 |
53 SkBitmap* ToBitmap(const unsigned char* data, size_t size) { | 54 SkBitmap* ToBitmap(const unsigned char* data, size_t size) { |
54 webkit_glue::ImageDecoder decoder; | |
55 SkBitmap* decoded = new SkBitmap(); | 55 SkBitmap* decoded = new SkBitmap(); |
56 *decoded = decoder.Decode(data, size); | 56 *decoded = content::DecodeImage(data, gfx::Size(), size); |
57 return decoded; | 57 return decoded; |
58 } | 58 } |
59 | 59 |
60 } // namespace | 60 } // namespace |
61 | 61 |
62 ExtensionIconSource::ExtensionIconSource(Profile* profile) | 62 ExtensionIconSource::ExtensionIconSource(Profile* profile) |
63 : profile_(profile) { | 63 : profile_(profile) { |
64 } | 64 } |
65 | 65 |
66 struct ExtensionIconSource::ExtensionIconRequest { | 66 struct ExtensionIconSource::ExtensionIconRequest { |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 | 340 |
341 void ExtensionIconSource::ClearData(int request_id) { | 341 void ExtensionIconSource::ClearData(int request_id) { |
342 std::map<int, ExtensionIconRequest*>::iterator i = | 342 std::map<int, ExtensionIconRequest*>::iterator i = |
343 request_map_.find(request_id); | 343 request_map_.find(request_id); |
344 if (i == request_map_.end()) | 344 if (i == request_map_.end()) |
345 return; | 345 return; |
346 | 346 |
347 delete i->second; | 347 delete i->second; |
348 request_map_.erase(i); | 348 request_map_.erase(i); |
349 } | 349 } |
OLD | NEW |