Remove keyboard_ui.css and manifest_keyboard.json
[chromium-blink-merge.git] / chrome / browser / extensions / chrome_component_extension_resource_manager.cc
blob969069a0dd3632f9f6ed63e3a493be873fa3f7d9
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/extensions/chrome_component_extension_resource_manager.h"
7 #include "base/logging.h"
8 #include "base/path_service.h"
9 #include "chrome/common/chrome_paths.h"
10 #include "grit/chrome_unscaled_resources.h"
11 #include "grit/component_extension_resources_map.h"
12 #include "grit/theme_resources.h"
14 #if defined(OS_CHROMEOS)
15 #include "components/chrome_apps/chrome_apps_resource_util.h"
16 #include "ui/file_manager/file_manager_resource_util.h"
17 #endif
19 #if defined(USE_AURA)
20 #include "ui/keyboard/keyboard_util.h"
21 #endif
23 namespace extensions {
25 ChromeComponentExtensionResourceManager::
26 ChromeComponentExtensionResourceManager() {
27 static const GritResourceMap kExtraComponentExtensionResources[] = {
28 {"web_store/webstore_icon_128.png", IDR_WEBSTORE_ICON},
29 {"web_store/webstore_icon_16.png", IDR_WEBSTORE_ICON_16},
30 {"chrome_app/product_logo_128.png", IDR_PRODUCT_LOGO_128},
31 {"chrome_app/product_logo_16.png", IDR_PRODUCT_LOGO_16},
32 #if defined(OS_CHROMEOS)
33 {"webstore_widget/app/icons/icon_16.png", IDR_WEBSTORE_ICON_16},
34 {"webstore_widget/app/icons/icon_32.png", IDR_WEBSTORE_ICON_32},
35 {"webstore_widget/app/icons/icon_128.png", IDR_WEBSTORE_ICON},
36 #endif
37 #if defined(ENABLE_SETTINGS_APP)
38 {"settings_app/settings_app_icon_128.png", IDR_SETTINGS_APP_ICON_128},
39 {"settings_app/settings_app_icon_16.png", IDR_SETTINGS_APP_ICON_16},
40 {"settings_app/settings_app_icon_32.png", IDR_SETTINGS_APP_ICON_32},
41 {"settings_app/settings_app_icon_48.png", IDR_SETTINGS_APP_ICON_48},
42 #endif
45 AddComponentResourceEntries(
46 kComponentExtensionResources,
47 kComponentExtensionResourcesSize);
48 AddComponentResourceEntries(
49 kExtraComponentExtensionResources,
50 arraysize(kExtraComponentExtensionResources));
51 #if defined(OS_CHROMEOS)
52 size_t chrome_apps_resource_size;
53 const GritResourceMap* chrome_apps_resources =
54 chrome_apps::GetChromeAppsResources(&chrome_apps_resource_size);
55 AddComponentResourceEntries(
56 chrome_apps_resources,
57 chrome_apps_resource_size);
59 size_t file_manager_resource_size;
60 const GritResourceMap* file_manager_resources =
61 file_manager::GetFileManagerResources(&file_manager_resource_size);
62 AddComponentResourceEntries(
63 file_manager_resources,
64 file_manager_resource_size);
66 size_t keyboard_resource_size;
67 const GritResourceMap* keyboard_resources =
68 keyboard::GetKeyboardExtensionResources(&keyboard_resource_size);
69 AddComponentResourceEntries(
70 keyboard_resources,
71 keyboard_resource_size);
72 #endif
75 ChromeComponentExtensionResourceManager::
76 ~ChromeComponentExtensionResourceManager() {}
78 bool ChromeComponentExtensionResourceManager::IsComponentExtensionResource(
79 const base::FilePath& extension_path,
80 const base::FilePath& resource_path,
81 int* resource_id) const {
82 base::FilePath directory_path = extension_path;
83 base::FilePath resources_dir;
84 base::FilePath relative_path;
85 if (!PathService::Get(chrome::DIR_RESOURCES, &resources_dir) ||
86 !resources_dir.AppendRelativePath(directory_path, &relative_path)) {
87 return false;
89 relative_path = relative_path.Append(resource_path);
90 relative_path = relative_path.NormalizePathSeparators();
92 std::map<base::FilePath, int>::const_iterator entry =
93 path_to_resource_id_.find(relative_path);
94 if (entry != path_to_resource_id_.end())
95 *resource_id = entry->second;
97 return entry != path_to_resource_id_.end();
100 void ChromeComponentExtensionResourceManager::AddComponentResourceEntries(
101 const GritResourceMap* entries,
102 size_t size) {
103 for (size_t i = 0; i < size; ++i) {
104 base::FilePath resource_path = base::FilePath().AppendASCII(
105 entries[i].name);
106 resource_path = resource_path.NormalizePathSeparators();
108 DCHECK(path_to_resource_id_.find(resource_path) ==
109 path_to_resource_id_.end());
110 path_to_resource_id_[resource_path] = entries[i].value;
114 } // namespace extensions