Chromium Code Reviews| 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_MEDIA_ROUTER) | 10 #if defined(ENABLE_MEDIA_ROUTER) |
| 11 #if defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS) | 11 #if defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS) |
| 12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
| 13 #include "components/prefs/pref_service.h" | 13 #include "components/prefs/pref_service.h" |
| 14 #include "components/user_prefs/user_prefs.h" | 14 #include "components/user_prefs/user_prefs.h" |
| 15 #endif // defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS) | 15 #endif // defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS) |
| 16 #if defined(ENABLE_EXTENSIONS) | |
| 17 #include "extensions/common/feature_switch.h" | |
| 18 #endif // defined(ENABLE_EXTENSIONS) | |
| 19 #endif // defined(ENABLE_MEDIA_ROUTER) | 16 #endif // defined(ENABLE_MEDIA_ROUTER) |
| 20 | 17 |
| 21 namespace media_router { | 18 namespace media_router { |
| 22 | 19 |
| 23 #if defined(ENABLE_MEDIA_ROUTER) | 20 #if defined(ENABLE_MEDIA_ROUTER) |
| 24 #if defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS) | 21 #if defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS) |
| 25 namespace { | 22 namespace { |
| 26 const PrefService::Preference* GetMediaRouterPref( | 23 const PrefService::Preference* GetMediaRouterPref( |
| 27 content::BrowserContext* context) { | 24 content::BrowserContext* context) { |
| 28 return user_prefs::UserPrefs::Get(context) | 25 return user_prefs::UserPrefs::Get(context) |
| 29 ->FindPreference(prefs::kEnableMediaRouter); | 26 ->FindPreference(prefs::kEnableMediaRouter); |
| 30 } | 27 } |
| 31 } // namespace | 28 } // namespace |
| 32 #endif // defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS) | 29 #endif // defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS) |
| 33 #endif // defined(ENABLE_MEDIA_ROUTER) | 30 #endif // defined(ENABLE_MEDIA_ROUTER) |
| 34 | 31 |
| 35 bool MediaRouterEnabled(content::BrowserContext* context) { | 32 bool MediaRouterEnabled(content::BrowserContext* context) { |
| 36 #if defined(ENABLE_MEDIA_ROUTER) | 33 #if defined(ENABLE_MEDIA_ROUTER) |
| 37 #if defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS) | 34 #if defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS) |
| 38 const PrefService::Preference* pref = GetMediaRouterPref(context); | 35 const PrefService::Preference* pref = GetMediaRouterPref(context); |
| 39 // Only use the pref value if it set from a mandatory policy. | 36 // Only use the pref value if it set from a mandatory policy. |
| 40 if (pref->IsManaged() && !pref->IsDefaultValue()) { | 37 if (pref->IsManaged() && !pref->IsDefaultValue()) { |
| 41 bool allowed = false; | 38 bool allowed = false; |
| 42 CHECK(pref->GetValue()->GetAsBoolean(&allowed)); | 39 CHECK(pref->GetValue()->GetAsBoolean(&allowed)); |
| 43 return allowed; | 40 return allowed; |
| 44 } | 41 } |
| 45 #if defined(OS_ANDROID) | 42 #if defined(OS_ANDROID) |
| 46 return true; | 43 return true; |
|
apacible
2016/10/25 22:01:28
L43 and L45 both return true -- can we consolidate
mark a. foltz
2016/10/25 22:56:36
Done.
| |
| 47 #else // defined(ENABLE_EXTENSIONS) | 44 #else // defined(ENABLE_EXTENSIONS) |
| 48 return extensions::FeatureSwitch::media_router()->IsEnabled(); | 45 return true; |
| 49 #endif // defined(OS_ANDROID) | 46 #endif // defined(OS_ANDROID) |
| 50 #else // !(defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS)) | 47 #else // !(defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS)) |
| 51 return false; | 48 return false; |
| 52 #endif // defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS) | 49 #endif // defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS) |
| 53 #else // !defined(ENABLE_MEDIA_ROUTER) | 50 #else // !defined(ENABLE_MEDIA_ROUTER) |
| 54 return false; | 51 return false; |
| 55 #endif // defined(ENABLE_MEDIA_ROUTER) | 52 #endif // defined(ENABLE_MEDIA_ROUTER) |
| 56 } | 53 } |
| 57 | 54 |
| 58 } // namespace media_router | 55 } // namespace media_router |
| OLD | NEW |