Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Settings]: Fix missing permissions (uplift to 1.75.x) #27213

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 19 additions & 25 deletions browser/resources/settings/brave_overrides/site_details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,26 @@
// 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/.

import type {SiteDetailsPermissionElement} from '../site_settings/site_details_permission.js'
import type { SiteDetailsPermissionElement } from '../site_settings/site_details_permission.js'

import {RegisterPolymerTemplateModifications} from 'chrome://resources/brave/polymer_overriding.js'
import {html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'
import {loadTimeData} from '../i18n_setup.js'
import { RegisterPolymerTemplateModifications, html } from 'chrome://resources/brave/polymer_overriding.js'
import { loadTimeData } from '../i18n_setup.js'

import 'chrome://resources/brave/leo.bundle.js'

const insertBefore = (element: Element, newElement: Element | Node) => {
if (!element.parentNode) {
throw new Error('Element has no parent node - nothing will be inserted')
}

element.parentNode.insertBefore(newElement, element)
}

RegisterPolymerTemplateModifications({
'site-details': (templateContent: HTMLTemplateElement) => {
// Add top-padding to subpage
templateContent.prepend(
html`<style>#usage { padding-top: var(--leo-spacing-l); }</style>`.
content)
html`<style>#usage { padding-top: var(--leo-spacing-l); }</style>`)

if (!loadTimeData.getBoolean('isIdleDetectionFeatureEnabled')) {
const idleDetectionItem =
Expand All @@ -41,9 +47,7 @@ RegisterPolymerTemplateModifications({
if (!firstPermissionItem) {
console.error('[Settings] Couldn\'t find first permission item')
} else {
firstPermissionItem.insertAdjacentElement(
'beforebegin',
html`<site-details-permission
insertBefore(firstPermissionItem, html`<site-details-permission
category="[[contentSettingsTypesEnum_.AUTOPLAY]]"
icon="autoplay-on">
</site-details-permission>`)
Expand All @@ -62,9 +66,7 @@ RegisterPolymerTemplateModifications({
const isGoogleSignInFeatureEnabled =
loadTimeData.getBoolean('isGoogleSignInFeatureEnabled')
if (isGoogleSignInFeatureEnabled) {
firstPermissionItem.insertAdjacentElement(
'beforebegin',
html`<site-details-permission
insertBefore(firstPermissionItem, html`<site-details-permission
category="[[contentSettingsTypesEnum_.GOOGLE_SIGN_IN]]"
icon="user">
</site-details-permission>`)
Expand All @@ -83,9 +85,7 @@ RegisterPolymerTemplateModifications({
const isLocalhostAccessFeatureEnabled =
loadTimeData.getBoolean('isLocalhostAccessFeatureEnabled')
if (isLocalhostAccessFeatureEnabled) {
firstPermissionItem.insertAdjacentElement(
'beforebegin',
html`<site-details-permission
insertBefore(firstPermissionItem, html`<site-details-permission
category="[[contentSettingsTypesEnum_.LOCALHOST_ACCESS]]"
icon="smartphone-desktop">
</site-details-permission>`)
Expand All @@ -103,9 +103,7 @@ RegisterPolymerTemplateModifications({
const isOpenAIChatFromBraveSearchEnabled =
loadTimeData.getBoolean('isOpenAIChatFromBraveSearchEnabled')
if (isOpenAIChatFromBraveSearchEnabled) {
firstPermissionItem.insertAdjacentElement(
'beforebegin',
html`<site-details-permission
insertBefore(firstPermissionItem, html`<site-details-permission
category="[[contentSettingsTypesEnum_.BRAVE_OPEN_AI_CHAT]]"
icon="user">
</site-details-permission>`)
Expand All @@ -122,9 +120,7 @@ RegisterPolymerTemplateModifications({
const isNativeBraveWalletEnabled =
loadTimeData.getBoolean('isNativeBraveWalletFeatureEnabled')
if (isNativeBraveWalletEnabled) {
firstPermissionItem.insertAdjacentElement(
'beforebegin',
html`<site-details-permission
insertBefore(firstPermissionItem, html`<site-details-permission
category="[[contentSettingsTypesEnum_.ETHEREUM]]"
icon="ethereum-on">
</site-details-permission>`)
Expand All @@ -137,9 +133,7 @@ RegisterPolymerTemplateModifications({
'label', loadTimeData.getString('siteSettingsEthereum'))
}
curChild++
firstPermissionItem.insertAdjacentElement(
'beforebegin',
html`<site-details-permission
insertBefore(firstPermissionItem, html`<site-details-permission
category="[[contentSettingsTypesEnum_.SOLANA]]"
icon="solana-on">
</site-details-permission>`)
Expand All @@ -166,6 +160,6 @@ RegisterPolymerTemplateModifications({
// separate ones.
templateContent.
querySelector('site-details-permission[icon="settings:vr-headset"]')?.
setAttribute('icon', 'smartphone-hand')
setAttribute('icon', 'smartphone-hand')
}
})
Loading