| 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 "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/extensions/component_extensions_whitelist/whitelist.h" | 9 #include "chrome/browser/extensions/component_extensions_whitelist/whitelist.h" |
| 10 #include "chrome/browser/search/hotword_service.h" | 10 #include "chrome/browser/search/hotword_service.h" |
| 11 #include "chrome/browser/search/hotword_service_factory.h" | 11 #include "chrome/browser/search/hotword_service_factory.h" |
| 12 #include "chrome/browser/signin/signin_manager_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" | 13 #include "chrome/common/extensions/extension_constants.h" |
| 15 #include "components/signin/core/browser/signin_manager.h" | 14 #include "components/signin/core/browser/signin_manager.h" |
| 16 #include "extensions/common/extension_urls.h" | 15 #include "extensions/common/extension_urls.h" |
| 17 #include "extensions/common/manifest.h" | 16 #include "extensions/common/manifest.h" |
| 18 | 17 |
| 19 #if defined(OS_CHROMEOS) | 18 #if defined(OS_CHROMEOS) |
| 20 #include "base/command_line.h" | 19 #include "base/command_line.h" |
| 21 #include "chromeos/chromeos_switches.h" | 20 #include "chromeos/chromeos_switches.h" |
| 22 #endif | 21 #endif |
| 23 | 22 |
| 24 #if defined(ENABLE_APP_LIST) && defined(OS_CHROMEOS) | 23 #if defined(ENABLE_APP_LIST) && defined(OS_CHROMEOS) |
| 25 #include "chrome/browser/ui/app_list/google_now_extension.h" | 24 #include "chrome/browser/ui/app_list/google_now_extension.h" |
| 26 #endif | 25 #endif |
| 27 | 26 |
| 27 #if defined(ENABLE_MEDIA_ROUTER) && defined(GOOGLE_CHROME_BUILD) |
| 28 #include "chrome/browser/media/router/media_router_feature.h" |
| 29 #endif |
| 30 |
| 28 namespace extensions { | 31 namespace extensions { |
| 29 | 32 |
| 30 ExternalComponentLoader::ExternalComponentLoader(Profile* profile) | 33 ExternalComponentLoader::ExternalComponentLoader(Profile* profile) |
| 31 : profile_(profile) { | 34 : profile_(profile) { |
| 32 } | 35 } |
| 33 | 36 |
| 34 ExternalComponentLoader::~ExternalComponentLoader() {} | 37 ExternalComponentLoader::~ExternalComponentLoader() {} |
| 35 | 38 |
| 36 void ExternalComponentLoader::StartLoading() { | 39 void ExternalComponentLoader::StartLoading() { |
| 37 prefs_.reset(new base::DictionaryValue()); | 40 prefs_.reset(new base::DictionaryValue()); |
| 38 AddExternalExtension(extension_misc::kInAppPaymentsSupportAppId); | 41 AddExternalExtension(extension_misc::kInAppPaymentsSupportAppId); |
| 39 | 42 |
| 40 if (HotwordServiceFactory::IsHotwordAllowed(profile_)) | 43 if (HotwordServiceFactory::IsHotwordAllowed(profile_)) |
| 41 AddExternalExtension(extension_misc::kHotwordSharedModuleId); | 44 AddExternalExtension(extension_misc::kHotwordSharedModuleId); |
| 42 | 45 |
| 43 #if defined(OS_CHROMEOS) | 46 #if defined(OS_CHROMEOS) |
| 44 { | 47 { |
| 45 base::CommandLine* const command_line = | 48 base::CommandLine* const command_line = |
| 46 base::CommandLine::ForCurrentProcess(); | 49 base::CommandLine::ForCurrentProcess(); |
| 47 if (!command_line->HasSwitch(chromeos::switches::kDisableNewZIPUnpacker)) | 50 if (!command_line->HasSwitch(chromeos::switches::kDisableNewZIPUnpacker)) |
| 48 AddExternalExtension(extension_misc::kZIPUnpackerExtensionId); | 51 AddExternalExtension(extension_misc::kZIPUnpackerExtensionId); |
| 49 } | 52 } |
| 50 #endif | 53 #endif |
| 51 | 54 |
| 52 #if defined(ENABLE_MEDIA_ROUTER) && defined(GOOGLE_CHROME_BUILD) | 55 #if defined(ENABLE_MEDIA_ROUTER) && defined(GOOGLE_CHROME_BUILD) |
| 53 if (switches::MediaRouterEnabled()) | 56 if (media_router::MediaRouterEnabled()) |
| 54 AddExternalExtension(extension_misc::kMediaRouterStableExtensionId); | 57 AddExternalExtension(extension_misc::kMediaRouterStableExtensionId); |
| 55 #endif // defined(ENABLE_MEDIA_ROUTER) && defined(GOOGLE_CHROME_BUILD) | 58 #endif // defined(ENABLE_MEDIA_ROUTER) && defined(GOOGLE_CHROME_BUILD) |
| 56 | 59 |
| 57 #if defined(ENABLE_APP_LIST) && defined(OS_CHROMEOS) | 60 #if defined(ENABLE_APP_LIST) && defined(OS_CHROMEOS) |
| 58 std::string google_now_extension_id; | 61 std::string google_now_extension_id; |
| 59 if (GetGoogleNowExtensionId(&google_now_extension_id)) | 62 if (GetGoogleNowExtensionId(&google_now_extension_id)) |
| 60 AddExternalExtension(google_now_extension_id); | 63 AddExternalExtension(google_now_extension_id); |
| 61 #endif | 64 #endif |
| 62 | 65 |
| 63 LoadFinished(); | 66 LoadFinished(); |
| 64 } | 67 } |
| 65 | 68 |
| 66 void ExternalComponentLoader::AddExternalExtension( | 69 void ExternalComponentLoader::AddExternalExtension( |
| 67 const std::string& extension_id) { | 70 const std::string& extension_id) { |
| 68 if (!IsComponentExtensionWhitelisted(extension_id)) | 71 if (!IsComponentExtensionWhitelisted(extension_id)) |
| 69 return; | 72 return; |
| 70 | 73 |
| 71 prefs_->SetString(extension_id + ".external_update_url", | 74 prefs_->SetString(extension_id + ".external_update_url", |
| 72 extension_urls::GetWebstoreUpdateUrl().spec()); | 75 extension_urls::GetWebstoreUpdateUrl().spec()); |
| 73 } | 76 } |
| 74 | 77 |
| 75 } // namespace extensions | 78 } // namespace extensions |
| OLD | NEW |