Open
Bug 961233
Opened 12 years ago
Updated 3 years ago
nsIWebHandlerApp uriTemplate not reset when changing to a non web protocol handler
Categories
(Firefox :: File Handling, defect)
Firefox
File Handling
Tracking
()
NEW
People
(Reporter: mkaply, Unassigned)
Details
If you have a system mailto handler (like Windows Live Mail) and a web mail handler (like Yahoo), when you switch to Yahoo, then switch to Windows Live Mail and run the following code:
handlerInfo = gExternalProtocolServ.getProtocolHandlerInfo("mailto");
if (handlerInfo && handlerInfo.preferredApplicationHandler) {
var handler = handlerInfo.preferredApplicationHandler
.QueryInterface(Ci.nsIWebHandlerApp);
Components.utils.reportError(uriTemplate);
}
You'll get the uriTemplate for Yahoo mail, even though the preferredApplicationHandler is now Windows Live Mail.
The workaround for me was to make sure that preferredAction is 2 (which would mean it's not a system handler).
But uriTemplate shouldn't be set anymore if it's not really an nsIWebHandlerApp.
Maybe Cc['@mozilla.org/uriloader/handler-service;1'].getService(Ci.nsIHandlerService).store(handlerInfo); wasn't being called?
Flags: needinfo?(mozilla)
| Reporter | ||
Comment 2•10 years ago
|
||
Are you saying I should be calling store? I'll check.
Flags: needinfo?(mozilla)
Yep you have to call store otherwise things don't save :(
I found an issue where even if you call store, it will not update the .name of the non preferred handler.
var handlerInfoXPCOM = Cc['@mozilla.org/uriloader/external-protocol-service;1'].getService(Ci.nsIExternalProtocolService).getProtocolHandlerInfo('mailto');
var i = 0;
var handlersXPCOM = handlerInfoXPCOM.possibleApplicationHandlers.enumerate();
var handlers = [];
while (handlersXPCOM.hasMoreElements()) {
var handler = handlersXPCOM.getNext();
var handlerQI = handler.QueryInterface(Ci.nsIWebHandlerApp);
handlerQI.name = 'ya' + i;
i++;
handlers.push(handler);
}
console.info('handlers:', handlers);
Cc['@mozilla.org/uriloader/handler-service;1'].getService(Ci.nsIHandlerService).store(handlerInfoXPCOM);
Wow working more with this I found a very peculilar thing.
var handlerInfoXPCOM = myServices.eps.getProtocolHandlerInfo('mailto');
so now if handlerInfoXPCOM.preferredApplicationHandler is a webapphandler, we would have to QI it right? in order to get the .uriTemplate
so we do:
handlerInfoXPCOM.preferredApplicationHandler.QueryInterface(Ci.nsIWebHandlerApp)
then we can acesss
handlerInfoXPCOM.preferredApplicationHandler.uriTemplate
What I found reallllly interesting was that doing instanceof test is basically equivalent of doing QI on it:
if (handlerInfoXPCOM.preferredApplicationHandler instanceof Ci.nsIWebAppHandler) {
var uri = handlerInfoXPCOM.preferredApplicationHandler.uriTemplate;
}
very interesting, i never knew that doing instanceof would QI it
Updated•3 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•