michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsAboutBlank.h" michael@0: #include "nsStringStream.h" michael@0: #include "nsNetUtil.h" michael@0: michael@0: NS_IMPL_ISUPPORTS(nsAboutBlank, nsIAboutModule) michael@0: michael@0: NS_IMETHODIMP michael@0: nsAboutBlank::NewChannel(nsIURI *aURI, nsIChannel **result) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aURI); michael@0: michael@0: nsCOMPtr in; michael@0: nsresult rv = NS_NewCStringInputStream(getter_AddRefs(in), EmptyCString()); michael@0: if (NS_FAILED(rv)) return rv; michael@0: michael@0: nsCOMPtr channel; michael@0: rv = NS_NewInputStreamChannel(getter_AddRefs(channel), aURI, in, michael@0: NS_LITERAL_CSTRING("text/html"), michael@0: NS_LITERAL_CSTRING("utf-8")); michael@0: if (NS_FAILED(rv)) return rv; michael@0: michael@0: channel.forget(result); michael@0: return rv; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsAboutBlank::GetURIFlags(nsIURI *aURI, uint32_t *result) michael@0: { michael@0: *result = nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT | michael@0: nsIAboutModule::HIDE_FROM_ABOUTABOUT; michael@0: return NS_OK; michael@0: } michael@0: michael@0: nsresult michael@0: nsAboutBlank::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) michael@0: { michael@0: nsAboutBlank* about = new nsAboutBlank(); michael@0: if (about == nullptr) michael@0: return NS_ERROR_OUT_OF_MEMORY; michael@0: NS_ADDREF(about); michael@0: nsresult rv = about->QueryInterface(aIID, aResult); michael@0: NS_RELEASE(about); michael@0: return rv; michael@0: } michael@0: michael@0: ////////////////////////////////////////////////////////////////////////////////