Skip to content

Commit 09024f2

Browse files
Bug 1880368 - change firefox and firefox-private protocols to firefox-bridge and firefox-private-bridge protocols r=nshukla,mossop
Differential Revision: https://phabricator.services.mozilla.com/D201879
1 parent 98aecb3 commit 09024f2

File tree

13 files changed

+694
-195
lines changed

13 files changed

+694
-195
lines changed

browser/app/macbuild/Contents/Info.plist.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,15 @@
237237
<string>Firefox Protocol</string>
238238
<key>CFBundleURLSchemes</key>
239239
<array>
240-
<string>firefox</string>
240+
<string>firefox-bridge</string>
241241
</array>
242242
</dict>
243243
<dict>
244244
<key>CFBundleURLName</key>
245245
<string>Firefox Private Browsing Protocol</string>
246246
<key>CFBundleURLSchemes</key>
247247
<array>
248-
<string>firefox-private</string>
248+
<string>firefox-private-bridge</string>
249249
</array>
250250
</dict>
251251
</array>

browser/app/profile/firefox.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,6 @@ pref("browser.shell.checkDefaultPDF.silencedByUser", false);
298298
// URL to navigate to when launching Firefox after accepting the Windows Default
299299
// Browser Agent "Set Firefox as default" call to action.
300300
pref("browser.shell.defaultBrowserAgent.thanksURL", "https://www.mozilla.org/%LOCALE%/firefox/set-as-default/thanks/");
301-
// Whether or not we want to run through the early startup idle task
302-
// which registers the firefox and firefox-private registry keys.
303-
pref("browser.shell.customProtocolsRegistered", false);
304301
#endif
305302

306303

browser/components/BrowserContentHandler.sys.mjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function resolveURIInternal(
9090
if (aArgument.startsWith(protocolWithColon)) {
9191
if (!validateFirefoxProtocol(aCmdLine, launchedWithArg_osint)) {
9292
throw new Error(
93-
"Invalid use of Firefox and Firefox-private protocols."
93+
"Invalid use of Firefox-bridge and Firefox-private-bridge protocols."
9494
);
9595
}
9696
aArgument = aArgument.substring(protocolWithColon.length);
@@ -100,7 +100,7 @@ function resolveURIInternal(
100100
!aArgument.startsWith("https://")
101101
) {
102102
throw new Error(
103-
"Firefox and Firefox-private protocols can only be used in conjunction with http and https urls."
103+
"Firefox-bridge and Firefox-private-bridge protocols can only be used in conjunction with http and https urls."
104104
);
105105
}
106106

@@ -113,8 +113,8 @@ function resolveURIInternal(
113113
}
114114
};
115115

116-
handleFirefoxProtocol("firefox");
117-
handleFirefoxProtocol("firefox-private");
116+
handleFirefoxProtocol("firefox-bridge");
117+
handleFirefoxProtocol("firefox-private-bridge");
118118

119119
var uri = aCmdLine.resolveURI(aArgument);
120120
var uriFixup = Services.uriFixup;
@@ -599,7 +599,7 @@ nsBrowserContentHandler.prototype = {
599599
if (urlFlagIdx > -1 && cmdLine.length > 1) {
600600
url = cmdLine.getArgument(urlFlagIdx + 1);
601601
}
602-
if (privateWindowParam || url?.startsWith("firefox-private:")) {
602+
if (privateWindowParam || url?.startsWith("firefox-private-bridge:")) {
603603
// Check if the osint flag is present on Windows
604604
let launchedWithArg_osint =
605605
AppConstants.platform == "win" &&
@@ -614,7 +614,7 @@ nsBrowserContentHandler.prototype = {
614614
uri: Services.io.newURI("about:privatebrowsing"),
615615
principal: lazy.gSystemPrincipal,
616616
};
617-
} else if (url?.startsWith("firefox-private:")) {
617+
} else if (url?.startsWith("firefox-private-bridge:")) {
618618
cmdLine.removeArguments(urlFlagIdx, urlFlagIdx + 1);
619619
resolvedInfo = resolveURIInternal(
620620
cmdLine,
@@ -1463,7 +1463,7 @@ nsDefaultCommandLineHandler.prototype = {
14631463
}
14641464

14651465
// Can't open multiple URLs without using system principal.
1466-
// The firefox and firefox-private protocols should only
1466+
// The firefox-bridge and firefox-private-bridge protocols should only
14671467
// accept a single URL due to using the -osint option
14681468
// so this isn't very relevant.
14691469
var URLlist = urilist.filter(shouldLoadURI).map(u => u.spec);

browser/components/BrowserGlue.sys.mjs

Lines changed: 31 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ ChromeUtils.defineESModuleGetters(lazy, {
3838
E10SUtils: "resource://gre/modules/E10SUtils.sys.mjs",
3939
ExtensionsUI: "resource:///modules/ExtensionsUI.sys.mjs",
4040
FeatureGate: "resource://featuregates/FeatureGate.sys.mjs",
41+
FirefoxBridgeExtensionUtils:
42+
"resource:///modules/FirefoxBridgeExtensionUtils.sys.mjs",
4143
FxAccounts: "resource://gre/modules/FxAccounts.sys.mjs",
4244
HomePage: "resource:///modules/HomePage.sys.mjs",
4345
Integration: "resource://gre/modules/Integration.sys.mjs",
@@ -2641,126 +2643,6 @@ BrowserGlue.prototype = {
26412643
},
26422644
},
26432645

2644-
{
2645-
name: "dualBrowserProtocolHandler",
2646-
condition:
2647-
AppConstants.platform == "win" &&
2648-
!Services.prefs.getBoolPref(
2649-
"browser.shell.customProtocolsRegistered"
2650-
),
2651-
task: async () => {
2652-
Services.prefs.setBoolPref(
2653-
"browser.shell.customProtocolsRegistered",
2654-
true
2655-
);
2656-
const FIREFOX_HANDLER_NAME = "firefox";
2657-
const FIREFOX_PRIVATE_HANDLER_NAME = "firefox-private";
2658-
const path = Services.dirsvc.get("XREExeF", Ci.nsIFile).path;
2659-
let wrk = Cc["@mozilla.org/windows-registry-key;1"].createInstance(
2660-
Ci.nsIWindowsRegKey
2661-
);
2662-
try {
2663-
wrk.open(wrk.ROOT_KEY_CLASSES_ROOT, "", wrk.ACCESS_READ);
2664-
let FxSet = wrk.hasChild(FIREFOX_HANDLER_NAME);
2665-
let FxPrivateSet = wrk.hasChild(FIREFOX_PRIVATE_HANDLER_NAME);
2666-
wrk.close();
2667-
if (FxSet && FxPrivateSet) {
2668-
return;
2669-
}
2670-
wrk.open(
2671-
wrk.ROOT_KEY_CURRENT_USER,
2672-
"Software\\Classes",
2673-
wrk.ACCESS_ALL
2674-
);
2675-
const maybeUpdateRegistry = (
2676-
isSetAlready,
2677-
handler,
2678-
protocolName
2679-
) => {
2680-
if (isSetAlready) {
2681-
return;
2682-
}
2683-
let FxKey = wrk.createChild(handler, wrk.ACCESS_ALL);
2684-
try {
2685-
// Write URL protocol key
2686-
FxKey.writeStringValue("", protocolName);
2687-
FxKey.writeStringValue("URL Protocol", "");
2688-
FxKey.close();
2689-
// Write defaultIcon key
2690-
FxKey.create(
2691-
FxKey.ROOT_KEY_CURRENT_USER,
2692-
"Software\\Classes\\" + handler + "\\DefaultIcon",
2693-
FxKey.ACCESS_ALL
2694-
);
2695-
FxKey.open(
2696-
FxKey.ROOT_KEY_CURRENT_USER,
2697-
"Software\\Classes\\" + handler + "\\DefaultIcon",
2698-
FxKey.ACCESS_ALL
2699-
);
2700-
FxKey.writeStringValue("", `\"${path}\",1`);
2701-
FxKey.close();
2702-
// Write shell\\open\\command key
2703-
FxKey.create(
2704-
FxKey.ROOT_KEY_CURRENT_USER,
2705-
"Software\\Classes\\" + handler + "\\shell",
2706-
FxKey.ACCESS_ALL
2707-
);
2708-
FxKey.create(
2709-
FxKey.ROOT_KEY_CURRENT_USER,
2710-
"Software\\Classes\\" + handler + "\\shell\\open",
2711-
FxKey.ACCESS_ALL
2712-
);
2713-
FxKey.create(
2714-
FxKey.ROOT_KEY_CURRENT_USER,
2715-
"Software\\Classes\\" + handler + "\\shell\\open\\command",
2716-
FxKey.ACCESS_ALL
2717-
);
2718-
FxKey.open(
2719-
FxKey.ROOT_KEY_CURRENT_USER,
2720-
"Software\\Classes\\" + handler + "\\shell\\open\\command",
2721-
FxKey.ACCESS_ALL
2722-
);
2723-
if (handler == FIREFOX_PRIVATE_HANDLER_NAME) {
2724-
FxKey.writeStringValue(
2725-
"",
2726-
`\"${path}\" -osint -private-window \"%1\"`
2727-
);
2728-
} else {
2729-
FxKey.writeStringValue("", `\"${path}\" -osint -url \"%1\"`);
2730-
}
2731-
} catch (ex) {
2732-
console.log(ex);
2733-
} finally {
2734-
FxKey.close();
2735-
}
2736-
};
2737-
try {
2738-
maybeUpdateRegistry(
2739-
FxSet,
2740-
FIREFOX_HANDLER_NAME,
2741-
"URL:Firefox Protocol"
2742-
);
2743-
} catch (ex) {
2744-
console.log(ex);
2745-
}
2746-
try {
2747-
maybeUpdateRegistry(
2748-
FxPrivateSet,
2749-
FIREFOX_PRIVATE_HANDLER_NAME,
2750-
"URL:Firefox Private Browsing Protocol"
2751-
);
2752-
} catch (ex) {
2753-
console.log(ex);
2754-
}
2755-
} catch (ex) {
2756-
console.log(ex);
2757-
} finally {
2758-
wrk.close();
2759-
}
2760-
},
2761-
timeout: 5000,
2762-
},
2763-
27642646
// Ensure a Private Browsing Shortcut exists. This is needed in case
27652647
// a user tries to use Windows functionality to pin our Private Browsing
27662648
// mode icon to the Taskbar (eg: the "Pin to Taskbar" context menu item).
@@ -3821,13 +3703,20 @@ BrowserGlue.prototype = {
38213703
_migrateUI() {
38223704
// Use an increasing number to keep track of the current migration state.
38233705
// Completely unrelated to the current Firefox release number.
3824-
const UI_VERSION = 142;
3706+
const UI_VERSION = 143;
38253707
const BROWSER_DOCURL = AppConstants.BROWSER_CHROME_URL;
38263708

38273709
if (!Services.prefs.prefHasUserValue("browser.migration.version")) {
38283710
// This is a new profile, nothing to migrate.
38293711
Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
38303712
this._isNewProfile = true;
3713+
3714+
if (AppConstants.platform == "win") {
3715+
// Ensure that the Firefox Bridge protocols are registered for the new profile.
3716+
// No-op if they are registered for the user or the local machine already.
3717+
lazy.FirefoxBridgeExtensionUtils.maybeRegisterFirefoxBridgeProtocols();
3718+
}
3719+
38313720
return;
38323721
}
38333722

@@ -4427,6 +4316,27 @@ BrowserGlue.prototype = {
44274316
}
44284317
}
44294318

4319+
if (currentUIVersion < 143) {
4320+
if (AppConstants.platform == "win") {
4321+
// In Firefox 122, we enabled the firefox and firefox-private protocols.
4322+
// We switched over to using firefox-bridge and firefox-private-bridge,
4323+
// but we want to clean up the use of the other protocols.
4324+
lazy.FirefoxBridgeExtensionUtils.maybeDeleteBridgeProtocolRegistryEntries();
4325+
4326+
// Register the new firefox bridge related protocols now
4327+
lazy.FirefoxBridgeExtensionUtils.maybeRegisterFirefoxBridgeProtocols();
4328+
4329+
// Clean up the old user prefs from FX 122
4330+
Services.prefs.clearUserPref(
4331+
"network.protocol-handler.external.firefox"
4332+
);
4333+
Services.prefs.clearUserPref(
4334+
"network.protocol-handler.external.firefox-private"
4335+
);
4336+
Services.prefs.clearUserPref("browser.shell.customProtocolsRegistered");
4337+
}
4338+
}
4339+
44304340
// Update the migration version.
44314341
Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
44324342
},

browser/installer/windows/msix/AppxManifest.xml.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@
9292
</uap3:Protocol>
9393
</uap3:Extension>
9494
<uap3:Extension Category="windows.protocol">
95-
<uap3:Protocol Name="firefox" Parameters="-osint -url &quot;%1&quot;">
96-
<uap:DisplayName>Firefox Protocol</uap:DisplayName>
95+
<uap3:Protocol Name="firefox-bridge" Parameters="-osint -url &quot;%1&quot;">
96+
<uap:DisplayName>Firefox Bridge Protocol</uap:DisplayName>
9797
<uap:Logo>Assets\Document44x44.png</uap:Logo>
9898
</uap3:Protocol>
9999
</uap3:Extension>
100100
<uap3:Extension Category="windows.protocol">
101-
<uap3:Protocol Name="firefox-private" Parameters="-osint -private-window &quot;%1&quot;">
102-
<uap:DisplayName>Firefox Private Browsing Protocol</uap:DisplayName>
101+
<uap3:Protocol Name="firefox-private-bridge" Parameters="-osint -private-window &quot;%1&quot;">
102+
<uap:DisplayName>Firefox Private Bridge Protocol</uap:DisplayName>
103103
<uap:Logo>Assets\Document44x44.png</uap:Logo>
104104
</uap3:Protocol>
105105
</uap3:Extension>

browser/installer/windows/nsis/installer.nsi

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -474,22 +474,22 @@ Section "-Application" APP_IDX
474474
${AddDisabledDDEHandlerValues} "FirefoxURL-$AppUserModelID" "$2" "$8,${IDI_DOCUMENT_ZERO_BASED}" \
475475
"${AppRegName} URL" "true"
476476

477-
; Create protocol registry keys for dual browser extensions - only if not already set
477+
; Create protocol registry keys for FirefoxBridge extensions - only if not already set
478478
SetShellVarContext current ; Set SHCTX to HKCU
479-
!define FIREFOX_PROTOCOL "firefox"
479+
!define FIREFOX_PROTOCOL "firefox-bridge"
480480
ClearErrors
481481
ReadRegStr $0 SHCTX "Software\Classes\${FIREFOX_PROTOCOL}" ""
482482
${If} $0 == ""
483483
${AddDisabledDDEHandlerValues} "${FIREFOX_PROTOCOL}" "$2" "$8,${IDI_APPICON_ZERO_BASED}" \
484-
"Firefox Browsing Protocol" "true"
484+
"Firefox Bridge Protocol" "true"
485485
${EndIf}
486486

487-
!define FIREFOX_PRIVATE_PROTOCOL "firefox-private"
487+
!define FIREFOX_PRIVATE_PROTOCOL "firefox-private-bridge"
488488
ClearErrors
489489
ReadRegStr $0 SHCTX "Software\Classes\${FIREFOX_PRIVATE_PROTOCOL}" ""
490490
${If} $0 == ""
491491
${AddDisabledDDEHandlerValues} "${FIREFOX_PRIVATE_PROTOCOL}" "$\"$8$\" -osint -private-window $\"%1$\"" \
492-
"$8,${IDI_PBICON_PB_EXE_ZERO_BASED}" "Firefox Private Browsing Protocol" "true"
492+
"$8,${IDI_PBICON_PB_EXE_ZERO_BASED}" "Firefox Private Bridge Protocol" "true"
493493
${EndIf}
494494
SetShellVarContext all ; Set SHCTX to HKLM
495495

@@ -794,6 +794,15 @@ Section "-InstallEndCleanup"
794794
; Refresh desktop icons
795795
${RefreshShellIcons}
796796

797+
; Remove old unsupported firefox and firefox-private extension protocol
798+
; handlers which were added in FX122 for the dual browser extension, since
799+
; renamed to FirefoxBridge
800+
Push $1
801+
${GetLongPath} "$INSTDIR\${FileMainEXE}" $1
802+
${DeleteProtocolRegistryIfSetToInstallation} "$1" "firefox"
803+
${DeleteProtocolRegistryIfSetToInstallation} "$1" "firefox-private"
804+
Pop $1
805+
797806
${InstallEndCleanupCommon}
798807

799808
${If} $PreventRebootRequired == "true"

browser/installer/windows/nsis/shared.nsh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,3 +1824,49 @@ FunctionEnd
18241824
${WriteRegStr2} ${RegKey} "Software\Classes\CLSID\$0\InProcServer32" "" "$INSTDIR\notificationserver.dll" 0
18251825
!macroend
18261826
!define WriteToastNotificationRegistration "!insertmacro WriteToastNotificationRegistration"
1827+
1828+
/**
1829+
* Deletes the registry keys for a protocol handler but only if those registry
1830+
* keys were pointed to the installation being uninstalled.
1831+
* Does this with both the HKLM and the HKCU registry entries.
1832+
*
1833+
* @param _PROTOCOL
1834+
* The protocol to delete the registry keys for
1835+
*/
1836+
!macro DeleteProtocolRegistryIfSetToInstallation INSTALL_PATH _PROTOCOL
1837+
Push $0
1838+
1839+
; Check if there is a protocol handler registered by fetching the DefaultIcon value
1840+
; in the registry.
1841+
; If there is something registered for the icon, it will be the path to the executable,
1842+
; plus a comma and a number for the id of the resource for the icon.
1843+
; Use StrCpy with -2 to remove the comma and the resource id so that
1844+
; the whole path to the executable can be compared against what's being
1845+
; uninstalled.
1846+
1847+
; Do all of that twice, once for the local machine and once for the current user
1848+
1849+
; Remove protocol handlers
1850+
ClearErrors
1851+
ReadRegStr $0 HKLM "Software\Classes\${_PROTOCOL}\DefaultIcon" ""
1852+
${If} $0 != ""
1853+
StrCpy $0 $0 -2
1854+
${If} $0 == '"${INSTALL_PATH}"'
1855+
DeleteRegKey HKLM "Software\Classes\${_PROTOCOL}"
1856+
${EndIf}
1857+
${EndIf}
1858+
1859+
ClearErrors
1860+
ReadRegStr $0 HKCU "Software\Classes\${_PROTOCOL}\DefaultIcon" ""
1861+
${If} $0 != ""
1862+
StrCpy $0 $0 -2
1863+
${If} $0 == '"${INSTALL_PATH}"'
1864+
DeleteRegKey HKCU "Software\Classes\${_PROTOCOL}"
1865+
${EndIf}
1866+
${EndIf}
1867+
1868+
ClearErrors
1869+
1870+
Pop $0
1871+
!macroend
1872+
!define DeleteProtocolRegistryIfSetToInstallation '!insertmacro DeleteProtocolRegistryIfSetToInstallation'

0 commit comments

Comments
 (0)