Bug 1743914 - Part 3: Telemetry for when Firefox is the default handler. r=chutten,mhowell

This only records whether Firefox is the default PDF handler for now.
But it will accommodate additional file types and protocols in the
future, should they be desired.

This is Windows 10+ only, since we really only care about PDF handling
defaults where Edgium is the OS default.

Differential Revision: https://phabricator.services.mozilla.com/D132659
This commit is contained in:
Nick Alexander
2021-12-11 06:25:57 +00:00
parent 8f6c831713
commit 67477c0843
7 changed files with 148 additions and 30 deletions

View File

@@ -207,6 +207,32 @@ nsWindowsShellService::IsDefaultBrowser(bool aForAllTypes,
return NS_OK;
}
NS_IMETHODIMP
nsWindowsShellService::IsDefaultHandlerFor(
const nsAString& aFileExtensionOrProtocol, bool* aIsDefaultHandlerFor) {
*aIsDefaultHandlerFor = false;
RefPtr<IApplicationAssociationRegistration> pAAR;
HRESULT hr = CoCreateInstance(
CLSID_ApplicationAssociationRegistration, nullptr, CLSCTX_INPROC,
IID_IApplicationAssociationRegistration, getter_AddRefs(pAAR));
if (FAILED(hr)) {
return NS_OK;
}
wchar_t exePath[MAXPATHLEN] = L"";
nsresult rv = BinaryPath::GetLong(exePath);
if (NS_FAILED(rv)) {
return NS_OK;
}
const nsString& flatClass = PromiseFlatString(aFileExtensionOrProtocol);
*aIsDefaultHandlerFor = IsPathDefaultForClass(pAAR, exePath, flatClass.get());
return NS_OK;
}
nsresult nsWindowsShellService::LaunchControlPanelDefaultsSelectionUI() {
IApplicationAssociationRegistrationUI* pAARUI;
HRESULT hr = CoCreateInstance(