diff --git a/mozilla/browser/installer/unix/packages-static b/mozilla/browser/installer/unix/packages-static index 441f21cdca2..75a59ec00b8 100644 --- a/mozilla/browser/installer/unix/packages-static +++ b/mozilla/browser/installer/unix/packages-static @@ -237,6 +237,7 @@ bin/components/nsContentPrefService.js bin/components/nsContentDispatchChooser.js bin/components/nsHandlerService.js bin/components/nsScriptableIO.js +bin/components/nsWebHandlerApp.js ; Modules bin/modules/* diff --git a/mozilla/browser/installer/windows/packages-static b/mozilla/browser/installer/windows/packages-static index 9f110a29fb7..534d3bca31f 100644 --- a/mozilla/browser/installer/windows/packages-static +++ b/mozilla/browser/installer/windows/packages-static @@ -237,6 +237,7 @@ bin\components\nsContentPrefService.js bin\components\nsContentDispatchChooser.js bin\components\nsHandlerService.js bin\components\nsScriptableIO.js +bin\components\nsWebHandlerApp.js ; Modules bin\modules\* diff --git a/mozilla/docshell/build/nsDocShellModule.cpp b/mozilla/docshell/build/nsDocShellModule.cpp index bbdc6247b08..75e2f63c447 100644 --- a/mozilla/docshell/build/nsDocShellModule.cpp +++ b/mozilla/docshell/build/nsDocShellModule.cpp @@ -55,7 +55,7 @@ #include "nsExternalProtocolHandler.h" #include "nsPrefetchService.h" #include "nsOfflineCacheUpdate.h" -#include "nsHandlerAppImpl.h" +#include "nsLocalHandlerApp.h" // session history #include "nsSHEntry.h" diff --git a/mozilla/mail/installer/windows/packages-static b/mozilla/mail/installer/windows/packages-static index e63e9010a3c..819a1883140 100644 --- a/mozilla/mail/installer/windows/packages-static +++ b/mozilla/mail/installer/windows/packages-static @@ -149,6 +149,7 @@ bin\components\downloads.xpt ; Protocol/Content handling bin\components\nsContentDispatchChooser.js bin\components\nsHandlerService.js +bin\components\nsWebHandlerApp.js ; spellchecker (may not be present) bin\components\spellchecker.xpt diff --git a/mozilla/netwerk/mime/public/nsIMIMEInfo.idl b/mozilla/netwerk/mime/public/nsIMIMEInfo.idl index 9b6ecabde89..d16ef62a29a 100644 --- a/mozilla/netwerk/mime/public/nsIMIMEInfo.idl +++ b/mozilla/netwerk/mime/public/nsIMIMEInfo.idl @@ -222,8 +222,8 @@ interface nsIHandlerApp : nsISupports { /** * nsILocalHandlerApp is a local OS-level executable */ -[scriptable, uuid(e21f3d75-9103-490e-bfb9-1bf09cc3f103)] -interface nsILocalHandlerApp: nsISupports { +[scriptable, uuid(9812be73-273c-478c-8170-c3e0db08ae7c)] +interface nsILocalHandlerApp : nsIHandlerApp { /** * Pointer to the executable file used to handle content @@ -237,8 +237,8 @@ interface nsILocalHandlerApp: nsISupports { * we probably want to work with WhatWG to spec out and implement POST-based * handlers as well. */ -[scriptable, uuid(065cd099-2f71-4ac8-9dab-17fc079e9647)] -interface nsIWebHandlerApp: nsISupports { +[scriptable, uuid(7521a093-c498-45ce-b462-df7ba0d882f6)] +interface nsIWebHandlerApp : nsIHandlerApp { /** * Template used to construct the URI to GET. Template is expected to have diff --git a/mozilla/suite/installer/windows/packages b/mozilla/suite/installer/windows/packages index ec11cb29ab3..822b6468846 100644 --- a/mozilla/suite/installer/windows/packages +++ b/mozilla/suite/installer/windows/packages @@ -288,6 +288,7 @@ bin\components\nsAboutAbout.js bin\components\nsDefaultCLH.js bin\components\nsContentDispatchChooser.js bin\components\nsHandlerService.js +bin\components\nsWebHandlerApp.js ; Modules bin\modules\* diff --git a/mozilla/uriloader/exthandler/Makefile.in b/mozilla/uriloader/exthandler/Makefile.in index 869f6f1b20c..b86b77942a8 100644 --- a/mozilla/uriloader/exthandler/Makefile.in +++ b/mozilla/uriloader/exthandler/Makefile.in @@ -148,7 +148,7 @@ CPPSRCS = \ nsExternalHelperAppService.cpp \ nsExternalProtocolHandler.cpp \ nsMIMEInfoImpl.cpp \ - nsHandlerAppImpl.cpp \ + nsLocalHandlerApp.cpp \ $(OSHELPER) \ $(NULL) @@ -158,7 +158,10 @@ GARBAGE += nsOSHelperAppService.cpp $(srcdir)/nsOSHelperAppService.cpp \ nsMIMEInfoWin.cpp $(srcdir)/nsMIMEInfoWin.cpp endif -EXTRA_COMPONENTS = nsHandlerService.js +EXTRA_COMPONENTS = \ + nsHandlerService.js \ + nsWebHandlerApp.js \ + $(NULL) # we don't want the shared lib, but we want to force the creation of a static lib. FORCE_STATIC_LIB = 1 diff --git a/mozilla/uriloader/exthandler/nsCExternalHandlerService.idl b/mozilla/uriloader/exthandler/nsCExternalHandlerService.idl index e35609537e5..b6cd5519b52 100644 --- a/mozilla/uriloader/exthandler/nsCExternalHandlerService.idl +++ b/mozilla/uriloader/exthandler/nsCExternalHandlerService.idl @@ -75,5 +75,8 @@ nsIExternalHelperAppService #define NS_LOCALHANDLERAPP_CONTRACTID \ "@mozilla.org/uriloader/local-handler-app;1" +#define NS_WEBHANDLERAPP_CONTRACTID \ +"@mozilla.org/uriloader/web-handler-app;1" + %} diff --git a/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp b/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp index 7b42555a5f0..6b7535d8042 100644 --- a/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -42,6 +42,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsExternalHelperAppService.h" +#include "nsCExternalHandlerService.h" #include "nsIURI.h" #include "nsIURL.h" #include "nsIFile.h" @@ -124,7 +125,7 @@ #include "nsCRT.h" #include "nsMIMEInfoImpl.h" -#include "nsHandlerAppImpl.h" +#include "nsLocalHandlerApp.h" #ifdef PR_LOGGING PRLogModuleInfo* nsExternalHelperAppService::mLog = nsnull; @@ -824,11 +825,13 @@ nsresult nsExternalHelperAppService::FillHandlerAppFromSource( const PRUnichar * uriTemplate = nsnull; FillLiteralValueFromTarget(aSource, kNC_UriTemplate, &uriTemplate); if (uriTemplate && uriTemplate[0]) { - nsWebHandlerApp *handlerApp(new nsWebHandlerApp(appName, - NS_ConvertUTF16toUTF8(uriTemplate))); - if (!handlerApp) { - return NS_ERROR_OUT_OF_MEMORY; - } + nsCOMPtr handlerApp = + do_CreateInstance(NS_WEBHANDLERAPP_CONTRACTID, &rv); + NS_ENSURE_SUCCESS(rv, rv); + + handlerApp->SetName(nsDependentString(appName)); + handlerApp->SetUriTemplate(NS_ConvertUTF16toUTF8(uriTemplate)); + NS_ADDREF(*aHandlerApp = handlerApp); } else { return NS_ERROR_FAILURE; // no path name _and_ no uri template diff --git a/mozilla/uriloader/exthandler/nsHandlerAppImpl.cpp b/mozilla/uriloader/exthandler/nsLocalHandlerApp.cpp similarity index 73% rename from mozilla/uriloader/exthandler/nsHandlerAppImpl.cpp rename to mozilla/uriloader/exthandler/nsLocalHandlerApp.cpp index e3c18a4b137..4b7b3ed88b3 100644 --- a/mozilla/uriloader/exthandler/nsHandlerAppImpl.cpp +++ b/mozilla/uriloader/exthandler/nsLocalHandlerApp.cpp @@ -37,43 +37,14 @@ * * ***** END LICENSE BLOCK ***** */ -#include "nsHandlerAppImpl.h" +#include "nsLocalHandlerApp.h" // XXX why does nsMIMEInfoImpl have a threadsafe nsISupports? do we need one // here too? +NS_IMPL_ISUPPORTS2(nsLocalHandlerApp, nsILocalHandlerApp, nsIHandlerApp) -nsHandlerAppBase::nsHandlerAppBase() -{ -} - -nsHandlerAppBase::nsHandlerAppBase(const PRUnichar *aName) - : mName(aName) -{ -} - -nsHandlerAppBase::nsHandlerAppBase(const nsAString & aName) - : mName(aName) -{ -} - -NS_IMPL_ISUPPORTS1(nsHandlerAppBase, nsIHandlerApp) - -/* AString name; */ -NS_IMETHODIMP nsHandlerAppBase::GetName(nsAString & aName) -{ - aName.Assign(mName); - - return NS_OK; -} - -NS_IMETHODIMP nsHandlerAppBase::SetName(const nsAString & aName) -{ - mName.Assign(aName); - - return NS_OK; -} - -NS_IMPL_ISUPPORTS_INHERITED1(nsLocalHandlerApp, nsHandlerAppBase, nsILocalHandlerApp) +//////////////////////////////////////////////////////////////////////////////// +//// nsIHandlerApp NS_IMETHODIMP nsLocalHandlerApp::GetName(nsAString& aName) { @@ -88,6 +59,16 @@ NS_IMETHODIMP nsLocalHandlerApp::GetName(nsAString& aName) return NS_OK; } +NS_IMETHODIMP nsLocalHandlerApp::SetName(const nsAString & aName) +{ + mName.Assign(aName); + + return NS_OK; +} + +//////////////////////////////////////////////////////////////////////////////// +//// nsILocalHandlerApp + NS_IMETHODIMP nsLocalHandlerApp::GetExecutable(nsIFile **aExecutable) { NS_IF_ADDREF(*aExecutable = mExecutable); @@ -100,19 +81,3 @@ NS_IMETHODIMP nsLocalHandlerApp::SetExecutable(nsIFile *aExecutable) return NS_OK; } - -NS_IMPL_ISUPPORTS_INHERITED1(nsWebHandlerApp, nsHandlerAppBase, - nsIWebHandlerApp) - - -NS_IMETHODIMP nsWebHandlerApp::GetUriTemplate(nsACString &aUriTemplate) -{ - aUriTemplate.Assign(mUriTemplate); - return NS_OK; -} - -NS_IMETHODIMP nsWebHandlerApp::SetUriTemplate(const nsACString &aUriTemplate) -{ - mUriTemplate.Assign(aUriTemplate); - return NS_OK; -} diff --git a/mozilla/uriloader/exthandler/nsHandlerAppImpl.h b/mozilla/uriloader/exthandler/nsLocalHandlerApp.h similarity index 65% rename from mozilla/uriloader/exthandler/nsHandlerAppImpl.h rename to mozilla/uriloader/exthandler/nsLocalHandlerApp.h index 20f3804655d..3318dcc4a05 100644 --- a/mozilla/uriloader/exthandler/nsHandlerAppImpl.h +++ b/mozilla/uriloader/exthandler/nsLocalHandlerApp.h @@ -37,66 +37,32 @@ * * ***** END LICENSE BLOCK ***** */ -#ifndef __nshandlerappimpl_h__ -#define __nshandlerappimpl_h__ +#ifndef __nsLocalHandlerAppImpl_h__ +#define __nsLocalHandlerAppImpl_h__ #include "nsString.h" #include "nsIMIMEInfo.h" #include "nsIFile.h" -class nsHandlerAppBase : public nsIHandlerApp +class nsLocalHandlerApp : public nsILocalHandlerApp { public: NS_DECL_ISUPPORTS NS_DECL_NSIHANDLERAPP + NS_DECL_NSILOCALHANDLERAPP - nsHandlerAppBase() NS_HIDDEN; - nsHandlerAppBase(const PRUnichar *aName) NS_HIDDEN; - nsHandlerAppBase(const nsAString & aName) NS_HIDDEN; - virtual ~nsHandlerAppBase() {} + nsLocalHandlerApp() { } + + nsLocalHandlerApp(const PRUnichar *aName, nsIFile *aExecutable) + : mName(aName), mExecutable(aExecutable) { } + + nsLocalHandlerApp(const nsAString & aName, nsIFile *aExecutable) + : mName(aName), mExecutable(aExecutable) { } + virtual ~nsLocalHandlerApp() { } protected: nsString mName; -}; - -class nsLocalHandlerApp : public nsHandlerAppBase, public nsILocalHandlerApp -{ -public: - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSILOCALHANDLERAPP - - nsLocalHandlerApp() {} - - nsLocalHandlerApp(const PRUnichar *aName, nsIFile *aExecutable) - : nsHandlerAppBase(aName), mExecutable(aExecutable) {} - - nsLocalHandlerApp(const nsAString & aName, nsIFile *aExecutable) - : nsHandlerAppBase(aName), mExecutable(aExecutable) {} - - virtual ~nsLocalHandlerApp() {} - - // overriding to keep old caching behavior (that a useful name is returned - // even if none was given to the constructor) - NS_IMETHOD GetName(nsAString & aName); - -protected: nsCOMPtr mExecutable; }; -class nsWebHandlerApp : public nsHandlerAppBase, public nsIWebHandlerApp -{ - public: - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIWEBHANDLERAPP - - nsWebHandlerApp(const PRUnichar *aName, const nsACString &aUriTemplate) - : nsHandlerAppBase(aName), mUriTemplate(aUriTemplate) { } - - virtual ~nsWebHandlerApp() {} - - protected: - nsCString mUriTemplate; - -}; - -#endif // __nshandlerappimpl_h__ +#endif // __nsLocalHandlerAppImpl_h__ diff --git a/mozilla/uriloader/exthandler/nsWebHandlerApp.js b/mozilla/uriloader/exthandler/nsWebHandlerApp.js new file mode 100644 index 00000000000..ea2647220f8 --- /dev/null +++ b/mozilla/uriloader/exthandler/nsWebHandlerApp.js @@ -0,0 +1,98 @@ +/* ***** 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 Mozilla browser. + * + * The Initial Developer of the Original Code is + * Mozilla Corporation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Shawn Wilsher + * + * 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 ***** */ + +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); + +//////////////////////////////////////////////////////////////////////////////// +//// Constants + +const Ci = Components.interfaces; + +//////////////////////////////////////////////////////////////////////////////// +//// nsWebHandler class + +function nsWebHandlerApp() {} + +nsWebHandlerApp.prototype = { + ////////////////////////////////////////////////////////////////////////////// + //// nsWebHandler + + classDescription: "A web handler for protocols and content", + classID: Components.ID("8b1ae382-51a9-4972-b930-56977a57919d"), + contractID: "@mozilla.org/uriloader/web-handler-app;1", + + _name: null, + _uriTemplate: null, + + ////////////////////////////////////////////////////////////////////////////// + //// nsIHandlerApp + + get name() { + return this._name; + }, + + set name(aName) { + this._name = aName; + }, + + ////////////////////////////////////////////////////////////////////////////// + //// nsIWebHandlerApp + + get uriTemplate() { + return this._uriTemplate; + }, + + set uriTemplate(aURITemplate) { + this._uriTemplate = aURITemplate; + }, + + ////////////////////////////////////////////////////////////////////////////// + //// nsISupports + + QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebHandlerApp, Ci.nsIHandlerApp]) +}; + +//////////////////////////////////////////////////////////////////////////////// +//// Module + +let components = [nsWebHandlerApp]; + +function NSGetModule(compMgr, fileSpec) +{ + return XPCOMUtils.generateModule(components); +} + diff --git a/mozilla/uriloader/exthandler/tests/unit/test_handlerService.js b/mozilla/uriloader/exthandler/tests/unit/test_handlerService.js index 728fb5220ec..a917f66acf5 100755 --- a/mozilla/uriloader/exthandler/tests/unit/test_handlerService.js +++ b/mozilla/uriloader/exthandler/tests/unit/test_handlerService.js @@ -53,16 +53,10 @@ function run_test() { } }; - var webHandler = { - name: "Web Handler", - uriTemplate: "http://www.example.com/?%s", - interfaces: [Ci.nsIHandlerApp, Ci.nsIWebHandlerApp, Ci.nsISupports], - QueryInterface: function(iid) { - if (!this.interfaces.some( function(v) { return iid.equals(v) } )) - throw Cr.NS_ERROR_NO_INTERFACE; - return this; - } - }; + var webHandler = Cc["@mozilla.org/uriloader/web-handler-app;1"]. + createInstance(Ci.nsIWebHandlerApp); + webHandler.name = "Web Handler"; + webHandler.uriTemplate = "http://www.example.com/?%s"; var handlerSvc = Cc["@mozilla.org/uriloader/handler-service;1"]. getService(Ci.nsIHandlerService);