tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsAboutBlank.cpp (1724B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      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 
      6 #include "nsAboutBlank.h"
      7 #include "nsStringStream.h"
      8 #include "nsNetUtil.h"
      9 #include "nsContentUtils.h"
     10 #include "nsIChannel.h"
     11 
     12 NS_IMPL_ISUPPORTS(nsAboutBlank, nsIAboutModule)
     13 
     14 NS_IMETHODIMP
     15 nsAboutBlank::NewChannel(nsIURI* aURI, nsILoadInfo* aLoadInfo,
     16                         nsIChannel** result) {
     17  NS_ENSURE_ARG_POINTER(aURI);
     18 
     19  nsCOMPtr<nsIInputStream> in;
     20  nsresult rv = NS_NewCStringInputStream(getter_AddRefs(in), ""_ns);
     21  if (NS_FAILED(rv)) return rv;
     22 
     23  nsCOMPtr<nsIChannel> channel;
     24  rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel), aURI,
     25                                        in.forget(), "text/html"_ns, "utf-8"_ns,
     26                                        aLoadInfo);
     27  if (NS_FAILED(rv)) return rv;
     28 
     29  channel.forget(result);
     30  return rv;
     31 }
     32 
     33 NS_IMETHODIMP
     34 nsAboutBlank::GetURIFlags(nsIURI* aURI, uint32_t* result) {
     35  *result = nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
     36            nsIAboutModule::URI_CAN_LOAD_IN_CHILD |
     37            nsIAboutModule::MAKE_LINKABLE |
     38            nsIAboutModule::HIDE_FROM_ABOUTABOUT;
     39  return NS_OK;
     40 }
     41 
     42 NS_IMETHODIMP
     43 nsAboutBlank::GetChromeURI(nsIURI* aURI, nsIURI** chromeURI) {
     44  return NS_ERROR_ILLEGAL_VALUE;
     45 }
     46 
     47 nsresult nsAboutBlank::Create(REFNSIID aIID, void** aResult) {
     48  RefPtr<nsAboutBlank> about = new nsAboutBlank();
     49  return about->QueryInterface(aIID, aResult);
     50 }
     51 
     52 ////////////////////////////////////////////////////////////////////////////////