Roll src/third_party/WebKit f298044:aa8346d (svn 202628:202629)
[chromium-blink-merge.git] / chrome / browser / extensions / external_component_loader.cc
blob8bace512e06e1e3b2d79163c4868d3d677c276ed
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 "chrome/browser/browser_process.h"
9 #include "chrome/browser/extensions/component_extensions_whitelist/whitelist.h"
10 #include "chrome/browser/search/hotword_service.h"
11 #include "chrome/browser/search/hotword_service_factory.h"
12 #include "chrome/browser/signin/signin_manager_factory.h"
13 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/extensions/extension_constants.h"
15 #include "components/signin/core/browser/signin_manager.h"
16 #include "extensions/common/extension_urls.h"
17 #include "extensions/common/manifest.h"
19 #if defined(OS_CHROMEOS)
20 #include "base/command_line.h"
21 #include "chromeos/chromeos_switches.h"
22 #endif
24 #if defined(ENABLE_APP_LIST) && defined(OS_CHROMEOS)
25 #include "chrome/browser/ui/app_list/google_now_extension.h"
26 #endif
28 namespace extensions {
30 ExternalComponentLoader::ExternalComponentLoader(Profile* profile)
31 : profile_(profile) {
34 ExternalComponentLoader::~ExternalComponentLoader() {}
36 void ExternalComponentLoader::StartLoading() {
37 prefs_.reset(new base::DictionaryValue());
38 AddExternalExtension(extension_misc::kInAppPaymentsSupportAppId);
40 if (HotwordServiceFactory::IsHotwordAllowed(profile_))
41 AddExternalExtension(extension_misc::kHotwordSharedModuleId);
43 #if defined(OS_CHROMEOS)
45 base::CommandLine* const command_line =
46 base::CommandLine::ForCurrentProcess();
47 if (!command_line->HasSwitch(chromeos::switches::kDisableNewZIPUnpacker))
48 AddExternalExtension(extension_misc::kZIPUnpackerExtensionId);
50 #endif
52 #if defined(ENABLE_MEDIA_ROUTER) && defined(GOOGLE_CHROME_BUILD)
53 if (switches::MediaRouterEnabled())
54 AddExternalExtension(extension_misc::kMediaRouterStableExtensionId);
55 #endif // defined(ENABLE_MEDIA_ROUTER) && defined(GOOGLE_CHROME_BUILD)
57 #if defined(ENABLE_APP_LIST) && defined(OS_CHROMEOS)
58 std::string google_now_extension_id;
59 if (GetGoogleNowExtensionId(&google_now_extension_id))
60 AddExternalExtension(google_now_extension_id);
61 #endif
63 LoadFinished();
66 void ExternalComponentLoader::AddExternalExtension(
67 const std::string& extension_id) {
68 if (!IsComponentExtensionWhitelisted(extension_id))
69 return;
71 prefs_->SetString(extension_id + ".external_update_url",
72 extension_urls::GetWebstoreUpdateUrl().spec());
75 } // namespace extensions