1 // Copyright (c) 2013 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/external_component_loader.h"
7 #include "base/command_line.h"
8 #include "base/strings/string_number_conversions.h"
9 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h"
10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/extensions/component_extensions_whitelist/whitelist.h"
12 #include "chrome/browser/search/hotword_service.h"
13 #include "chrome/browser/search/hotword_service_factory.h"
14 #include "chrome/browser/signin/signin_manager_factory.h"
15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/extensions/extension_constants.h"
17 #include "components/signin/core/browser/signin_manager.h"
18 #include "extensions/common/extension.h"
19 #include "extensions/common/extension_urls.h"
20 #include "extensions/common/features/simple_feature.h"
22 #if defined(OS_CHROMEOS)
23 #include "base/command_line.h"
24 #include "chromeos/chromeos_switches.h"
27 #if defined(ENABLE_APP_LIST) && defined(OS_CHROMEOS)
28 #include "chrome/browser/ui/app_list/google_now_extension.h"
31 namespace extensions
{
33 ExternalComponentLoader::ExternalComponentLoader(Profile
* profile
)
37 ExternalComponentLoader::~ExternalComponentLoader() {}
40 bool ExternalComponentLoader::IsModifiable(const Extension
* extension
) {
41 if (extension
->location() == Manifest::EXTERNAL_COMPONENT
) {
42 static const char* const kEnhancedExtensions
[] = {
43 "D5736E4B5CF695CB93A2FB57E4FDC6E5AFAB6FE2", // http://crbug.com/312900
44 "D57DE394F36DC1C3220E7604C575D29C51A6C495", // http://crbug.com/319444
45 "3F65507A3B39259B38C8173C6FFA3D12DF64CCE9" // http://crbug.com/371562
47 return SimpleFeature::IsIdInArray(
48 extension
->id(), kEnhancedExtensions
, arraysize(kEnhancedExtensions
));
53 void ExternalComponentLoader::StartLoading() {
54 prefs_
.reset(new base::DictionaryValue());
55 AddExternalExtension(extension_misc::kInAppPaymentsSupportAppId
);
57 if (HotwordServiceFactory::IsHotwordAllowed(profile_
))
58 AddExternalExtension(extension_misc::kHotwordSharedModuleId
);
61 std::string extension_id
;
62 if (IsEnhancedBookmarksEnabled(&extension_id
))
63 AddExternalExtension(extension_id
);
66 #if defined(OS_CHROMEOS)
68 base::CommandLine
* const command_line
=
69 base::CommandLine::ForCurrentProcess();
70 if (!command_line
->HasSwitch(chromeos::switches::kDisableNewZIPUnpacker
))
71 AddExternalExtension(extension_misc::kZIPUnpackerExtensionId
);
76 #if defined(ENABLE_MEDIA_ROUTER)
77 if (switches::MediaRouterEnabled())
78 AddExternalExtension(extension_misc::kMediaRouterStableExtensionId
);
79 #endif // defined(ENABLE_MEDIA_ROUTER)
81 #if defined(ENABLE_APP_LIST) && defined(OS_CHROMEOS)
82 std::string google_now_extension_id
;
83 if (GetGoogleNowExtensionId(&google_now_extension_id
))
84 AddExternalExtension(google_now_extension_id
);
90 void ExternalComponentLoader::AddExternalExtension(
91 const std::string
& extension_id
) {
92 if (!IsComponentExtensionWhitelisted(extension_id
))
95 prefs_
->SetString(extension_id
+ ".external_update_url",
96 extension_urls::GetWebstoreUpdateUrl().spec());
99 } // namespace extensions