Backed out 2 changesets (bug 1893458, bug 1890634) for causing bustages at TaskbarPinningMetricsTests.cpp. CLOSED TREE
Backed out changeset 29ad5906bfb0 (bug 1890634) Backed out changeset bfcfe75b775a (bug 1893458)
This commit is contained in:
@@ -5,11 +5,8 @@
|
||||
|
||||
#define UNICODE
|
||||
|
||||
#include "nsWindowsShellServiceInternal.h"
|
||||
#include "nsWindowsShellService.h"
|
||||
|
||||
#include "mozilla/glean/GleanMetrics.h"
|
||||
|
||||
#include "BinaryPath.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "imgIRequest.h"
|
||||
@@ -1640,28 +1637,26 @@ static nsresult PinCurrentAppToTaskbarWin10(bool aCheckOnly,
|
||||
return ManageShortcutTaskbarPins(aCheckOnly, pinType, aShortcutPath);
|
||||
}
|
||||
|
||||
void PinCurrentAppToTaskbarHelper::CheckNotMainThread() {
|
||||
static nsresult PinCurrentAppToTaskbarImpl(
|
||||
bool aCheckOnly, bool aPrivateBrowsing, const nsAString& aAppUserModelId,
|
||||
const nsAString& aShortcutName, const nsAString& aShortcutSubstring,
|
||||
nsIFile* aShortcutsLogDir, nsIFile* aGreDir, nsIFile* aProgramsDir) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(
|
||||
!NS_IsMainThread(),
|
||||
"PinCurrentAppToTaskbarImpl should be called off main thread only");
|
||||
}
|
||||
|
||||
Result<bool, nsresult> PinCurrentAppToTaskbarHelper::CreateShortcutForTaskbar(
|
||||
bool aCheckOnly, bool aPrivateBrowsing, const nsAString& aAppUserModelId,
|
||||
const nsAString& aShortcutName, const nsAString& aShortcutSubstring,
|
||||
nsIFile* aShortcutsLogDir, nsIFile* aGreDir, nsIFile* aProgramsDir,
|
||||
nsAutoString& aShortcutPath) {
|
||||
nsAutoString shortcutPath;
|
||||
nsresult rv = FindMatchingShortcut(aAppUserModelId, aShortcutSubstring,
|
||||
aPrivateBrowsing, aShortcutPath);
|
||||
aPrivateBrowsing, shortcutPath);
|
||||
if (NS_FAILED(rv)) {
|
||||
aShortcutPath.Truncate();
|
||||
shortcutPath.Truncate();
|
||||
}
|
||||
if (aShortcutPath.IsEmpty()) {
|
||||
if (shortcutPath.IsEmpty()) {
|
||||
if (aCheckOnly) {
|
||||
// Later checks rely on a shortcut already existing.
|
||||
// We don't want to create a shortcut in check only mode
|
||||
// so the best we can do is assume those parts will work.
|
||||
return false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoString linkName(aShortcutName);
|
||||
@@ -1671,23 +1666,23 @@ Result<bool, nsresult> PinCurrentAppToTaskbarHelper::CreateShortcutForTaskbar(
|
||||
nsAutoString pbExeStr(PRIVATE_BROWSING_BINARY);
|
||||
nsresult rv = exeFile->Append(pbExeStr);
|
||||
if (!NS_SUCCEEDED(rv)) {
|
||||
return Err(NS_ERROR_FAILURE);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
} else {
|
||||
wchar_t exePath[MAXPATHLEN] = {};
|
||||
if (NS_WARN_IF(NS_FAILED(BinaryPath::GetLong(exePath)))) {
|
||||
return Err(NS_ERROR_FAILURE);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsAutoString exeStr(exePath);
|
||||
nsresult rv = NS_NewLocalFile(exeStr, true, getter_AddRefs(exeFile));
|
||||
if (!NS_SUCCEEDED(rv)) {
|
||||
return Err(NS_ERROR_FILE_NOT_FOUND);
|
||||
return NS_ERROR_FILE_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> shortcutFile(aProgramsDir);
|
||||
shortcutFile->Append(aShortcutName);
|
||||
aShortcutPath.Assign(shortcutFile->NativePath());
|
||||
shortcutPath.Assign(shortcutFile->NativePath());
|
||||
|
||||
nsTArray<nsString> arguments;
|
||||
rv = CreateShortcutImpl(exeFile, arguments, aShortcutName, exeFile,
|
||||
@@ -1697,62 +1692,12 @@ Result<bool, nsresult> PinCurrentAppToTaskbarHelper::CreateShortcutForTaskbar(
|
||||
linkName, shortcutFile->NativePath(),
|
||||
aShortcutsLogDir);
|
||||
if (!NS_SUCCEEDED(rv)) {
|
||||
return Err(NS_ERROR_FILE_NOT_FOUND);
|
||||
return NS_ERROR_FILE_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Win11PinToTaskBarResult PinCurrentAppToTaskbarHelper::PinCurrentAppViaAPI(
|
||||
bool aCheckOnly, const nsAString& aAppUserModelId,
|
||||
nsAutoString aShortcutPath) {
|
||||
return PinCurrentAppToTaskbarWin11(aCheckOnly, aAppUserModelId,
|
||||
aShortcutPath);
|
||||
}
|
||||
|
||||
nsresult PinCurrentAppToTaskbarHelper::PinCurrentAppFallback(
|
||||
bool aCheckOnly, const nsAString& aAppUserModelId,
|
||||
const nsAString& aShortcutPath) {
|
||||
return PinCurrentAppToTaskbarWin10(aCheckOnly, aAppUserModelId,
|
||||
aShortcutPath);
|
||||
}
|
||||
|
||||
nsresult PinCurrentAppToTaskbarImpl(
|
||||
bool aCheckOnly, bool aPrivateBrowsing, const nsAString& aAppUserModelId,
|
||||
const nsAString& aShortcutName, const nsAString& aShortcutSubstring,
|
||||
nsIFile* aShortcutsLogDir, nsIFile* aGreDir, nsIFile* aProgramsDir,
|
||||
UniquePtr<PinCurrentAppToTaskbarHelper> helper) {
|
||||
if (!helper) {
|
||||
helper.reset(new PinCurrentAppToTaskbarHelper);
|
||||
}
|
||||
|
||||
helper->CheckNotMainThread();
|
||||
|
||||
nsAutoString shortcutPath;
|
||||
|
||||
auto shortcutResult = helper->CreateShortcutForTaskbar(
|
||||
aCheckOnly, aPrivateBrowsing, aAppUserModelId, aShortcutName,
|
||||
aShortcutSubstring, aShortcutsLogDir, aGreDir, aProgramsDir,
|
||||
shortcutPath);
|
||||
|
||||
if (shortcutResult.isErr()) {
|
||||
nsresult err = shortcutResult.unwrapErr();
|
||||
|
||||
telemetry::shortcut::Record(aCheckOnly, err, aPrivateBrowsing);
|
||||
|
||||
return err;
|
||||
} else {
|
||||
if (!shortcutResult.unwrap()) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
telemetry::shortcut::Record(aCheckOnly, NS_OK, aPrivateBrowsing);
|
||||
|
||||
auto pinWithWin11TaskbarAPIResults =
|
||||
helper->PinCurrentAppViaAPI(aCheckOnly, aAppUserModelId, shortcutPath);
|
||||
|
||||
PinCurrentAppToTaskbarWin11(aCheckOnly, aAppUserModelId, shortcutPath);
|
||||
switch (pinWithWin11TaskbarAPIResults.result) {
|
||||
case Win11PinToTaskBarResultStatus::NotSupported:
|
||||
// Fall through to the win 10 mechanism
|
||||
@@ -1760,21 +1705,9 @@ nsresult PinCurrentAppToTaskbarImpl(
|
||||
|
||||
case Win11PinToTaskBarResultStatus::Success:
|
||||
case Win11PinToTaskBarResultStatus::AlreadyPinned:
|
||||
telemetry::pinning::Record(aCheckOnly, pinWithWin11TaskbarAPIResults,
|
||||
aPrivateBrowsing, false);
|
||||
return NS_OK;
|
||||
|
||||
case Win11PinToTaskBarResultStatus::ErrorLimitedAccessFeatures:
|
||||
case Win11PinToTaskBarResultStatus::LimitedAccessFeaturesLocked:
|
||||
case Win11PinToTaskBarResultStatus::NotCurrentlyAllowed:
|
||||
// return NS_ERROR_FAILURE;
|
||||
|
||||
// Fall through to the old mechanism for now
|
||||
// In future, we should be sending telemetry for when
|
||||
// an error occurs or for when pinning is not allowed
|
||||
// with the Win 11 APIs.
|
||||
break;
|
||||
|
||||
case Win11PinToTaskBarResultStatus::Failed:
|
||||
// return NS_ERROR_FAILURE;
|
||||
|
||||
@@ -1785,13 +1718,7 @@ nsresult PinCurrentAppToTaskbarImpl(
|
||||
break;
|
||||
}
|
||||
|
||||
auto result =
|
||||
helper->PinCurrentAppFallback(aCheckOnly, aAppUserModelId, shortcutPath);
|
||||
|
||||
telemetry::pinning::Record(aCheckOnly, pinWithWin11TaskbarAPIResults,
|
||||
aPrivateBrowsing, NS_SUCCEEDED(result));
|
||||
|
||||
return result;
|
||||
return PinCurrentAppToTaskbarWin10(aCheckOnly, aAppUserModelId, shortcutPath);
|
||||
}
|
||||
|
||||
static nsresult PinCurrentAppToTaskbarAsyncImpl(bool aCheckOnly,
|
||||
|
||||
Reference in New Issue
Block a user