tor-browser

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

nsIconProtocolHandler.cpp (1683B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
      2 *
      3 * This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "nsIconProtocolHandler.h"
      8 
      9 #include "nsIconChannel.h"
     10 #include "nsIconURI.h"
     11 #include "nsCRT.h"
     12 #include "nsCOMPtr.h"
     13 #include "nsNetCID.h"
     14 
     15 ///////////////////////////////////////////////////////////////////////////////
     16 
     17 nsIconProtocolHandler::nsIconProtocolHandler() {}
     18 
     19 nsIconProtocolHandler::~nsIconProtocolHandler() {}
     20 
     21 NS_IMPL_ISUPPORTS(nsIconProtocolHandler, nsIProtocolHandler,
     22                  nsISupportsWeakReference)
     23 
     24 ///////////////////////////////////////////////////////////////////////////////
     25 // nsIProtocolHandler methods:
     26 
     27 NS_IMETHODIMP
     28 nsIconProtocolHandler::GetScheme(nsACString& result) {
     29  result = "moz-icon";
     30  return NS_OK;
     31 }
     32 
     33 NS_IMETHODIMP
     34 nsIconProtocolHandler::AllowPort(int32_t port, const char* scheme,
     35                                 bool* _retval) {
     36  // don't override anything.
     37  *_retval = false;
     38  return NS_OK;
     39 }
     40 
     41 NS_IMETHODIMP
     42 nsIconProtocolHandler::NewChannel(nsIURI* url, nsILoadInfo* aLoadInfo,
     43                                  nsIChannel** result) {
     44  NS_ENSURE_ARG_POINTER(url);
     45  nsIconChannel* channel = new nsIconChannel;
     46  if (!channel) {
     47    return NS_ERROR_OUT_OF_MEMORY;
     48  }
     49  NS_ADDREF(channel);
     50 
     51  nsresult rv = channel->Init(url, aLoadInfo);
     52  if (NS_FAILED(rv)) {
     53    NS_RELEASE(channel);
     54    return rv;
     55  }
     56 
     57  *result = channel;
     58  return NS_OK;
     59 }
     60 
     61 ////////////////////////////////////////////////////////////////////////////////