gecko/netwerk/protocol/about/nsAboutBlank.cpp
Valentin Gosu ext:(%2C%20Jason%20Duell%20%3Cjduell.mcbugs%40gmail.com%3E%2C%20Ms2ger%20%3CMs2ger%40gmail.com%3E) b32522b36e Bug 745296 - Enable FAIL_ON_WARNINGS in more of /netwerk r=jduell
2012-08-25 11:19:00 -07:00

54 lines
1.6 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsAboutBlank.h"
#include "nsIIOService.h"
#include "nsIServiceManager.h"
#include "nsStringStream.h"
#include "nsNetUtil.h"
NS_IMPL_ISUPPORTS1(nsAboutBlank, nsIAboutModule)
NS_IMETHODIMP
nsAboutBlank::NewChannel(nsIURI *aURI, nsIChannel **result)
{
NS_ENSURE_ARG_POINTER(aURI);
nsCOMPtr<nsIInputStream> in;
nsresult rv = NS_NewCStringInputStream(getter_AddRefs(in), EmptyCString());
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIChannel> channel;
rv = NS_NewInputStreamChannel(getter_AddRefs(channel), aURI, in,
NS_LITERAL_CSTRING("text/html"),
NS_LITERAL_CSTRING("utf-8"));
if (NS_FAILED(rv)) return rv;
channel.forget(result);
return rv;
}
NS_IMETHODIMP
nsAboutBlank::GetURIFlags(nsIURI *aURI, uint32_t *result)
{
*result = nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::HIDE_FROM_ABOUTABOUT;
return NS_OK;
}
nsresult
nsAboutBlank::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
nsAboutBlank* about = new nsAboutBlank();
if (about == nullptr)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(about);
nsresult rv = about->QueryInterface(aIID, aResult);
NS_RELEASE(about);
return rv;
}
////////////////////////////////////////////////////////////////////////////////