nsAboutBlank.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. #include "nsAboutBlank.h"
  6. #include "nsStringStream.h"
  7. #include "nsNetUtil.h"
  8. #include "nsContentUtils.h"
  9. NS_IMPL_ISUPPORTS(nsAboutBlank, nsIAboutModule)
  10. NS_IMETHODIMP
  11. nsAboutBlank::NewChannel(nsIURI* aURI,
  12. nsILoadInfo* aLoadInfo,
  13. nsIChannel** result)
  14. {
  15. NS_ENSURE_ARG_POINTER(aURI);
  16. nsCOMPtr<nsIInputStream> in;
  17. nsresult rv = NS_NewCStringInputStream(getter_AddRefs(in), EmptyCString());
  18. if (NS_FAILED(rv)) return rv;
  19. nsCOMPtr<nsIChannel> channel;
  20. rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel),
  21. aURI,
  22. in,
  23. NS_LITERAL_CSTRING("text/html"),
  24. NS_LITERAL_CSTRING("utf-8"),
  25. aLoadInfo);
  26. if (NS_FAILED(rv)) return rv;
  27. channel.forget(result);
  28. return rv;
  29. }
  30. NS_IMETHODIMP
  31. nsAboutBlank::GetURIFlags(nsIURI *aURI, uint32_t *result)
  32. {
  33. *result = nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
  34. nsIAboutModule::URI_CAN_LOAD_IN_CHILD |
  35. nsIAboutModule::MAKE_LINKABLE |
  36. nsIAboutModule::HIDE_FROM_ABOUTABOUT;
  37. return NS_OK;
  38. }
  39. nsresult
  40. nsAboutBlank::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
  41. {
  42. nsAboutBlank* about = new nsAboutBlank();
  43. if (about == nullptr)
  44. return NS_ERROR_OUT_OF_MEMORY;
  45. NS_ADDREF(about);
  46. nsresult rv = about->QueryInterface(aIID, aResult);
  47. NS_RELEASE(about);
  48. return rv;
  49. }
  50. ////////////////////////////////////////////////////////////////////////////////