netwerk/protocol/about/nsAboutProtocolHandler.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/protocol/about/nsAboutProtocolHandler.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,76 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsAboutProtocolHandler_h___
    1.10 +#define nsAboutProtocolHandler_h___
    1.11 +
    1.12 +#include "nsIProtocolHandler.h"
    1.13 +#include "nsSimpleNestedURI.h"
    1.14 +#include "mozilla/Attributes.h"
    1.15 +
    1.16 +class nsIURI;
    1.17 +
    1.18 +class nsAboutProtocolHandler : public nsIProtocolHandler
    1.19 +{
    1.20 +public:
    1.21 +    NS_DECL_ISUPPORTS
    1.22 +
    1.23 +    // nsIProtocolHandler methods:
    1.24 +    NS_DECL_NSIPROTOCOLHANDLER
    1.25 +
    1.26 +    // nsAboutProtocolHandler methods:
    1.27 +    nsAboutProtocolHandler() {}
    1.28 +    virtual ~nsAboutProtocolHandler() {}
    1.29 +};
    1.30 +
    1.31 +class nsSafeAboutProtocolHandler MOZ_FINAL : public nsIProtocolHandler
    1.32 +{
    1.33 +public:
    1.34 +    NS_DECL_ISUPPORTS
    1.35 +
    1.36 +    // nsIProtocolHandler methods:
    1.37 +    NS_DECL_NSIPROTOCOLHANDLER
    1.38 +
    1.39 +    // nsSafeAboutProtocolHandler methods:
    1.40 +    nsSafeAboutProtocolHandler() {}
    1.41 +
    1.42 +private:
    1.43 +    ~nsSafeAboutProtocolHandler() {}
    1.44 +};
    1.45 +
    1.46 +
    1.47 +// Class to allow us to propagate the base URI to about:blank correctly
    1.48 +class nsNestedAboutURI : public nsSimpleNestedURI {
    1.49 +public:
    1.50 +    nsNestedAboutURI(nsIURI* aInnerURI, nsIURI* aBaseURI)
    1.51 +        : nsSimpleNestedURI(aInnerURI)
    1.52 +        , mBaseURI(aBaseURI)
    1.53 +    {}
    1.54 +
    1.55 +    // For use only from deserialization
    1.56 +    nsNestedAboutURI() : nsSimpleNestedURI() {}
    1.57 +
    1.58 +    virtual ~nsNestedAboutURI() {}
    1.59 +
    1.60 +    // Override QI so we can QI to our CID as needed
    1.61 +    NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
    1.62 +
    1.63 +    // Override StartClone(), the nsISerializable methods, and
    1.64 +    // GetClassIDNoAlloc; this last is needed to make our nsISerializable impl
    1.65 +    // work right.
    1.66 +    virtual nsSimpleURI* StartClone(RefHandlingEnum aRefHandlingMode);
    1.67 +    NS_IMETHOD Read(nsIObjectInputStream* aStream);
    1.68 +    NS_IMETHOD Write(nsIObjectOutputStream* aStream);
    1.69 +    NS_IMETHOD GetClassIDNoAlloc(nsCID *aClassIDNoAlloc);
    1.70 +
    1.71 +    nsIURI* GetBaseURI() const {
    1.72 +        return mBaseURI;
    1.73 +    }
    1.74 +
    1.75 +protected:
    1.76 +    nsCOMPtr<nsIURI> mBaseURI;
    1.77 +};
    1.78 +
    1.79 +#endif /* nsAboutProtocolHandler_h___ */

mercurial