Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / extensions / external_component_loader.cc
blobd53618740b591ed593c90848ca946d1aaeaee5a0
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/strings/string_number_conversions.h"
8 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h"
9 #include "chrome/browser/browser_process.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/extensions/extension_constants.h"
14 #include "components/signin/core/browser/signin_manager.h"
15 #include "extensions/common/extension.h"
16 #include "extensions/common/extension_urls.h"
17 #include "extensions/common/features/simple_feature.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 // static
37 bool ExternalComponentLoader::IsModifiable(const Extension* extension) {
38 if (extension->location() == Manifest::EXTERNAL_COMPONENT) {
39 static const char* const kEnhancedExtensions[] = {
40 "D5736E4B5CF695CB93A2FB57E4FDC6E5AFAB6FE2", // http://crbug.com/312900
41 "D57DE394F36DC1C3220E7604C575D29C51A6C495", // http://crbug.com/319444
42 "3F65507A3B39259B38C8173C6FFA3D12DF64CCE9" // http://crbug.com/371562
44 return SimpleFeature::IsIdInArray(
45 extension->id(), kEnhancedExtensions, arraysize(kEnhancedExtensions));
47 return false;
50 void ExternalComponentLoader::StartLoading() {
51 prefs_.reset(new base::DictionaryValue());
52 std::string app_id = extension_misc::kInAppPaymentsSupportAppId;
53 prefs_->SetString(app_id + ".external_update_url",
54 extension_urls::GetWebstoreUpdateUrl().spec());
56 if (HotwordServiceFactory::IsHotwordAllowed(profile_)) {
57 std::string hotword_id = extension_misc::kHotwordSharedModuleId;
58 prefs_->SetString(hotword_id + ".external_update_url",
59 extension_urls::GetWebstoreUpdateUrl().spec());
63 std::string extension_id;
64 if (IsEnhancedBookmarksEnabled(&extension_id)) {
65 prefs_->SetString(extension_id + ".external_update_url",
66 extension_urls::GetWebstoreUpdateUrl().spec());
70 #if defined(OS_CHROMEOS)
72 base::CommandLine* const command_line =
73 base::CommandLine::ForCurrentProcess();
74 if (!command_line->HasSwitch(chromeos::switches::kDisableNewZIPUnpacker)) {
75 const std::string extension_id = extension_misc::kZIPUnpackerExtensionId;
76 prefs_->SetString(extension_id + ".external_update_url",
77 extension_urls::GetWebstoreUpdateUrl().spec());
80 #endif
82 #if defined(ENABLE_APP_LIST) && defined(OS_CHROMEOS)
83 std::string google_now_extension_id;
84 if (GetGoogleNowExtensionId(&google_now_extension_id)) {
85 prefs_->SetString(google_now_extension_id + ".external_update_url",
86 extension_urls::GetWebstoreUpdateUrl().spec());
88 #endif
90 LoadFinished();
93 } // namespace extensions