| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/external_component_loader.h" | 5 #include "chrome/browser/extensions/external_component_loader.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/extensions/component_extensions_whitelist/whitelist.h" | 10 #include "chrome/browser/extensions/component_extensions_whitelist/whitelist.h" |
| 11 #include "chrome/browser/search/hotword_service.h" | 11 #include "chrome/browser/search/hotword_service.h" |
| 12 #include "chrome/browser/search/hotword_service_factory.h" | 12 #include "chrome/browser/search/hotword_service_factory.h" |
| 13 #include "chrome/browser/signin/signin_manager_factory.h" | 13 #include "chrome/browser/signin/signin_manager_factory.h" |
| 14 #include "chrome/common/extensions/extension_constants.h" | 14 #include "chrome/common/extensions/extension_constants.h" |
| 15 #include "chrome/common/features.h" | 15 #include "chrome/common/features.h" |
| 16 #include "components/signin/core/browser/signin_manager.h" | 16 #include "components/signin/core/browser/signin_manager.h" |
| 17 #include "extensions/common/extension_urls.h" | 17 #include "extensions/common/extension_urls.h" |
| 18 #include "extensions/common/feature_switch.h" |
| 18 #include "extensions/common/manifest.h" | 19 #include "extensions/common/manifest.h" |
| 19 | 20 |
| 20 #if defined(OS_CHROMEOS) | 21 #if defined(OS_CHROMEOS) |
| 21 #include "base/command_line.h" | 22 #include "base/command_line.h" |
| 22 #include "chromeos/chromeos_switches.h" | 23 #include "chromeos/chromeos_switches.h" |
| 23 #endif | 24 #endif |
| 24 | 25 |
| 25 #if BUILDFLAG(ENABLE_APP_LIST) && defined(OS_CHROMEOS) | 26 #if BUILDFLAG(ENABLE_APP_LIST) && defined(OS_CHROMEOS) |
| 26 #include "chrome/browser/ui/app_list/google_now_extension.h" | 27 #include "chrome/browser/ui/app_list/google_now_extension.h" |
| 27 #endif | 28 #endif |
| 28 | 29 |
| 29 #if defined(ENABLE_MEDIA_ROUTER) && defined(GOOGLE_CHROME_BUILD) | 30 #if defined(ENABLE_MEDIA_ROUTER) |
| 30 #include "chrome/browser/media/router/media_router_feature.h" | 31 #include "chrome/browser/media/router/media_router_feature.h" |
| 31 #endif | 32 #endif |
| 32 | 33 |
| 33 namespace extensions { | 34 namespace extensions { |
| 34 | 35 |
| 35 ExternalComponentLoader::ExternalComponentLoader(Profile* profile) | 36 ExternalComponentLoader::ExternalComponentLoader(Profile* profile) |
| 36 : profile_(profile) { | 37 : profile_(profile) { |
| 37 } | 38 } |
| 38 | 39 |
| 39 ExternalComponentLoader::~ExternalComponentLoader() {} | 40 ExternalComponentLoader::~ExternalComponentLoader() {} |
| 40 | 41 |
| 41 void ExternalComponentLoader::StartLoading() { | 42 void ExternalComponentLoader::StartLoading() { |
| 42 prefs_.reset(new base::DictionaryValue()); | 43 prefs_.reset(new base::DictionaryValue()); |
| 43 AddExternalExtension(extension_misc::kInAppPaymentsSupportAppId); | 44 AddExternalExtension(extension_misc::kInAppPaymentsSupportAppId); |
| 44 | 45 |
| 45 if (HotwordServiceFactory::IsHotwordAllowed(profile_)) | 46 if (HotwordServiceFactory::IsHotwordAllowed(profile_)) |
| 46 AddExternalExtension(extension_misc::kHotwordSharedModuleId); | 47 AddExternalExtension(extension_misc::kHotwordSharedModuleId); |
| 47 | 48 |
| 48 #if defined(OS_CHROMEOS) | 49 #if defined(OS_CHROMEOS) |
| 49 { | 50 { |
| 50 base::CommandLine* const command_line = | 51 base::CommandLine* const command_line = |
| 51 base::CommandLine::ForCurrentProcess(); | 52 base::CommandLine::ForCurrentProcess(); |
| 52 if (!command_line->HasSwitch(chromeos::switches::kDisableNewZIPUnpacker)) | 53 if (!command_line->HasSwitch(chromeos::switches::kDisableNewZIPUnpacker)) |
| 53 AddExternalExtension(extension_misc::kZIPUnpackerExtensionId); | 54 AddExternalExtension(extension_misc::kZIPUnpackerExtensionId); |
| 54 } | 55 } |
| 55 #endif | 56 #endif |
| 56 | 57 |
| 57 #if defined(ENABLE_MEDIA_ROUTER) && defined(GOOGLE_CHROME_BUILD) | 58 #if defined(ENABLE_MEDIA_ROUTER) |
| 58 if (media_router::MediaRouterEnabled(profile_)) | 59 if (media_router::MediaRouterEnabled(profile_) && |
| 60 FeatureSwitch::load_media_router_component_extension()->IsEnabled()) { |
| 59 AddExternalExtension(extension_misc::kMediaRouterStableExtensionId); | 61 AddExternalExtension(extension_misc::kMediaRouterStableExtensionId); |
| 60 #endif // defined(ENABLE_MEDIA_ROUTER) && defined(GOOGLE_CHROME_BUILD) | 62 } |
| 63 #endif // defined(ENABLE_MEDIA_ROUTER) |
| 61 | 64 |
| 62 #if BUILDFLAG(ENABLE_APP_LIST) && defined(OS_CHROMEOS) | 65 #if BUILDFLAG(ENABLE_APP_LIST) && defined(OS_CHROMEOS) |
| 63 std::string google_now_extension_id; | 66 std::string google_now_extension_id; |
| 64 if (GetGoogleNowExtensionId(&google_now_extension_id)) | 67 if (GetGoogleNowExtensionId(&google_now_extension_id)) |
| 65 AddExternalExtension(google_now_extension_id); | 68 AddExternalExtension(google_now_extension_id); |
| 66 #endif | 69 #endif |
| 67 | 70 |
| 68 LoadFinished(); | 71 LoadFinished(); |
| 69 } | 72 } |
| 70 | 73 |
| 71 void ExternalComponentLoader::AddExternalExtension( | 74 void ExternalComponentLoader::AddExternalExtension( |
| 72 const std::string& extension_id) { | 75 const std::string& extension_id) { |
| 73 if (!IsComponentExtensionWhitelisted(extension_id)) | 76 if (!IsComponentExtensionWhitelisted(extension_id)) |
| 74 return; | 77 return; |
| 75 | 78 |
| 76 prefs_->SetString(extension_id + ".external_update_url", | 79 prefs_->SetString(extension_id + ".external_update_url", |
| 77 extension_urls::GetWebstoreUpdateUrl().spec()); | 80 extension_urls::GetWebstoreUpdateUrl().spec()); |
| 78 } | 81 } |
| 79 | 82 |
| 80 } // namespace extensions | 83 } // namespace extensions |
| OLD | NEW |