Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: chrome/browser/media/router/media_router_feature.cc

Issue 2451573003: [Media Router] Update Media Router flags post-launch. (Closed)
Patch Set: Respond to msw@ comments. Update histograms.xml for new flag. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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)
46 return true; 42 return true;
47 #else // defined(ENABLE_EXTENSIONS)
48 return extensions::FeatureSwitch::media_router()->IsEnabled();
49 #endif // defined(OS_ANDROID)
50 #else // !(defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS)) 43 #else // !(defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS))
apacible 2016/10/28 02:42:37 Could we do: #if defined(ENABLE_MEDIA_ROUTER) &&
mark a. foltz 2016/10/28 19:54:44 I tried it, but it results in line wrapping the #i
51 return false; 44 return false;
52 #endif // defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS) 45 #endif // defined(OS_ANDROID) || defined(ENABLE_EXTENSIONS)
53 #else // !defined(ENABLE_MEDIA_ROUTER) 46 #else // !defined(ENABLE_MEDIA_ROUTER)
54 return false; 47 return false;
55 #endif // defined(ENABLE_MEDIA_ROUTER) 48 #endif // defined(ENABLE_MEDIA_ROUTER)
56 } 49 }
57 50
58 } // namespace media_router 51 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698