michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 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 "nsDeviceProtocolHandler.h" michael@0: #include "nsDeviceChannel.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsSimpleURI.h" michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: michael@0: NS_IMPL_ISUPPORTS(nsDeviceProtocolHandler, michael@0: nsIProtocolHandler) michael@0: michael@0: nsresult michael@0: nsDeviceProtocolHandler::Init(){ michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsDeviceProtocolHandler::GetScheme(nsACString &aResult) michael@0: { michael@0: aResult.AssignLiteral("moz-device"); michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsDeviceProtocolHandler::GetDefaultPort(int32_t *aResult) michael@0: { michael@0: *aResult = -1; // no port for moz_device: URLs michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsDeviceProtocolHandler::GetProtocolFlags(uint32_t *aResult) michael@0: { michael@0: *aResult = URI_NORELATIVE | URI_NOAUTH | URI_DANGEROUS_TO_LOAD; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsDeviceProtocolHandler::NewURI(const nsACString &spec, michael@0: const char *originCharset, michael@0: nsIURI *baseURI, michael@0: nsIURI **result) michael@0: { michael@0: nsRefPtr uri = new nsSimpleURI(); michael@0: michael@0: nsresult rv = uri->SetSpec(spec); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: return CallQueryInterface(uri, result); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsDeviceProtocolHandler::NewChannel(nsIURI* aURI, nsIChannel **aResult) michael@0: { michael@0: nsRefPtr channel = new nsDeviceChannel(); michael@0: nsresult rv = channel->Init(aURI); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: return CallQueryInterface(channel, aResult); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsDeviceProtocolHandler::AllowPort(int32_t port, michael@0: const char *scheme, michael@0: bool *aResult) michael@0: { michael@0: // don't override anything. michael@0: *aResult = false; michael@0: return NS_OK; michael@0: }