nsAboutProtocolHandler.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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/. */
  5. #ifndef nsAboutProtocolHandler_h___
  6. #define nsAboutProtocolHandler_h___
  7. #include "nsIProtocolHandler.h"
  8. #include "nsSimpleNestedURI.h"
  9. #include "nsWeakReference.h"
  10. #include "mozilla/Attributes.h"
  11. class nsIURI;
  12. namespace mozilla {
  13. namespace net {
  14. class nsAboutProtocolHandler : public nsIProtocolHandlerWithDynamicFlags
  15. , public nsIProtocolHandler
  16. , public nsSupportsWeakReference
  17. {
  18. public:
  19. NS_DECL_ISUPPORTS
  20. // nsIProtocolHandler methods:
  21. NS_DECL_NSIPROTOCOLHANDLER
  22. NS_DECL_NSIPROTOCOLHANDLERWITHDYNAMICFLAGS
  23. // nsAboutProtocolHandler methods:
  24. nsAboutProtocolHandler() {}
  25. private:
  26. virtual ~nsAboutProtocolHandler() {}
  27. };
  28. class nsSafeAboutProtocolHandler final : public nsIProtocolHandler
  29. , public nsSupportsWeakReference
  30. {
  31. public:
  32. NS_DECL_ISUPPORTS
  33. // nsIProtocolHandler methods:
  34. NS_DECL_NSIPROTOCOLHANDLER
  35. // nsSafeAboutProtocolHandler methods:
  36. nsSafeAboutProtocolHandler() {}
  37. private:
  38. ~nsSafeAboutProtocolHandler() {}
  39. };
  40. // Class to allow us to propagate the base URI to about:blank correctly
  41. class nsNestedAboutURI : public nsSimpleNestedURI {
  42. public:
  43. nsNestedAboutURI(nsIURI* aInnerURI, nsIURI* aBaseURI)
  44. : nsSimpleNestedURI(aInnerURI)
  45. , mBaseURI(aBaseURI)
  46. {}
  47. // For use only from deserialization
  48. nsNestedAboutURI() : nsSimpleNestedURI() {}
  49. virtual ~nsNestedAboutURI() {}
  50. // Override QI so we can QI to our CID as needed
  51. NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
  52. // Override StartClone(), the nsISerializable methods, and
  53. // GetClassIDNoAlloc; this last is needed to make our nsISerializable impl
  54. // work right.
  55. virtual nsSimpleURI* StartClone(RefHandlingEnum aRefHandlingMode,
  56. const nsACString& newRef);
  57. NS_IMETHOD Read(nsIObjectInputStream* aStream);
  58. NS_IMETHOD Write(nsIObjectOutputStream* aStream);
  59. NS_IMETHOD GetClassIDNoAlloc(nsCID *aClassIDNoAlloc);
  60. nsIURI* GetBaseURI() const {
  61. return mBaseURI;
  62. }
  63. protected:
  64. nsCOMPtr<nsIURI> mBaseURI;
  65. };
  66. } // namespace net
  67. } // namespace mozilla
  68. #endif /* nsAboutProtocolHandler_h___ */