1 // Copyright 2015 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/component_extensions_whitelist/whitelist.h"
7 #include "base/logging.h"
8 #include "base/macros.h"
9 #include "chrome/common/extensions/extension_constants.h"
10 #include "extensions/common/constants.h"
11 #include "grit/browser_resources.h"
13 #if defined(ENABLE_APP_LIST) && defined(OS_CHROMEOS)
14 #include "chrome/browser/ui/app_list/google_now_extension.h"
17 #if defined(OS_CHROMEOS)
18 #include "chrome/browser/chromeos/input_method/component_extension_ime_manager_impl.h"
19 #include "components/chrome_apps/grit/chrome_apps_resources.h"
20 #include "grit/keyboard_resources.h"
21 #include "ui/file_manager/grit/file_manager_resources.h"
24 namespace extensions
{
26 bool IsComponentExtensionWhitelisted(const std::string
& extension_id
) {
27 const char* allowed
[] = {
28 extension_misc::kHotwordSharedModuleId
,
29 extension_misc::kInAppPaymentsSupportAppId
,
30 #if defined(ENABLE_MEDIA_ROUTER)
31 extension_misc::kMediaRouterStableExtensionId
,
32 #endif // defined(ENABLE_MEDIA_ROUTER)
33 extension_misc::kPdfExtensionId
,
34 #if defined(OS_CHROMEOS)
35 extension_misc::kChromeVoxExtensionId
,
36 extension_misc::kSpeechSynthesisExtensionId
,
37 extension_misc::kZIPUnpackerExtensionId
,
41 for (size_t i
= 0; i
< arraysize(allowed
); ++i
) {
42 if (extension_id
== allowed
[i
])
46 #if defined(ENABLE_APP_LIST) && defined(OS_CHROMEOS)
47 std::string google_now_extension_id
;
48 if (GetGoogleNowExtensionId(&google_now_extension_id
) &&
49 google_now_extension_id
== extension_id
)
53 #if defined(OS_CHROMEOS)
54 if (chromeos::ComponentExtensionIMEManagerImpl::IsIMEExtensionID(
59 LOG(ERROR
) << "Component extension with id " << extension_id
<< " not in "
60 << "whitelist and is not being loaded as a result.";
65 bool IsComponentExtensionWhitelisted(int manifest_resource_id
) {
67 IDR_BOOKMARKS_MANIFEST
,
68 IDR_CHROME_APP_MANIFEST
,
69 IDR_CLOUDPRINT_MANIFEST
,
70 IDR_CONNECTIVITY_DIAGNOSTICS_MANIFEST
,
71 IDR_CRYPTOTOKEN_MANIFEST
,
72 IDR_FEEDBACK_MANIFEST
,
73 IDR_GAIA_AUTH_MANIFEST
,
74 IDR_GOOGLE_NOW_MANIFEST
,
75 IDR_HANGOUT_SERVICES_MANIFEST
,
76 IDR_HOTWORD_AUDIO_VERIFICATION_MANIFEST
,
78 IDR_IDENTITY_API_SCOPE_APPROVAL_MANIFEST
,
79 IDR_NETWORK_SPEECH_SYNTHESIS_MANIFEST
,
80 IDR_SETTINGS_APP_MANIFEST
,
81 IDR_WALLPAPERMANAGER_MANIFEST
,
82 IDR_WEBSTORE_MANIFEST
,
83 IDR_WHISPERNET_PROXY_MANIFEST
,
84 #if defined(IMAGE_LOADER_EXTENSION)
85 IDR_IMAGE_LOADER_MANIFEST
,
87 #if defined(OS_CHROMEOS)
88 IDR_AUDIO_PLAYER_MANIFEST
,
89 IDR_CHROME_APPS_WEBSTORE_WIDGET_MANIFEST
,
90 IDR_CONNECTIVITY_DIAGNOSTICS_LAUNCHER_MANIFEST
,
91 IDR_CONNECTIVITY_DIAGNOSTICS_MANIFEST
,
92 IDR_CROSH_BUILTIN_MANIFEST
,
93 IDR_DEMO_APP_MANIFEST
,
94 IDR_EASY_UNLOCK_MANIFEST
,
95 IDR_EASY_UNLOCK_MANIFEST_SIGNIN
,
97 IDR_FILEMANAGER_MANIFEST
,
98 IDR_FIRST_RUN_DIALOG_MANIFEST
,
100 IDR_GENIUS_APP_MANIFEST
,
102 IDR_KEYBOARD_MANIFEST
,
104 IDR_QUICKOFFICE_MANIFEST
,
105 IDR_VIDEO_PLAYER_MANIFEST
,
106 IDR_WALLPAPERMANAGER_MANIFEST
,
110 for (size_t i
= 0; i
< arraysize(allowed
); ++i
) {
111 if (manifest_resource_id
== allowed
[i
])
115 LOG(ERROR
) << "Component extension with manifest resource id "
116 << manifest_resource_id
<< " not in whitelist and is not being "
117 << "loaded as a result.";
122 } // namespace extensions