Bug 1761504 - Add setDefaultPDFHandlerOnlyReplaceBrowsers Nimbus feature. r=bhearsum
When enabled, this feature restricts the existing `setDefaultPDFHandler` Nimbus feature to only set Firefox as the default PDF handler when the existing handler is a known browser. Depends on D142147 Differential Revision: https://phabricator.services.mozilla.com/D142148
This commit is contained in:
@@ -242,6 +242,37 @@ nsWindowsShellService::IsDefaultHandlerFor(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::QueryCurrentDefaultHandlerFor(
|
||||
const nsAString& aFileExtensionOrProtocol, nsAString& aResult) {
|
||||
aResult.Truncate();
|
||||
|
||||
RefPtr<IApplicationAssociationRegistration> pAAR;
|
||||
HRESULT hr = CoCreateInstance(
|
||||
CLSID_ApplicationAssociationRegistration, nullptr, CLSCTX_INPROC,
|
||||
IID_IApplicationAssociationRegistration, getter_AddRefs(pAAR));
|
||||
if (FAILED(hr)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const nsString& flatClass = PromiseFlatString(aFileExtensionOrProtocol);
|
||||
|
||||
LPWSTR registeredApp;
|
||||
bool isProtocol = flatClass.First() != L'.';
|
||||
ASSOCIATIONTYPE queryType = isProtocol ? AT_URLPROTOCOL : AT_FILEEXTENSION;
|
||||
hr = pAAR->QueryCurrentDefault(flatClass.get(), queryType, AL_EFFECTIVE,
|
||||
®isteredApp);
|
||||
if (hr == HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION)) {
|
||||
return NS_OK;
|
||||
}
|
||||
NS_ENSURE_HRESULT(hr, NS_ERROR_FAILURE);
|
||||
|
||||
aResult = registeredApp;
|
||||
CoTaskMemFree(registeredApp);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsWindowsShellService::LaunchControlPanelDefaultsSelectionUI() {
|
||||
IApplicationAssociationRegistrationUI* pAARUI;
|
||||
HRESULT hr = CoCreateInstance(
|
||||
|
||||
Reference in New Issue
Block a user