Skip to content

Commit 12fba69

Browse files
committed
Backed out 2 changesets (bug 1801954, bug 1863980) for bc failures on browser_setDefaultBrowser.js. CLOSED TREE
Backed out changeset b96506a6d950 (bug 1801954) Backed out changeset 306a649fcc00 (bug 1863980)
1 parent b69f929 commit 12fba69

File tree

8 files changed

+24
-46
lines changed

8 files changed

+24
-46
lines changed

browser/components/BrowserContentHandler.sys.mjs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -613,13 +613,7 @@ nsBrowserContentHandler.prototype = {
613613
}
614614
}
615615
if (cmdLine.handleFlag("setDefaultBrowser", false)) {
616-
// Note that setDefaultBrowser is an async function, but "handle" (the method being executed)
617-
// is an implementation of an interface method and changing it to be async would be complicated
618-
// and ultimately nothing here needs the result of setDefaultBrowser, so we do not bother doing
619-
// an await.
620-
lazy.ShellService.setDefaultBrowser(true).catch(e => {
621-
console.error("setDefaultBrowser failed:", e);
622-
});
616+
lazy.ShellService.setDefaultBrowser(true);
623617
}
624618

625619
if (cmdLine.handleFlag("first-startup", false)) {

browser/components/BrowserGlue.sys.mjs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5488,12 +5488,7 @@ export var DefaultBrowserCheck = {
54885488
let buttonNumClicked = rv.get("buttonNumClicked");
54895489
let checkboxState = rv.get("checked");
54905490
if (buttonNumClicked == 0) {
5491-
try {
5492-
await shellService.setAsDefault();
5493-
} catch (e) {
5494-
this.log.error("Failed to set the default browser", e);
5495-
}
5496-
5491+
shellService.setAsDefault();
54975492
shellService.pinToTaskbar();
54985493
}
54995494
if (checkboxState) {

browser/components/preferences/main.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,7 +1734,7 @@ var gMainPane = {
17341734
/**
17351735
* Set browser as the operating system default browser.
17361736
*/
1737-
async setDefaultBrowser() {
1737+
setDefaultBrowser() {
17381738
if (AppConstants.HAVE_SHELL_SERVICE) {
17391739
let alwaysCheckPref = Preferences.get(
17401740
"browser.shell.checkDefaultBrowser"
@@ -1748,20 +1748,11 @@ var gMainPane = {
17481748
if (!shellSvc) {
17491749
return;
17501750
}
1751-
1752-
// Disable the set default button, so that the user doesn't try to hit it again
1753-
// while awaiting on setDefaultBrowser
1754-
let setDefaultButton = document.getElementById("setDefaultButton");
1755-
setDefaultButton.disabled = true;
1756-
17571751
try {
1758-
await shellSvc.setDefaultBrowser(false);
1752+
shellSvc.setDefaultBrowser(false);
17591753
} catch (ex) {
17601754
console.error(ex);
17611755
return;
1762-
} finally {
1763-
// Make sure to re-enable the default button when we're finished, regardless of the outcome
1764-
setDefaultButton.disabled = false;
17651756
}
17661757

17671758
let isDefault = shellSvc.isDefaultBrowser(false, true);

browser/components/preferences/tests/browser_defaultbrowser_alwayscheck.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ async function test_with_mock_shellservice(options, testFn) {
164164
isDefaultBrowser() {
165165
return this._isDefault;
166166
},
167-
async setDefaultBrowser() {
167+
setDefaultBrowser() {
168168
this._isDefault = true;
169169
},
170170
};

browser/components/shell/ShellService.sys.mjs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ let ShellServiceInternal = {
253253
}
254254
}
255255
try {
256-
await this.defaultAgent.setDefaultBrowserUserChoiceAsync(
256+
this.defaultAgent.setDefaultBrowserUserChoice(
257257
aumi,
258258
extraFileExtensions
259259
);
@@ -314,34 +314,32 @@ let ShellServiceInternal = {
314314
},
315315

316316
// override nsIShellService.setDefaultBrowser() on the ShellService proxy.
317-
async setDefaultBrowser(forAllUsers) {
317+
setDefaultBrowser(forAllUsers) {
318318
// On Windows, our best chance is to set UserChoice, so try that first.
319319
if (
320320
AppConstants.platform == "win" &&
321321
lazy.NimbusFeatures.shellService.getVariable(
322322
"setDefaultBrowserUserChoice"
323323
)
324324
) {
325-
try {
326-
await this.setAsDefaultUserChoice();
327-
return;
328-
} catch (err) {
329-
lazy.log.warn(
330-
"Error thrown during setAsDefaultUserChoice. Full exception:",
331-
err
332-
);
333-
334-
// intentionally fall through to setting via the non-user choice pathway on error
335-
}
325+
// nsWindowsShellService::SetDefaultBrowser() kicks off several
326+
// operations, but doesn't wait for their result. So we don't need to
327+
// await the result of setAsDefaultUserChoice() here, either, we just need
328+
// to fall back in case it fails.
329+
this.setAsDefaultUserChoice().catch(err => {
330+
console.error(err);
331+
this.shellService.setDefaultBrowser(forAllUsers);
332+
});
333+
return;
336334
}
337335

338336
this.shellService.setDefaultBrowser(forAllUsers);
339337
},
340338

341-
async setAsDefault() {
339+
setAsDefault() {
342340
let setAsDefaultError = false;
343341
try {
344-
await ShellService.setDefaultBrowser(false);
342+
ShellService.setDefaultBrowser(false);
345343
} catch (ex) {
346344
setAsDefaultError = true;
347345
console.error(ex);

browser/components/uitour/UITour.sys.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1666,7 +1666,7 @@ export var UITour = {
16661666
try {
16671667
let shell = aWindow.getShellService();
16681668
if (shell) {
1669-
await shell.setDefaultBrowser(false);
1669+
shell.setDefaultBrowser(false);
16701670
}
16711671
} catch (e) {}
16721672
break;

toolkit/components/messaging-system/lib/SpecialMessageActions.sys.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ export const SpecialMessageActions = {
9797
*
9898
* @param {Window} window Reference to a window object
9999
*/
100-
async setDefaultBrowser(window) {
101-
await window.getShellService().setAsDefault();
100+
setDefaultBrowser(window) {
101+
window.getShellService().setAsDefault();
102102
},
103103

104104
/**
@@ -442,10 +442,10 @@ export const SpecialMessageActions = {
442442
break;
443443
case "PIN_AND_DEFAULT":
444444
await this.pinFirefoxToTaskbar(window, action.data?.privatePin);
445-
await this.setDefaultBrowser(window);
445+
this.setDefaultBrowser(window);
446446
break;
447447
case "SET_DEFAULT_BROWSER":
448-
await this.setDefaultBrowser(window);
448+
this.setDefaultBrowser(window);
449449
break;
450450
case "SET_DEFAULT_PDF_HANDLER":
451451
this.setDefaultPDFHandler(

toolkit/mozapps/defaultagent/SetDefaultBrowser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#define DEFAULT_BROWSER_SET_DEFAULT_BROWSER_H__
88

99
#include "nsStringFwd.h"
10-
#include "nsArray.h"
10+
#include "nsTArrayForwardDeclare.h"
1111
#include <functional>
1212

1313
namespace mozilla::default_agent {

0 commit comments

Comments
 (0)