/src/mozilla-central/image/decoders/icon/nsIconProtocolHandler.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
2 | | * |
3 | | * This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #include "nsIconProtocolHandler.h" |
8 | | |
9 | | #include "nsIconChannel.h" |
10 | | #include "nsIconURI.h" |
11 | | #include "nsIURL.h" |
12 | | #include "nsCRT.h" |
13 | | #include "nsCOMPtr.h" |
14 | | #include "nsIComponentManager.h" |
15 | | #include "nsIServiceManager.h" |
16 | | #include "nsNetCID.h" |
17 | | |
18 | | /////////////////////////////////////////////////////////////////////////////// |
19 | | |
20 | | nsIconProtocolHandler::nsIconProtocolHandler() |
21 | 0 | { } |
22 | | |
23 | | nsIconProtocolHandler::~nsIconProtocolHandler() |
24 | 0 | { } |
25 | | |
26 | | NS_IMPL_ISUPPORTS(nsIconProtocolHandler, nsIProtocolHandler, |
27 | | nsISupportsWeakReference) |
28 | | |
29 | | |
30 | | /////////////////////////////////////////////////////////////////////////////// |
31 | | // nsIProtocolHandler methods: |
32 | | |
33 | | NS_IMETHODIMP |
34 | | nsIconProtocolHandler::GetScheme(nsACString& result) |
35 | 0 | { |
36 | 0 | result = "moz-icon"; |
37 | 0 | return NS_OK; |
38 | 0 | } |
39 | | |
40 | | NS_IMETHODIMP |
41 | | nsIconProtocolHandler::GetDefaultPort(int32_t* result) |
42 | 0 | { |
43 | 0 | *result = 0; |
44 | 0 | return NS_OK; |
45 | 0 | } |
46 | | |
47 | | NS_IMETHODIMP |
48 | | nsIconProtocolHandler::AllowPort(int32_t port, |
49 | | const char* scheme, |
50 | | bool* _retval) |
51 | 0 | { |
52 | 0 | // don't override anything. |
53 | 0 | *_retval = false; |
54 | 0 | return NS_OK; |
55 | 0 | } |
56 | | |
57 | | NS_IMETHODIMP |
58 | | nsIconProtocolHandler::GetProtocolFlags(uint32_t* result) |
59 | 0 | { |
60 | 0 | *result = URI_NORELATIVE | URI_NOAUTH | URI_IS_UI_RESOURCE | |
61 | 0 | URI_IS_LOCAL_RESOURCE; |
62 | 0 | return NS_OK; |
63 | 0 | } |
64 | | |
65 | | NS_IMETHODIMP |
66 | | nsIconProtocolHandler::NewURI(const nsACString& aSpec, |
67 | | const char* aOriginCharset, // ignored |
68 | | nsIURI* aBaseURI, |
69 | | nsIURI** result) |
70 | 0 | { |
71 | 0 | return NS_MutateURI(new nsMozIconURI::Mutator()) |
72 | 0 | .SetSpec(aSpec) |
73 | 0 | .Finalize(result); |
74 | 0 | } |
75 | | |
76 | | NS_IMETHODIMP |
77 | | nsIconProtocolHandler::NewChannel2(nsIURI* url, |
78 | | nsILoadInfo* aLoadInfo, |
79 | | nsIChannel** result) |
80 | 0 | { |
81 | 0 | NS_ENSURE_ARG_POINTER(url); |
82 | 0 | nsIconChannel* channel = new nsIconChannel; |
83 | 0 | if (!channel) { |
84 | 0 | return NS_ERROR_OUT_OF_MEMORY; |
85 | 0 | } |
86 | 0 | NS_ADDREF(channel); |
87 | 0 |
|
88 | 0 | nsresult rv = channel->Init(url); |
89 | 0 | if (NS_FAILED(rv)) { |
90 | 0 | NS_RELEASE(channel); |
91 | 0 | return rv; |
92 | 0 | } |
93 | 0 |
|
94 | 0 | // set the loadInfo on the new channel |
95 | 0 | rv = channel->SetLoadInfo(aLoadInfo); |
96 | 0 | if (NS_FAILED(rv)) { |
97 | 0 | NS_RELEASE(channel); |
98 | 0 | return rv; |
99 | 0 | } |
100 | 0 |
|
101 | 0 | *result = channel; |
102 | 0 | return NS_OK; |
103 | 0 | } |
104 | | |
105 | | NS_IMETHODIMP |
106 | | nsIconProtocolHandler::NewChannel(nsIURI* url, nsIChannel** result) |
107 | 0 | { |
108 | 0 | return NewChannel2(url, nullptr, result); |
109 | 0 | } |
110 | | |
111 | | //////////////////////////////////////////////////////////////////////////////// |