bug 386906 - remove xpfe chrome registry, r=bsmedberg

This commit is contained in:
Robert Kaiser 2008-08-26 20:02:43 +02:00
Родитель d17ef73f74
Коммит 5cac0472fc
26 изменённых файлов: 0 добавлений и 10060 удалений

Просмотреть файл

@ -1 +0,0 @@
THIS DIRECTORY AND CONTENTS ARE OBSOLETE. See mozilla/minimo.

Просмотреть файл

@ -1,74 +0,0 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Minimo.
#
# The Initial Developer of the Original Code is
# Doug Turner <dougt@meer.net>.
# Portions created by the Initial Developer are Copyright (C) 2003
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE_NAME = chromelite
MODULE = chrmlite
LIBRARY_NAME = chrmlite
IS_COMPONENT = 1
EXPORT_LIBRARY = 1
MOZILLA_INTERNAL_API = 1
REQUIRES = \
layout \
content \
necko \
xpcom \
string \
uconv \
$(NULL)
CPPSRCS = \
nsSimpleChromeHandler.cpp \
nsSimpleChromeRegistry.cpp \
$(NULL)
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS)
LOCAL_INCLUDES = \
-I$(topsrcdir)/netwerk/base/src \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,265 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Minimo.
*
* The Initial Developer of the Original Code is
* Doug Turner <dougt@meer.net>.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsSimpleChromeHandler.h"
#include "nsIServiceManager.h"
#include "nsILocalFile.h"
#include "nsDirectoryServiceDefs.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsIURL.h"
#include "nsIIOService.h"
#include "nsNetUtil.h"
#include "nsURLHelper.h"
#include "nsIGenericFactory.h"
#include "nsSimpleChromeRegistry.h"
#include "nsURLHelper.h"
#include "nsStandardURL.h"
class nsSimpleChromeURL : public nsIFileURL
{
public:
nsSimpleChromeURL(nsIFile* file);
nsresult Init(PRUint32 urlType,
PRInt32 defaultPort,
const nsACString &spec,
const char *charset,
nsIURI *baseURI);
NS_DECL_ISUPPORTS
NS_DECL_NSIFILEURL
NS_FORWARD_SAFE_NSIURI(mStandardURL)
NS_FORWARD_SAFE_NSIURL(mStandardURL)
private:
nsCOMPtr<nsIFile> mChromeDir;
nsCOMPtr<nsIURL> mStandardURL;
};
nsSimpleChromeURL::nsSimpleChromeURL(nsIFile *file) : mChromeDir(file)
{
}
nsresult
nsSimpleChromeURL::Init(PRUint32 urlType,
PRInt32 defaultPort,
const nsACString &spec,
const char *charset,
nsIURI *baseURI)
{
nsresult rv;
mStandardURL = do_CreateInstance(NS_STANDARDURL_CONTRACTID, &rv);
NS_ASSERTION(mStandardURL, "Could not create a Standard URL");
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIStandardURL> surl = do_QueryInterface(mStandardURL);
return surl->Init(urlType, defaultPort, spec, charset, baseURI);
}
NS_IMPL_ADDREF(nsSimpleChromeURL)
NS_IMPL_RELEASE(nsSimpleChromeURL)
// DO we need to implements a QI for equals?
NS_INTERFACE_MAP_BEGIN(nsSimpleChromeURL)
NS_INTERFACE_MAP_ENTRY(nsIURI)
NS_INTERFACE_MAP_ENTRY(nsIURL)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIFileURL, mChromeDir)
NS_INTERFACE_MAP_END
NS_IMETHODIMP
nsSimpleChromeURL::SetFile(nsIFile * aFile) { return NS_ERROR_FAILURE; }
NS_IMETHODIMP
nsSimpleChromeURL::GetFile(nsIFile **result)
{
nsCAutoString fileName;
GetFileName(fileName);
nsCOMPtr<nsIFile> newFile;
mChromeDir->Clone(getter_AddRefs(newFile));
nsresult rv = newFile->AppendNative(fileName);
NS_IF_ADDREF(*result = newFile);
return rv;
}
nsSimpleChromeHandler::nsSimpleChromeHandler()
{
}
nsSimpleChromeHandler::~nsSimpleChromeHandler()
{
}
nsresult
nsSimpleChromeHandler::Init()
{
nsresult rv;
mIOService = do_GetIOService(&rv);
if (NS_FAILED(rv)) return rv;
rv = NS_GetSpecialDirectory(NS_APP_CHROME_DIR, getter_AddRefs(mChromeDir));
return rv;
}
NS_IMPL_THREADSAFE_ISUPPORTS2(nsSimpleChromeHandler,
nsIProtocolHandler,
nsISupportsWeakReference)
NS_IMETHODIMP
nsSimpleChromeHandler::GetScheme(nsACString &result)
{
result = "chrome";
return NS_OK;
}
NS_IMETHODIMP
nsSimpleChromeHandler::GetDefaultPort(PRInt32 *result)
{
*result = -1;
return NS_OK;
}
NS_IMETHODIMP
nsSimpleChromeHandler::GetProtocolFlags(PRUint32 *result)
{
*result = URI_STD | URI_IS_UI_RESOURCE;
return NS_OK;
}
NS_IMETHODIMP
nsSimpleChromeHandler::NewURI(const nsACString &aSpec,
const char *aCharset,
nsIURI *aBaseURI,
nsIURI **result)
{
nsresult rv;
nsSimpleChromeURL *chromeURL = new nsSimpleChromeURL(mChromeDir);
if (!chromeURL)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(chromeURL);
rv = chromeURL->Init(nsIStandardURL::URLTYPE_STANDARD, -1, aSpec, aCharset, aBaseURI);
if (NS_SUCCEEDED(rv))
rv = CallQueryInterface(chromeURL, result);
NS_RELEASE(chromeURL);
return rv;
}
NS_IMETHODIMP
nsSimpleChromeHandler::NewChannel(nsIURI* uri, nsIChannel* *result)
{
nsCOMPtr<nsIURL> url = do_QueryInterface(uri);
if (!url) return NS_ERROR_UNEXPECTED;
nsCAutoString fileName;
url->GetFileName(fileName);
nsCOMPtr<nsIFile> newFile;
mChromeDir->Clone(getter_AddRefs(newFile));
newFile->AppendNative(fileName);
nsCOMPtr<nsIURI> resultingURI;
mIOService->NewFileURI(newFile, getter_AddRefs(resultingURI));
nsresult rv = NS_NewChannel(result,
resultingURI,
mIOService);
(*result)->SetOriginalURI(uri);
return rv;
}
NS_IMETHODIMP
nsSimpleChromeHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_retval)
{
// don't override anything.
*_retval = PR_FALSE;
return NS_OK;
}
#define NS_SIMPLECHROMEPROTOCOLHANDLER_CLASSNAME \
"nsSimpleChromeHandler"
#define NS_SIMPLECHROMEPROTOCOLHANDLER_CID \
{ /* f6b3c2cc-b2a3-11d7-82a0-000802c1aa31 */ \
0xf6b3c2cc, \
0xb2a3, \
0x11d7, \
{0x82, 0xa0, 0x00, 0x08, 0x02, 0xc1, 0xaa, 0x31} \
}
#define NS_SIMPLECHROMEREGISTRY_CID \
{ /* 5972e8f4-a3a6-44d0-8994-57bf4eeb066d */ \
0x5972e8f4, \
0xa3a6, \
0x44d0, \
{0x89, 0x94, 0x57, 0xbf, 0x4e, 0xeb, 0x06, 0x6d} \
}
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSimpleChromeHandler, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSimpleChromeRegistry)
static const nsModuleComponentInfo components[] =
{
{ "Simple Chrome Registry",
NS_SIMPLECHROMEREGISTRY_CID,
"@mozilla.org/chrome/chrome-registry;1",
nsSimpleChromeRegistryConstructor,
},
{ NS_SIMPLECHROMEPROTOCOLHANDLER_CLASSNAME,
NS_SIMPLECHROMEPROTOCOLHANDLER_CID,
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "chrome",
nsSimpleChromeHandlerConstructor
},
};
NS_IMPL_NSGETMODULE(chromelite, components)

Просмотреть файл

@ -1,60 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Minimo.
*
* The Initial Developer of the Original Code is
* Doug Turner <dougt@meer.net>.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsSimpleChromeHandler_h___
#define nsSimpleChromeHandler_h___
#include "nsIProtocolHandler.h"
#include "nsIIOService.h"
#include "nsWeakReference.h"
class nsSimpleChromeHandler : public nsIProtocolHandler, public nsSupportsWeakReference
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIPROTOCOLHANDLER
nsSimpleChromeHandler();
virtual ~nsSimpleChromeHandler();
nsresult Init();
private:
nsCOMPtr<nsIIOService> mIOService;
nsCOMPtr<nsIFile> mChromeDir;
};
#endif /* nsSimpleChromeHandler_h___ */

Просмотреть файл

@ -1,65 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Minimo.
*
* The Initial Developer of the Original Code is
* Doug Turner <dougt@meer.net>.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsSimpleChromeRegistry.h"
#include "nsNetUtil.h"
#include "nsLayoutCID.h"
static NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID);
NS_IMPL_ISUPPORTS1(nsSimpleChromeRegistry, nsIChromeRegistry)
nsSimpleChromeRegistry::nsSimpleChromeRegistry()
{
}
nsSimpleChromeRegistry::~nsSimpleChromeRegistry()
{
}
NS_IMETHODIMP
nsSimpleChromeRegistry::ConvertChromeURL(nsIURI *aChromeURL, nsIURI* *aResult)
{
NS_WARNING("Who is calling ConvertChromeURL?");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSimpleChromeRegistry::CheckForNewChrome()
{
return NS_OK;
}

Просмотреть файл

@ -1,54 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Minimo.
*
* The Initial Developer of the Original Code is
* Doug Turner <dougt@meer.net>.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsSimpleChromeRegistry_h___
#define nsSimpleChromeRegistry_h___
#include "nsIChromeRegistry.h"
#include "nsICSSStyleSheet.h"
#include "nsICSSLoader.h"
class nsSimpleChromeRegistry : public nsIChromeRegistry
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSICHROMEREGISTRY
nsSimpleChromeRegistry();
virtual ~nsSimpleChromeRegistry();
};
#endif

Просмотреть файл

@ -1,47 +0,0 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public src build tools
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,76 +0,0 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = chrome
LIBRARY_NAME = chrome
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsChromeModule
GRE_MODULE = 1
MOZILLA_INTERNAL_API = 1
PACKAGE_FILE = chrome.pkg
REQUIRES = xpcom \
string \
rdf \
necko \
content \
layout \
xuldoc \
jar \
$(NULL)
CPPSRCS = nsChromeFactory.cpp
LOCAL_INCLUDES = -I$(srcdir)/../src
SHARED_LIBRARY_LIBS = ../src/$(LIB_PREFIX)chrome_s.$(LIB_SUFFIX)
EXTRA_DSO_LDOPTS = \
$(MOZ_COMPONENT_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,11 +0,0 @@
[gecko]
#if SHARED_LIBRARY
dist/bin/components/@SHARED_LIBRARY@
#else
!staticcomp @LIBRARY@ @MODULE_NAME@
#endif
dist/bin/regchrome@BINS@
[unpackaged-files]
!optional dist/bin/chrome/chrome.rdf
!ignore ^dist/bin/chrome/overlayinfo

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,69 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsIModule.h"
#include "nsIGenericFactory.h"
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
#include "nsIChromeRegistry.h"
#include "nscore.h"
#include "rdf.h"
#include "nsChromeProtocolHandler.h"
#include "nsChromeRegistry.h"
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsChromeRegistry, Init)
// The list of components we register
static const nsModuleComponentInfo components[] =
{
{ "Chrome Registry",
NS_CHROMEREGISTRY_CID,
NS_CHROMEREGISTRY_CONTRACTID,
nsChromeRegistryConstructor
},
{ "Chrome Protocol Handler",
NS_CHROMEPROTOCOLHANDLER_CID,
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "chrome",
nsChromeProtocolHandler::Create
}
};
NS_IMPL_NSGETMODULE(nsChromeModule, components)

Просмотреть файл

@ -1,48 +0,0 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = chrome
XPIDLSRCS = nsIChromeRegistrySea.idl
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,110 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* pav
* Blake Ross (blaker@netscape.com)
* Benjamin Smedberg <bsmedberg@covad.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsIChromeRegistry.idl"
[scriptable, uuid(382370d0-a7cd-47ae-aa4e-af74f5edf652)]
interface nsIChromeRegistrySea : nsIXULChromeRegistry
{
/* Applies a skin or locale to all possible packages */
void selectSkin(in ACString skinName, in boolean useProfile);
void selectLocale(in ACString localeName, in boolean useProfile);
void deselectSkin(in ACString skinName, in boolean useProfile);
void deselectLocale(in ACString localeName, in boolean useProfile);
PRInt32 isSkinSelected(in ACString skinName, in boolean useProfile);
PRInt32 isLocaleSelected(in ACString localeName, in boolean useProfile);
//Special additional APIs for locales and skin.
void selectLocaleForProfile(in ACString localeName, in wstring profilePath);
void selectSkinForProfile(in ACString skinName, in wstring profilePath);
/* runtimeProvider == true: don't assert the runtime change */
void setRuntimeProvider(in boolean runtimeProvider);
boolean checkThemeVersion(in ACString skinName);
boolean checkLocaleVersion(in ACString localeName);
/* Apply skin/locale to a specific package */
void selectSkinForPackage(in ACString skinName,
in wstring packageName,
in boolean useProfile);
void selectLocaleForPackage(in ACString localeName,
in wstring packageName,
in boolean useProfile);
void deselectSkinForPackage(in ACString skinName,
in wstring packageName,
in boolean useProfile);
void deselectLocaleForPackage(in ACString localeName,
in wstring packageName,
in boolean useProfile);
boolean isSkinSelectedForPackage(in ACString skinName,
in wstring packageName,
in boolean useProfile);
boolean isLocaleSelectedForPackage(in ACString localeName,
in wstring packageName,
in boolean useProfile);
ACString getSelectedSkin(in ACString packageName);
/* Installation APIs */
void installSkin(in string baseURL,
in boolean useProfile,
in boolean allowScripts);
void uninstallSkin(in ACString skinName, in boolean useProfile);
void installLocale(in string baseURL, in boolean useProfile);
void uninstallLocale(in ACString localeName, in boolean useProfile);
void installPackage(in string baseURL, in boolean useProfile);
void uninstallPackage(in ACString packageName, in boolean useProfile);
/* Whether or not an addon package can dynamically overlay another package.
You can use these APIs to effectively disable a chrome add-on without
uninstalling it. */
void setAllowOverlaysForPackage(in wstring packageName, in boolean allowOverlays);
};

Просмотреть файл

@ -1,78 +0,0 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = chrome
LIBRARY_NAME = chrome_s
MOZILLA_INTERNAL_API = 1
REQUIRES = xpcom \
string \
rdf \
content \
xuldoc \
gfx \
layout \
necko \
dom \
widget \
js \
appshell \
caps \
pref \
docshell \
xpconnect \
jar \
$(NULL)
CPPSRCS = \
nsChromeRegistry.cpp \
nsChromeUIDataSource.cpp \
nsChromeProtocolHandler.cpp \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a static lib.
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,742 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
A protocol handler for ``chrome:''
*/
#include "nsChromeProtocolHandler.h"
#include "nsChromeRegistry.h"
#include "nsCOMPtr.h"
#include "nsContentCID.h"
#include "nsThreadUtils.h"
#include "nsCRT.h"
#include "nsIChannel.h"
#include "nsIChromeRegistry.h"
#include "nsIComponentManager.h"
#include "nsIFastLoadService.h"
#include "nsIFile.h"
#include "nsIFileURL.h"
#include "nsIFileChannel.h"
#include "nsIIOService.h"
#include "nsIJARChannel.h"
#include "nsIJARURI.h"
#include "nsILoadGroup.h"
#include "nsIObjectOutputStream.h"
#include "nsIScriptSecurityManager.h"
#include "nsIServiceManager.h"
#include "nsIStandardURL.h"
#include "nsIStreamListener.h"
#ifdef MOZ_XUL
#include "nsIXULPrototypeCache.h"
#endif
#include "nsNetCID.h"
#include "nsNetUtil.h"
#include "nsAutoPtr.h"
#include "nsXPIDLString.h"
#include "nsString.h"
#include "prlog.h"
//----------------------------------------------------------------------
#ifdef MOZ_XUL
static NS_DEFINE_CID(kXULPrototypeCacheCID, NS_XULPROTOTYPECACHE_CID);
#endif
// This comes from nsChromeRegistry.cpp
extern nsIChromeRegistry* gChromeRegistry;
//----------------------------------------------------------------------
//
// A channel that's used for loading cached chrome documents. Since a
// cached chrome document really doesn't have anything to do to load,
// this is just the puppeteer that pulls the webshell's strings at the
// right time.
//
// Specifically, when AsyncOpen() is called, it adds the channel to
// the load group, and queues an asychronous event to fire the
// listener's OnStartRequest().
//
// After triggering OnStartRequest(), it then queues another event
// which will fire the listener's OnStopRequest() and remove the
// channel from the load group.
//
// Each is done asynchronously to allow the stack to unwind back to
// the main event loop. This avoids any weird re-entrancy that occurs
// if we try to immediately fire the On[Start|Stop]Request().
//
// For logging information, NSPR_LOG_MODULES=nsCachedChromeChannel:5
//
class nsCachedChromeChannel : public nsIChannel
{
protected:
nsCachedChromeChannel(nsIURI* aURI);
virtual ~nsCachedChromeChannel();
nsCOMPtr<nsIURI> mURI;
nsCOMPtr<nsIURI> mOriginalURI;
nsCOMPtr<nsILoadGroup> mLoadGroup;
nsCOMPtr<nsIStreamListener> mListener;
nsCOMPtr<nsISupports> mContext;
nsLoadFlags mLoadFlags;
nsCOMPtr<nsISupports> mOwner;
nsresult mStatus;
typedef void (*LoadEventCallback)(nsCachedChromeChannel*);
struct LoadEvent : nsRunnable {
LoadEvent(nsCachedChromeChannel *chan, LoadEventCallback callback)
: mChannel(chan), mCallback(callback) {}
nsRefPtr<nsCachedChromeChannel> mChannel;
LoadEventCallback mCallback;
NS_IMETHOD Run() {
mCallback(mChannel);
return NS_OK;
}
};
static nsresult
PostLoadEvent(nsCachedChromeChannel* aChannel, LoadEventCallback aCallback);
static void HandleStartLoadEvent(nsCachedChromeChannel* channel);
static void HandleStopLoadEvent(nsCachedChromeChannel* channel);
#ifdef PR_LOGGING
static PRLogModuleInfo* gLog;
#endif
public:
static nsresult
Create(nsIURI* aURI, nsIChannel** aResult);
NS_DECL_ISUPPORTS
// nsIRequest
NS_IMETHOD GetName(nsACString &result) { return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHOD IsPending(PRBool *_retval) { *_retval = (mListener != nsnull); return NS_OK; }
NS_IMETHOD GetStatus(nsresult *status) { *status = mStatus; return NS_OK; }
NS_IMETHOD Cancel(nsresult status) { mStatus = status; return NS_OK; }
NS_IMETHOD Suspend(void) { return NS_OK; }
NS_IMETHOD Resume(void) { return NS_OK; }
NS_IMETHOD GetLoadGroup(nsILoadGroup **);
NS_IMETHOD SetLoadGroup(nsILoadGroup *);
NS_IMETHOD GetLoadFlags(nsLoadFlags *);
NS_IMETHOD SetLoadFlags(nsLoadFlags);
// nsIChannel
NS_DECL_NSICHANNEL
};
#ifdef PR_LOGGING
PRLogModuleInfo* nsCachedChromeChannel::gLog;
#endif
NS_IMPL_ISUPPORTS2(nsCachedChromeChannel,
nsIChannel,
nsIRequest)
nsresult
nsCachedChromeChannel::Create(nsIURI* aURI, nsIChannel** aResult)
{
NS_PRECONDITION(aURI != nsnull, "null ptr");
if (! aURI)
return NS_ERROR_NULL_POINTER;
nsCachedChromeChannel* channel = new nsCachedChromeChannel(aURI);
if (! channel)
return NS_ERROR_OUT_OF_MEMORY;
*aResult = channel;
NS_ADDREF(*aResult);
return NS_OK;
}
nsCachedChromeChannel::nsCachedChromeChannel(nsIURI* aURI)
: mURI(aURI),
mLoadFlags(nsIRequest::LOAD_NORMAL),
mStatus(NS_OK)
{
#ifdef PR_LOGGING
if (! gLog)
gLog = PR_NewLogModule("nsCachedChromeChannel");
#endif
PR_LOG(gLog, PR_LOG_DEBUG,
("nsCachedChromeChannel[%p]: created", this));
}
nsCachedChromeChannel::~nsCachedChromeChannel()
{
PR_LOG(gLog, PR_LOG_DEBUG,
("nsCachedChromeChannel[%p]: destroyed", this));
}
NS_IMETHODIMP
nsCachedChromeChannel::GetOriginalURI(nsIURI* *aOriginalURI)
{
*aOriginalURI = mOriginalURI ? mOriginalURI : mURI;
NS_ADDREF(*aOriginalURI);
return NS_OK;
}
NS_IMETHODIMP
nsCachedChromeChannel::SetOriginalURI(nsIURI* aOriginalURI)
{
mOriginalURI = aOriginalURI;
return NS_OK;
}
NS_IMETHODIMP
nsCachedChromeChannel::GetURI(nsIURI* *aURI)
{
*aURI = mURI;
NS_ADDREF(*aURI);
return NS_OK;
}
NS_IMETHODIMP
nsCachedChromeChannel::Open(nsIInputStream **_retval)
{
// NS_NOTREACHED("don't do that");
*_retval = nsnull;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsCachedChromeChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt)
{
if (listener) {
nsresult rv;
if (mLoadGroup) {
PR_LOG(gLog, PR_LOG_DEBUG,
("nsCachedChromeChannel[%p]: adding self to load group %p",
this, mLoadGroup.get()));
rv = mLoadGroup->AddRequest(this, nsnull);
if (NS_FAILED(rv)) return rv;
}
// Fire the OnStartRequest(), which will cause the XUL
// document to get embedded.
PR_LOG(gLog, PR_LOG_DEBUG,
("nsCachedChromeChannel[%p]: firing OnStartRequest for %p",
this, listener));
// Queue an event to ourselves to let the stack unwind before
// calling OnStartRequest(). This allows embedding to occur
// before we fire OnStopRequest().
rv = PostLoadEvent(this, HandleStartLoadEvent);
if (NS_FAILED(rv)) {
if (mLoadGroup) {
PR_LOG(gLog, PR_LOG_DEBUG,
("nsCachedChromeChannel[%p]: removing self from load group %p",
this, mLoadGroup.get()));
(void) mLoadGroup->RemoveRequest(this, nsnull, NS_OK);
}
return rv;
}
mContext = ctxt;
mListener = listener;
}
return NS_OK;
}
NS_IMETHODIMP
nsCachedChromeChannel::GetSecurityInfo(nsISupports * *aSecurityInfo)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsCachedChromeChannel::GetLoadFlags(nsLoadFlags *aLoadFlags)
{
*aLoadFlags = mLoadFlags;
return NS_OK;
}
NS_IMETHODIMP
nsCachedChromeChannel::SetLoadFlags(nsLoadFlags aLoadFlags)
{
mLoadFlags = aLoadFlags;
return NS_OK;
}
NS_IMETHODIMP
nsCachedChromeChannel::GetOwner(nsISupports * *aOwner)
{
*aOwner = mOwner.get();
NS_IF_ADDREF(*aOwner);
return NS_OK;
}
NS_IMETHODIMP
nsCachedChromeChannel::SetOwner(nsISupports * aOwner)
{
mOwner = aOwner;
return NS_OK;
}
NS_IMETHODIMP
nsCachedChromeChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
{
*aLoadGroup = mLoadGroup;
NS_IF_ADDREF(*aLoadGroup);
return NS_OK;
}
NS_IMETHODIMP
nsCachedChromeChannel::SetLoadGroup(nsILoadGroup * aLoadGroup)
{
mLoadGroup = aLoadGroup;
return NS_OK;
}
NS_IMETHODIMP
nsCachedChromeChannel::GetNotificationCallbacks(nsIInterfaceRequestor * *aNotificationCallbacks)
{
*aNotificationCallbacks = nsnull;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsCachedChromeChannel::SetNotificationCallbacks(nsIInterfaceRequestor * aNotificationCallbacks)
{
return NS_OK; // ignored
}
NS_IMETHODIMP
nsCachedChromeChannel::GetContentType(nsACString &aContentType)
{
aContentType.AssignLiteral("mozilla.application/cached-xul");
return NS_OK;
}
NS_IMETHODIMP
nsCachedChromeChannel::SetContentType(const nsACString &aContentType)
{
// Do not allow the content-type to be changed.
NS_NOTREACHED("don't do that");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsCachedChromeChannel::GetContentCharset(nsACString &aContentCharset)
{
aContentCharset.Truncate();
return NS_OK;
}
NS_IMETHODIMP
nsCachedChromeChannel::SetContentCharset(const nsACString &aContentCharset)
{
// Do not allow the content charset to be changed.
NS_NOTREACHED("don't do that");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsCachedChromeChannel::GetContentLength(PRInt32 *aContentLength)
{
NS_NOTREACHED("don't do that");
*aContentLength = 0;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsCachedChromeChannel::SetContentLength(PRInt32 aContentLength)
{
NS_NOTREACHED("nsCachedChromeChannel::SetContentLength");
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsCachedChromeChannel::PostLoadEvent(nsCachedChromeChannel* aChannel,
LoadEventCallback aCallback)
{
nsCOMPtr<nsIRunnable> event = new LoadEvent(aChannel, aCallback);
if (! event)
return NS_ERROR_OUT_OF_MEMORY;
return NS_DispatchToCurrentThread(event);
}
/*static*/ void
nsCachedChromeChannel::HandleStartLoadEvent(nsCachedChromeChannel *channel)
{
// Fire the OnStartRequest() for the cached chrome channel, then
// queue another event to trigger the OnStopRequest()...
// If the load has been cancelled, then just bail now. We won't
// send On[Start|Stop]Request().
// XXX(darin): this violates the nsIChannel API
if (NS_FAILED(channel->mStatus))
return;
PR_LOG(gLog, PR_LOG_DEBUG,
("nsCachedChromeChannel[%p]: firing OnStartRequest for %p",
channel, channel->mListener.get()));
(void) channel->mListener->OnStartRequest(channel, channel->mContext);
(void) PostLoadEvent(channel, HandleStopLoadEvent);
}
/*static*/ void
nsCachedChromeChannel::HandleStopLoadEvent(nsCachedChromeChannel* channel)
{
// Fire the OnStopRequest() for the cached chrome channel, and
// remove it from the load group.
PR_LOG(gLog, PR_LOG_DEBUG,
("nsCachedChromeChannel[%p]: firing OnStopRequest for %p",
channel, channel->mListener.get()));
(void) channel->mListener->OnStopRequest(channel, channel->mContext,
channel->mStatus);
if (channel->mLoadGroup) {
PR_LOG(gLog, PR_LOG_DEBUG,
("nsCachedChromeChannel[%p]: removing self from load group %p",
channel, channel->mLoadGroup.get()));
(void) channel->mLoadGroup->RemoveRequest(channel, nsnull, NS_OK);
}
channel->mListener = nsnull;
channel->mContext = nsnull;
}
////////////////////////////////////////////////////////////////////////////////
nsChromeProtocolHandler::nsChromeProtocolHandler()
{
}
nsresult
nsChromeProtocolHandler::Init()
{
return NS_OK;
}
nsChromeProtocolHandler::~nsChromeProtocolHandler()
{
}
NS_IMPL_THREADSAFE_ISUPPORTS2(nsChromeProtocolHandler, nsIProtocolHandler, nsISupportsWeakReference)
NS_METHOD
nsChromeProtocolHandler::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsChromeProtocolHandler* ph = new nsChromeProtocolHandler();
if (ph == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(ph);
nsresult rv = ph->Init();
if (NS_SUCCEEDED(rv)) {
rv = ph->QueryInterface(aIID, aResult);
}
NS_RELEASE(ph);
return rv;
}
////////////////////////////////////////////////////////////////////////////////
// nsIProtocolHandler methods:
NS_IMETHODIMP
nsChromeProtocolHandler::GetScheme(nsACString &result)
{
result = "chrome";
return NS_OK;
}
NS_IMETHODIMP
nsChromeProtocolHandler::GetDefaultPort(PRInt32 *result)
{
*result = -1; // no port for chrome: URLs
return NS_OK;
}
NS_IMETHODIMP
nsChromeProtocolHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_retval)
{
// don't override anything.
*_retval = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsChromeProtocolHandler::GetProtocolFlags(PRUint32 *result)
{
// XXXbz we should probably have different flags for different package
// types and put the things that ARE OK for random crap to load into a
// separate package type!
*result = URI_STD | URI_IS_UI_RESOURCE;
return NS_OK;
}
NS_IMETHODIMP
nsChromeProtocolHandler::NewURI(const nsACString &aSpec,
const char *aCharset,
nsIURI *aBaseURI,
nsIURI **result)
{
NS_PRECONDITION(result, "Null out param");
nsresult rv;
*result = nsnull;
// Chrome: URLs (currently) have no additional structure beyond that provided
// by standard URLs, so there is no "outer" given to CreateInstance
nsCOMPtr<nsIStandardURL> url(do_CreateInstance(NS_STANDARDURL_CONTRACTID, &rv));
if (NS_FAILED(rv))
return rv;
rv = url->Init(nsIStandardURL::URLTYPE_STANDARD, -1, aSpec, aCharset, aBaseURI);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIURI> uri(do_QueryInterface(url, &rv));
if (NS_FAILED(rv))
return rv;
// Canonify the "chrome:" URL; e.g., so that we collapse
// "chrome://navigator/content/" and "chrome://navigator/content"
// and "chrome://navigator/content/navigator.xul".
rv = nsChromeRegistry::Canonify(uri);
if (NS_FAILED(rv))
return rv;
*result = uri;
NS_ADDREF(*result);
return NS_OK;
}
NS_IMETHODIMP
nsChromeProtocolHandler::NewChannel(nsIURI* aURI,
nsIChannel* *aResult)
{
NS_ENSURE_ARG_POINTER(aURI);
NS_PRECONDITION(aResult, "Null out param");
#ifdef DEBUG
// Check that the uri we got is already canonified
nsresult debug_rv;
nsCOMPtr<nsIChromeRegistry> debugReg(do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &debug_rv));
if (NS_SUCCEEDED(debug_rv)) {
nsCOMPtr<nsIURI> debugClone;
debug_rv = aURI->Clone(getter_AddRefs(debugClone));
if (NS_SUCCEEDED(debug_rv)) {
debug_rv = nsChromeRegistry::Canonify(debugClone);
if (NS_SUCCEEDED(debug_rv)) {
PRBool same;
debug_rv = aURI->Equals(debugClone, &same);
if (NS_SUCCEEDED(debug_rv)) {
NS_ASSERTION(same, "Non-canonified chrome uri passed to nsChromeProtocolHandler::NewChannel!");
}
}
}
}
#endif
nsresult rv;
nsCOMPtr<nsIChannel> result;
#ifdef MOZ_XUL
// Check the prototype cache to see if we've already got the
// document in the cache.
nsCOMPtr<nsIXULPrototypeCache> cache =
do_GetService(kXULPrototypeCacheCID, &rv);
if (NS_FAILED(rv)) return rv;
PRBool isCached = PR_FALSE;
isCached = cache->IsCached(aURI);
// Same comment as nsXULDocument::StartDocumentLoad and
// nsXULDocument::ResumeWalk
// - Ben Goodger
//
// We don't abort on failure here because there are too many valid
// cases that can return failure, and the null-ness of |proto| is enough
// to trigger the fail-safe parse-from-disk solution. Example failure cases
// (for reference) include:
//
// NS_ERROR_NOT_AVAILABLE: the URI cannot be found in the FastLoad cache,
// parse from disk
// other: the FastLoad cache file, XUL.mfl, could not be found, probably
// due to being accessed before a profile has been selected (e.g.
// loading chrome for the profile manager itself). This must be
// parsed from disk.
if (isCached) {
// ...in which case, we'll create a dummy stream that'll just
// load the thing.
rv = nsCachedChromeChannel::Create(aURI, getter_AddRefs(result));
if (NS_FAILED(rv)) return rv;
}
else
#endif
{
// Miss. Resolve the chrome URL using the registry and do a
// normal necko load.
//nsXPIDLCString oldSpec;
//aURI->GetSpec(getter_Copies(oldSpec));
//printf("*************************** %s\n", (const char*)oldSpec);
nsCOMPtr<nsIChromeRegistry> reg = gChromeRegistry;
if (!reg) {
reg = do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
}
nsCOMPtr<nsIURI> chromeURI;
rv = reg->ConvertChromeURL(aURI, getter_AddRefs(chromeURI));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIIOService> ioServ (do_GetIOService());
if (!ioServ) return NS_ERROR_FAILURE;
rv = ioServ->NewChannelFromURI(chromeURI, getter_AddRefs(result));
if (NS_FAILED(rv)) return rv;
// XXX Will be removed someday when we handle remote chrome.
nsCOMPtr<nsIFileChannel> fileChan;
nsCOMPtr<nsIJARChannel> jarChan;
fileChan = do_QueryInterface(result);
if (!fileChan)
jarChan = do_QueryInterface(result);
if (!fileChan && !jarChan) {
NS_WARNING("Remote chrome not allowed! Only file:, resource:, and jar: are valid.\n");
result = nsnull;
return NS_ERROR_FAILURE;
}
// Make sure that the channel remembers where it was
// originally loaded from.
rv = result->SetOriginalURI(aURI);
if (NS_FAILED(rv)) return rv;
// Get a system principal for content files and set the owner
// property of the result
nsCOMPtr<nsIURL> url = do_QueryInterface(aURI);
nsCAutoString path;
rv = url->GetPath(path);
if (StringBeginsWith(path, NS_LITERAL_CSTRING("/content/")))
{
nsCOMPtr<nsIScriptSecurityManager> securityManager =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIPrincipal> principal;
rv = securityManager->GetSystemPrincipal(getter_AddRefs(principal));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISupports> owner = do_QueryInterface(principal);
result->SetOwner(owner);
}
// Track FastLoad file dependencies.
//
// This is harder than it ought to be! While an nsResChannel "is-a"
// nsIFileChannel, an nsJARChannel is not. Once you unravel the jar:
// URI, you may have a resource: URL -- but without a channel for it,
// you can't get the URI that it yields through substitution!
//
// XXXbe fix nsResChannel.cpp to move the substitution code into a new
// nsResURL class?
nsCOMPtr<nsIFastLoadService> fastLoadServ(do_GetFastLoadService());
if (fastLoadServ) {
nsCOMPtr<nsIObjectOutputStream> objectOutput;
fastLoadServ->GetOutputStream(getter_AddRefs(objectOutput));
if (objectOutput) {
nsCOMPtr<nsIFile> file;
if (fileChan) {
fileChan->GetFile(getter_AddRefs(file));
} else {
nsCOMPtr<nsIURI> uri;
result->GetURI(getter_AddRefs(uri));
// Loop, jar URIs can nest (e.g. jar:jar:A.jar!B.jar!C.xml).
// Often, however, we have jar:resource:/chrome/A.jar!C.xml.
nsCOMPtr<nsIJARURI> jarURI;
while ((jarURI = do_QueryInterface(uri)) != nsnull)
jarURI->GetJARFile(getter_AddRefs(uri));
// Here we have a URL of the form resource:/chrome/A.jar
// or file:/some/path/to/A.jar.
nsCOMPtr<nsIFileURL> fileURL(do_QueryInterface(uri));
if (fileURL)
fileURL->GetFile(getter_AddRefs(file));
}
if (file) {
rv = fastLoadServ->AddDependency(file);
#ifdef MOZ_XUL
if (NS_FAILED(rv))
cache->AbortFastLoads();
#endif
}
}
}
}
*aResult = result;
NS_ADDREF(*aResult);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -1,70 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsChromeProtocolHandler_h___
#define nsChromeProtocolHandler_h___
#include "nsIProtocolHandler.h"
#include "nsWeakReference.h"
#define NS_CHROMEPROTOCOLHANDLER_CID \
{ /* 61ba33c0-3031-11d3-8cd0-0060b0fc14a3 */ \
0x61ba33c0, \
0x3031, \
0x11d3, \
{0x8c, 0xd0, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
}
class nsChromeProtocolHandler : public nsIProtocolHandler, public nsSupportsWeakReference
{
public:
NS_DECL_ISUPPORTS
// nsIProtocolHandler methods:
NS_DECL_NSIPROTOCOLHANDLER
// nsChromeProtocolHandler methods:
nsChromeProtocolHandler();
virtual ~nsChromeProtocolHandler();
static NS_METHOD
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
nsresult Init();
};
#endif /* nsChromeProtocolHandler_h___ */

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,285 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Original Author: David W. Hyatt (hyatt@netscape.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
class nsIAtom;
class nsICSSStyleSheet;
class nsIRDFService;
class nsIRDFDataSource;
class nsIRDFResource;
class nsIRDFNode;
class nsISimpleEnumerator;
class nsSupportsHashtable;
class nsIRDFContainer;
class nsIRDFContainerUtils;
class nsIDOMWindowInternal;
class nsIDocument;
#include "nsIChromeRegistry.h"
#include "nsIChromeRegistrySea.h"
#include "nsIXULOverlayProvider.h"
#include "nsIRDFCompositeDataSource.h"
#include "nsIObserver.h"
#include "nsWeakReference.h"
#include "nsString.h"
#include "nsICSSLoader.h"
#include "nsIZipReader.h"
#include "nsCOMArray.h"
// for component registration
// {D8C7D8A2-E84C-11d2-BF87-00105A1B0627}
#define NS_CHROMEREGISTRY_CID \
{ 0xd8c7d8a2, 0xe84c, 0x11d2, { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
class nsChromeRegistry : public nsIChromeRegistrySea,
public nsIXULOverlayProvider,
public nsIObserver,
public nsSupportsWeakReference
{
public:
NS_DECL_ISUPPORTS
// nsIChromeRegistry methods:
NS_DECL_NSICHROMEREGISTRY
NS_DECL_NSIXULCHROMEREGISTRY
NS_DECL_NSIXULOVERLAYPROVIDER
NS_DECL_NSICHROMEREGISTRYSEA
NS_DECL_NSIOBSERVER
// nsChromeRegistry methods:
nsChromeRegistry();
virtual ~nsChromeRegistry();
nsresult Init();
// used by the protocol handler
static nsresult Canonify(nsIURI* aChromeURL);
public:
static nsresult FollowArc(nsIRDFDataSource *aDataSource,
nsACString& aResult,
nsIRDFResource* aChromeResource,
nsIRDFResource* aProperty);
static nsresult UpdateArc(nsIRDFDataSource *aDataSource, nsIRDFResource* aSource, nsIRDFResource* aProperty,
nsIRDFNode *aTarget, PRBool aRemove);
protected:
nsresult GetDynamicDataSource(nsIURI *aChromeURL, PRBool aIsOverlay, PRBool aUseProfile, PRBool aCreateDS, nsIRDFDataSource **aResult);
nsresult GetURIList(nsIRDFDataSource *aDS, nsIRDFResource *aResource, nsCOMArray<nsIURI>& aArray);
nsresult GetDynamicInfo(nsIURI *aChromeURL, PRBool aIsOverlay, nsISimpleEnumerator **aResult);
PRBool IsOverlayAllowed(nsIURI *aChromeURI);
nsresult GetResource(const nsACString& aChromeType, nsIRDFResource** aResult);
nsresult UpdateDynamicDataSource(nsIRDFDataSource *aDataSource,
nsIRDFResource *aResource,
PRBool aIsOverlay, PRBool
aUseProfile, PRBool aRemove);
nsresult UpdateDynamicDataSources(nsIRDFDataSource *aDataSource,
PRBool aIsOverlay,
PRBool aUseProfile, PRBool
aRemove);
nsresult WriteInfoToDataSource(const char *aDocURI,
const PRUnichar *aOverlayURI,
PRBool aIsOverlay, PRBool
aUseProfile, PRBool aRemove);
nsresult LoadStyleSheetWithURL(nsIURI* aURL, PRBool aEnableUnsafeRules, nsICSSStyleSheet** aSheet);
nsresult LoadInstallDataSource();
nsresult LoadProfileDataSource();
void FlushSkinCaches();
void FlushAllCaches();
private:
nsresult LoadDataSource(const nsACString &aFileName,
nsIRDFDataSource **aResult,
PRBool aUseProfileDirOnly = PR_FALSE,
const char *aProfilePath = nsnull);
static nsresult GetProfileRoot(nsACString& aFileURL);
static nsresult GetInstallRoot(nsIFile** aFileURL);
nsresult RefreshWindow(nsIDOMWindowInternal* aWindow);
nsresult GetArcs(nsIRDFDataSource* aDataSource,
const nsACString& aType,
nsISimpleEnumerator** aResult);
nsresult AddToCompositeDataSource(PRBool aUseProfile);
nsresult FlagXPCNativeWrappers();
nsresult GetBaseURL(const nsACString& aPackage,
const nsACString& aProvider,
nsACString& aBaseURL);
nsresult InitOverrideJAR();
nsresult GetOverrideURL(const nsACString& aPackage,
const nsACString& aProvider,
const nsACString& aPath,
nsACString& aResult);
nsresult VerifyCompatibleProvider(nsIRDFResource* aPackageResource,
nsIRDFResource* aProviderResource,
nsIRDFResource* aArc,
PRBool *aAcceptable);
nsresult FindProvider(const nsACString& aPackage,
const nsACString& aProvider,
nsIRDFResource *aArc,
nsIRDFNode **aSelectedProvider);
nsresult SelectPackageInProvider(nsIRDFResource *aPackageList,
const nsACString& aPackage,
const nsACString& aProvider,
const nsACString& aProviderName,
nsIRDFResource *aArc,
nsIRDFNode **aSelectedProvider);
nsresult SetProvider(const nsACString& aProvider,
nsIRDFResource* aSelectionArc,
const nsACString& aProviderName,
PRBool aAllUsers,
const char *aProfilePath,
PRBool aIsAdding);
nsresult SetProviderForPackage(const nsACString& aProvider,
nsIRDFResource* aPackageResource,
nsIRDFResource* aProviderPackageResource,
nsIRDFResource* aSelectionArc,
PRBool aAllUsers, const char *aProfilePath,
PRBool aIsAdding);
nsresult SelectProviderForPackage(const nsACString& aProviderType,
const nsACString& aProviderName,
const PRUnichar *aPackageName,
nsIRDFResource* aSelectionArc,
PRBool aUseProfile, PRBool aIsAdding);
nsresult GetSelectedProvider(const nsACString& aPackage,
const nsACString& aProviderName,
nsIRDFResource* aSelectionArc,
nsACString& aResult);
nsresult CheckProviderVersion (const nsACString& aProviderType,
const nsACString& aProviderName,
nsIRDFResource* aSelectionArc,
PRBool *aCompatible);
nsresult IsProviderSelected(const nsACString& aProvider,
const nsACString& aProviderName,
nsIRDFResource* aSelectionArc,
PRBool aUseProfile, PRInt32* aResult);
nsresult IsProviderSelectedForPackage(const nsACString& aProviderType,
const nsACString& aProviderName,
const PRUnichar *aPackageName,
nsIRDFResource* aSelectionArc,
PRBool aUseProfile, PRBool* aResult);
nsresult IsProviderSetForPackage(const nsACString& aProvider,
nsIRDFResource* aPackageResource,
nsIRDFResource* aProviderPackageResource,
nsIRDFResource* aSelectionArc,
PRBool aUseProfile, PRBool* aResult);
nsresult InstallProvider(const nsACString& aProviderType,
const nsACString& aBaseURL,
PRBool aUseProfile, PRBool aAllowScripts, PRBool aRemove);
nsresult UninstallProvider(const nsACString& aProviderType, const nsACString& aProviderName, PRBool aUseProfile);
nsresult ProcessNewChromeBuffer(char *aBuffer, PRInt32 aLength);
PRBool GetProviderCount(const nsACString& aProviderType, nsIRDFDataSource* aDataSource);
protected:
nsCString mProfileRoot;
nsCString mInstallRoot;
nsCOMPtr<nsIRDFCompositeDataSource> mChromeDataSource;
nsCOMPtr<nsIRDFDataSource> mInstallDirChromeDataSource;
nsCOMPtr<nsIRDFDataSource> mUIDataSource;
nsSupportsHashtable* mDataSourceTable;
nsIRDFService* mRDFService;
nsIRDFContainerUtils* mRDFContainerUtils;
// Resources
nsCOMPtr<nsIRDFResource> mSelectedSkin;
nsCOMPtr<nsIRDFResource> mSelectedLocale;
nsCOMPtr<nsIRDFResource> mBaseURL;
nsCOMPtr<nsIRDFResource> mPackages;
nsCOMPtr<nsIRDFResource> mPackage;
nsCOMPtr<nsIRDFResource> mName;
nsCOMPtr<nsIRDFResource> mImage;
nsCOMPtr<nsIRDFResource> mLocType;
nsCOMPtr<nsIRDFResource> mAllowScripts;
nsCOMPtr<nsIRDFResource> mHasOverlays;
nsCOMPtr<nsIRDFResource> mHasStylesheets;
nsCOMPtr<nsIRDFResource> mSkinVersion;
nsCOMPtr<nsIRDFResource> mLocaleVersion;
nsCOMPtr<nsIRDFResource> mPackageVersion;
nsCOMPtr<nsIRDFResource> mDisabled;
nsCOMPtr<nsIRDFResource> mXPCNativeWrappers;
nsCOMPtr<nsICSSLoader> mCSSLoader;
nsCOMPtr<nsIZipReader> mOverrideJAR;
nsCString mOverrideJARURL;
// useful atoms - these are static atoms, so don't use nsCOMPtr
static nsIAtom* sCPrefix; // "c"
PRPackedBool mInstallInitialized;
PRPackedBool mProfileInitialized;
PRPackedBool mRuntimeProvider;
// Boolean that indicates we should batch flushes of the main
// chrome.rdf file.
PRPackedBool mBatchInstallFlushes;
// make sure we only look once for the JAR override
PRPackedBool mSearchedForOverride;
// if we find an old profile overlayinfo/ directory structure, use it
// else use the new flat files
PRPackedBool mLegacyOverlayinfo;
};

Просмотреть файл

@ -1,389 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Original Author: David W. Hyatt (hyatt@netscape.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsChromeUIDataSource.h"
#include "nsIRDFDataSource.h"
#include "nsIRDFObserver.h"
#include "nsIRDFRemoteDataSource.h"
#include "nsCRTGlue.h"
#include "rdf.h"
#include "nsIServiceManager.h"
#include "nsIRDFService.h"
#include "nsRDFCID.h"
#include "nsIRDFResource.h"
#include "nsIRDFDataSource.h"
#include "nsIRDFContainer.h"
#include "nsHashtable.h"
#include "nsString.h"
#include "nsXPIDLString.h"
#include "nsISimpleEnumerator.h"
#include "nsNetUtil.h"
#include "nsISupportsArray.h"
#include "nsIIOService.h"
////////////////////////////////////////////////////////////////////////////////
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
nsChromeUIDataSource::nsChromeUIDataSource(nsIRDFDataSource* aComposite)
{
mComposite = aComposite;
mComposite->AddObserver(this);
nsresult rv;
rv = CallGetService(kRDFServiceCID, &mRDFService);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service");
mRDFService->RegisterDataSource(this, PR_TRUE);
}
nsChromeUIDataSource::~nsChromeUIDataSource()
{
mRDFService->UnregisterDataSource(this);
NS_IF_RELEASE(mRDFService);
}
NS_IMPL_CYCLE_COLLECTION_CLASS(nsChromeUIDataSource)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsChromeUIDataSource)
if (tmp->mComposite) {
tmp->mComposite->RemoveObserver(tmp);
tmp->mComposite = nsnull;
}
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMARRAY(mObservers);
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsChromeUIDataSource)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mComposite)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mObservers)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTING_ADDREF_AMBIGUOUS(nsChromeUIDataSource,
nsIRDFDataSource)
NS_IMPL_CYCLE_COLLECTING_RELEASE_AMBIGUOUS(nsChromeUIDataSource,
nsIRDFDataSource)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsChromeUIDataSource)
NS_INTERFACE_MAP_ENTRY(nsIRDFDataSource)
NS_INTERFACE_MAP_ENTRY(nsIRDFObserver)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIRDFDataSource)
NS_INTERFACE_MAP_END
//----------------------------------------------------------------------
//
// nsIRDFDataSource interface
//
NS_IMETHODIMP
nsChromeUIDataSource::GetURI(char** aURI)
{
*aURI = NS_strdup("rdf:chrome");
if (! *aURI)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP
nsChromeUIDataSource::GetSource(nsIRDFResource* property,
nsIRDFNode* target,
PRBool tv,
nsIRDFResource** source)
{
return mComposite->GetSource(property, target, tv, source);
}
NS_IMETHODIMP
nsChromeUIDataSource::GetSources(nsIRDFResource* aProperty,
nsIRDFNode* aTarget,
PRBool aTruthValue,
nsISimpleEnumerator** aResult)
{
return mComposite->GetSources(aProperty, aTarget, aTruthValue, aResult);
}
NS_IMETHODIMP
nsChromeUIDataSource::GetTarget(nsIRDFResource* aSource,
nsIRDFResource* aProperty,
PRBool aTruthValue,
nsIRDFNode** aResult)
{
return mComposite->GetTarget(aSource, aProperty, aTruthValue, aResult);
}
NS_IMETHODIMP
nsChromeUIDataSource::GetTargets(nsIRDFResource* aSource,
nsIRDFResource* aProperty,
PRBool aTruthValue,
nsISimpleEnumerator** aResult)
{
return mComposite->GetTargets(aSource, aProperty, aTruthValue, aResult);
}
NS_IMETHODIMP
nsChromeUIDataSource::Assert(nsIRDFResource* aSource,
nsIRDFResource* aProperty,
nsIRDFNode* aTarget,
PRBool aTruthValue)
{
return mComposite->Assert(aSource, aProperty, aTarget, aTruthValue);
}
NS_IMETHODIMP
nsChromeUIDataSource::Unassert(nsIRDFResource* aSource,
nsIRDFResource* aProperty,
nsIRDFNode* aTarget)
{
return mComposite->Unassert(aSource, aProperty, aTarget);
}
NS_IMETHODIMP
nsChromeUIDataSource::Change(nsIRDFResource* aSource,
nsIRDFResource* aProperty,
nsIRDFNode* aOldTarget,
nsIRDFNode* aNewTarget)
{
return mComposite->Change(aSource, aProperty, aOldTarget, aNewTarget);
}
NS_IMETHODIMP
nsChromeUIDataSource::Move(nsIRDFResource* aOldSource,
nsIRDFResource* aNewSource,
nsIRDFResource* aProperty,
nsIRDFNode* aTarget)
{
return mComposite->Move(aOldSource, aNewSource, aProperty, aTarget);
}
NS_IMETHODIMP
nsChromeUIDataSource::HasAssertion(nsIRDFResource* aSource,
nsIRDFResource* aProperty,
nsIRDFNode* aTarget,
PRBool aTruthValue,
PRBool* aResult)
{
return mComposite->HasAssertion(aSource, aProperty, aTarget, aTruthValue, aResult);
}
NS_IMETHODIMP
nsChromeUIDataSource::AddObserver(nsIRDFObserver* aObserver)
{
NS_PRECONDITION(aObserver != nsnull, "null ptr");
if (! aObserver)
return NS_ERROR_NULL_POINTER;
// XXX ensure uniqueness?
mObservers.AppendObject(aObserver);
return NS_OK;
}
NS_IMETHODIMP
nsChromeUIDataSource::RemoveObserver(nsIRDFObserver* aObserver)
{
NS_PRECONDITION(aObserver != nsnull, "null ptr");
if (! aObserver)
return NS_ERROR_NULL_POINTER;
mObservers.RemoveObject(aObserver);
return NS_OK;
}
NS_IMETHODIMP
nsChromeUIDataSource::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *result)
{
return mComposite->HasArcIn(aNode, aArc, result);
}
NS_IMETHODIMP
nsChromeUIDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
{
return mComposite->HasArcOut(aSource, aArc, result);
}
NS_IMETHODIMP
nsChromeUIDataSource::ArcLabelsIn(nsIRDFNode* aTarget, nsISimpleEnumerator** aResult)
{
return mComposite->ArcLabelsIn(aTarget, aResult);
}
NS_IMETHODIMP
nsChromeUIDataSource::ArcLabelsOut(nsIRDFResource* aSource,
nsISimpleEnumerator** aResult)
{
return mComposite->ArcLabelsOut(aSource, aResult);
}
NS_IMETHODIMP
nsChromeUIDataSource::GetAllResources(nsISimpleEnumerator** aResult)
{
return mComposite->GetAllResources(aResult);
}
NS_IMETHODIMP
nsChromeUIDataSource::GetAllCmds(nsIRDFResource* source,
nsISimpleEnumerator/*<nsIRDFResource>*/** result)
{
return mComposite->GetAllCmds(source, result);
}
NS_IMETHODIMP
nsChromeUIDataSource::IsCommandEnabled(nsISupportsArray/*<nsIRDFResource>*/* aSources,
nsIRDFResource* aCommand,
nsISupportsArray/*<nsIRDFResource>*/* aArguments,
PRBool* aResult)
{
return mComposite->IsCommandEnabled(aSources, aCommand, aArguments, aResult);
}
NS_IMETHODIMP
nsChromeUIDataSource::DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSources,
nsIRDFResource* aCommand,
nsISupportsArray/*<nsIRDFResource>*/* aArguments)
{
return mComposite->DoCommand(aSources, aCommand, aArguments);
}
NS_IMETHODIMP
nsChromeUIDataSource::BeginUpdateBatch() {
return mComposite->BeginUpdateBatch();
}
NS_IMETHODIMP
nsChromeUIDataSource::EndUpdateBatch() {
return mComposite->EndUpdateBatch();
}
//////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsChromeUIDataSource::OnAssert(nsIRDFDataSource* aDataSource,
nsIRDFResource* aSource,
nsIRDFResource* aProperty,
nsIRDFNode* aTarget)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = count - 1; i >= 0; --i) {
mObservers[i]->OnAssert(this, aSource, aProperty, aTarget);
}
return NS_OK;
}
NS_IMETHODIMP
nsChromeUIDataSource::OnUnassert(nsIRDFDataSource* aDataSource,
nsIRDFResource* aSource,
nsIRDFResource* aProperty,
nsIRDFNode* aTarget)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = count - 1; i >= 0; --i) {
mObservers[i]->OnUnassert(aDataSource, aSource, aProperty, aTarget);
}
return NS_OK;
}
NS_IMETHODIMP
nsChromeUIDataSource::OnChange(nsIRDFDataSource* aDataSource,
nsIRDFResource* aSource,
nsIRDFResource* aProperty,
nsIRDFNode* aOldTarget,
nsIRDFNode* aNewTarget)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = count - 1; i >= 0; --i) {
mObservers[i]->OnChange(aDataSource, aSource, aProperty, aOldTarget, aNewTarget);
}
return NS_OK;
}
NS_IMETHODIMP
nsChromeUIDataSource::OnMove(nsIRDFDataSource* aDataSource,
nsIRDFResource* aOldSource,
nsIRDFResource* aNewSource,
nsIRDFResource* aProperty,
nsIRDFNode* aTarget)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = count - 1; i >= 0; --i) {
mObservers[i]->OnMove(aDataSource, aOldSource, aNewSource, aProperty, aTarget);
}
return NS_OK;
}
NS_IMETHODIMP
nsChromeUIDataSource::OnBeginUpdateBatch(nsIRDFDataSource* aDataSource)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = count - 1; i >= 0; --i) {
mObservers[i]->OnBeginUpdateBatch(aDataSource);
}
return NS_OK;
}
NS_IMETHODIMP
nsChromeUIDataSource::OnEndUpdateBatch(nsIRDFDataSource* aDataSource)
{
PRInt32 count = mObservers.Count();
for (PRInt32 i = count - 1; i >= 0; --i) {
mObservers[i]->OnEndUpdateBatch(aDataSource);
}
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////////////////
nsresult
NS_NewChromeUIDataSource(nsIRDFDataSource* aComposite, nsIRDFDataSource** aResult)
{
NS_PRECONDITION(aResult != nsnull, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
nsChromeUIDataSource* ChromeUIDataSource = new nsChromeUIDataSource(aComposite);
if (ChromeUIDataSource == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aResult = ChromeUIDataSource);
return NS_OK;
}

Просмотреть файл

@ -1,76 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Original Author: David W. Hyatt (hyatt@netscape.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
class nsIRDFService;
class nsIRDFResource;
class nsICSSLoader;
class nsISimpleEnumerator;
class nsSupportsHashtable;
class nsIRDFContainer;
class nsIDOMWindowInternal;
class nsIDocument;
#include "nsIRDFDataSource.h"
#include "nsIRDFObserver.h"
#include "nsCOMArray.h"
#include "nsCycleCollectionParticipant.h"
class nsChromeUIDataSource : public nsIRDFDataSource, public nsIRDFObserver
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsChromeUIDataSource,
nsIRDFDataSource)
// nsIRDFDataSource methods
NS_DECL_NSIRDFDATASOURCE
// nsIRDFObserver methods
NS_DECL_NSIRDFOBSERVER
// nsChromeUIDataSource methods:
nsChromeUIDataSource(nsIRDFDataSource* aComposite);
virtual ~nsChromeUIDataSource();
protected:
nsCOMPtr<nsIRDFDataSource> mComposite;
nsCOMArray<nsIRDFObserver> mObservers;
nsIRDFService* mRDFService;
};
nsresult NS_NewChromeUIDataSource(nsIRDFDataSource* aComposite, nsIRDFDataSource** aResult);

Просмотреть файл

@ -1,47 +0,0 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = chromereg
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,64 +0,0 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MOZILLA_INTERNAL_API = 1
REQUIRES = xpcom \
content \
necko \
string \
rdf \
$(NULL)
CPPSRCS = regchrome.cpp
SIMPLE_PROGRAMS = $(CPPSRCS:.cpp=$(BIN_SUFFIX))
LIBS = \
$(LIBS_DIR) \
$(XPCOM_LIBS) \
$(NSPR_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,308 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
#include "nsIChromeRegistry.h"
#include "rdf.h"
#include "nsIRDFResource.h"
#include "nsIRDFService.h"
#include "nsIRDFContainer.h"
#include "nsIFile.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsNetUtil.h"
#include "nsString.h"
#include "plgetopt.h"
#include <stdlib.h> // for exit()
static const char uri_prefix[] = "http://www.mozilla.org/rdf/chrome#";
static const char urn_prefix[] = "urn:mozilla:";
// this is nasty - this is in nsChromeRegistry.h, but to include that,
// we double our REQUIRES dependencies. We need the CID rather than
// the ContractID because we need to guarantee that we're getting the
// RDF-based chrome registry in order to build up chrome.rdf
// {D8C7D8A2-E84C-11d2-BF87-00105A1B0627}
#define NS_CHROMEREGISTRY_CID \
{ 0xd8c7d8a2, 0xe84c, 0x11d2, { 0xbf, 0x87, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID);
nsresult
WritePropertiesTo(nsIRDFDataSource*, const char* aProviderType, FILE* out);
nsresult
WriteAttributes(nsIRDFDataSource*, const char* aProviderType, const char* aProvider,
nsIRDFResource* aResource,
FILE* out);
void
TranslateResourceValue(const char* aProviderType,
const char* aProvider,
const char* aArc,
const char* aResourceValue,
nsACString& aResult);
nsresult WriteProperties(const char* properties_file);
void print_help();
int main(int argc, char **argv)
{
const char* properties_filename = nsnull;
PLOptState* optstate = PL_CreateOptState(argc, argv, "p:");
while (PL_GetNextOpt(optstate) == PL_OPT_OK) {
switch (optstate->option) {
case 'p': // output properties file
properties_filename = optstate->value;
break;
case '?':
print_help();
exit(1);
break;
}
}
PL_DestroyOptState(optstate);
NS_InitXPCOM2(nsnull, nsnull, nsnull);
nsCOMPtr <nsIChromeRegistry> chromeReg =
do_GetService(kChromeRegistryCID);
if (!chromeReg) {
NS_WARNING("chrome check couldn't get the chrome registry");
return NS_ERROR_FAILURE;
}
chromeReg->CheckForNewChrome();
// ok, now load the rdf that just got written
if (properties_filename)
WriteProperties(properties_filename);
// release the chrome registry before we shutdown XPCOM
chromeReg = 0;
NS_ShutdownXPCOM(nsnull);
return 0;
}
nsresult
WritePropertiesTo(nsIRDFDataSource* aDataSource,
const char* aProviderType, FILE* out)
{
// attempt to mimic nsXMLRDFDataSource::Flush?
nsCOMPtr<nsIRDFService> rdfService =
do_GetService("@mozilla.org/rdf/rdf-service;1");
nsCOMPtr<nsIRDFResource> providerRoot;
nsCAutoString urn(NS_LITERAL_CSTRING(urn_prefix) +
nsDependentCString(aProviderType) + NS_LITERAL_CSTRING(":root"));
rdfService->GetResource(urn,
getter_AddRefs(providerRoot));
nsCOMPtr<nsIRDFContainer> providerContainer =
do_CreateInstance("@mozilla.org/rdf/container;1");
providerContainer->Init(aDataSource, providerRoot);
nsCOMPtr<nsISimpleEnumerator> providers;
providerContainer->GetElements(getter_AddRefs(providers));
PRBool hasMore;
providers->HasMoreElements(&hasMore);
for (; hasMore; providers->HasMoreElements(&hasMore)) {
nsCOMPtr<nsISupports> supports;
providers->GetNext(getter_AddRefs(supports));
nsCOMPtr<nsIRDFResource> kid = do_QueryInterface(supports);
const char* providerUrn;
kid->GetValueConst(&providerUrn);
// remove the prefix, the provider type, and the trailing ':'
// (the compiler will optimize out the -1 + 1
providerUrn += (sizeof(urn_prefix)-1) + strlen(aProviderType) + 1;
WriteAttributes(aDataSource, aProviderType, providerUrn, kid, out);
}
return NS_OK;
}
nsresult
WriteAttributes(nsIRDFDataSource* aDataSource,
const char* aProviderType,
const char* aProvider,
nsIRDFResource* aResource, FILE* out)
{
nsresult rv;
nsCOMPtr<nsISimpleEnumerator> arcs;
rv = aDataSource->ArcLabelsOut(aResource, getter_AddRefs(arcs));
if (NS_FAILED(rv))
return rv;
PRBool hasMore;
rv = arcs->HasMoreElements(&hasMore);
if (NS_FAILED(rv))
return rv;
for (; hasMore; arcs->HasMoreElements(&hasMore)) {
nsCOMPtr<nsISupports> supports;
arcs->GetNext(getter_AddRefs(supports));
nsCOMPtr<nsIRDFResource> arc = do_QueryInterface(supports);
const char* arcValue;
arc->GetValueConst(&arcValue);
arcValue += (sizeof(uri_prefix)-1); // skip past prefix
// get the literal value on the other end
nsCOMPtr<nsIRDFNode> valueNode;
aDataSource->GetTarget(aResource, arc, PR_TRUE,
getter_AddRefs(valueNode));
nsCOMPtr<nsIRDFLiteral> literal = do_QueryInterface(valueNode);
if (literal) {
const PRUnichar* literalValue;
literal->GetValueConst(&literalValue);
fprintf(out, "%s.%s.%s=%s\n", aProviderType, aProvider, arcValue, NS_ConvertUTF16toUTF8(literalValue).get());
}
nsCOMPtr<nsIRDFResource> resource = do_QueryInterface(valueNode);
if (resource) {
const char* resourceValue;
resource->GetValueConst(&resourceValue);
nsCAutoString translatedValue;
TranslateResourceValue(aProviderType, aProvider,
arcValue, resourceValue, translatedValue);
fprintf(out, "%s.%s.%s=%s\n", aProviderType, aProvider, arcValue, translatedValue.get());
}
}
return NS_OK;
}
nsresult WriteProperties(const char* properties_file)
{
FILE* props;
printf("writing to %s\n", properties_file);
if (!(props = fopen(properties_file, "w"))) {
printf("Could not write to %s\n", properties_file);
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIFile> chromeFile;
nsresult rv = NS_GetSpecialDirectory(NS_APP_CHROME_DIR, getter_AddRefs(chromeFile));
if(NS_FAILED(rv)) {
fclose(props);
return rv;
}
chromeFile->AppendNative(NS_LITERAL_CSTRING("chrome.rdf"));
nsCAutoString pathURL;
NS_GetURLSpecFromFile(chromeFile, pathURL);
nsCOMPtr<nsIRDFService> rdf =
do_GetService("@mozilla.org/rdf/rdf-service;1");
nsCOMPtr<nsIRDFDataSource> chromeDS;
rdf->GetDataSource(pathURL.get(), getter_AddRefs(chromeDS));
WritePropertiesTo(chromeDS, "package", props);
WritePropertiesTo(chromeDS, "skin", props);
WritePropertiesTo(chromeDS, "locale", props);
fclose(props);
return NS_OK;
}
void print_help() {
printf("Usage: regchrome [-p file.properties]\n"
"Registers chrome by scanning installed-chrome.txt\n"
"\n"
"Options: \n"
" -p file.properties Output a flat-file version of the registry to\n"
" the specified file\n");
}
void
TranslateResourceValue(const char* aProviderType,
const char* aProvider,
const char* aArc,
const char* aResourceValue,
nsACString& aResult)
{
PRUint32 chopStart=0, chopEnd=0; // bytes to chop off the front/back of aResourceValue
static const char localeUrn[] = "urn:mozilla:locale:";
if ((strcmp(aArc, "selectedLocale") == 0) &&
(strncmp(aResourceValue, localeUrn, sizeof(localeUrn)-1) == 0)) {
chopStart = sizeof(localeUrn) - 1;
chopEnd = strlen(aProvider) + 1;
}
static const char skinUrn[] = "urn:mozilla:skin:";
if ((strcmp(aArc, "selectedSkin") == 0) &&
(strncmp(aResourceValue, skinUrn, sizeof(skinUrn)-1) == 0)) {
chopStart = sizeof(skinUrn) - 1;
chopEnd = strlen(aProvider) + 1;
}
// strip off 'urn:mozilla:<foo>:' and ':<provider>'
aResult = (aResourceValue + chopStart);
aResult.Truncate(aResult.Length() - chopEnd);
}

Просмотреть файл

@ -458,13 +458,6 @@ MAKEFILES_chrome="
chrome/Makefile
chrome/public/Makefile
chrome/src/Makefile
embedding/minimo/chromelite/Makefile
rdf/chrome/Makefile
rdf/chrome/public/Makefile
rdf/chrome/build/Makefile
rdf/chrome/src/Makefile
rdf/chrome/tools/Makefile
rdf/chrome/tools/chromereg/Makefile
"
MAKEFILES_view="

Просмотреть файл

@ -189,15 +189,7 @@ endif
# "toolkit" was.
#
ifdef MOZ_XUL_APP
tier_toolkit_dirs += chrome
else
ifdef MOZ_XUL
tier_toolkit_dirs += rdf/chrome
else
tier_toolkit_dirs += embedding/minimo/chromelite
endif
endif
tier_toolkit_dirs += profile