Backed out changeset 677c3005fd69 (bug 1860271) for causing node newtab failures at browser/components/newtab CLOSED TREE
This commit is contained in:
@@ -1237,24 +1237,18 @@ BrowserGlue.prototype = {
|
|||||||
].getService(Ci.nsIToolkitProfileService);
|
].getService(Ci.nsIToolkitProfileService);
|
||||||
if (
|
if (
|
||||||
AppConstants.platform == "win" &&
|
AppConstants.platform == "win" &&
|
||||||
|
Services.prefs.getBoolPref(launchOnLoginPref) &&
|
||||||
!profileSvc.startWithLastProfile
|
!profileSvc.startWithLastProfile
|
||||||
) {
|
) {
|
||||||
// If we don't start with last profile, the user
|
// If we don't start with last profile, the user
|
||||||
// likely sees the profile selector on launch.
|
// likely sees the profile selector on launch.
|
||||||
if (Services.prefs.getBoolPref(launchOnLoginPref)) {
|
Services.prefs.setBoolPref(launchOnLoginPref, false);
|
||||||
Services.telemetry.setEventRecordingEnabled(
|
Services.telemetry.setEventRecordingEnabled("launch_on_login", true);
|
||||||
"launch_on_login",
|
|
||||||
true
|
|
||||||
);
|
|
||||||
Services.telemetry.recordEvent(
|
Services.telemetry.recordEvent(
|
||||||
"launch_on_login",
|
"launch_on_login",
|
||||||
"last_profile_disable",
|
"last_profile_disable:",
|
||||||
"startup"
|
"startup"
|
||||||
);
|
);
|
||||||
}
|
|
||||||
Services.prefs.setBoolPref(launchOnLoginPref, false);
|
|
||||||
// Only remove registry key, not shortcut here as we can assume
|
|
||||||
// if a user manually created a shortcut they want this behavior.
|
|
||||||
await lazy.WindowsLaunchOnLogin.removeLaunchOnLoginRegistryKey();
|
await lazy.WindowsLaunchOnLogin.removeLaunchOnLoginRegistryKey();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
|||||||
TargetingContext: "resource://messaging-system/targeting/Targeting.sys.mjs",
|
TargetingContext: "resource://messaging-system/targeting/Targeting.sys.mjs",
|
||||||
TelemetryEnvironment: "resource://gre/modules/TelemetryEnvironment.sys.mjs",
|
TelemetryEnvironment: "resource://gre/modules/TelemetryEnvironment.sys.mjs",
|
||||||
TelemetrySession: "resource://gre/modules/TelemetrySession.sys.mjs",
|
TelemetrySession: "resource://gre/modules/TelemetrySession.sys.mjs",
|
||||||
WindowsLaunchOnLogin: "resource://gre/modules/WindowsLaunchOnLogin.sys.mjs",
|
|
||||||
});
|
});
|
||||||
|
|
||||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||||
@@ -837,13 +836,6 @@ const TargetingGetters = {
|
|||||||
return QueryCache.getters.doesAppNeedPrivatePin.get();
|
return QueryCache.getters.doesAppNeedPrivatePin.get();
|
||||||
},
|
},
|
||||||
|
|
||||||
get launchOnLoginEnabled() {
|
|
||||||
if (AppConstants.platform !== "win") {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return lazy.WindowsLaunchOnLogin.getLaunchOnLoginEnabled();
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this invocation running in background task mode?
|
* Is this invocation running in background task mode?
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -990,8 +990,7 @@ const BASE_MESSAGES = () => [
|
|||||||
lifetime: 1,
|
lifetime: 1,
|
||||||
},
|
},
|
||||||
trigger: { id: "defaultBrowserCheck" },
|
trigger: { id: "defaultBrowserCheck" },
|
||||||
targeting: `source == 'newtab' && !launchOnLoginEnabled
|
targeting: `source == 'newtab' && 'browser.startup.windowsLaunchOnLogin.disableLaunchOnLoginPrompt'|preferenceValue == false
|
||||||
&& 'browser.startup.windowsLaunchOnLogin.disableLaunchOnLoginPrompt'|preferenceValue == false
|
|
||||||
&& 'browser.startup.windowsLaunchOnLogin.enabled'|preferenceValue == true && isDefaultBrowser && !activeNotifications`,
|
&& 'browser.startup.windowsLaunchOnLogin.enabled'|preferenceValue == true && isDefaultBrowser && !activeNotifications`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1054,8 +1053,7 @@ const BASE_MESSAGES = () => [
|
|||||||
lifetime: 1,
|
lifetime: 1,
|
||||||
},
|
},
|
||||||
trigger: { id: "defaultBrowserCheck" },
|
trigger: { id: "defaultBrowserCheck" },
|
||||||
targeting: `source == 'newtab' && !launchOnLoginEnabled
|
targeting: `source == 'newtab' && 'browser.startup.windowsLaunchOnLogin.disableLaunchOnLoginPrompt'|preferenceValue == false
|
||||||
&& 'browser.startup.windowsLaunchOnLogin.disableLaunchOnLoginPrompt'|preferenceValue == false
|
|
||||||
&& 'browser.startup.windowsLaunchOnLogin.enabled'|preferenceValue == true && isDefaultBrowser && !activeNotifications
|
&& 'browser.startup.windowsLaunchOnLogin.enabled'|preferenceValue == true && isDefaultBrowser && !activeNotifications
|
||||||
&& messageImpressions.INFOBAR_LAUNCH_ON_LOGIN[messageImpressions.INFOBAR_LAUNCH_ON_LOGIN | length - 1]
|
&& messageImpressions.INFOBAR_LAUNCH_ON_LOGIN[messageImpressions.INFOBAR_LAUNCH_ON_LOGIN | length - 1]
|
||||||
&& messageImpressions.INFOBAR_LAUNCH_ON_LOGIN[messageImpressions.INFOBAR_LAUNCH_ON_LOGIN | length - 1] <
|
&& messageImpressions.INFOBAR_LAUNCH_ON_LOGIN[messageImpressions.INFOBAR_LAUNCH_ON_LOGIN | length - 1] <
|
||||||
|
|||||||
@@ -423,15 +423,7 @@ var gMainPane = {
|
|||||||
NimbusFeatures.windowsLaunchOnLogin.recordExposureEvent({
|
NimbusFeatures.windowsLaunchOnLogin.recordExposureEvent({
|
||||||
once: true,
|
once: true,
|
||||||
});
|
});
|
||||||
// We do a check here for startWithLastProfile as we could
|
if (NimbusFeatures.windowsLaunchOnLogin.getVariable("enabled")) {
|
||||||
// have disabled the pref for the user before they're ever
|
|
||||||
// exposed to the experiment on a new profile.
|
|
||||||
if (
|
|
||||||
NimbusFeatures.windowsLaunchOnLogin.getVariable("enabled") &&
|
|
||||||
Cc["@mozilla.org/toolkit/profile-service;1"].getService(
|
|
||||||
Ci.nsIToolkitProfileService
|
|
||||||
).startWithLastProfile
|
|
||||||
) {
|
|
||||||
document.getElementById("windowsLaunchOnLoginBox").hidden = false;
|
document.getElementById("windowsLaunchOnLoginBox").hidden = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -667,8 +659,17 @@ var gMainPane = {
|
|||||||
let launchOnLoginCheckbox = document.getElementById(
|
let launchOnLoginCheckbox = document.getElementById(
|
||||||
"windowsLaunchOnLogin"
|
"windowsLaunchOnLogin"
|
||||||
);
|
);
|
||||||
launchOnLoginCheckbox.checked =
|
let registryName = WindowsLaunchOnLogin.getLaunchOnLoginRegistryName();
|
||||||
WindowsLaunchOnLogin.getLaunchOnLoginEnabled();
|
WindowsLaunchOnLogin.withLaunchOnLoginRegistryKey(async wrk => {
|
||||||
|
try {
|
||||||
|
// Reflect registry key value in about:preferences
|
||||||
|
launchOnLoginCheckbox.checked = wrk.hasValue(registryName);
|
||||||
|
} catch (e) {
|
||||||
|
// We should only end up here if we fail to open the registry
|
||||||
|
console.error("Failed to open Windows registry", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let approvedByWindows = WindowsLaunchOnLogin.getLaunchOnLoginApproved();
|
let approvedByWindows = WindowsLaunchOnLogin.getLaunchOnLoginApproved();
|
||||||
launchOnLoginCheckbox.disabled = !approvedByWindows;
|
launchOnLoginCheckbox.disabled = !approvedByWindows;
|
||||||
document.getElementById("windowsLaunchOnLoginDisabledBox").hidden =
|
document.getElementById("windowsLaunchOnLoginDisabledBox").hidden =
|
||||||
@@ -1634,7 +1635,7 @@ var gMainPane = {
|
|||||||
startupPref.value = newValue;
|
startupPref.value = newValue;
|
||||||
},
|
},
|
||||||
|
|
||||||
async onWindowsLaunchOnLoginChange(event) {
|
onWindowsLaunchOnLoginChange(event) {
|
||||||
if (AppConstants.platform !== "win") {
|
if (AppConstants.platform !== "win") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1646,9 +1647,8 @@ var gMainPane = {
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// windowsLaunchOnLogin has been unchecked: delete registry key and shortcut
|
// windowsLaunchOnLogin has been unchecked: delete registry key
|
||||||
WindowsLaunchOnLogin.removeLaunchOnLoginRegistryKey();
|
WindowsLaunchOnLogin.removeLaunchOnLoginRegistryKey();
|
||||||
await WindowsLaunchOnLogin.removeLaunchOnLoginShortcuts();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -52,29 +52,6 @@ interface nsIWindowsShellService : nsISupports
|
|||||||
in AString aDescription, in nsIFile aIconFile, in unsigned short aIconIndex,
|
in AString aDescription, in nsIFile aIconFile, in unsigned short aIconIndex,
|
||||||
in AString aAppUserModelId, in AString aShortcutFolder, in AString aShortcutName);
|
in AString aAppUserModelId, in AString aShortcutFolder, in AString aShortcutName);
|
||||||
|
|
||||||
/*
|
|
||||||
* Searches the %USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
|
|
||||||
* folder and returns an array with the path of all shortcuts with a target matching the
|
|
||||||
* current Firefox install location. The AUMID isn't required here as we are only looking
|
|
||||||
* for the currently running binary, whether that's firefox.exe or the private browsing
|
|
||||||
* proxy executable.
|
|
||||||
*
|
|
||||||
* It is possible to return an empty array if no shortcuts are found.
|
|
||||||
*
|
|
||||||
* @return An array of paths for all launch on login shortcuts.s
|
|
||||||
*
|
|
||||||
* @throws NS_ERROR_ABORT
|
|
||||||
* if instance cannot be created.
|
|
||||||
* @throws NS_ERROR_FILE_NOT_FOUND
|
|
||||||
* if %USERPROFILE%\AppData\Roaming\ cannot be opened.
|
|
||||||
* @throws NS_ERROR_FAILURE
|
|
||||||
* if the executable file cannot be found.
|
|
||||||
* @throws NS_ERROR_FILE_UNRECOGNIZED_PATH
|
|
||||||
* if the executable file cannot be converted into a string.
|
|
||||||
*/
|
|
||||||
|
|
||||||
Array<AString> getLaunchOnLoginShortcuts();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pin the current app to the taskbar. If aPrivateBrowsing is true, the
|
* Pin the current app to the taskbar. If aPrivateBrowsing is true, the
|
||||||
* Private Browsing version of the app (with a different icon and launch
|
* Private Browsing version of the app (with a different icon and launch
|
||||||
|
|||||||
@@ -41,7 +41,6 @@
|
|||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
#include <strsafe.h>
|
|
||||||
#include <propvarutil.h>
|
#include <propvarutil.h>
|
||||||
#include <propkey.h>
|
#include <propkey.h>
|
||||||
|
|
||||||
@@ -912,103 +911,6 @@ nsWindowsShellService::CreateShortcut(
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsWindowsShellService::GetLaunchOnLoginShortcuts(
|
|
||||||
nsTArray<nsString>& aShortcutPaths) {
|
|
||||||
aShortcutPaths.Clear();
|
|
||||||
|
|
||||||
// Get AppData\\Roaming folder using a known folder ID
|
|
||||||
RefPtr<IKnownFolderManager> fManager;
|
|
||||||
RefPtr<IKnownFolder> roamingAppData;
|
|
||||||
LPWSTR roamingAppDataW;
|
|
||||||
nsString roamingAppDataNS;
|
|
||||||
HRESULT hr =
|
|
||||||
CoCreateInstance(CLSID_KnownFolderManager, nullptr, CLSCTX_INPROC_SERVER,
|
|
||||||
IID_IKnownFolderManager, getter_AddRefs(fManager));
|
|
||||||
if (FAILED(hr)) {
|
|
||||||
return NS_ERROR_ABORT;
|
|
||||||
}
|
|
||||||
fManager->GetFolder(FOLDERID_RoamingAppData,
|
|
||||||
roamingAppData.StartAssignment());
|
|
||||||
hr = roamingAppData->GetPath(0, &roamingAppDataW);
|
|
||||||
if (FAILED(hr)) {
|
|
||||||
return NS_ERROR_FILE_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Append startup folder to AppData\\Roaming
|
|
||||||
roamingAppDataNS.Assign(roamingAppDataW);
|
|
||||||
CoTaskMemFree(roamingAppDataW);
|
|
||||||
nsString startupFolder =
|
|
||||||
roamingAppDataNS +
|
|
||||||
u"\\Microsoft\\Windows\\Start Menu\\Programs\\Startup"_ns;
|
|
||||||
nsString startupFolderWildcard = startupFolder + u"\\*.lnk"_ns;
|
|
||||||
|
|
||||||
// Get known path for binary file for later comparison with shortcuts.
|
|
||||||
// Returns lowercase file path which should be fine for Windows as all
|
|
||||||
// directories and files are case-insensitive by default.
|
|
||||||
RefPtr<nsIFile> binFile;
|
|
||||||
nsString binPath;
|
|
||||||
nsresult rv = XRE_GetBinaryPath(binFile.StartAssignment());
|
|
||||||
if (FAILED(rv)) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
rv = binFile->GetPath(binPath);
|
|
||||||
if (FAILED(rv)) {
|
|
||||||
return NS_ERROR_FILE_UNRECOGNIZED_PATH;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for if first file exists with a shortcut extension (.lnk)
|
|
||||||
WIN32_FIND_DATAW ffd;
|
|
||||||
HANDLE fileHandle = INVALID_HANDLE_VALUE;
|
|
||||||
fileHandle = FindFirstFileW(startupFolderWildcard.get(), &ffd);
|
|
||||||
if (fileHandle == INVALID_HANDLE_VALUE) {
|
|
||||||
// This means that no files were found in the folder which
|
|
||||||
// doesn't imply an error. Most of the time the user won't
|
|
||||||
// have any shortcuts here.
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
|
||||||
// Extract shortcut target path from every
|
|
||||||
// shortcut in the startup folder.
|
|
||||||
nsString fileName(ffd.cFileName);
|
|
||||||
RefPtr<IShellLinkW> link;
|
|
||||||
RefPtr<IPersistFile> ppf;
|
|
||||||
nsString target;
|
|
||||||
target.SetLength(MAX_PATH);
|
|
||||||
CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER,
|
|
||||||
IID_IShellLinkW, getter_AddRefs(link));
|
|
||||||
hr = link->QueryInterface(IID_IPersistFile, getter_AddRefs(ppf));
|
|
||||||
if (NS_WARN_IF(FAILED(hr))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
nsString filePath = startupFolder + u"\\"_ns + fileName;
|
|
||||||
hr = ppf->Load(filePath.get(), STGM_READ);
|
|
||||||
if (NS_WARN_IF(FAILED(hr))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
hr = link->Resolve(nullptr, SLR_NO_UI);
|
|
||||||
if (NS_WARN_IF(FAILED(hr))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
hr = link->GetPath(target.get(), MAX_PATH, nullptr, 0);
|
|
||||||
if (NS_WARN_IF(FAILED(hr))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If shortcut target matches known binary file value
|
|
||||||
// then add the path to the shortcut as a valid
|
|
||||||
// startup shortcut. This has to be a substring search as
|
|
||||||
// the user could have added unknown command line arguments
|
|
||||||
// to the shortcut.
|
|
||||||
if (_wcsnicmp(target.get(), binPath.get(), binPath.Length()) == 0) {
|
|
||||||
aShortcutPaths.AppendElement(filePath);
|
|
||||||
}
|
|
||||||
} while (FindNextFile(fileHandle, &ffd) != 0);
|
|
||||||
FindClose(fileHandle);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Look for any installer-created shortcuts in the given location that match
|
// Look for any installer-created shortcuts in the given location that match
|
||||||
// the given AUMID and EXE Path. If one is found, output its path.
|
// the given AUMID and EXE Path. If one is found, output its path.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -84,30 +84,6 @@ export var WindowsLaunchOnLogin = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a list of all launch on login shortcuts in the
|
|
||||||
* %USERNAME%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup folder
|
|
||||||
* that point to the current Firefox executable.
|
|
||||||
*/
|
|
||||||
getLaunchOnLoginShortcutList() {
|
|
||||||
let shellService = Cc["@mozilla.org/browser/shell-service;1"].getService(
|
|
||||||
Ci.nsIWindowsShellService
|
|
||||||
);
|
|
||||||
return shellService.getLaunchOnLoginShortcuts();
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Safely removes all launch on login shortcuts in the
|
|
||||||
* %USERNAME%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup folder
|
|
||||||
* that point to the current Firefox executable.
|
|
||||||
*/
|
|
||||||
async removeLaunchOnLoginShortcuts() {
|
|
||||||
let shortcuts = this.getLaunchOnLoginShortcutList();
|
|
||||||
for (let i = 0; i < shortcuts.length; i++) {
|
|
||||||
await IOUtils.remove(shortcuts[i]);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if Windows launch on login was independently enabled or disabled
|
* Checks if Windows launch on login was independently enabled or disabled
|
||||||
* by the user in the Windows Startup Apps menu. The registry key that
|
* by the user in the Windows Startup Apps menu. The registry key that
|
||||||
@@ -143,38 +119,6 @@ export var WindowsLaunchOnLogin = {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if Windows launch on login has an existing registry key or user-created shortcut in
|
|
||||||
* %USERNAME%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup. The registry key that
|
|
||||||
* stores this information should not be modified.
|
|
||||||
*/
|
|
||||||
getLaunchOnLoginEnabled() {
|
|
||||||
let registryName = this.getLaunchOnLoginRegistryName();
|
|
||||||
let regExists = false;
|
|
||||||
let shortcutExists = false;
|
|
||||||
this.withLaunchOnLoginRegistryKey(wrk => {
|
|
||||||
try {
|
|
||||||
// Start by checking if registry key exists.
|
|
||||||
regExists = wrk.hasValue(registryName);
|
|
||||||
} catch (e) {
|
|
||||||
// We should only end up here if we fail to open the registry
|
|
||||||
console.error("Failed to open Windows registry", e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (!regExists) {
|
|
||||||
shortcutExists = !!this.getLaunchOnLoginShortcutList().length;
|
|
||||||
}
|
|
||||||
// Even if a user disables it later on we want the launch on login
|
|
||||||
// infobar to remain disabled as the user is aware of the option.
|
|
||||||
if (regExists || shortcutExists) {
|
|
||||||
Services.prefs.setBoolPref(
|
|
||||||
"browser.startup.windowsLaunchOnLogin.disableLaunchOnLoginPrompt",
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return regExists || shortcutExists;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Quotes a string for use as a single command argument, using Windows quoting
|
* Quotes a string for use as a single command argument, using Windows quoting
|
||||||
* conventions.
|
* conventions.
|
||||||
|
|||||||
Reference in New Issue
Block a user