From 46aab5e560571479035ed5806881092769630285 Mon Sep 17 00:00:00 2001 From: Takumi Fujimoto Date: Fri, 16 Dec 2022 23:54:41 +0000 Subject: [PATCH] Disable Media Router for sign-in and lock screen profiles Media Router cannot be disabled for these profiles with per-profile admin policies so we'll blanket disable Media Router for them for now. Bug: 1380828 Change-Id: I79ddc952bdf74695a01d768eaf516fcb353b9e7b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4113644 Reviewed-by: Muyao Xu Commit-Queue: Takumi Fujimoto Cr-Commit-Position: refs/heads/main@{#1084608} --- chrome/browser/media/router/BUILD.gn | 1 + chrome/browser/media/router/media_router_feature.cc | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/chrome/browser/media/router/BUILD.gn b/chrome/browser/media/router/BUILD.gn index 18c600096deadd..7c50e58ee2160f 100644 --- a/chrome/browser/media/router/BUILD.gn +++ b/chrome/browser/media/router/BUILD.gn @@ -44,6 +44,7 @@ static_library("media_router_feature") { public_deps = [ "//base" ] deps = [ "//chrome/browser/profiles", + "//chrome/browser/profiles:profile", "//chrome/common:constants", "//components/media_router/common:common", "//components/prefs:prefs", diff --git a/chrome/browser/media/router/media_router_feature.cc b/chrome/browser/media/router/media_router_feature.cc index b215648cdac700..516be25ee310ab 100644 --- a/chrome/browser/media/router/media_router_feature.cc +++ b/chrome/browser/media/router/media_router_feature.cc @@ -17,6 +17,7 @@ #include "base/strings/string_util.h" #include "build/build_config.h" #include "chrome/browser/profiles/incognito_helpers.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/common/pref_names.h" #include "components/media_router/common/pref_names.h" #include "components/prefs/pref_service.h" @@ -31,6 +32,10 @@ #include "components/prefs/pref_registry_simple.h" #endif +#if BUILDFLAG(IS_CHROMEOS_ASH) +#include "chrome/browser/profiles/profile_types_ash.h" +#endif + namespace media_router { #if BUILDFLAG(IS_ANDROID) @@ -85,6 +90,12 @@ bool MediaRouterEnabled(content::BrowserContext* context) { if (!base::FeatureList::IsEnabled(kMediaRouter)) return false; #endif // !BUILDFLAG(IS_ANDROID) +#if BUILDFLAG(IS_CHROMEOS_ASH) + // TODO(crbug.com/1380828): Make the Media Router feature configurable via a + // policy for non-user profiles, i.e. sign-in and lock screen profiles. + if (!IsUserProfile(Profile::FromBrowserContext(context))) + return false; +#endif // BUILDFLAG(IS_CHROMEOS_ASH) // The MediaRouter service is shared across the original and the incognito // profiles, so we must use the original context for consistency between them.