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 "base/feature_list.h" |
7 #include "build/build_config.h" | 8 #include "build/build_config.h" |
8 #include "content/public/browser/browser_context.h" | 9 #include "content/public/browser/browser_context.h" |
9 #include "extensions/features/features.h" | 10 #include "extensions/features/features.h" |
10 | 11 |
11 #if defined(OS_ANDROID) || BUILDFLAG(ENABLE_EXTENSIONS) | 12 #if defined(OS_ANDROID) || BUILDFLAG(ENABLE_EXTENSIONS) |
12 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
13 #include "components/prefs/pref_service.h" | 14 #include "components/prefs/pref_service.h" |
14 #include "components/user_prefs/user_prefs.h" | 15 #include "components/user_prefs/user_prefs.h" |
15 #endif // defined(OS_ANDROID) || BUILDFLAG(ENABLE_EXTENSIONS) | 16 #endif // defined(OS_ANDROID) || BUILDFLAG(ENABLE_EXTENSIONS) |
16 | 17 |
17 namespace media_router { | 18 namespace media_router { |
18 | 19 |
| 20 #if !defined(OS_ANDROID) |
| 21 // Controls if browser side DIAL device discovery is enabled. |
| 22 const base::Feature kEnableDialLocalDiscovery{ |
| 23 "EnableDialLocalDiscovery", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 24 |
| 25 // Controls if browser side Cast device discovery is enabled. |
| 26 const base::Feature kEnableCastDiscovery{"EnableCastDiscovery", |
| 27 base::FEATURE_DISABLED_BY_DEFAULT}; |
| 28 #endif |
| 29 |
19 #if defined(OS_ANDROID) || BUILDFLAG(ENABLE_EXTENSIONS) | 30 #if defined(OS_ANDROID) || BUILDFLAG(ENABLE_EXTENSIONS) |
20 namespace { | 31 namespace { |
21 const PrefService::Preference* GetMediaRouterPref( | 32 const PrefService::Preference* GetMediaRouterPref( |
22 content::BrowserContext* context) { | 33 content::BrowserContext* context) { |
23 return user_prefs::UserPrefs::Get(context) | 34 return user_prefs::UserPrefs::Get(context) |
24 ->FindPreference(prefs::kEnableMediaRouter); | 35 ->FindPreference(prefs::kEnableMediaRouter); |
25 } | 36 } |
26 } // namespace | 37 } // namespace |
27 #endif // defined(OS_ANDROID) || BUILDFLAG(ENABLE_EXTENSIONS) | 38 #endif // defined(OS_ANDROID) || BUILDFLAG(ENABLE_EXTENSIONS) |
28 | 39 |
29 bool MediaRouterEnabled(content::BrowserContext* context) { | 40 bool MediaRouterEnabled(content::BrowserContext* context) { |
30 #if defined(OS_ANDROID) || BUILDFLAG(ENABLE_EXTENSIONS) | 41 #if defined(OS_ANDROID) || BUILDFLAG(ENABLE_EXTENSIONS) |
31 const PrefService::Preference* pref = GetMediaRouterPref(context); | 42 const PrefService::Preference* pref = GetMediaRouterPref(context); |
32 // Only use the pref value if it set from a mandatory policy. | 43 // Only use the pref value if it set from a mandatory policy. |
33 if (pref->IsManaged() && !pref->IsDefaultValue()) { | 44 if (pref->IsManaged() && !pref->IsDefaultValue()) { |
34 bool allowed = false; | 45 bool allowed = false; |
35 CHECK(pref->GetValue()->GetAsBoolean(&allowed)); | 46 CHECK(pref->GetValue()->GetAsBoolean(&allowed)); |
36 return allowed; | 47 return allowed; |
37 } | 48 } |
38 return true; | 49 return true; |
39 #else // !(defined(OS_ANDROID) || BUILDFLAG(ENABLE_EXTENSIONS)) | 50 #else // !(defined(OS_ANDROID) || BUILDFLAG(ENABLE_EXTENSIONS)) |
40 return false; | 51 return false; |
41 #endif // defined(OS_ANDROID) || BUILDFLAG(ENABLE_EXTENSIONS) | 52 #endif // defined(OS_ANDROID) || BUILDFLAG(ENABLE_EXTENSIONS) |
42 } | 53 } |
43 | 54 |
| 55 #if !defined(OS_ANDROID) |
| 56 // Returns true if browser side DIAL discovery is enabled. |
| 57 bool DialLocalDiscoveryEnabled() { |
| 58 return base::FeatureList::IsEnabled(kEnableDialLocalDiscovery); |
| 59 } |
| 60 |
| 61 // Returns true if browser side Cast discovery is enabled. |
| 62 bool CastDiscoveryEnabled() { |
| 63 return base::FeatureList::IsEnabled(kEnableCastDiscovery); |
| 64 } |
| 65 #endif |
| 66 |
44 } // namespace media_router | 67 } // namespace media_router |
OLD | NEW |