|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
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/. */ |
|
5 |
|
6 #include "nsAboutBlank.h" |
|
7 #include "nsStringStream.h" |
|
8 #include "nsNetUtil.h" |
|
9 |
|
10 NS_IMPL_ISUPPORTS(nsAboutBlank, nsIAboutModule) |
|
11 |
|
12 NS_IMETHODIMP |
|
13 nsAboutBlank::NewChannel(nsIURI *aURI, nsIChannel **result) |
|
14 { |
|
15 NS_ENSURE_ARG_POINTER(aURI); |
|
16 |
|
17 nsCOMPtr<nsIInputStream> in; |
|
18 nsresult rv = NS_NewCStringInputStream(getter_AddRefs(in), EmptyCString()); |
|
19 if (NS_FAILED(rv)) return rv; |
|
20 |
|
21 nsCOMPtr<nsIChannel> channel; |
|
22 rv = NS_NewInputStreamChannel(getter_AddRefs(channel), aURI, in, |
|
23 NS_LITERAL_CSTRING("text/html"), |
|
24 NS_LITERAL_CSTRING("utf-8")); |
|
25 if (NS_FAILED(rv)) return rv; |
|
26 |
|
27 channel.forget(result); |
|
28 return rv; |
|
29 } |
|
30 |
|
31 NS_IMETHODIMP |
|
32 nsAboutBlank::GetURIFlags(nsIURI *aURI, uint32_t *result) |
|
33 { |
|
34 *result = nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT | |
|
35 nsIAboutModule::HIDE_FROM_ABOUTABOUT; |
|
36 return NS_OK; |
|
37 } |
|
38 |
|
39 nsresult |
|
40 nsAboutBlank::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) |
|
41 { |
|
42 nsAboutBlank* about = new nsAboutBlank(); |
|
43 if (about == nullptr) |
|
44 return NS_ERROR_OUT_OF_MEMORY; |
|
45 NS_ADDREF(about); |
|
46 nsresult rv = about->QueryInterface(aIID, aResult); |
|
47 NS_RELEASE(about); |
|
48 return rv; |
|
49 } |
|
50 |
|
51 //////////////////////////////////////////////////////////////////////////////// |