2008-08-28 02:11:02 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=2 sts=2 expandtab
|
2012-05-21 15:12:37 +04:00
|
|
|
* 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/. */
|
2008-08-28 02:11:02 +04:00
|
|
|
|
2017-03-22 13:38:40 +03:00
|
|
|
#include "NullPrincipalURI.h"
|
2013-06-30 20:26:39 +04:00
|
|
|
|
2014-07-03 05:55:19 +04:00
|
|
|
#include "mozilla/DebugOnly.h"
|
2013-06-30 20:26:39 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
|
|
|
|
2015-02-24 23:54:40 +03:00
|
|
|
#include "mozilla/ipc/URIParams.h"
|
|
|
|
|
2008-08-28 02:11:02 +04:00
|
|
|
#include "nsEscape.h"
|
|
|
|
#include "nsCRT.h"
|
|
|
|
|
2019-02-11 21:03:12 +03:00
|
|
|
#include "mozilla/GkRustUtils.h"
|
|
|
|
|
2018-07-17 22:37:48 +03:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2008-08-28 02:11:02 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2017-03-22 13:38:40 +03:00
|
|
|
//// NullPrincipalURI
|
2008-08-28 02:11:02 +04:00
|
|
|
|
2019-11-27 07:41:07 +03:00
|
|
|
NullPrincipalURI::NullPrincipalURI() {
|
2019-02-11 21:03:12 +03:00
|
|
|
GkRustUtils::GenerateUUID(mPath);
|
2015-03-31 20:11:00 +03:00
|
|
|
MOZ_ASSERT(mPath.Length() == NSID_LENGTH - 1);
|
|
|
|
MOZ_ASSERT(strlen(mPath.get()) == NSID_LENGTH - 1);
|
2019-11-27 07:41:07 +03:00
|
|
|
}
|
2015-03-31 20:11:00 +03:00
|
|
|
|
2019-11-27 07:41:07 +03:00
|
|
|
NullPrincipalURI::NullPrincipalURI(const NullPrincipalURI& aOther) {
|
|
|
|
mPath.Assign(aOther.mPath);
|
2015-03-31 20:11:00 +03:00
|
|
|
}
|
|
|
|
|
2008-08-28 02:11:02 +04:00
|
|
|
static NS_DEFINE_CID(kNullPrincipalURIImplementationCID,
|
|
|
|
NS_NULLPRINCIPALURI_IMPLEMENTATION_CID);
|
|
|
|
|
2017-03-22 13:38:40 +03:00
|
|
|
NS_IMPL_ADDREF(NullPrincipalURI)
|
|
|
|
NS_IMPL_RELEASE(NullPrincipalURI)
|
2008-08-28 02:11:02 +04:00
|
|
|
|
2017-03-22 13:38:40 +03:00
|
|
|
NS_INTERFACE_MAP_BEGIN(NullPrincipalURI)
|
2012-02-20 07:51:48 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIURI)
|
2008-08-28 02:11:02 +04:00
|
|
|
if (aIID.Equals(kNullPrincipalURIImplementationCID))
|
2017-03-22 13:38:40 +03:00
|
|
|
foundInterface = static_cast<nsIURI*>(this);
|
2008-08-28 02:11:02 +04:00
|
|
|
else
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIURI)
|
2012-02-20 07:51:48 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISizeOf)
|
2008-08-28 02:11:02 +04:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//// nsIURI
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipalURI::GetAsciiHost(nsACString& _host) {
|
2008-08-28 02:11:02 +04:00
|
|
|
_host.Truncate();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-08-17 22:34:17 +03:00
|
|
|
NS_IMETHODIMP
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipalURI::GetAsciiHostPort(nsACString& _hostport) {
|
2015-08-17 22:34:17 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2008-08-28 02:11:02 +04:00
|
|
|
NS_IMETHODIMP
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipalURI::GetAsciiSpec(nsACString& _spec) {
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString buffer;
|
2017-03-22 13:38:40 +03:00
|
|
|
// Ignore the return value -- NullPrincipalURI::GetSpec() is infallible.
|
2016-08-30 07:22:04 +03:00
|
|
|
Unused << GetSpec(buffer);
|
2017-01-24 22:11:44 +03:00
|
|
|
// This uses the infallible version of |NS_EscapeURL| as |GetSpec| is
|
|
|
|
// already infallible.
|
2008-08-28 02:11:02 +04:00
|
|
|
NS_EscapeURL(buffer, esc_OnlyNonASCII | esc_AlwaysCopy, _spec);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipalURI::GetHost(nsACString& _host) {
|
2008-08-28 02:11:02 +04:00
|
|
|
_host.Truncate();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-03-22 13:38:40 +03:00
|
|
|
nsresult NullPrincipalURI::SetHost(const nsACString& aHost) {
|
2008-08-28 02:11:02 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipalURI::GetHostPort(nsACString& _host) {
|
2008-08-28 02:11:02 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2017-03-22 13:38:40 +03:00
|
|
|
nsresult NullPrincipalURI::SetHostPort(const nsACString& aHost) {
|
2008-08-28 02:11:02 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipalURI::GetPassword(nsACString& _password) {
|
2008-08-28 02:11:02 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2017-03-22 13:38:40 +03:00
|
|
|
nsresult NullPrincipalURI::SetPassword(const nsACString& aPassword) {
|
2008-08-28 02:11:02 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2017-07-29 14:50:21 +03:00
|
|
|
NullPrincipalURI::GetPathQueryRef(nsACString& _path) {
|
2008-08-30 00:40:05 +04:00
|
|
|
_path = mPath;
|
2008-08-28 02:11:02 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-07-29 14:50:21 +03:00
|
|
|
nsresult NullPrincipalURI::SetPathQueryRef(const nsACString& aPath) {
|
2008-08-28 02:11:02 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2016-12-28 14:40:21 +03:00
|
|
|
NS_IMETHODIMP
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipalURI::GetFilePath(nsACString& aFilePath) {
|
2016-12-28 14:40:21 +03:00
|
|
|
aFilePath.Truncate();
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2017-03-22 13:38:40 +03:00
|
|
|
nsresult NullPrincipalURI::SetFilePath(const nsACString& aFilePath) {
|
2016-12-28 14:40:21 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipalURI::GetQuery(nsACString& aQuery) {
|
2016-12-28 14:40:21 +03:00
|
|
|
aQuery.Truncate();
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2017-03-22 13:38:40 +03:00
|
|
|
nsresult NullPrincipalURI::SetQuery(const nsACString& aQuery) {
|
2016-12-28 14:40:21 +03:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2017-08-02 14:43:30 +03:00
|
|
|
nsresult NullPrincipalURI::SetQueryWithEncoding(const nsACString& aQuery,
|
|
|
|
const Encoding* aEncoding) {
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2011-05-22 05:12:45 +04:00
|
|
|
NS_IMETHODIMP
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipalURI::GetRef(nsACString& _ref) {
|
2011-05-22 05:12:45 +04:00
|
|
|
_ref.Truncate();
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2017-03-22 13:38:40 +03:00
|
|
|
nsresult NullPrincipalURI::SetRef(const nsACString& aRef) {
|
2011-05-22 05:12:45 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2008-08-28 02:11:02 +04:00
|
|
|
NS_IMETHODIMP
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipalURI::GetPrePath(nsACString& _prePath) {
|
2015-03-31 20:11:04 +03:00
|
|
|
_prePath = nsLiteralCString(NS_NULLPRINCIPAL_SCHEME ":");
|
2008-08-28 02:11:02 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipalURI::GetPort(int32_t* _port) { return NS_ERROR_NOT_IMPLEMENTED; }
|
2008-08-28 02:11:02 +04:00
|
|
|
|
2017-03-22 13:38:40 +03:00
|
|
|
nsresult NullPrincipalURI::SetPort(int32_t aPort) {
|
2008-08-28 02:11:02 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipalURI::GetScheme(nsACString& _scheme) {
|
2015-03-31 20:11:04 +03:00
|
|
|
_scheme = nsLiteralCString(NS_NULLPRINCIPAL_SCHEME);
|
2008-08-28 02:11:02 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-03-22 13:38:40 +03:00
|
|
|
nsresult NullPrincipalURI::SetScheme(const nsACString& aScheme) {
|
2008-08-28 02:11:02 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipalURI::GetSpec(nsACString& _spec) {
|
2015-03-31 20:11:04 +03:00
|
|
|
_spec = nsLiteralCString(NS_NULLPRINCIPAL_SCHEME ":") + mPath;
|
2008-08-28 02:11:02 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-08-16 01:18:15 +04:00
|
|
|
// result may contain unescaped UTF-8 characters
|
|
|
|
NS_IMETHODIMP
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipalURI::GetSpecIgnoringRef(nsACString& _result) {
|
|
|
|
return GetSpec(_result);
|
2011-08-16 01:18:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipalURI::GetHasRef(bool* _result) {
|
|
|
|
*_result = false;
|
2011-08-16 01:18:15 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2018-01-19 17:26:07 +03:00
|
|
|
nsresult NullPrincipalURI::SetSpecInternal(const nsACString& aSpec) {
|
2008-08-28 02:11:02 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipalURI::GetUsername(nsACString& _username) {
|
2008-08-28 02:11:02 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2017-03-22 13:38:40 +03:00
|
|
|
nsresult NullPrincipalURI::SetUsername(const nsACString& aUsername) {
|
2008-08-28 02:11:02 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipalURI::GetUserPass(nsACString& _userPass) {
|
2008-08-28 02:11:02 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2017-03-22 13:38:40 +03:00
|
|
|
nsresult NullPrincipalURI::SetUserPass(const nsACString& aUserPass) {
|
2008-08-28 02:11:02 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2017-03-22 13:38:40 +03:00
|
|
|
nsresult NullPrincipalURI::Clone(nsIURI** _newURI) {
|
|
|
|
nsCOMPtr<nsIURI> uri = new NullPrincipalURI(*this);
|
2008-08-28 02:11:02 +04:00
|
|
|
uri.forget(_newURI);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-11-20 19:11:30 +03:00
|
|
|
NS_IMPL_ISUPPORTS(NullPrincipalURI::Mutator, nsIURISetters, nsIURIMutator)
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
NullPrincipalURI::Mutate(nsIURIMutator** aMutator) {
|
|
|
|
RefPtr<NullPrincipalURI::Mutator> mutator = new NullPrincipalURI::Mutator();
|
|
|
|
nsresult rv = mutator->InitFromURI(this);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
mutator.forget(aMutator);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-08-28 02:11:02 +04:00
|
|
|
NS_IMETHODIMP
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipalURI::Equals(nsIURI* aOther, bool* _equals) {
|
2011-10-17 18:59:28 +04:00
|
|
|
*_equals = false;
|
2017-03-22 13:38:40 +03:00
|
|
|
RefPtr<NullPrincipalURI> otherURI;
|
2008-08-28 02:11:02 +04:00
|
|
|
nsresult rv = aOther->QueryInterface(kNullPrincipalURIImplementationCID,
|
2015-09-14 13:43:00 +03:00
|
|
|
getter_AddRefs(otherURI));
|
2008-08-28 02:11:02 +04:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2015-03-31 20:11:04 +03:00
|
|
|
*_equals = mPath == otherURI->mPath;
|
2008-08-28 02:11:02 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-05-22 05:12:45 +04:00
|
|
|
NS_IMETHODIMP
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipalURI::EqualsExceptRef(nsIURI* aOther, bool* _equals) {
|
|
|
|
// GetRef/SetRef not supported by NullPrincipalURI, so
|
2011-05-22 05:12:45 +04:00
|
|
|
// EqualsExceptRef() is the same as Equals().
|
|
|
|
return Equals(aOther, _equals);
|
|
|
|
}
|
|
|
|
|
2008-08-28 02:11:02 +04:00
|
|
|
NS_IMETHODIMP
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipalURI::Resolve(const nsACString& aRelativePath,
|
|
|
|
nsACString& _resolvedURI) {
|
2008-08-28 02:11:02 +04:00
|
|
|
_resolvedURI = aRelativePath;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipalURI::SchemeIs(const char* aScheme, bool* _schemeIs) {
|
2015-03-31 20:11:04 +03:00
|
|
|
*_schemeIs = (0 == nsCRT::strcasecmp(NS_NULLPRINCIPAL_SCHEME, aScheme));
|
2008-08-28 02:11:02 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2012-02-20 07:51:48 +04:00
|
|
|
|
2017-07-11 20:09:10 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
NullPrincipalURI::GetDisplaySpec(nsACString& aUnicodeSpec) {
|
|
|
|
return GetSpec(aUnicodeSpec);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
NullPrincipalURI::GetDisplayHostPort(nsACString& aUnicodeHostPort) {
|
|
|
|
return GetHostPort(aUnicodeHostPort);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
NullPrincipalURI::GetDisplayHost(nsACString& aUnicodeHost) {
|
|
|
|
return GetHost(aUnicodeHost);
|
|
|
|
}
|
|
|
|
|
2017-08-09 18:43:58 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
NullPrincipalURI::GetDisplayPrePath(nsACString& aPrePath) {
|
|
|
|
return GetPrePath(aPrePath);
|
|
|
|
}
|
|
|
|
|
2017-03-22 13:38:40 +03:00
|
|
|
void NullPrincipalURI::Serialize(mozilla::ipc::URIParams& aParams) {
|
2015-02-24 23:54:40 +03:00
|
|
|
aParams = mozilla::ipc::NullPrincipalURIParams();
|
|
|
|
}
|
|
|
|
|
2017-03-22 13:38:40 +03:00
|
|
|
bool NullPrincipalURI::Deserialize(const mozilla::ipc::URIParams& aParams) {
|
2015-02-24 23:54:40 +03:00
|
|
|
if (aParams.type() != mozilla::ipc::URIParams::TNullPrincipalURIParams) {
|
|
|
|
MOZ_ASSERT_UNREACHABLE("unexpected URIParams type");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-02-20 07:51:48 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//// nsISizeOf
|
|
|
|
|
2018-07-17 22:37:48 +03:00
|
|
|
size_t NullPrincipalURI::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const {
|
2015-03-31 20:11:04 +03:00
|
|
|
return mPath.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
|
2012-02-20 07:51:48 +04:00
|
|
|
}
|
|
|
|
|
2018-07-17 22:37:48 +03:00
|
|
|
size_t NullPrincipalURI::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
|
2012-02-20 07:51:48 +04:00
|
|
|
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
|
|
|
|
}
|