Skip to content

Commit

Permalink
🐛 Fix extension panel multiprocess support
Browse files Browse the repository at this point in the history
  • Loading branch information
trickypr committed Dec 24, 2023
1 parent 1e91e6a commit 75b49d9
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 19 deletions.
45 changes: 28 additions & 17 deletions src/content/browser/components/omnibox/PageAction.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,25 @@
}
})
function setupBrowser(browser) {
browser.messageManager.addMessageListener(
'Extension:BrowserResized',
messageReceiver,
)
browser.messageManager.loadFrameScript(
'chrome://extensions/content/ext-browser-content.js',
false,
true,
)
browser.messageManager.sendAsyncMessage('Extension:InitBrowser', {
allowScriptsToClose: true,
maxWidth: 800,
maxHeight: 600,
})
}
async function buildPanelBrowser() {
if (browser) {
browser.remove()
Expand All @@ -49,7 +68,7 @@
remoteType: getBrowserRemoteType(uri),
attributes: {
disableglobalhistory: 'true',
messagemanagergroup: 'todo',
messagemanagergroup: 'webext-browsers',
'webextension-view-type': 'popup',
},
})
Expand All @@ -58,23 +77,11 @@
panel.appendChild(lBrowser)
browser = lBrowser
lBrowser.messageManager.addMessageListener(
'Extension:BrowserResized',
messageReceiver,
)
lBrowser.messageManager.loadFrameScript(
'chrome://extensions/content/ext-browser-content.js',
false,
true,
)
lBrowser.messageManager.sendAsyncMessage('Extension:InitBrowser', {
allowScriptsToClose: true,
maxWidth: 800,
maxHeight: 600,
})
lBrowser.style.borderRadius = 'inherit'
setupBrowser(lBrowser)
lBrowser.addEventListener('DidChangeBrowserRemoteness', () =>
setupBrowser(lBrowser),
)
await spinLock(() => lBrowser.mInitialized)
setURI(lBrowser, uri)
Expand Down Expand Up @@ -138,5 +145,9 @@
height: 1em;
color: var(--text);
/* This is firefox's dark mode filter
TODO: When we have themes, toggle this correctly */
filter: grayscale(100%) brightness(20%) invert();
}
</style>
14 changes: 12 additions & 2 deletions src/content/shared/search/providers/URLProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import tld from './data/tld.txt'

const HTTPS_REGEX =
/^(?<protocol>https?:\/\/)?(?<domain>(\w+\.)+(?<tld>\w+))(?<path>\/.*)?$/m
const EXTENSION_REGEX = /^moz-extension:\/\/.+$/m
const CHROME_REGEX = /^chrome:\/\/.+$/m
const ABOUT_REGEX = /^about:.+$/m
const tlds = tld
Expand All @@ -19,7 +20,12 @@ const tlds = tld
* @returns If the query is a url or not
*/
export function isUrlLike(query: string): boolean {
if (ABOUT_REGEX.test(query) || CHROME_REGEX.test(query)) return true
if (
ABOUT_REGEX.test(query) ||
CHROME_REGEX.test(query) ||
EXTENSION_REGEX.test(query)
)
return true
const match = HTTPS_REGEX.exec(query)
if (match === null) return false

Expand All @@ -35,7 +41,11 @@ export class URLProvider extends Provider {

public async getResults(query: string): Promise<ProviderResult[]> {
// Check against chrome urls
if (CHROME_REGEX.test(query) || ABOUT_REGEX.test(query))
if (
CHROME_REGEX.test(query) ||
ABOUT_REGEX.test(query) ||
EXTENSION_REGEX.test(query)
)
return [
{
title: query,
Expand Down
3 changes: 3 additions & 0 deletions src/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ pref('browser.download.alwaysOpenPanel', true);
// 2 - Remove the download from both session list and history.
pref('browser.download.clearHistoryOnDelete', 0);

// We do this because we want page actions etc. to have color schemes
pref('svg.context-properties.content.enabled', true);

// =============================================================================
// Multithreading

Expand Down

0 comments on commit 75b49d9

Please sign in to comment.