| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/media/router/media_router_feature.h" | 5 #include "chrome/browser/media/router/media_router_feature.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "content/public/browser/browser_context.h" | 8 #include "content/public/browser/browser_context.h" |
| 9 | 9 |
| 10 #if defined(ENABLE_EXTENSIONS) | 10 #if defined(ENABLE_EXTENSIONS) |
| 11 #include "chrome/browser/extensions/api/tab_capture/tab_capture_api.h" | |
| 12 #include "extensions/browser/extension_registry.h" | |
| 13 #include "extensions/common/extension_set.h" | |
| 14 #include "extensions/common/feature_switch.h" | 11 #include "extensions/common/feature_switch.h" |
| 15 #endif | 12 #endif |
| 16 | 13 |
| 17 namespace media_router { | 14 namespace media_router { |
| 18 | 15 |
| 19 bool MediaRouterEnabled(content::BrowserContext* context) { | 16 bool MediaRouterEnabled(content::BrowserContext* context) { |
| 20 #if defined(ENABLE_MEDIA_ROUTER) | 17 #if defined(ENABLE_MEDIA_ROUTER) |
| 21 #if defined(OS_ANDROID) | 18 #if defined(OS_ANDROID) |
| 22 return true; | 19 return true; |
| 23 #elif defined(ENABLE_EXTENSIONS) | 20 #elif defined(ENABLE_EXTENSIONS) |
| 24 extensions::ExtensionRegistry* registry = | |
| 25 extensions::ExtensionRegistry::Get(context); | |
| 26 if (!registry) { | |
| 27 DLOG(ERROR) << "ExtensionRegistry is null. Assume no cast extension " | |
| 28 "installed."; | |
| 29 return extensions::FeatureSwitch::media_router()->IsEnabled(); | |
| 30 } | |
| 31 | |
| 32 const extensions::ExtensionSet& extension_set = | |
| 33 registry->enabled_extensions(); | |
| 34 if (extension_set.Contains(extensions::kStableChromecastExtensionId) || | |
| 35 extension_set.Contains(extensions::kBetaChromecastExtensionId)) { | |
| 36 return extensions::FeatureSwitch::media_router_with_cast_extension() | |
| 37 ->IsEnabled(); | |
| 38 } | |
| 39 | |
| 40 return extensions::FeatureSwitch::media_router()->IsEnabled(); | 21 return extensions::FeatureSwitch::media_router()->IsEnabled(); |
| 41 #else // !defined(ENABLE_EXTENSIONS) | 22 #else // !defined(ENABLE_EXTENSIONS) |
| 42 return false; | 23 return false; |
| 43 #endif // defined(OS_ANDROID) | 24 #endif // defined(OS_ANDROID) |
| 44 #else // !defined(ENABLE_MEDIA_ROUTER) | 25 #else // !defined(ENABLE_MEDIA_ROUTER) |
| 45 return false; | 26 return false; |
| 46 #endif // defined(ENABLE_MEDIA_ROUTER) | 27 #endif // defined(ENABLE_MEDIA_ROUTER) |
| 47 } | 28 } |
| 48 | 29 |
| 49 } // namespace media_router | 30 } // namespace media_router |
| OLD | NEW |