Bug 1785814: The "os.environment.is_taskbar_pinned_private" scalar is set to "false" even if the "Pin Private Window" shortcut is pinned to the taskbar r=bytesized
In an ideal world we'd pass in the `privateBrowsing` flag and use that to both find the correct AUMID and binary to compare against, but because this code runs off main thread, and finding AUMIDs requires prefs access - we must pass in the AUMID from elsewhere. Given that, checking that the target of the shortcut is one of the two possible Firefox entry points, and ensuring it matches the requested AUMID, seems reasonable. There's no technical reason why we couldn't pass in the `privateBrowsing` flag to use in determining which binary we're looking for -- but I don't think it really adds any real benefit, and passing both it an the AUMID makes the interface more confusing. Differential Revision: https://phabricator.services.mozilla.com/D155008
This commit is contained in:
@@ -1485,11 +1485,26 @@ nsWindowsShellService::CheckPinCurrentAppToTaskbarAsync(
|
||||
}
|
||||
|
||||
static bool IsCurrentAppPinnedToTaskbarSync(const nsAutoString& aumid) {
|
||||
// There are two shortcut targets that we created. One always matches the
|
||||
// binary we're running as (eg: firefox.exe). The other is the wrapper
|
||||
// for launching in Private Browsing mode. We need to inspect shortcuts
|
||||
// that point at either of these to accurately judge whether or not
|
||||
// the app is pinned with the given AUMID.
|
||||
wchar_t exePath[MAXPATHLEN] = {};
|
||||
wchar_t pbExePath[MAXPATHLEN] = {};
|
||||
|
||||
if (NS_WARN_IF(NS_FAILED(BinaryPath::GetLong(exePath)))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
wcscpy_s(pbExePath, MAXPATHLEN, exePath);
|
||||
if (!PathRemoveFileSpecW(pbExePath)) {
|
||||
return false;
|
||||
}
|
||||
if (!PathAppendW(pbExePath, L"private_browsing.exe")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
wchar_t folderChars[MAX_PATH] = {};
|
||||
HRESULT hr = SHGetFolderPathW(nullptr, CSIDL_APPDATA, nullptr,
|
||||
SHGFP_TYPE_CURRENT, folderChars);
|
||||
@@ -1549,9 +1564,6 @@ static bool IsCurrentAppPinnedToTaskbarSync(const nsAutoString& aumid) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Note: AUMID is not checked, so a pin that does not group properly
|
||||
// will still count as long as the exe matches.
|
||||
|
||||
// Check the exe path
|
||||
static_assert(MAXPATHLEN == MAX_PATH);
|
||||
wchar_t storedExePath[MAX_PATH] = {};
|
||||
@@ -1563,7 +1575,8 @@ static bool IsCurrentAppPinnedToTaskbarSync(const nsAutoString& aumid) {
|
||||
// Case insensitive path comparison
|
||||
// NOTE: Because this compares the path directly, it is possible to
|
||||
// have a false negative mismatch.
|
||||
if (wcsnicmp(storedExePath, exePath, MAXPATHLEN) == 0) {
|
||||
if (wcsnicmp(storedExePath, exePath, MAXPATHLEN) == 0 ||
|
||||
wcsnicmp(storedExePath, pbExePath, MAXPATHLEN) == 0) {
|
||||
RefPtr<IPropertyStore> propStore;
|
||||
hr = link->QueryInterface(IID_IPropertyStore, getter_AddRefs(propStore));
|
||||
if (NS_WARN_IF(FAILED(hr))) {
|
||||
|
||||
Reference in New Issue
Block a user