Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsDeviceProtocolHandler.h" |
michael@0 | 7 | #include "nsDeviceChannel.h" |
michael@0 | 8 | #include "nsAutoPtr.h" |
michael@0 | 9 | #include "nsSimpleURI.h" |
michael@0 | 10 | |
michael@0 | 11 | //----------------------------------------------------------------------------- |
michael@0 | 12 | |
michael@0 | 13 | NS_IMPL_ISUPPORTS(nsDeviceProtocolHandler, |
michael@0 | 14 | nsIProtocolHandler) |
michael@0 | 15 | |
michael@0 | 16 | nsresult |
michael@0 | 17 | nsDeviceProtocolHandler::Init(){ |
michael@0 | 18 | return NS_OK; |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | NS_IMETHODIMP |
michael@0 | 22 | nsDeviceProtocolHandler::GetScheme(nsACString &aResult) |
michael@0 | 23 | { |
michael@0 | 24 | aResult.AssignLiteral("moz-device"); |
michael@0 | 25 | return NS_OK; |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | NS_IMETHODIMP |
michael@0 | 29 | nsDeviceProtocolHandler::GetDefaultPort(int32_t *aResult) |
michael@0 | 30 | { |
michael@0 | 31 | *aResult = -1; // no port for moz_device: URLs |
michael@0 | 32 | return NS_OK; |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | NS_IMETHODIMP |
michael@0 | 36 | nsDeviceProtocolHandler::GetProtocolFlags(uint32_t *aResult) |
michael@0 | 37 | { |
michael@0 | 38 | *aResult = URI_NORELATIVE | URI_NOAUTH | URI_DANGEROUS_TO_LOAD; |
michael@0 | 39 | return NS_OK; |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | NS_IMETHODIMP |
michael@0 | 43 | nsDeviceProtocolHandler::NewURI(const nsACString &spec, |
michael@0 | 44 | const char *originCharset, |
michael@0 | 45 | nsIURI *baseURI, |
michael@0 | 46 | nsIURI **result) |
michael@0 | 47 | { |
michael@0 | 48 | nsRefPtr<nsSimpleURI> uri = new nsSimpleURI(); |
michael@0 | 49 | |
michael@0 | 50 | nsresult rv = uri->SetSpec(spec); |
michael@0 | 51 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 52 | |
michael@0 | 53 | return CallQueryInterface(uri, result); |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | NS_IMETHODIMP |
michael@0 | 57 | nsDeviceProtocolHandler::NewChannel(nsIURI* aURI, nsIChannel **aResult) |
michael@0 | 58 | { |
michael@0 | 59 | nsRefPtr<nsDeviceChannel> channel = new nsDeviceChannel(); |
michael@0 | 60 | nsresult rv = channel->Init(aURI); |
michael@0 | 61 | NS_ENSURE_SUCCESS(rv, rv); |
michael@0 | 62 | |
michael@0 | 63 | return CallQueryInterface(channel, aResult); |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | NS_IMETHODIMP |
michael@0 | 67 | nsDeviceProtocolHandler::AllowPort(int32_t port, |
michael@0 | 68 | const char *scheme, |
michael@0 | 69 | bool *aResult) |
michael@0 | 70 | { |
michael@0 | 71 | // don't override anything. |
michael@0 | 72 | *aResult = false; |
michael@0 | 73 | return NS_OK; |
michael@0 | 74 | } |