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/browser/bookmarks/enhanced_bookmarks_features.h"
10 #include "chrome/common/extensions/extension_constants.h"
11 #include "extensions/common/constants.h"
12 #include "grit/browser_resources.h"
14 #if defined(ENABLE_APP_LIST) && defined(OS_CHROMEOS)
15 #include "chrome/browser/ui/app_list/google_now_extension.h"
18 #if defined(OS_CHROMEOS)
19 #include "chrome/browser/chromeos/input_method/component_extension_ime_manager_impl.h"
20 #include "components/chrome_apps/grit/chrome_apps_resources.h"
21 #include "grit/keyboard_resources.h"
22 #include "ui/file_manager/grit/file_manager_resources.h"
25 namespace extensions
{
27 bool IsComponentExtensionWhitelisted(const std::string
& extension_id
) {
28 const char* allowed
[] = {
29 extension_misc::kHotwordSharedModuleId
,
30 extension_misc::kInAppPaymentsSupportAppId
,
31 #if defined(ENABLE_MEDIA_ROUTER)
32 extension_misc::kMediaRouterStableExtensionId
,
33 #endif // defined(ENABLE_MEDIA_ROUTER)
34 extension_misc::kPdfExtensionId
,
35 #if defined(OS_CHROMEOS)
36 extension_misc::kChromeVoxExtensionId
,
37 extension_misc::kSpeechSynthesisExtensionId
,
38 extension_misc::kZIPUnpackerExtensionId
,
42 for (size_t i
= 0; i
< arraysize(allowed
); ++i
) {
43 if (extension_id
== allowed
[i
])
47 std::string bookmark_extension_id
;
48 if (IsEnhancedBookmarksEnabled(&bookmark_extension_id
) &&
49 bookmark_extension_id
== extension_id
)
52 #if defined(ENABLE_APP_LIST) && defined(OS_CHROMEOS)
53 std::string google_now_extension_id
;
54 if (GetGoogleNowExtensionId(&google_now_extension_id
) &&
55 google_now_extension_id
== extension_id
)
59 #if defined(OS_CHROMEOS)
60 if (chromeos::ComponentExtensionIMEManagerImpl::IsIMEExtensionID(
65 LOG(ERROR
) << "Component extension with id " << extension_id
<< " not in "
66 << "whitelist and is not being loaded as a result.";
71 bool IsComponentExtensionWhitelisted(int manifest_resource_id
) {
73 IDR_BOOKMARKS_MANIFEST
,
74 IDR_CHROME_APP_MANIFEST
,
75 IDR_CLOUDPRINT_MANIFEST
,
76 IDR_CONNECTIVITY_DIAGNOSTICS_MANIFEST
,
77 IDR_CRYPTOTOKEN_MANIFEST
,
78 IDR_FEEDBACK_MANIFEST
,
79 IDR_GAIA_AUTH_MANIFEST
,
80 IDR_GOOGLE_NOW_MANIFEST
,
81 IDR_HANGOUT_SERVICES_MANIFEST
,
82 IDR_HOTWORD_AUDIO_VERIFICATION_MANIFEST
,
84 IDR_IDENTITY_API_SCOPE_APPROVAL_MANIFEST
,
85 IDR_NETWORK_SPEECH_SYNTHESIS_MANIFEST
,
86 IDR_SETTINGS_APP_MANIFEST
,
87 IDR_WALLPAPERMANAGER_MANIFEST
,
88 IDR_WEBSTORE_MANIFEST
,
89 IDR_WHISPERNET_PROXY_MANIFEST
,
90 #if defined(IMAGE_LOADER_EXTENSION)
91 IDR_IMAGE_LOADER_MANIFEST
,
93 #if defined(OS_CHROMEOS)
94 IDR_AUDIO_PLAYER_MANIFEST
,
95 IDR_CHROME_APPS_WEBSTORE_WIDGET_MANIFEST
,
96 IDR_CONNECTIVITY_DIAGNOSTICS_LAUNCHER_MANIFEST
,
97 IDR_CONNECTIVITY_DIAGNOSTICS_MANIFEST
,
98 IDR_CROSH_BUILTIN_MANIFEST
,
99 IDR_DEMO_APP_MANIFEST
,
100 IDR_EASY_UNLOCK_MANIFEST
,
101 IDR_EASY_UNLOCK_MANIFEST_SIGNIN
,
103 IDR_FILEMANAGER_MANIFEST
,
104 IDR_FIRST_RUN_DIALOG_MANIFEST
,
105 IDR_GALLERY_MANIFEST
,
106 IDR_GENIUS_APP_MANIFEST
,
108 IDR_KEYBOARD_MANIFEST
,
110 IDR_NETWORK_CONFIGURATION_MANIFEST
,
111 IDR_QUICKOFFICE_MANIFEST
,
112 IDR_VIDEO_PLAYER_MANIFEST
,
113 IDR_WALLPAPERMANAGER_MANIFEST
,
117 for (size_t i
= 0; i
< arraysize(allowed
); ++i
) {
118 if (manifest_resource_id
== allowed
[i
])
122 LOG(ERROR
) << "Component extension with manifest resource id "
123 << manifest_resource_id
<< " not in whitelist and is not being "
124 << "loaded as a result.";
129 } // namespace extensions