Skip to content

Commit 6964a15

Browse files
committed
Backed out changeset f83bd0235854 (bug 1863636) for causing Bug 1875554
1 parent 413530a commit 6964a15

File tree

4 files changed

+10
-217
lines changed

4 files changed

+10
-217
lines changed

browser/components/shell/nsIWindowsShellService.idl

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -189,42 +189,6 @@ interface nsIWindowsShellService : nsISupports
189189
*/
190190
void unpinShortcutFromTaskbar(in AString aShortcutPath);
191191

192-
193-
/**
194-
* Gets the full path of a taskbar tab shortcut.
195-
*
196-
* @param aShortcutName
197-
* The name of the taskbar tab shortcut, excluding the file extension.
198-
* @throws NS_ERROR_FAILURE
199-
* If the user token cannot be found.
200-
* @throws NS_ERROR_ABORT
201-
* If converting the sid to a string fails.
202-
*
203-
* @return The full path of the taskbar tab shortcut
204-
*/
205-
AString getTaskbarTabShortcutPath(in AString aShortcutName);
206-
207-
/*
208-
* Searches the %USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start
209-
* Menu\Programs folder and returns an array with the path of all
210-
* shortcuts with a target matching the current Firefox install location
211-
* and the -taskbar-tab argument.
212-
*
213-
* It is possible to return an empty array if no shortcuts are found.
214-
*
215-
* @return An array of paths for all taskbar tab shortcuts.
216-
*
217-
* @throws NS_ERROR_ABORT
218-
* if instance cannot be created.
219-
* @throws NS_ERROR_FILE_NOT_FOUND
220-
* if %USERPROFILE%\AppData\Roaming\ cannot be opened.
221-
* @throws NS_ERROR_FAILURE
222-
* if the executable file cannot be found.
223-
* @throws NS_ERROR_FILE_UNRECOGNIZED_PATH
224-
* if the executable file cannot be converted into a string.
225-
*/
226-
Array<AString> getTaskbarTabPins();
227-
228192
/*
229193
* Determine where a given shortcut likely appears in the shell.
230194
*

browser/components/shell/nsWindowsShellService.cpp

Lines changed: 10 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,15 +1418,23 @@ static nsresult ManageShortcutTaskbarPins(bool aCheckOnly, bool aPinType,
14181418
}
14191419
};
14201420

1421+
HRESULT hr = CoInitialize(nullptr);
1422+
if (FAILED(hr)) {
1423+
return NS_ERROR_FAILURE;
1424+
}
1425+
const struct ComUninitializer {
1426+
~ComUninitializer() { CoUninitialize(); }
1427+
} kCUi;
1428+
14211429
mozilla::UniquePtr<__unaligned ITEMIDLIST, ILFreeDeleter> path(
14221430
ILCreateFromPathW(nsString(aShortcutPath).get()));
14231431
if (NS_WARN_IF(!path)) {
14241432
return NS_ERROR_FILE_NOT_FOUND;
14251433
}
14261434

14271435
IPinnedList3* pinnedList = nullptr;
1428-
HRESULT hr = CoCreateInstance(CLSID_TaskbandPin, NULL, CLSCTX_INPROC_SERVER,
1429-
IID_IPinnedList3, (void**)&pinnedList);
1436+
hr = CoCreateInstance(CLSID_TaskbandPin, NULL, CLSCTX_INPROC_SERVER,
1437+
IID_IPinnedList3, (void**)&pinnedList);
14301438
if (FAILED(hr) || !pinnedList) {
14311439
return NS_ERROR_NOT_AVAILABLE;
14321440
}
@@ -1459,144 +1467,6 @@ nsWindowsShellService::UnpinShortcutFromTaskbar(
14591467
return ManageShortcutTaskbarPins(runInTestMode, pinType, aShortcutPath);
14601468
}
14611469

1462-
NS_IMETHODIMP
1463-
nsWindowsShellService::GetTaskbarTabShortcutPath(const nsAString& aShortcutName,
1464-
nsAString& aRetPath) {
1465-
// The taskbar tab shortcut will always be in
1466-
// %APPDATA%\Microsoft\Windows\Start Menu\Programs
1467-
RefPtr<IKnownFolderManager> fManager;
1468-
RefPtr<IKnownFolder> progFolder;
1469-
LPWSTR progFolderW;
1470-
nsString progFolderNS;
1471-
HRESULT hr =
1472-
CoCreateInstance(CLSID_KnownFolderManager, nullptr, CLSCTX_INPROC_SERVER,
1473-
IID_IKnownFolderManager, getter_AddRefs(fManager));
1474-
if (NS_WARN_IF(FAILED(hr))) {
1475-
return NS_ERROR_ABORT;
1476-
}
1477-
fManager->GetFolder(FOLDERID_Programs, progFolder.StartAssignment());
1478-
hr = progFolder->GetPath(0, &progFolderW);
1479-
if (FAILED(hr)) {
1480-
return NS_ERROR_FILE_NOT_FOUND;
1481-
}
1482-
progFolderNS.Assign(progFolderW);
1483-
aRetPath = progFolderNS + u"\\"_ns + aShortcutName + u".lnk"_ns;
1484-
return NS_OK;
1485-
}
1486-
1487-
NS_IMETHODIMP
1488-
nsWindowsShellService::GetTaskbarTabPins(nsTArray<nsString>& aShortcutPaths) {
1489-
aShortcutPaths.Clear();
1490-
1491-
// Get AppData\\Roaming folder using a known folder ID
1492-
RefPtr<IKnownFolderManager> fManager;
1493-
RefPtr<IKnownFolder> roamingAppData;
1494-
LPWSTR roamingAppDataW;
1495-
nsString roamingAppDataNS;
1496-
HRESULT hr =
1497-
CoCreateInstance(CLSID_KnownFolderManager, nullptr, CLSCTX_INPROC_SERVER,
1498-
IID_IKnownFolderManager, getter_AddRefs(fManager));
1499-
if (NS_WARN_IF(FAILED(hr))) {
1500-
return NS_ERROR_ABORT;
1501-
}
1502-
fManager->GetFolder(FOLDERID_RoamingAppData,
1503-
roamingAppData.StartAssignment());
1504-
hr = roamingAppData->GetPath(0, &roamingAppDataW);
1505-
if (FAILED(hr)) {
1506-
return NS_ERROR_FILE_NOT_FOUND;
1507-
}
1508-
1509-
// Append taskbar pins folder to AppData\\Roaming
1510-
roamingAppDataNS.Assign(roamingAppDataW);
1511-
CoTaskMemFree(roamingAppDataW);
1512-
nsString taskbarFolder =
1513-
roamingAppDataNS + u"\\Microsoft\\Windows\\Start Menu\\Programs"_ns;
1514-
nsString taskbarFolderWildcard = taskbarFolder + u"\\*.lnk"_ns;
1515-
1516-
// Get known path for binary file for later comparison with shortcuts.
1517-
// Returns lowercase file path which should be fine for Windows as all
1518-
// directories and files are case-insensitive by default.
1519-
RefPtr<nsIFile> binFile;
1520-
nsString binPath;
1521-
nsresult rv = XRE_GetBinaryPath(binFile.StartAssignment());
1522-
if (NS_WARN_IF(FAILED(rv))) {
1523-
return NS_ERROR_FAILURE;
1524-
}
1525-
rv = binFile->GetPath(binPath);
1526-
if (NS_WARN_IF(FAILED(rv))) {
1527-
return NS_ERROR_FILE_UNRECOGNIZED_PATH;
1528-
}
1529-
1530-
// Check for if first file exists with a shortcut extension (.lnk)
1531-
WIN32_FIND_DATAW ffd;
1532-
HANDLE fileHandle = INVALID_HANDLE_VALUE;
1533-
fileHandle = FindFirstFileW(taskbarFolderWildcard.get(), &ffd);
1534-
if (fileHandle == INVALID_HANDLE_VALUE) {
1535-
// This means that no files were found in the folder which
1536-
// doesn't imply an error.
1537-
return NS_OK;
1538-
}
1539-
1540-
do {
1541-
// Extract shortcut target path from every
1542-
// shortcut in the taskbar pins folder.
1543-
nsString fileName(ffd.cFileName);
1544-
RefPtr<IShellLinkW> link;
1545-
RefPtr<IPersistFile> ppf;
1546-
RefPtr<IPropertyStore> pps;
1547-
nsString target;
1548-
target.SetLength(MAX_PATH);
1549-
hr = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER,
1550-
IID_IShellLinkW, getter_AddRefs(link));
1551-
if (NS_WARN_IF(FAILED(hr))) {
1552-
continue;
1553-
}
1554-
nsString filePath = taskbarFolder + u"\\"_ns + fileName;
1555-
if (NS_WARN_IF(FAILED(hr))) {
1556-
continue;
1557-
}
1558-
1559-
// After loading shortcut, search through arguments to find if
1560-
// it is a taskbar tab shortcut.
1561-
hr = SHGetPropertyStoreFromParsingName(filePath.get(), nullptr,
1562-
GPS_READWRITE, IID_IPropertyStore,
1563-
getter_AddRefs(pps));
1564-
if (NS_WARN_IF(FAILED(hr)) || pps == nullptr) {
1565-
continue;
1566-
}
1567-
PROPVARIANT propVar;
1568-
PropVariantInit(&propVar);
1569-
auto cleanupPropVariant =
1570-
MakeScopeExit([&] { PropVariantClear(&propVar); });
1571-
// Get the PKEY_Link_Arguments property
1572-
hr = pps->GetValue(PKEY_Link_Arguments, &propVar);
1573-
if (NS_WARN_IF(FAILED(hr))) {
1574-
continue;
1575-
}
1576-
// Check if the argument matches
1577-
if (!(propVar.vt == VT_LPWSTR && propVar.pwszVal != nullptr &&
1578-
wcsstr(propVar.pwszVal, L"-taskbar-tab") != nullptr)) {
1579-
continue;
1580-
}
1581-
1582-
hr = link->GetPath(target.get(), MAX_PATH, nullptr, 0);
1583-
if (NS_WARN_IF(FAILED(hr))) {
1584-
continue;
1585-
}
1586-
1587-
// If shortcut target matches known binary file value
1588-
// then add the path to the shortcut as a valid
1589-
// shortcut. This has to be a substring search as
1590-
// the user could have added unknown command line arguments
1591-
// to the shortcut.
1592-
if (_wcsnicmp(target.get(), binPath.get(), binPath.Length()) == 0) {
1593-
aShortcutPaths.AppendElement(filePath);
1594-
}
1595-
} while (FindNextFile(fileHandle, &ffd) != 0);
1596-
FindClose(fileHandle);
1597-
return NS_OK;
1598-
}
1599-
16001470
static nsresult PinCurrentAppToTaskbarWin10(bool aCheckOnly,
16011471
const nsAString& aAppUserModelId,
16021472
nsAutoString aShortcutPath) {

widget/nsIWinTaskbar.idl

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,6 @@ interface nsIWinTaskbar : nsISupports
145145
* Application window taskbar group settings
146146
*/
147147

148-
/**
149-
* Get the grouping id for a window.
150-
*
151-
* The runtime sets a default, global grouping id for all windows on startup.
152-
* getGroupIdForWindow allows finding the grouping of individual windows
153-
* on the taskbar.
154-
*
155-
* @throw NS_ERROR_INVALID_ARG if the window is not a valid top level window
156-
* associated with a widget.
157-
* @throw NS_ERROR_FAILURE if the property on the window could not be set.
158-
* @throw NS_ERROR_UNEXPECTED for general failures.
159-
*/
160-
AString getGroupIdForWindow(in mozIDOMWindow aParent);
161-
162148
/**
163149
* Set the grouping id for a window.
164150
*

widget/windows/WinTaskbar.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -440,33 +440,6 @@ WinTaskbar::CreateJumpListBuilder(bool aPrivateBrowsing,
440440
return NS_OK;
441441
}
442442

443-
NS_IMETHODIMP
444-
WinTaskbar::GetGroupIdForWindow(mozIDOMWindow* aParent,
445-
nsAString& aIdentifier) {
446-
NS_ENSURE_ARG_POINTER(aParent);
447-
HWND toplevelHWND = ::GetAncestor(GetHWNDFromDOMWindow(aParent), GA_ROOT);
448-
if (!toplevelHWND) return NS_ERROR_INVALID_ARG;
449-
RefPtr<IPropertyStore> pPropStore;
450-
if (FAILED(SHGetPropertyStoreForWindow(toplevelHWND, IID_IPropertyStore,
451-
getter_AddRefs(pPropStore)))) {
452-
return NS_ERROR_INVALID_ARG;
453-
}
454-
PROPVARIANT pv;
455-
PropVariantInit(&pv);
456-
auto cleanupPropVariant = MakeScopeExit([&] { PropVariantClear(&pv); });
457-
if (FAILED(pPropStore->GetValue(PKEY_AppUserModel_ID, &pv))) {
458-
return NS_ERROR_FAILURE;
459-
}
460-
if (pv.vt != VT_LPWSTR) {
461-
// This can happen when there is no window specific group ID set
462-
// It's not an error case so we have to check for empty strings
463-
// returned from the function.
464-
return NS_OK;
465-
}
466-
aIdentifier.Assign(char16ptr_t(pv.pwszVal));
467-
return NS_OK;
468-
}
469-
470443
NS_IMETHODIMP
471444
WinTaskbar::SetGroupIdForWindow(mozIDOMWindow* aParent,
472445
const nsAString& aIdentifier) {

0 commit comments

Comments
 (0)