* Gate Playlist UI on BravePlaylistEnabled policy Complements #35732, which hides Playlist via the enable_playlist buildflag in is_brave_origin_branded=true builds, by also hiding the Playlist UI in is_brave_origin_branded=false builds when an administrator disables it via the BravePlaylistEnabled policy (kPlaylistEnabledPref managed=false). Adds playlist::IsPlaylistEnabled(prefs) / IsDisabledByPolicy(prefs) helpers alongside existing features.h / pref_names.h, mirroring the iOS PrefService.isPlaylistAvailable check and the ai_chat::IsAIChatEnabled pattern. The helper is used to gate the sidebar item, side panel coordinator and entry, browser action, playlist command, tab helper, page action icon, and the chrome-untrusted://playlist WebUI. The SidebarService now observes kPlaylistEnabledPref so the item appears and disappears when policy changes at runtime. User-driven pref toggles from settings keep their existing behaviour (UI stays reachable so the user can flip the pref back); only a managed pref forced off hides the UI. Fixes brave/brave-browser#50156 * Address review: move IsPlaylistAllowed out of common, simplify settings bools - Relocate playlist::IsPlaylistEnabled from components/playlist/core/common (which is reachable from any process) to a new components/playlist/core/browser target, since the helper depends on PrefService (browser-only). Rename the function to IsPlaylistAllowed to match its semantics (feature flag is enabled and the pref is not policy-disabled), matching bridiver's suggestion that "allowed" = managed+feature, "enabled" = user toggle. - Update all callers and BUILD/DEPS wiring for the new location. - In brave_settings_ui.cc, stop combining the feature flag and the user pref into a single isPlaylistAllowed loadTimeData bool. Instead expose isPlaylistFeatureEnabled and isPlaylistDisabledByPolicy (the Tor pattern), and let settings page code consult the pref directly via the prefs mixin when it needs the managed state. page_visibility.ts now computes playlist visibility from the two building blocks.
59 lines
2.0 KiB
Plaintext
59 lines
2.0 KiB
Plaintext
# Copyright (c) 2022 The Brave Authors. All rights reserved.
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
import("//brave/components/brave_education/buildflags.gni")
|
|
import("//brave/components/brave_origin/buildflags/buildflags.gni")
|
|
import("//brave/components/brave_vpn/common/buildflags/buildflags.gni")
|
|
import("//brave/components/containers/buildflags/buildflags.gni")
|
|
import("//brave/components/playlist/core/common/buildflags/buildflags.gni")
|
|
import("//brave/components/psst/buildflags/buildflags.gni")
|
|
|
|
# This is required for chromium_src overrides.
|
|
brave_browser_ui_webui_configs_deps = [
|
|
"//base",
|
|
"//brave/browser/ui",
|
|
"//brave/components/brave_account:features",
|
|
"//brave/components/brave_education:buildflags",
|
|
"//brave/components/brave_origin/buildflags",
|
|
"//brave/components/brave_shields/content/browser",
|
|
"//brave/components/brave_vpn/common/buildflags",
|
|
"//brave/components/containers/buildflags",
|
|
"//brave/components/playlist/core/common/buildflags",
|
|
]
|
|
|
|
if (enable_playlist_webui) {
|
|
brave_browser_ui_webui_configs_deps += [
|
|
"//brave/components/playlist/core/browser",
|
|
"//brave/components/playlist/core/common",
|
|
]
|
|
}
|
|
|
|
if (enable_brave_vpn) {
|
|
brave_browser_ui_webui_configs_deps +=
|
|
[ "//brave/components/brave_vpn/browser" ]
|
|
}
|
|
|
|
if (enable_brave_education) {
|
|
brave_browser_ui_webui_configs_deps +=
|
|
[ "//brave/browser/ui/webui/brave_education" ]
|
|
}
|
|
|
|
if (is_brave_origin_branded) {
|
|
brave_browser_ui_webui_configs_deps +=
|
|
[ "//brave/browser/ui/webui/brave_origin_startup" ]
|
|
}
|
|
|
|
if (enable_containers) {
|
|
brave_browser_ui_webui_configs_deps += [
|
|
"//brave/components/containers/core/browser",
|
|
"//brave/components/containers/core/common",
|
|
"//brave/components/containers/core/mojom",
|
|
]
|
|
}
|
|
|
|
if (enable_psst) {
|
|
brave_browser_ui_webui_configs_deps += [ "//brave/browser/ui/webui/psst" ]
|
|
}
|