2010-08-25 19:52:10 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-08-25 19:52:10 +04:00
|
|
|
|
|
|
|
#include "nsDeviceProtocolHandler.h"
|
|
|
|
#include "nsDeviceChannel.h"
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsSimpleURI.h"
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsDeviceProtocolHandler,
|
|
|
|
nsIProtocolHandler)
|
2010-08-25 19:52:10 +04:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsDeviceProtocolHandler::Init(){
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDeviceProtocolHandler::GetScheme(nsACString &aResult)
|
|
|
|
{
|
|
|
|
aResult.AssignLiteral("moz-device");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsDeviceProtocolHandler::GetDefaultPort(int32_t *aResult)
|
2010-08-25 19:52:10 +04:00
|
|
|
{
|
|
|
|
*aResult = -1; // no port for moz_device: URLs
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsDeviceProtocolHandler::GetProtocolFlags(uint32_t *aResult)
|
2010-08-25 19:52:10 +04:00
|
|
|
{
|
|
|
|
*aResult = URI_NORELATIVE | URI_NOAUTH | URI_DANGEROUS_TO_LOAD;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDeviceProtocolHandler::NewURI(const nsACString &spec,
|
|
|
|
const char *originCharset,
|
|
|
|
nsIURI *baseURI,
|
|
|
|
nsIURI **result)
|
|
|
|
{
|
|
|
|
nsRefPtr<nsSimpleURI> uri = new nsSimpleURI();
|
|
|
|
|
|
|
|
nsresult rv = uri->SetSpec(spec);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
return CallQueryInterface(uri, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-10-23 04:16:57 +04:00
|
|
|
nsDeviceProtocolHandler::NewChannel2(nsIURI* aURI,
|
|
|
|
nsILoadInfo* aLoadInfo,
|
|
|
|
nsIChannel** aResult)
|
2010-08-25 19:52:10 +04:00
|
|
|
{
|
|
|
|
nsRefPtr<nsDeviceChannel> channel = new nsDeviceChannel();
|
|
|
|
nsresult rv = channel->Init(aURI);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
return CallQueryInterface(channel, aResult);
|
|
|
|
}
|
|
|
|
|
2014-10-23 04:16:57 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDeviceProtocolHandler::NewChannel(nsIURI* aURI, nsIChannel **aResult)
|
|
|
|
{
|
|
|
|
return NewChannel2(aURI, nullptr, aResult);
|
|
|
|
}
|
|
|
|
|
2010-08-25 19:52:10 +04:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsDeviceProtocolHandler::AllowPort(int32_t port,
|
2010-08-25 19:52:10 +04:00
|
|
|
const char *scheme,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool *aResult)
|
2010-08-25 19:52:10 +04:00
|
|
|
{
|
|
|
|
// don't override anything.
|
2011-10-17 18:59:28 +04:00
|
|
|
*aResult = false;
|
2010-08-25 19:52:10 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|