dom/src/jsurl/nsJSProtocolHandler.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef nsJSProtocolHandler_h___
     7 #define nsJSProtocolHandler_h___
     9 #include "mozilla/Attributes.h"
    10 #include "nsIProtocolHandler.h"
    11 #include "nsITextToSubURI.h"
    12 #include "nsIURI.h"
    13 #include "nsIMutable.h"
    14 #include "nsISerializable.h"
    15 #include "nsIClassInfo.h"
    16 #include "nsSimpleURI.h"
    18 #define NS_JSPROTOCOLHANDLER_CID                     \
    19 { /* bfc310d2-38a0-11d3-8cd3-0060b0fc14a3 */         \
    20     0xbfc310d2,                                      \
    21     0x38a0,                                          \
    22     0x11d3,                                          \
    23     {0x8c, 0xd3, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
    24 }
    26 #define NS_JSURI_CID                                 \
    27 { /* 58f089ee-512a-42d2-a935-d0c874128930 */         \
    28     0x58f089ee,                                      \
    29     0x512a,                                          \
    30     0x42d2,                                          \
    31     {0xa9, 0x35, 0xd0, 0xc8, 0x74, 0x12, 0x89, 0x30} \
    32 }
    34 #define NS_JSPROTOCOLHANDLER_CONTRACTID \
    35     NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "javascript"
    38 class nsJSProtocolHandler : public nsIProtocolHandler
    39 {
    40 public:
    41     NS_DECL_ISUPPORTS
    43     // nsIProtocolHandler methods:
    44     NS_DECL_NSIPROTOCOLHANDLER
    46     // nsJSProtocolHandler methods:
    47     nsJSProtocolHandler();
    48     virtual ~nsJSProtocolHandler();
    50     static nsresult
    51     Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
    53     nsresult Init();
    55 protected:
    57     nsresult EnsureUTF8Spec(const nsAFlatCString &aSpec, const char *aCharset, 
    58                             nsACString &aUTF8Spec);
    60     nsCOMPtr<nsITextToSubURI>  mTextToSubURI;
    61 };
    64 class nsJSURI : public nsSimpleURI
    65 {
    66 public:
    67     using nsSimpleURI::Read;
    68     using nsSimpleURI::Write;
    70     nsJSURI() {}
    72     nsJSURI(nsIURI* aBaseURI) : mBaseURI(aBaseURI) {}
    74     nsIURI* GetBaseURI() const
    75     {
    76         return mBaseURI;
    77     }
    79     NS_DECL_ISUPPORTS_INHERITED
    81     // nsIURI overrides
    82     virtual nsSimpleURI* StartClone(RefHandlingEnum refHandlingMode) MOZ_OVERRIDE;
    84     // nsISerializable overrides
    85     NS_IMETHOD Read(nsIObjectInputStream* aStream) MOZ_OVERRIDE;
    86     NS_IMETHOD Write(nsIObjectOutputStream* aStream) MOZ_OVERRIDE;
    88     // Override the nsIClassInfo method GetClassIDNoAlloc to make sure our
    89     // nsISerializable impl works right.
    90     NS_IMETHOD GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) MOZ_OVERRIDE;
    91     //NS_IMETHOD QueryInterface( const nsIID& aIID, void** aInstancePtr );
    93 protected:
    94     virtual nsresult EqualsInternal(nsIURI* other,
    95                                     RefHandlingEnum refHandlingMode,
    96                                     bool* result) MOZ_OVERRIDE;
    97 private:
    98     nsCOMPtr<nsIURI> mBaseURI;
    99 };
   101 #endif /* nsJSProtocolHandler_h___ */

mercurial