diff --git a/browser/policy/brave_simple_policy_map.h b/browser/policy/brave_simple_policy_map.h index 9228e95d50f1..09dab6a26b58 100644 --- a/browser/policy/brave_simple_policy_map.h +++ b/browser/policy/brave_simple_policy_map.h @@ -46,6 +46,8 @@ inline constexpr PolicyToPreferenceMapEntry kBraveSimplePolicyMap[] = { kManagedBraveShieldsEnabledForUrls, base::Value::Type::LIST}, {policy::key::kBraveSyncUrl, brave_sync::kCustomSyncServiceUrl, base::Value::Type::STRING}, + {policy::key::kWebTorrentDisabled, + webtorrent::prefs::kWebTorrentDisabledByPolicy, base::Value::Type::BOOLEAN}, #endif #if BUILDFLAG(ENABLE_TOR) diff --git a/components/brave_webtorrent/browser/webtorrent_util.cc b/components/brave_webtorrent/browser/webtorrent_util.cc index d423fe60fc80..1d2ed64278d9 100644 --- a/components/brave_webtorrent/browser/webtorrent_util.cc +++ b/components/brave_webtorrent/browser/webtorrent_util.cc @@ -16,6 +16,8 @@ #include "extensions/common/constants.h" #include "net/http/http_content_disposition.h" #include "net/http/http_response_headers.h" +#include "brave/components/webtorrent/common/pref_names.h" +#include "components/prefs/pref_service.h" namespace webtorrent { @@ -47,6 +49,12 @@ bool IsWebtorrentEnabled(content::BrowserContext* browser_context) { if (!registry) { return false; } + + PrefService* prefs = Profile::FromBrowserContext(browser_context)->GetPrefs(); + if (prefs && prefs->GetBoolean(webtorrent::prefs::kWebTorrentDisabledByPolicy)) { + return false; + } + return registry->enabled_extensions().Contains(brave_webtorrent_extension_id); } diff --git a/components/brave_webtorrent/common/pref_names.h b/components/brave_webtorrent/common/pref_names.h new file mode 100644 index 000000000000..e3511cccfa1a --- /dev/null +++ b/components/brave_webtorrent/common/pref_names.h @@ -0,0 +1,18 @@ +// Copyright (c) 2021 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 https://mozilla.org/MPL/2.0/. + +#ifndef BRAVE_COMPONENTS_WEBTORRENT_COMMON_PREF_NAMES_H_ +#define BRAVE_COMPONENTS_WEBTORRENT_COMMON_PREF_NAMES_H_ + +namespace webtorrent { +namespace prefs { + +inline constexpr char kWebTorrentDisabledByPolicy[] = + "webtorrent.disabled_by_policy"; + +} // namespace prefs +} // namespace webtorrent + +#endif // BRAVE_COMPONENTS_WEBTORRENT_COMMON_PREF_NAMES_H_ diff --git a/components/policy/resources/templates/policy_definitions/BraveSoftware/BraveWebtorrentDisabled.yaml b/components/policy/resources/templates/policy_definitions/BraveSoftware/BraveWebtorrentDisabled.yaml new file mode 100644 index 000000000000..5f0094fa7903 --- /dev/null +++ b/components/policy/resources/templates/policy_definitions/BraveSoftware/BraveWebtorrentDisabled.yaml @@ -0,0 +1,37 @@ +caption: Disable WebTorrent +default: null +desc: |- + Disable WebTorrent in Brave. + + WebTorrent is a feature that allows users to stream and download torrents directly in Brave. + + If this policy is set to true, WebTorrent will always be disabled. + + If this policy is set to false, WebTorrent will always be enabled. + + If you set this policy, users cannot change or override it. + + If this policy is left unset, WebTorrent will be enabled by default. +example_value: true +features: + can_be_mandatory: true + can_be_recommended: false + dynamic_refresh: false + per_profile: true +items: +- caption: Enable WebTorrent + value: false +- caption: Disable WebTorrent + value: true +- caption: Allow the user to decide + value: null +owners: +- bbondy@brave.com +- peter@brave.com +- clifton@brave.com +schema: + type: boolean +supported_on: + - chrome.*:105- +tags: [] +type: main diff --git a/ui/webui/resources/br_elements/br_toolbar/br_toolbar.html b/ui/webui/resources/br_elements/br_toolbar/br_toolbar.html index d8fcb56f52be..e9a2a239e8f7 100644 --- a/ui/webui/resources/br_elements/br_toolbar/br_toolbar.html +++ b/ui/webui/resources/br_elements/br_toolbar/br_toolbar.html @@ -28,7 +28,8 @@ display: flex; justify-content: center; margin: 0; - padding: 6px 0; + padding-right:1em; + padding-left:1em; gap: 6px; } diff --git a/ui/webui/resources/br_elements/br_toolbar/br_toolbar_search_field.html b/ui/webui/resources/br_elements/br_toolbar/br_toolbar_search_field.html index 4906e0720b94..bc580a03bcbf 100644 --- a/ui/webui/resources/br_elements/br_toolbar/br_toolbar_search_field.html +++ b/ui/webui/resources/br_elements/br_toolbar/br_toolbar_search_field.html @@ -1,7 +1,7 @@