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