DOM changes for bug 349380 (better UI for registerContentHandler). r+sr=bzbarsky.

This commit is contained in:
mozilla.mano%sent.com 2006-09-13 23:45:16 +00:00
parent 6a579c885f
commit f384c540d5
3 changed files with 28 additions and 15 deletions

View File

@ -377,7 +377,7 @@ var WebContentConverterRegistrar = {
* See nsIWebContentHandlerRegistrar
*/
registerProtocolHandler:
function WCCR_registerProtocolHandler(protocol, uri, title) {
function WCCR_registerProtocolHandler(protocol, uri, title, contentWindow) {
// XXXben - for Firefox 2 we only support feed types
return;
@ -393,7 +393,7 @@ var WebContentConverterRegistrar = {
* preferences.
*/
registerContentHandler:
function WCCR_registerContentHandler(contentType, uri, title) {
function WCCR_registerContentHandler(contentType, uri, title, contentWindow) {
LOG("registerContentHandler(" + contentType + "," + uri + "," + title + ")");
// XXXben - for Firefox 2 we only support feed types

View File

@ -38,6 +38,8 @@
#include "nsISupports.idl"
interface nsIDOMWindow;
/**
* nsIWebContentHandlerRegistrar
*
@ -49,18 +51,22 @@
* can invoke it.
*/
[scriptable, uuid(5184749d-8b4c-4fa5-900e-fb84a08f196a)]
[scriptable, uuid(e6a75410-c93e-42bf-84ca-a5c3ec34a2f1)]
interface nsIWebContentHandlerRegistrar : nsISupports
{
/**
* Web Applications 1.0 Browser State: registerContentHandler
* Allows web services to register themselves as handlers for certain content
* types.
* http://whatwg.org/specs/web-apps/current-work/
* See also: nsIDOMClientInformation.idl
* See documentation in nsIDOMClientInformation.idl
* The additional contentWindow param for both methods represents the dom
* content window from which the method has been called.
*/
void registerContentHandler(in DOMString mimeType, in DOMString uri, in DOMString title);
void registerProtocolHandler(in DOMString protocol, in DOMString uri, in DOMString title);
void registerContentHandler(in DOMString mimeType,
in DOMString uri,
in DOMString title,
in nsIDOMWindow contentWindow);
void registerProtocolHandler(in DOMString protocol,
in DOMString uri,
in DOMString title,
in nsIDOMWindow contentWindow);
};
%{ C++

View File

@ -8144,8 +8144,12 @@ nsNavigator::RegisterContentHandler(const nsAString& aMIMEType,
{
nsCOMPtr<nsIWebContentHandlerRegistrar> registrar =
do_GetService(NS_WEBCONTENTHANDLERREGISTRAR_CONTRACTID);
if (registrar)
return registrar->RegisterContentHandler(aMIMEType, aURI, aTitle);
if (registrar && mDocShell) {
nsCOMPtr<nsIDOMWindow> contentDOMWindow(do_GetInterface(mDocShell));
if (contentDOMWindow)
return registrar->RegisterContentHandler(aMIMEType, aURI, aTitle,
contentDOMWindow);
}
return NS_OK;
}
@ -8157,9 +8161,12 @@ nsNavigator::RegisterProtocolHandler(const nsAString& aProtocol,
{
nsCOMPtr<nsIWebContentHandlerRegistrar> registrar =
do_GetService(NS_WEBCONTENTHANDLERREGISTRAR_CONTRACTID);
if (registrar)
return registrar->RegisterProtocolHandler(aProtocol, aURI, aTitle);
if (registrar && mDocShell) {
nsCOMPtr<nsIDOMWindow> contentDOMWindow(do_GetInterface(mDocShell));
if (contentDOMWindow)
return registrar->RegisterProtocolHandler(aProtocol, aURI, aTitle,
contentDOMWindow);
}
return NS_OK;
}