зеркало из https://github.com/mozilla/pjs.git
340179 - implement web applications 1.0 'registerContentHandler' method on navigator. r=sicking sr=darin
This commit is contained in:
Родитель
708008145e
Коммит
6506dcd934
|
@ -57,6 +57,7 @@ SDK_XPIDLSRCS = \
|
|||
|
||||
XPIDLSRCS = \
|
||||
nsIBrowserDOMWindow.idl \
|
||||
nsIDOMClientInformation.idl \
|
||||
nsIDOMConstructor.idl \
|
||||
nsIDOMCRMFObject.idl \
|
||||
nsIDOMCrypto.idl \
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is nsIDOMNavigator additions.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Google Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <beng@google.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
[scriptable, uuid(abbb51a4-be75-4d7f-bd4c-373fd7b52f85)]
|
||||
interface nsIDOMClientInformation : 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/
|
||||
*/
|
||||
void registerContentHandler(in DOMString mimeType, in DOMString uri, in DOMString title);
|
||||
void registerProtocolHandler(in DOMString protocol, in DOMString uri, in DOMString title);
|
||||
};
|
||||
|
||||
|
|
@ -48,6 +48,7 @@ GRE_MODULE = 1
|
|||
|
||||
XPIDLSRCS = \
|
||||
nsISidebar.idl \
|
||||
nsIWebContentHandlerRegistrar.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Web Content Handler Interface
|
||||
*
|
||||
* The Initial Developer of the Original Code is Google Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <beng@google.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* nsIWebContentHandlerRegistrar
|
||||
*
|
||||
* Applications wishing to use web content handlers need to implement this
|
||||
* interface. Typically they will prompt the user to confirm adding an entry
|
||||
* to the local list.
|
||||
*
|
||||
* The component must have the contract id defined below so that nsNavigator
|
||||
* can invoke it.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(5184749d-8b4c-4fa5-900e-fb84a08f196a)]
|
||||
interface nsIWebContentHandlerRegistrar : nsISupports
|
||||
{
|
||||
void registerContentHandler(in DOMString mimeType, in DOMString uri, in DOMString title);
|
||||
void registerProtocolHandler(in DOMString protocol, in DOMString uri, in DOMString title);
|
||||
};
|
||||
|
||||
%{ C++
|
||||
|
||||
#define NS_WEBCONTENTHANDLERREGISTRAR_CONTRACTID "@mozilla.org/web-content-handler-registrar;1"
|
||||
%}
|
|
@ -1801,6 +1801,7 @@ nsDOMClassInfo::Init()
|
|||
DOM_CLASSINFO_MAP_BEGIN(Navigator, nsIDOMNavigator)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigator)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSNavigator)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMClientInformation)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(Plugin, nsIDOMPlugin)
|
||||
|
|
|
@ -125,6 +125,7 @@
|
|||
#include "nsIWebBrowser.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "nsIWebBrowserFind.h" // For window.find()
|
||||
#include "nsIWebContentHandlerRegistrar.h"
|
||||
#include "nsIWindowMediator.h" // For window.find()
|
||||
#include "nsIComputedDOMStyle.h"
|
||||
#include "nsIEntropyCollector.h"
|
||||
|
@ -7525,6 +7526,7 @@ NS_INTERFACE_MAP_BEGIN(nsNavigator)
|
|||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMNavigator)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNavigator)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMJSNavigator)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMClientInformation)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Navigator)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
@ -8020,3 +8022,34 @@ nsNavigator::RefreshMIMEArray()
|
|||
rv = mMimeTypes->Refresh();
|
||||
return rv;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsNavigator::nsIDOMClientInformation
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNavigator::RegisterContentHandler(const nsAString& aMIMEType,
|
||||
const nsAString& aURI,
|
||||
const nsAString& aTitle)
|
||||
{
|
||||
nsCOMPtr<nsIWebContentHandlerRegistrar> registrar =
|
||||
do_GetService(NS_WEBCONTENTHANDLERREGISTRAR_CONTRACTID);
|
||||
if (registrar)
|
||||
return registrar->RegisterContentHandler(aMIMEType, aURI, aTitle);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNavigator::RegisterProtocolHandler(const nsAString& aProtocol,
|
||||
const nsAString& aURI,
|
||||
const nsAString& aTitle)
|
||||
{
|
||||
nsCOMPtr<nsIWebContentHandlerRegistrar> registrar =
|
||||
do_GetService(NS_WEBCONTENTHANDLERREGISTRAR_CONTRACTID);
|
||||
if (registrar)
|
||||
return registrar->RegisterProtocolHandler(aProtocol, aURI, aTitle);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include "nsIControllers.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIDOMClientInformation.h"
|
||||
#include "nsIDOMViewCSS.h"
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDOM3EventTarget.h"
|
||||
|
@ -704,7 +705,8 @@ private:
|
|||
//*****************************************************************************
|
||||
|
||||
class nsNavigator : public nsIDOMNavigator,
|
||||
public nsIDOMJSNavigator
|
||||
public nsIDOMJSNavigator,
|
||||
public nsIDOMClientInformation
|
||||
{
|
||||
public:
|
||||
nsNavigator(nsIDocShell *aDocShell);
|
||||
|
@ -713,6 +715,7 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMNAVIGATOR
|
||||
NS_DECL_NSIDOMJSNAVIGATOR
|
||||
NS_DECL_NSIDOMCLIENTINFORMATION
|
||||
|
||||
void SetDocShell(nsIDocShell *aDocShell);
|
||||
nsIDocShell *GetDocShell()
|
||||
|
|
Загрузка…
Ссылка в новой задаче