| 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/extensions/image_loader.h" | 5 #include "chrome/browser/extensions/image_loader.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/threading/sequenced_worker_pool.h" | 12 #include "base/threading/sequenced_worker_pool.h" |
| 13 #include "chrome/browser/extensions/image_loader_factory.h" | 13 #include "chrome/browser/extensions/image_loader_factory.h" |
| 14 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
| 15 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
| 16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 #include "grit/chrome_unscaled_resources.h" | 17 #include "grit/chrome_unscaled_resources.h" |
| 18 #include "grit/component_extension_resources_map.h" | 18 #include "grit/component_extension_resources_map.h" |
| 19 #include "grit/keyboard_resources.h" | |
| 20 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
| 21 #include "skia/ext/image_operations.h" | 20 #include "skia/ext/image_operations.h" |
| 22 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| 23 #include "ui/gfx/image/image_skia.h" | 22 #include "ui/gfx/image/image_skia.h" |
| 24 #include "webkit/glue/image_decoder.h" | 23 #include "webkit/glue/image_decoder.h" |
| 25 | 24 |
| 26 #if defined(USE_AURA) | |
| 27 #include "grit/keyboard_resources.h" | |
| 28 #endif | |
| 29 | |
| 30 using content::BrowserThread; | 25 using content::BrowserThread; |
| 31 using extensions::Extension; | 26 using extensions::Extension; |
| 32 using extensions::ImageLoader; | 27 using extensions::ImageLoader; |
| 33 using extensions::Manifest; | 28 using extensions::Manifest; |
| 34 | 29 |
| 35 namespace { | 30 namespace { |
| 36 | 31 |
| 37 bool ShouldResizeImageRepresentation( | 32 bool ShouldResizeImageRepresentation( |
| 38 ImageLoader::ImageRepresentation::ResizeCondition resize_method, | 33 ImageLoader::ImageRepresentation::ResizeCondition resize_method, |
| 39 const gfx::Size& decoded_size, | 34 const gfx::Size& decoded_size, |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 {"web_store/webstore_icon_128.png", IDR_WEBSTORE_ICON}, | 163 {"web_store/webstore_icon_128.png", IDR_WEBSTORE_ICON}, |
| 169 {"web_store/webstore_icon_16.png", IDR_WEBSTORE_ICON_16}, | 164 {"web_store/webstore_icon_16.png", IDR_WEBSTORE_ICON_16}, |
| 170 {"chrome_app/product_logo_128.png", IDR_PRODUCT_LOGO_128}, | 165 {"chrome_app/product_logo_128.png", IDR_PRODUCT_LOGO_128}, |
| 171 {"chrome_app/product_logo_16.png", IDR_PRODUCT_LOGO_16}, | 166 {"chrome_app/product_logo_16.png", IDR_PRODUCT_LOGO_16}, |
| 172 #if defined(ENABLE_SETTINGS_APP) | 167 #if defined(ENABLE_SETTINGS_APP) |
| 173 {"settings_app/settings_app_icon_128.png", IDR_SETTINGS_APP_ICON_128}, | 168 {"settings_app/settings_app_icon_128.png", IDR_SETTINGS_APP_ICON_128}, |
| 174 {"settings_app/settings_app_icon_16.png", IDR_SETTINGS_APP_ICON_16}, | 169 {"settings_app/settings_app_icon_16.png", IDR_SETTINGS_APP_ICON_16}, |
| 175 {"settings_app/settings_app_icon_32.png", IDR_SETTINGS_APP_ICON_32}, | 170 {"settings_app/settings_app_icon_32.png", IDR_SETTINGS_APP_ICON_32}, |
| 176 {"settings_app/settings_app_icon_48.png", IDR_SETTINGS_APP_ICON_48}, | 171 {"settings_app/settings_app_icon_48.png", IDR_SETTINGS_APP_ICON_48}, |
| 177 #endif | 172 #endif |
| 178 #if defined(USE_AURA) | |
| 179 {"keyboard/index.html", IDR_KEYBOARD_INDEX}, | |
| 180 {"keyboard/main.css", IDR_KEYBOARD_MAIN_CSS}, | |
| 181 {"keyboard/main.js", IDR_KEYBOARD_MAIN_JS}, | |
| 182 {"keyboard/common.js", IDR_KEYBOARD_COMMON_JS}, | |
| 183 {"keyboard/layout_us.js", IDR_KEYBOARD_LAYOUT_US_JS}, | |
| 184 {"keyboard/images/chevron.svg", IDR_KEYBOARD_IMAGES_CHEVRON}, | |
| 185 {"keyboard/images/del.svg", IDR_KEYBOARD_IMAGES_DEL}, | |
| 186 {"keyboard/images/keyboard.svg", IDR_KEYBOARD_IMAGES_KEYBOARD}, | |
| 187 {"keyboard/images/mic.svg", IDR_KEYBOARD_IMAGES_MIC}, | |
| 188 {"keyboard/images/ret.svg", IDR_KEYBOARD_IMAGES_RET}, | |
| 189 {"keyboard/images/shift_down.svg", IDR_KEYBOARD_IMAGES_SHIFT_DOWN}, | |
| 190 {"keyboard/images/shift.svg", IDR_KEYBOARD_IMAGES_SHIFT}, | |
| 191 {"keyboard/images/tab.svg", IDR_KEYBOARD_IMAGES_TAB}, | |
| 192 #endif | |
| 193 }; | 173 }; |
| 194 static const size_t kExtraComponentExtensionResourcesSize = | 174 static const size_t kExtraComponentExtensionResourcesSize = |
| 195 arraysize(kExtraComponentExtensionResources); | 175 arraysize(kExtraComponentExtensionResources); |
| 196 | 176 |
| 197 base::FilePath directory_path = extension_path; | 177 base::FilePath directory_path = extension_path; |
| 198 base::FilePath resources_dir; | 178 base::FilePath resources_dir; |
| 199 base::FilePath relative_path; | 179 base::FilePath relative_path; |
| 200 if (!PathService::Get(chrome::DIR_RESOURCES, &resources_dir) || | 180 if (!PathService::Get(chrome::DIR_RESOURCES, &resources_dir) || |
| 201 !resources_dir.AppendRelativePath(directory_path, &relative_path)) { | 181 !resources_dir.AppendRelativePath(directory_path, &relative_path)) { |
| 202 return false; | 182 return false; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 gfx::Image image; | 312 gfx::Image image; |
| 333 if (!image_skia.isNull()) { | 313 if (!image_skia.isNull()) { |
| 334 image_skia.MakeThreadSafe(); | 314 image_skia.MakeThreadSafe(); |
| 335 image = gfx::Image(image_skia); | 315 image = gfx::Image(image_skia); |
| 336 } | 316 } |
| 337 | 317 |
| 338 callback.Run(image); | 318 callback.Run(image); |
| 339 } | 319 } |
| 340 | 320 |
| 341 } // namespace extensions | 321 } // namespace extensions |
| OLD | NEW |