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 #include "extensions/features/features.h" |
9 | 10 |
10 #if defined(ENABLE_MEDIA_ROUTER) | 11 #if defined(ENABLE_MEDIA_ROUTER) |
11 #if defined(OS_ANDROID) || defined(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) || defined(ENABLE_EXTENSIONS) | 16 #endif // defined(OS_ANDROID) || BUILDFLAG(ENABLE_EXTENSIONS) |
16 #endif // defined(ENABLE_MEDIA_ROUTER) | 17 #endif // defined(ENABLE_MEDIA_ROUTER) |
17 | 18 |
18 namespace media_router { | 19 namespace media_router { |
19 | 20 |
20 #if defined(ENABLE_MEDIA_ROUTER) | 21 #if defined(ENABLE_MEDIA_ROUTER) |
21 #if defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS) | 22 #if defined(OS_ANDROID) || BUILDFLAG(ENABLE_EXTENSIONS) |
22 namespace { | 23 namespace { |
23 const PrefService::Preference* GetMediaRouterPref( | 24 const PrefService::Preference* GetMediaRouterPref( |
24 content::BrowserContext* context) { | 25 content::BrowserContext* context) { |
25 return user_prefs::UserPrefs::Get(context) | 26 return user_prefs::UserPrefs::Get(context) |
26 ->FindPreference(prefs::kEnableMediaRouter); | 27 ->FindPreference(prefs::kEnableMediaRouter); |
27 } | 28 } |
28 } // namespace | 29 } // namespace |
29 #endif // defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS) | 30 #endif // defined(OS_ANDROID) || BUILDFLAG(ENABLE_EXTENSIONS) |
30 #endif // defined(ENABLE_MEDIA_ROUTER) | 31 #endif // defined(ENABLE_MEDIA_ROUTER) |
31 | 32 |
32 bool MediaRouterEnabled(content::BrowserContext* context) { | 33 bool MediaRouterEnabled(content::BrowserContext* context) { |
33 #if defined(ENABLE_MEDIA_ROUTER) | 34 #if defined(ENABLE_MEDIA_ROUTER) |
34 #if defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS) | 35 #if defined(OS_ANDROID) || BUILDFLAG(ENABLE_EXTENSIONS) |
35 const PrefService::Preference* pref = GetMediaRouterPref(context); | 36 const PrefService::Preference* pref = GetMediaRouterPref(context); |
36 // Only use the pref value if it set from a mandatory policy. | 37 // Only use the pref value if it set from a mandatory policy. |
37 if (pref->IsManaged() && !pref->IsDefaultValue()) { | 38 if (pref->IsManaged() && !pref->IsDefaultValue()) { |
38 bool allowed = false; | 39 bool allowed = false; |
39 CHECK(pref->GetValue()->GetAsBoolean(&allowed)); | 40 CHECK(pref->GetValue()->GetAsBoolean(&allowed)); |
40 return allowed; | 41 return allowed; |
41 } | 42 } |
42 return true; | 43 return true; |
43 #else // !(defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS)) | 44 #else // !(defined(OS_ANDROID) || BUILDFLAG(ENABLE_EXTENSIONS)) |
44 return false; | 45 return false; |
45 #endif // defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS) | 46 #endif // defined(OS_ANDROID) || BUILDFLAG(ENABLE_EXTENSIONS) |
46 #else // !defined(ENABLE_MEDIA_ROUTER) | 47 #else // !defined(ENABLE_MEDIA_ROUTER) |
47 return false; | 48 return false; |
48 #endif // defined(ENABLE_MEDIA_ROUTER) | 49 #endif // defined(ENABLE_MEDIA_ROUTER) |
49 } | 50 } |
50 | 51 |
51 } // namespace media_router | 52 } // namespace media_router |
OLD | NEW |