netwerk/protocol/device/nsDeviceProtocolHandler.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/protocol/device/nsDeviceProtocolHandler.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,74 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "nsDeviceProtocolHandler.h"
    1.10 +#include "nsDeviceChannel.h"
    1.11 +#include "nsAutoPtr.h"
    1.12 +#include "nsSimpleURI.h"
    1.13 +
    1.14 +//-----------------------------------------------------------------------------
    1.15 +
    1.16 +NS_IMPL_ISUPPORTS(nsDeviceProtocolHandler,
    1.17 +                  nsIProtocolHandler)
    1.18 +
    1.19 +nsresult
    1.20 +nsDeviceProtocolHandler::Init(){
    1.21 +  return NS_OK;
    1.22 +}
    1.23 +
    1.24 +NS_IMETHODIMP
    1.25 +nsDeviceProtocolHandler::GetScheme(nsACString &aResult)
    1.26 +{
    1.27 +  aResult.AssignLiteral("moz-device");
    1.28 +  return NS_OK;
    1.29 +}
    1.30 +
    1.31 +NS_IMETHODIMP
    1.32 +nsDeviceProtocolHandler::GetDefaultPort(int32_t *aResult)
    1.33 +{
    1.34 +  *aResult = -1;        // no port for moz_device: URLs
    1.35 +  return NS_OK;
    1.36 +}
    1.37 +
    1.38 +NS_IMETHODIMP
    1.39 +nsDeviceProtocolHandler::GetProtocolFlags(uint32_t *aResult)
    1.40 +{
    1.41 +  *aResult = URI_NORELATIVE | URI_NOAUTH | URI_DANGEROUS_TO_LOAD;
    1.42 +  return NS_OK;
    1.43 +}
    1.44 +
    1.45 +NS_IMETHODIMP
    1.46 +nsDeviceProtocolHandler::NewURI(const nsACString &spec,
    1.47 +                                const char *originCharset,
    1.48 +                                nsIURI *baseURI,
    1.49 +                                nsIURI **result)
    1.50 +{
    1.51 +  nsRefPtr<nsSimpleURI> uri = new nsSimpleURI();
    1.52 +
    1.53 +  nsresult rv = uri->SetSpec(spec);
    1.54 +  NS_ENSURE_SUCCESS(rv, rv);
    1.55 +
    1.56 +  return CallQueryInterface(uri, result);
    1.57 +}
    1.58 +
    1.59 +NS_IMETHODIMP
    1.60 +nsDeviceProtocolHandler::NewChannel(nsIURI* aURI, nsIChannel **aResult)
    1.61 +{
    1.62 +  nsRefPtr<nsDeviceChannel> channel = new nsDeviceChannel();
    1.63 +  nsresult rv = channel->Init(aURI);
    1.64 +  NS_ENSURE_SUCCESS(rv, rv);
    1.65 +
    1.66 +  return CallQueryInterface(channel, aResult);
    1.67 +}
    1.68 +
    1.69 +NS_IMETHODIMP 
    1.70 +nsDeviceProtocolHandler::AllowPort(int32_t port,
    1.71 +                                   const char *scheme,
    1.72 +                                   bool *aResult)
    1.73 +{
    1.74 +  // don't override anything.  
    1.75 +  *aResult = false;
    1.76 +  return NS_OK;
    1.77 +}

mercurial