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