mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Backed out 2 changesets (bug 1117337) for b2g build bustage on a CLOSED TREE
Backed out changeset 016b3f06add1 (bug 1117337) Backed out changeset aa4817b6ad61 (bug 1117337)
This commit is contained in:
parent
fb57bc6ba1
commit
b3fc1b8237
@ -10,10 +10,6 @@ XPIDL_SOURCES += [
|
||||
|
||||
XPIDL_MODULE = 'imgicon'
|
||||
|
||||
EXPORTS += [
|
||||
'nsIconURI.h',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'nsIconModule.cpp',
|
||||
'nsIconProtocolHandler.cpp',
|
||||
@ -24,8 +20,6 @@ FAIL_ON_WARNINGS = True
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
|
||||
include('/ipc/chromium/chromium-config.mozbuild')
|
||||
|
||||
platform = None
|
||||
|
||||
if CONFIG['MOZ_WIDGET_GTK']:
|
||||
|
@ -1,5 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: set sw=2 sts=2 ts=2 et tw=80:
|
||||
*
|
||||
* 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
|
||||
@ -7,8 +6,6 @@
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
|
||||
#include "mozilla/ipc/URIUtils.h"
|
||||
|
||||
#include "nsIconURI.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIIOService.h"
|
||||
@ -18,7 +15,6 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
#define DEFAULT_IMAGE_SIZE 16
|
||||
|
||||
@ -63,7 +59,7 @@ nsMozIconURI::nsMozIconURI()
|
||||
nsMozIconURI::~nsMozIconURI()
|
||||
{ }
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsMozIconURI, nsIMozIconURI, nsIURI, nsIIPCSerializableURI)
|
||||
NS_IMPL_ISUPPORTS(nsMozIconURI, nsIMozIconURI, nsIURI)
|
||||
|
||||
#define MOZICON_SCHEME "moz-icon:"
|
||||
#define MOZICON_SCHEME_LEN (sizeof(MOZICON_SCHEME) - 1)
|
||||
@ -586,59 +582,3 @@ nsMozIconURI::GetIconState(nsACString& aState)
|
||||
return NS_OK;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIIPCSerializableURI methods:
|
||||
|
||||
void
|
||||
nsMozIconURI::Serialize(URIParams& aParams)
|
||||
{
|
||||
IconURIParams params;
|
||||
|
||||
if (mIconURL) {
|
||||
URIParams iconURLParams;
|
||||
SerializeURI(mIconURL, iconURLParams);
|
||||
if (iconURLParams.type() == URIParams::T__None) {
|
||||
// Serialization failed, bail.
|
||||
return;
|
||||
}
|
||||
|
||||
params.uri() = iconURLParams;
|
||||
} else {
|
||||
params.uri() = void_t();
|
||||
}
|
||||
|
||||
params.size() = mSize;
|
||||
params.fileName() = mFileName;
|
||||
params.stockIcon() = mStockIcon;
|
||||
params.iconSize() = mIconSize;
|
||||
params.iconState() = mIconState;
|
||||
|
||||
aParams = params;
|
||||
}
|
||||
|
||||
bool
|
||||
nsMozIconURI::Deserialize(const URIParams& aParams)
|
||||
{
|
||||
if (aParams.type() != URIParams::TIconURIParams) {
|
||||
MOZ_ASSERT_UNREACHABLE("Received unknown URI from other process!");
|
||||
return false;
|
||||
}
|
||||
|
||||
const IconURIParams& params = aParams.get_IconURIParams();
|
||||
if (params.uri().type() != OptionalURIParams::Tvoid_t) {
|
||||
nsCOMPtr<nsIURI> uri = DeserializeURI(params.uri().get_URIParams());
|
||||
mIconURL = do_QueryInterface(uri);
|
||||
if (!mIconURL) {
|
||||
MOZ_ASSERT_UNREACHABLE("bad nsIURI passed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
mSize = params.size();
|
||||
mContentType = params.contentType();
|
||||
mFileName = params.fileName();
|
||||
mStockIcon = params.stockIcon();
|
||||
mIconSize = params.iconSize();
|
||||
mIconState = params.iconState();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "nsIIconURI.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIIPCSerializableURI.h"
|
||||
|
||||
#define NS_MOZICONURI_CID \
|
||||
{ \
|
||||
@ -21,13 +20,11 @@
|
||||
}
|
||||
|
||||
class nsMozIconURI MOZ_FINAL : public nsIMozIconURI
|
||||
, public nsIIPCSerializableURI
|
||||
{
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIURI
|
||||
NS_DECL_NSIMOZICONURI
|
||||
NS_DECL_NSIIPCSERIALIZABLEURI
|
||||
|
||||
// nsMozIconURI
|
||||
nsMozIconURI();
|
||||
|
@ -53,15 +53,10 @@ struct JARURIParams
|
||||
nsCString charset;
|
||||
};
|
||||
|
||||
struct IconURIParams
|
||||
struct GenericURIParams
|
||||
{
|
||||
OptionalURIParams uri;
|
||||
uint32_t size;
|
||||
nsCString contentType;
|
||||
nsCString fileName;
|
||||
nsCString stockIcon;
|
||||
int32_t iconSize;
|
||||
int32_t iconState;
|
||||
nsCString spec;
|
||||
nsCString charset;
|
||||
};
|
||||
|
||||
union URIParams
|
||||
@ -69,7 +64,7 @@ union URIParams
|
||||
SimpleURIParams;
|
||||
StandardURLParams;
|
||||
JARURIParams;
|
||||
IconURIParams;
|
||||
GenericURIParams;
|
||||
};
|
||||
|
||||
union OptionalURIParams
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "nsDebug.h"
|
||||
#include "nsID.h"
|
||||
#include "nsJARURI.h"
|
||||
#include "nsIconURI.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsThreadUtils.h"
|
||||
@ -26,6 +25,23 @@ NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
|
||||
NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID);
|
||||
NS_DEFINE_CID(kJARURICID, NS_JARURI_CID);
|
||||
|
||||
struct StringWithLengh
|
||||
{
|
||||
const char* string;
|
||||
size_t length;
|
||||
};
|
||||
|
||||
#define STRING_WITH_LENGTH(_str) \
|
||||
{ _str, ArrayLength(_str) - 1 }
|
||||
|
||||
const StringWithLengh kGenericURIAllowedSchemes[] = {
|
||||
STRING_WITH_LENGTH("about:"),
|
||||
STRING_WITH_LENGTH("javascript:"),
|
||||
STRING_WITH_LENGTH("javascript")
|
||||
};
|
||||
|
||||
#undef STRING_WITH_LENGTH
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
namespace mozilla {
|
||||
@ -39,14 +55,41 @@ SerializeURI(nsIURI* aURI,
|
||||
MOZ_ASSERT(aURI);
|
||||
|
||||
nsCOMPtr<nsIIPCSerializableURI> serializable = do_QueryInterface(aURI);
|
||||
if (!serializable) {
|
||||
MOZ_CRASH("All IPDL URIs must be serializable!");
|
||||
if (serializable) {
|
||||
serializable->Serialize(aParams);
|
||||
if (aParams.type() == URIParams::T__None) {
|
||||
MOZ_CRASH("Serialize failed!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
serializable->Serialize(aParams);
|
||||
if (aParams.type() == URIParams::T__None) {
|
||||
MOZ_CRASH("Serialize failed!");
|
||||
nsCString scheme;
|
||||
if (NS_FAILED(aURI->GetScheme(scheme))) {
|
||||
MOZ_CRASH("This must never fail!");
|
||||
}
|
||||
|
||||
bool allowed = false;
|
||||
|
||||
for (size_t i = 0; i < ArrayLength(kGenericURIAllowedSchemes); i++) {
|
||||
const StringWithLengh& entry = kGenericURIAllowedSchemes[i];
|
||||
if (scheme.EqualsASCII(entry.string, entry.length)) {
|
||||
allowed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!allowed) {
|
||||
MOZ_CRASH("All IPDL URIs must be serializable or an allowed "
|
||||
"scheme!");
|
||||
}
|
||||
|
||||
GenericURIParams params;
|
||||
if (NS_FAILED(aURI->GetSpec(params.spec())) ||
|
||||
NS_FAILED(aURI->GetOriginCharset(params.charset()))) {
|
||||
MOZ_CRASH("This must never fail!");
|
||||
}
|
||||
|
||||
aParams = params;
|
||||
}
|
||||
|
||||
void
|
||||
@ -70,38 +113,70 @@ DeserializeURI(const URIParams& aParams)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsCOMPtr<nsIIPCSerializableURI> serializable;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
|
||||
switch (aParams.type()) {
|
||||
case URIParams::TSimpleURIParams:
|
||||
serializable = do_CreateInstance(kSimpleURICID);
|
||||
break;
|
||||
if (aParams.type() != URIParams::TGenericURIParams) {
|
||||
nsCOMPtr<nsIIPCSerializableURI> serializable;
|
||||
|
||||
case URIParams::TStandardURLParams:
|
||||
serializable = do_CreateInstance(kStandardURLCID);
|
||||
break;
|
||||
switch (aParams.type()) {
|
||||
case URIParams::TSimpleURIParams:
|
||||
serializable = do_CreateInstance(kSimpleURICID);
|
||||
break;
|
||||
|
||||
case URIParams::TJARURIParams:
|
||||
serializable = do_CreateInstance(kJARURICID);
|
||||
break;
|
||||
case URIParams::TStandardURLParams:
|
||||
serializable = do_CreateInstance(kStandardURLCID);
|
||||
break;
|
||||
|
||||
case URIParams::TIconURIParams:
|
||||
serializable = new nsMozIconURI();
|
||||
break;
|
||||
case URIParams::TJARURIParams:
|
||||
serializable = do_CreateInstance(kJARURICID);
|
||||
break;
|
||||
|
||||
default:
|
||||
MOZ_CRASH("Unknown params!");
|
||||
default:
|
||||
MOZ_CRASH("Unknown params!");
|
||||
}
|
||||
|
||||
MOZ_ASSERT(serializable);
|
||||
|
||||
if (!serializable->Deserialize(aParams)) {
|
||||
MOZ_ASSERT(false, "Deserialize failed!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uri = do_QueryInterface(serializable);
|
||||
MOZ_ASSERT(uri);
|
||||
|
||||
return uri.forget();
|
||||
}
|
||||
|
||||
MOZ_ASSERT(serializable);
|
||||
MOZ_ASSERT(aParams.type() == URIParams::TGenericURIParams);
|
||||
|
||||
if (!serializable->Deserialize(aParams)) {
|
||||
MOZ_ASSERT(false, "Deserialize failed!");
|
||||
const GenericURIParams& params = aParams.get_GenericURIParams();
|
||||
|
||||
if (NS_FAILED(NS_NewURI(getter_AddRefs(uri), params.spec(),
|
||||
params.charset().get()))) {
|
||||
NS_WARNING("Failed to make new URI!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri = do_QueryInterface(serializable);
|
||||
MOZ_ASSERT(uri);
|
||||
nsCString scheme;
|
||||
if (NS_FAILED(uri->GetScheme(scheme))) {
|
||||
MOZ_CRASH("This must never fail!");
|
||||
}
|
||||
|
||||
bool allowed = false;
|
||||
|
||||
for (size_t i = 0; i < ArrayLength(kGenericURIAllowedSchemes); i++) {
|
||||
const StringWithLengh& entry = kGenericURIAllowedSchemes[i];
|
||||
if (scheme.EqualsASCII(entry.string, entry.length)) {
|
||||
allowed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!allowed) {
|
||||
MOZ_ASSERT(false, "This type of URI is not allowed!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return uri.forget();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user