Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/netwerk/protocol/about/nsAboutBlank.cpp
Line
Count
Source (jump to first uncovered line)
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
#include "nsContentUtils.h"
10
11
NS_IMPL_ISUPPORTS(nsAboutBlank, nsIAboutModule)
12
13
NS_IMETHODIMP
14
nsAboutBlank::NewChannel(nsIURI* aURI,
15
                         nsILoadInfo* aLoadInfo,
16
                         nsIChannel** result)
17
0
{
18
0
    NS_ENSURE_ARG_POINTER(aURI);
19
0
20
0
    nsCOMPtr<nsIInputStream> in;
21
0
    nsresult rv = NS_NewCStringInputStream(getter_AddRefs(in), EmptyCString());
22
0
    if (NS_FAILED(rv)) return rv;
23
0
24
0
    nsCOMPtr<nsIChannel> channel;
25
0
    rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel),
26
0
                                          aURI,
27
0
                                          in.forget(),
28
0
                                          NS_LITERAL_CSTRING("text/html"),
29
0
                                          NS_LITERAL_CSTRING("utf-8"),
30
0
                                          aLoadInfo);
31
0
    if (NS_FAILED(rv)) return rv;
32
0
33
0
    channel.forget(result);
34
0
    return rv;
35
0
}
36
37
NS_IMETHODIMP
38
nsAboutBlank::GetURIFlags(nsIURI *aURI, uint32_t *result)
39
0
{
40
0
    *result = nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
41
0
              nsIAboutModule::URI_CAN_LOAD_IN_CHILD |
42
0
              nsIAboutModule::MAKE_LINKABLE |
43
0
              nsIAboutModule::HIDE_FROM_ABOUTABOUT;
44
0
    return NS_OK;
45
0
}
46
47
nsresult
48
nsAboutBlank::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
49
0
{
50
0
    nsAboutBlank* about = new nsAboutBlank();
51
0
    if (about == nullptr)
52
0
        return NS_ERROR_OUT_OF_MEMORY;
53
0
    NS_ADDREF(about);
54
0
    nsresult rv = about->QueryInterface(aIID, aResult);
55
0
    NS_RELEASE(about);
56
0
    return rv;
57
0
}
58
59
////////////////////////////////////////////////////////////////////////////////