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

Preinstalled extensions #2

Open
wants to merge 6 commits into
base: mozilla-central
Choose a base branch
from
Open
Show file tree
Hide file tree
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
25 changes: 25 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# Argo?

## Setup

**this is unverified, but seems right**

- You need an `origin` git remote of the Mozilla Mercurial repo, along with whatever remote you're using for this fork repo:
```
origin hg::https://hg.mozilla.org/mozilla-unified (fetch)
origin hg::https://hg.mozilla.org/mozilla-unified (push)
opfn [email protected]:operating-function/gecko-dev.git (fetch)
opfn [email protected]:operating-function/gecko-dev.git (push)
mozilla [email protected]:mozilla/gecko-dev.git (fetch)
mozilla [email protected]:mozilla/gecko-dev.git (push)
```
- You probably need to follow the directions Mozilla provides in general first, including having a `git cinnabar` installation working. (https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html)
- We have a `mozilla-central` branch which is based off of the _gecko-dev_ readonly git mirror's `master`. This seems to track the `mozilla-unified` repo's `bookmarks/central` branch.
- For the sake of our purposes here, consider our `mozilla-central` branch to be "master", I suppose.
- We should attempt to keep our `mozilla-central` branch reasonably up-to-date with the upstream; or else lock to a version for now and push off the daunting task of keeping our fork updated...
- Once you have an `origin` remote and a local `gecko-dev` mirror, you should be able to `./mach build` from the root of this repo. The build process seems to require having the Mercurial `origin` present.

---

# `README.txt` From original fork:

An explanation of the Firefox Source Code Directory Structure and links to
project pages with documentation can be found at:

Expand Down
40 changes: 40 additions & 0 deletions browser/app/profile/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"addons": [
{
"id": "[email protected]",
"syncGUID": "{c1619560-4d77-4744-997b-b0eb33c49444}",
"version": "1.0",
"type": "extension",
"loader": null,
"updateDate": 1705507200000,
"path": "features/[email protected]",
"defaultLocale": {
"name": "WARC Availability Indicator",
"description": "Shows when a WARC archive is available"
},
"visible": true,
"active": true,
"userDisabled": false,
"appDisabled": false,
"installDate": 1705507200000
},
{
"id": "[email protected]",
"syncGUID": "{d1619560-4d77-4744-997b-b0eb33c49444}",
"version": "1.0",
"type": "extension",
"loader": null,
"updateDate": 1705507200000,
"path": "features/[email protected]",
"defaultLocale": {
"name": "WARC Recorder",
"description": "Records web traffic in WARC format",
},
"visible": true,
"active": true,
"userDisabled": false,
"appDisabled": false,
"installDate": 1705507200000
}
]
}
39 changes: 27 additions & 12 deletions browser/app/profile/firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,21 @@

pref("browser.hiddenWindowChromeURL", "chrome://browser/content/hiddenWindowMac.xhtml");

pref("[email protected]", true);
pref("extensions.systemAddonSet", '{"schema":1,"addons":{"[email protected]":{"version":"1.0"}}}');
pref("extensions.installDistroAddons", true);

pref("[email protected]", true);
pref("extensions.systemAddonSet", '{"schema":1,"addons":{"[email protected]":{"version":"1.0"}}}');

pref("extensions.activeThemeID", "[email protected]");


// Set add-ons abuse report related prefs specific to Firefox Desktop.
pref("extensions.abuseReport.enabled", true);

// Enables some extra Extension System Logging (can reduce performance)
pref("extensions.logging.enabled", false);
pref("extensions.logging.enabled", true);

// Disables strict compatibility, making addons compatible-by-default.
pref("extensions.strictCompatibility", false);
Expand Down Expand Up @@ -56,9 +66,10 @@ pref("extensions.systemAddon.update.enabled", true);

// Disable add-ons that are not installed by the user in all scopes by default.
// See the SCOPE constants in AddonManager.sys.mjs for values to use here.
pref("extensions.autoDisableScopes", 15);
pref("extensions.autoDisableScopes", 0);
// Scopes to scan for changes at startup.
pref("extensions.startupScanScopes", 0);
// OPFN: changed from 0 to 31 to include ALL scopes
pref("extensions.startupScanScopes", 31);

pref("extensions.geckoProfiler.acceptedExtensionIds", "[email protected],[email protected],[email protected]");

Expand Down Expand Up @@ -358,6 +369,11 @@ pref("browser.startup.windowsLaunchOnLogin.disableLaunchOnLoginPrompt", false);
// Show an upgrade dialog on major upgrades.
pref("browser.startup.upgradeDialog.enabled", false);

// Enable verbose extension logging
pref("extensions.logging.enabled", true);
pref("extensions.webextensions.log.level", "debug");
pref("extensions.webextensions.log.stdout", true);

pref("browser.chrome.site_icons", true);
// browser.warnOnQuit == false will override all other possible prompts when quitting or restarting
pref("browser.warnOnQuit", true);
Expand Down Expand Up @@ -635,7 +651,11 @@ pref("browser.urlbar.sponsoredTopSites", false);

// Global toggle for whether the show search terms feature
// can be used at all, and enabled/disabled by the user.
#if defined(EARLY_BETA_OR_EARLIER)
pref("browser.urlbar.showSearchTerms.featureGate", true);
#else
pref("browser.urlbar.showSearchTerms.featureGate", false);
#endif

// If true, show the search term in the Urlbar while on
// a default search engine results page.
Expand Down Expand Up @@ -2019,6 +2039,8 @@ pref("browser.newtabpage.activity-stream.hideTopSitesWithSearchParam", "mfadid=a
pref("browser.aboutwelcome.enabled", true);
// Used to set multistage welcome UX
pref("browser.aboutwelcome.screens", "");
// Used to enable window modal onboarding
pref("browser.aboutwelcome.showModal", false);

// Experiment Manager
// See Console.sys.mjs LOG_LEVELS for all possible values
Expand Down Expand Up @@ -2263,9 +2285,6 @@ pref("privacy.trackingprotection.fingerprinting.enabled", true);
// Enable cryptomining blocking by default for all channels, only on desktop.
pref("privacy.trackingprotection.cryptomining.enabled", true);

// Skip earlyBlankFirstPaint by default if resistFingerprinting is enabled.
pref("privacy.resistFingerprinting.skipEarlyBlankFirstPaint", true);

pref("browser.contentblocking.database.enabled", true);

// Enable Strip on Share by default on desktop
Expand Down Expand Up @@ -3314,12 +3333,8 @@ pref("browser.backup.template.fallback-download.aurora", "https://www.mozilla.or
pref("browser.backup.template.fallback-download.nightly", "https://www.mozilla.org/firefox/channel/desktop/?utm_medium=firefox-desktop&utm_source=backup&utm_campaign=firefox-backup-2024&utm_content=control#nightly");
pref("browser.backup.template.fallback-download.esr", "https://www.mozilla.org/firefox/enterprise/?utm_medium=firefox-desktop&utm_source=backup&utm_campaign=firefox-backup-2024&utm_content=control#download");

#ifdef NIGHTLY_BUILD
// Pref to enable the new profiles
pref("browser.profiles.enabled", true);
#else
pref("browser.profiles.enabled", false);
#endif
// Pref to enable the new profiles
pref("browser.profiles.enabled", false);
pref("browser.profiles.profile-name.updated", false);
// Whether to allow the user to merge profile data
pref("browser.profiles.sync.allow-danger-merge", false);
Expand Down
3 changes: 3 additions & 0 deletions browser/extensions/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ DIRS += [
"report-site-issue",
"pictureinpicture",
"search-detection",
"warc-indicator",
"warc-recorder",
"peer-sidebar",
]
3 changes: 3 additions & 0 deletions browser/extensions/moz.configure
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
imply_option('warc-indicator', True)
imply_option('warc-recorder', True)
imply_option('peer-sidebar', True)
54 changes: 54 additions & 0 deletions browser/extensions/peer-sidebar/background/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* 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/. */

"use strict";

let gPeers = [];
// const REFRESH_INTERVAL = 30000; // 30 seconds
const REFRESH_INTERVAL = 3000; // 3 seconds

// Handle messages from the sidebar panel
browser.runtime.onMessage.addListener((message, sender) => {
switch (message.type) {
case "get-peers":
return Promise.resolve(gPeers);
default:
console.warn("Unknown message type:", message.type);
return Promise.reject(new Error("Unknown message type"));
}
});

async function fetchPeers() {
try {
const response = await fetch("http://localhost:8000/users", {});

gPeers = await response.json();
console.log("gPeers ", { gPeers });

// Notify all sidebar instances of the update
const tabs = await browser.tabs.query({});
for (const tab of tabs) {
try {
console.log('sending "peers-updated"');
browser.runtime.sendMessage({
type: "peers-updated",
peers: gPeers,
});
} catch (e) {
// Ignore errors from tabs that can't receive the message
console.debug("Could not send peers-updated to tab", tab.id, e);
}
}
} catch (error) {
// Suppress CORS errors in console
if (!error.message.includes("CORS")) {
console.error("Error fetching peers:", error);
}
// Keep the old peer list on error
}
}

// Initialize polling when the background script starts
fetchPeers(); // Initial fetch
setInterval(fetchPeers, REFRESH_INTERVAL);
1 change: 1 addition & 0 deletions browser/extensions/peer-sidebar/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions browser/extensions/peer-sidebar/knowledge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Peer Sidebar Extension

## Known Issues

### CORS Configuration
The backend at localhost:8000 needs CORS headers to allow requests from the extension.
Backend should add:
```
Access-Control-Allow-Origin: moz-extension://*
Access-Control-Allow-Methods: GET
```

Currently using `mode: 'no-cors'` as temporary workaround.

## Development Notes
- Polling interval: 3s (dev), 30s (prod)
- Background script manages state and polling
- Panel script handles UI only
27 changes: 27 additions & 0 deletions browser/extensions/peer-sidebar/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"manifest_version": 2,
"name": "Peer Sidebar",
"version": "1.0",
"description": "Shows peer information in a sidebar",
"browser_specific_settings": {
"gecko": {
"id": "[email protected]"
}
},
"icons": {
"48": "icon.png",
"96": "icon.png"
},
"permissions": [
"http://localhost:8000/*",
"tabs"
],
"background": {
"scripts": ["background/background.js"]
},
"sidebar_action": {
"default_title": "Peer List",
"default_panel": "sidebar/panel.html",
"default_icon": "icon.png"
}
}
26 changes: 26 additions & 0 deletions browser/extensions/peer-sidebar/moz.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.

DEFINES['MOZ_APP_VERSION'] = CONFIG['MOZ_APP_VERSION']
DEFINES['MOZ_APP_MAXVERSION'] = CONFIG['MOZ_APP_MAXVERSION']

FINAL_TARGET_FILES.features['[email protected]'] += [
'manifest.json',
]

FINAL_TARGET_FILES.features['[email protected]'].background += [
'background/background.js',
]

FINAL_TARGET_FILES.features['[email protected]'].sidebar += [
'sidebar/panel.css',
'sidebar/panel.html',
'sidebar/panel.js',
]

FINAL_TARGET_FILES.features['[email protected]'].icons += [
'icon.png',
]
30 changes: 30 additions & 0 deletions browser/extensions/peer-sidebar/sidebar/panel.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
padding: 16px;
background-color: #ffffff;
}

.peer-item {
border: 1px solid #ddd;
margin-bottom: 8px;
padding: 12px;
border-radius: 4px;
}

.peer-name {
font-weight: bold;
margin-bottom: 4px;
}

.peer-ip {
color: #666;
font-family: monospace;
margin-bottom: 4px;
}

.peer-key {
color: #444;
font-family: monospace;
font-size: 0.9em;
word-break: break-all;
}
14 changes: 14 additions & 0 deletions browser/extensions/peer-sidebar/sidebar/panel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="panel.css">
</head>
<body>
<div id="container">
<h2>Peer List</h2>
<div id="peer-list"></div>
</div>
<script src="panel.js"></script>
</body>
</html>
Loading