Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
michael@0 | 2 | * |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "nsIconChannel.h" |
michael@0 | 8 | #include "nsIconURI.h" |
michael@0 | 9 | #include "nsIconProtocolHandler.h" |
michael@0 | 10 | #include "nsIURL.h" |
michael@0 | 11 | #include "nsCRT.h" |
michael@0 | 12 | #include "nsCOMPtr.h" |
michael@0 | 13 | #include "nsIComponentManager.h" |
michael@0 | 14 | #include "nsIServiceManager.h" |
michael@0 | 15 | #include "nsNetCID.h" |
michael@0 | 16 | |
michael@0 | 17 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 18 | |
michael@0 | 19 | nsIconProtocolHandler::nsIconProtocolHandler() |
michael@0 | 20 | { |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | nsIconProtocolHandler::~nsIconProtocolHandler() |
michael@0 | 24 | {} |
michael@0 | 25 | |
michael@0 | 26 | NS_IMPL_ISUPPORTS(nsIconProtocolHandler, nsIProtocolHandler, nsISupportsWeakReference) |
michael@0 | 27 | |
michael@0 | 28 | |
michael@0 | 29 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 30 | // nsIProtocolHandler methods: |
michael@0 | 31 | |
michael@0 | 32 | NS_IMETHODIMP nsIconProtocolHandler::GetScheme(nsACString &result) |
michael@0 | 33 | { |
michael@0 | 34 | result = "moz-icon"; |
michael@0 | 35 | return NS_OK; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | NS_IMETHODIMP nsIconProtocolHandler::GetDefaultPort(int32_t *result) |
michael@0 | 39 | { |
michael@0 | 40 | *result = 0; |
michael@0 | 41 | return NS_OK; |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | NS_IMETHODIMP nsIconProtocolHandler::AllowPort(int32_t port, const char *scheme, bool *_retval) |
michael@0 | 45 | { |
michael@0 | 46 | // don't override anything. |
michael@0 | 47 | *_retval = false; |
michael@0 | 48 | return NS_OK; |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | NS_IMETHODIMP nsIconProtocolHandler::GetProtocolFlags(uint32_t *result) |
michael@0 | 52 | { |
michael@0 | 53 | *result = URI_NORELATIVE | URI_NOAUTH | URI_IS_UI_RESOURCE | |
michael@0 | 54 | URI_IS_LOCAL_RESOURCE; |
michael@0 | 55 | return NS_OK; |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | NS_IMETHODIMP nsIconProtocolHandler::NewURI(const nsACString &aSpec, |
michael@0 | 59 | const char *aOriginCharset, // ignored |
michael@0 | 60 | nsIURI *aBaseURI, |
michael@0 | 61 | nsIURI **result) |
michael@0 | 62 | { |
michael@0 | 63 | |
michael@0 | 64 | nsCOMPtr<nsIURI> uri = new nsMozIconURI(); |
michael@0 | 65 | if (!uri) return NS_ERROR_OUT_OF_MEMORY; |
michael@0 | 66 | |
michael@0 | 67 | nsresult rv = uri->SetSpec(aSpec); |
michael@0 | 68 | if (NS_FAILED(rv)) return rv; |
michael@0 | 69 | |
michael@0 | 70 | NS_ADDREF(*result = uri); |
michael@0 | 71 | return NS_OK; |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | NS_IMETHODIMP nsIconProtocolHandler::NewChannel(nsIURI* url, nsIChannel* *result) |
michael@0 | 75 | { |
michael@0 | 76 | NS_ENSURE_ARG_POINTER(url); |
michael@0 | 77 | nsIconChannel* channel = new nsIconChannel; |
michael@0 | 78 | if (!channel) |
michael@0 | 79 | return NS_ERROR_OUT_OF_MEMORY; |
michael@0 | 80 | NS_ADDREF(channel); |
michael@0 | 81 | |
michael@0 | 82 | nsresult rv = channel->Init(url); |
michael@0 | 83 | if (NS_FAILED(rv)) { |
michael@0 | 84 | NS_RELEASE(channel); |
michael@0 | 85 | return rv; |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | *result = channel; |
michael@0 | 89 | return NS_OK; |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | //////////////////////////////////////////////////////////////////////////////// |