diff --git a/app/filtering.js b/app/filtering.js index 1ec5bc459c5..14e992d23c0 100644 --- a/app/filtering.js +++ b/app/filtering.js @@ -318,13 +318,6 @@ function registerPermissionHandler (session, partition) { } } } - const url = mainFrameUrl || origin - // Allow notifications for the main app - if (url === appUrlUtil.getIndexHTML() && permission === 'notifications' || - url.startsWith('chrome-extension://') && permission === 'openExternal') { - cb(true) - return - } if (!permissions[permission]) { console.log('WARNING: got unregistered permission request', permission) @@ -332,10 +325,27 @@ function registerPermissionHandler (session, partition) { return } + // TOOD(bridiver) - this seems overly permissive and we should narrow this down + // to the specific extension that required it which is most likely PDFJS + if (origin.startsWith('chrome-extension://') && permission === 'openExternal') { + cb(true) + return + } + + if (mainFrameUrl === appUrlUtil.getIndexHTML() || origin.startsWith('chrome-extension://' + config.braveExtensionId)) { + // lookup, display and store site settings by "Brave Browser" + origin = 'Brave Browser' + // display on all tabs + mainFrameUrl = null + } else { + // Strip trailing slash + origin = getOrigin(origin) + } + // Check whether there is a persistent site setting for this host const appState = AppStore.getState() - const settings = siteSettings.getSiteSettingsForURL(appState.get('siteSettings'), url) - const tempSettings = siteSettings.getSiteSettingsForURL(appState.get('temporarySiteSettings'), url) + const settings = siteSettings.getSiteSettingsForHostPattern(appState.get('siteSettings'), origin) + const tempSettings = siteSettings.getSiteSettingsForHostPattern(appState.get('temporarySiteSettings'), origin) const permissionName = permission + 'Permission' if (settings) { let isAllowed = settings.get(permissionName) @@ -365,7 +375,7 @@ function registerPermissionHandler (session, partition) { {text: locale.translation('deny')}, {text: locale.translation('allow')} ], - origin, + frameOrigin: getOrigin(mainFrameUrl), options: { persist: true }, @@ -380,7 +390,7 @@ function registerPermissionHandler (session, partition) { cb(result) if (persist) { // remember site setting for this host over http(s) - appActions.changeSiteSetting(getOrigin(url), permission + 'Permission', result, isPrivate) + appActions.changeSiteSetting(origin, permission + 'Permission', result, isPrivate) } } }) diff --git a/app/index.js b/app/index.js index fcbfba49871..6bb60f7b2ab 100644 --- a/app/index.js +++ b/app/index.js @@ -450,13 +450,6 @@ app.on('ready', () => { electron.clipboard.writeText(text) }) - ipcMain.on(messages.SHOW_NOTIFICATION, (e, msg) => { - if (BrowserWindow.getFocusedWindow()) { - BrowserWindow.getFocusedWindow().webContents.send(messages.SHOW_NOTIFICATION, - locale.translation(msg)) - } - }) - ipcMain.on(messages.CHECK_FLASH_INSTALLED, (e) => { flash.checkFlashInstalled((installed) => { e.sender.send(messages.FLASH_UPDATED, installed) diff --git a/js/about/aboutActions.js b/js/about/aboutActions.js index 3fc84766479..27e612aa99f 100644 --- a/js/about/aboutActions.js +++ b/js/about/aboutActions.js @@ -156,10 +156,6 @@ const AboutActions = { ipc.send(messages.CHECK_FLASH_INSTALLED) }, - showNotification: function (msg) { - ipc.send(messages.SHOW_NOTIFICATION, msg) - }, - setResourceEnabled: function (resourceName, enabled) { AboutActions.dispatchAction({ actionType: AppConstants.APP_SET_RESOURCE_ENABLED, diff --git a/js/about/passwords.js b/js/about/passwords.js index 25a92c80c3a..38d4a5e0ea0 100644 --- a/js/about/passwords.js +++ b/js/about/passwords.js @@ -63,7 +63,6 @@ class PasswordItem extends React.Component { onCopy () { if (this.state.decrypted !== null) { aboutActions.setClipboard(this.state.decrypted) - aboutActions.showNotification('passwordCopied') } else { this.decrypt(false) } @@ -74,7 +73,6 @@ class PasswordItem extends React.Component { return } aboutActions.setClipboard(details.decrypted) - aboutActions.showNotification('passwordCopied') this.setState({ decrypted: details.decrypted }) diff --git a/js/components/frame.js b/js/components/frame.js index bfd762cc895..1651e52b780 100644 --- a/js/components/frame.js +++ b/js/components/frame.js @@ -580,8 +580,7 @@ class Frame extends ImmutableComponent { } else { flash.checkFlashInstalled((installed) => { if (installed) { - currentWindow.webContents.send(messages.SHOW_NOTIFICATION, - locale.translation('flashInstalled')) + void new window.Notification(locale.translation('flashInstalled')) } else if (noFlashCallback) { noFlashCallback() } diff --git a/js/components/main.js b/js/components/main.js index 2194af8aa09..c85429ebe52 100644 --- a/js/components/main.js +++ b/js/components/main.js @@ -340,10 +340,6 @@ class Main extends ImmutableComponent { frameProps && windowActions.setRedirectedBy(frameProps, ruleset, details.url) }) - ipc.on(messages.SHOW_NOTIFICATION, (e, text) => { - void new window.Notification(text) - }) - ipc.on(messages.SHORTCUT_ACTIVE_FRAME_BACK, this.onBack) ipc.on(messages.SHORTCUT_ACTIVE_FRAME_FORWARD, this.onForward) diff --git a/js/constants/messages.js b/js/constants/messages.js index 37c2fb405fb..b65f0385919 100644 --- a/js/constants/messages.js +++ b/js/constants/messages.js @@ -72,7 +72,6 @@ const messages = { ENTER_FULL_SCREEN: _, SET_CLIPBOARD: _, GOT_CANVAS_FINGERPRINTING: _, - SHOW_NOTIFICATION: _, /** @arg {string} l10n id of desktop notification message */ GO_BACK: _, GO_FORWARD: _, RELOAD: _,