зеркало из https://github.com/mozilla/pjs.git
Support for enumeration of skins, packages, and locales nearing completion. r=mini-me
This commit is contained in:
Родитель
61077ebcd9
Коммит
d9edd8611f
|
@ -24,6 +24,7 @@
|
|||
#include "nsIComponentManager.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsIChromeEntry.h"
|
||||
#include "nscore.h"
|
||||
#include "rdf.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -33,6 +34,7 @@
|
|||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
static NS_DEFINE_CID(kGenericFactoryCID, NS_GENERICFACTORY_CID);
|
||||
static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID);
|
||||
static NS_DEFINE_CID(kChromeEntryCID, NS_CHROMEENTRY_CID);
|
||||
static NS_DEFINE_CID(kChromeProtocolHandlerCID, NS_CHROMEPROTOCOLHANDLER_CID);
|
||||
|
||||
static NS_IMETHODIMP
|
||||
|
@ -52,6 +54,24 @@ NS_ConstructChromeRegistry(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
|||
return rv;
|
||||
}
|
||||
|
||||
static NS_IMETHODIMP
|
||||
NS_ConstructChromeEntry(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ASSERTION(aOuter == nsnull, "no aggregation");
|
||||
nsIChromeEntry* chromeEntry;
|
||||
rv = NS_NewChromeEntry(&chromeEntry);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("Unable to construct chrome entry");
|
||||
return rv;
|
||||
}
|
||||
rv = chromeEntry->QueryInterface(aIID, aResult);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to find correct interface");
|
||||
NS_RELEASE(chromeEntry);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
// Module implementation
|
||||
class nsChromeModule : public nsIModule
|
||||
{
|
||||
|
@ -71,6 +91,7 @@ protected:
|
|||
PRBool mInitialized;
|
||||
nsCOMPtr<nsIGenericFactory> mChromeRegistryFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mChromeProtocolHandlerFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mChromeEntryFactory;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -110,6 +131,7 @@ nsChromeModule::Shutdown()
|
|||
// Release the factory objects
|
||||
mChromeRegistryFactory = nsnull;
|
||||
mChromeProtocolHandlerFactory = nsnull;
|
||||
mChromeEntryFactory = nsnull;
|
||||
}
|
||||
|
||||
// Create a factory object for creating instances of aClass.
|
||||
|
@ -150,6 +172,17 @@ nsChromeModule::GetClassObject(nsIComponentManager *aCompMgr,
|
|||
}
|
||||
fact = mChromeRegistryFactory;
|
||||
}
|
||||
else if (aClass.Equals(kChromeEntryCID)) {
|
||||
if (!mChromeEntryFactory) {
|
||||
// Create and save away the factory object for creating
|
||||
// new instances of ChromeRegistry. This way if we are called
|
||||
// again for the factory, we won't need to create a new
|
||||
// one.
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mChromeEntryFactory),
|
||||
NS_ConstructChromeEntry);
|
||||
}
|
||||
fact = mChromeRegistryFactory;
|
||||
}
|
||||
else if (aClass.Equals(kChromeProtocolHandlerCID)) {
|
||||
if (!mChromeProtocolHandlerFactory) {
|
||||
// Create and save away the factory object for creating
|
||||
|
@ -188,7 +221,9 @@ struct Components {
|
|||
// The list of components we register
|
||||
static Components gComponents[] = {
|
||||
{ "Chrome Registry", &kChromeRegistryCID,
|
||||
"component://netscape/chrome", },
|
||||
"component://netscape/chrome/chrome-registry", },
|
||||
{ "Chrome Entry", &kChromeEntryCID,
|
||||
"component://netscape/chrome/chrome-entry", },
|
||||
{ "Chrome Protocol Handler", &kChromeProtocolHandlerCID,
|
||||
NS_NETWORK_PROTOCOL_PROGID_PREFIX "chrome", },
|
||||
};
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "nsFileSpec.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsIChromeEntry.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFObserver.h"
|
||||
#include "nsIRDFRemoteDataSource.h"
|
||||
|
@ -77,7 +78,7 @@ DEFINE_RDF_VOCAB(CHROME_NAMESPACE_URI, CHROME, archive);
|
|||
DEFINE_RDF_VOCAB(CHROME_NAMESPACE_URI, CHROME, theme);
|
||||
DEFINE_RDF_VOCAB(CHROME_NAMESPACE_URI, CHROME, name);
|
||||
|
||||
// This nasty function should disappear when we land Necko completely and
|
||||
// XXX This nasty function should disappear when we land Necko completely and
|
||||
// change chrome://global/skin/foo to chrome://skin@global/foo
|
||||
//
|
||||
void BreakProviderAndRemainingFromPath(const char* i_path, char** o_provider, char** o_remaining);
|
||||
|
@ -234,6 +235,27 @@ NS_IMETHODIMP nsChromeEntryEnumerator::GetNext(nsISupports **aResult)
|
|||
nsCOMPtr<nsISupports> supports;
|
||||
mCurrentArcs->GetNext(getter_AddRefs(supports));
|
||||
|
||||
// The resource that we obtain is the name of the skin/locale/package with
|
||||
// "chrome:" prepended to it. It has arcs to simple literals
|
||||
// for each of the fields that should be in the chrome entry.
|
||||
// We need to construct a chrome entry and then fill in the
|
||||
// values by enumerating the arcs out of our resource (to the
|
||||
// literals)
|
||||
nsCOMPtr<nsIRDFResource> resource = do_QueryInterface(supports, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIChromeEntry> chromeEntry;
|
||||
rv = nsComponentManager::CreateInstance("component://netscape/chrome/chrome-entry",
|
||||
nsnull,
|
||||
NS_GET_IID(nsIChromeEntry),
|
||||
getter_AddRefs(chromeEntry));
|
||||
|
||||
// XXX Now that we have a resource, we must examine all of its outgoing
|
||||
// arcs and use the literals at the ends of the arcs to set the fields
|
||||
// of the chrome entry.
|
||||
|
||||
/*
|
||||
nsCOMPtr<nsIRDFLiteral> value = do_QueryInterface(supports, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
@ -242,15 +264,16 @@ NS_IMETHODIMP nsChromeEntryEnumerator::GetNext(nsISupports **aResult)
|
|||
rv = value->GetValueConst(&valueStr);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
/*
|
||||
*/
|
||||
|
||||
nsCOMPtr<nsISupports> sup;
|
||||
sup = do_QueryInterface(url, &rv);
|
||||
sup = do_QueryInterface(chromeEntry, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
*aResult = sup;
|
||||
NS_ADDREF(*aResult);
|
||||
*/
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -314,6 +337,10 @@ private:
|
|||
|
||||
NS_IMETHOD ProcessStyleSheet(nsIURL* aURL, nsICSSLoader* aLoader, nsIDocument* aDocument);
|
||||
|
||||
NS_IMETHOD GetArcs(nsIRDFDataSource* aDataSource,
|
||||
const nsCAutoString& aType,
|
||||
nsISimpleEnumerator** aResult);
|
||||
|
||||
};
|
||||
|
||||
PRUint32 nsChromeRegistry::gRefCnt ;
|
||||
|
@ -831,22 +858,6 @@ nsChromeRegistry::GetChromeResource(nsIRDFDataSource *aDataSource,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewChromeRegistry(nsIChromeRegistry** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsChromeRegistry* chromeRegistry = new nsChromeRegistry();
|
||||
if (chromeRegistry == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(chromeRegistry);
|
||||
*aResult = chromeRegistry;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
|
@ -1399,7 +1410,6 @@ nsChromeRegistry::GetEnumeratorForType(const nsCAutoString& type, nsISimpleEnume
|
|||
nsCOMPtr<nsIRDFRemoteDataSource> remoteProfile = do_QueryInterface(profileDataSource);
|
||||
nsCOMPtr<nsIRDFRemoteDataSource> remoteInstall = do_QueryInterface(installDataSource);
|
||||
|
||||
nsCAutoString fileURL;
|
||||
nsCOMPtr<nsIFileLocator> fl;
|
||||
|
||||
rv = nsComponentManager::CreateInstance("component://netscape/filelocator",
|
||||
|
@ -1411,12 +1421,10 @@ nsChromeRegistry::GetEnumeratorForType(const nsCAutoString& type, nsISimpleEnume
|
|||
return NS_OK;
|
||||
|
||||
// Build a fileSpec that points to the destination
|
||||
// (profile dir + chrome + package + provider + chrome.rdf)
|
||||
nsCOMPtr<nsIFileSpec> chromeFileInterface;
|
||||
fl->GetFileLocation(nsSpecialFileSpec::App_UserProfileDirectory50, getter_AddRefs(chromeFileInterface));
|
||||
nsFileSpec fileSpec;
|
||||
|
||||
PRBool exists = PR_FALSE;
|
||||
if (chromeFileInterface) {
|
||||
// Read in the profile data source (or try to anyway)
|
||||
chromeFileInterface->GetFileSpec(&fileSpec);
|
||||
|
@ -1439,9 +1447,15 @@ nsChromeRegistry::GetEnumeratorForType(const nsCAutoString& type, nsISimpleEnume
|
|||
remoteInstall->Refresh(PR_TRUE);
|
||||
|
||||
// Get some arcs from each data source.
|
||||
|
||||
// Build an nsChromeEntryEnumerator and return it.
|
||||
nsCOMPtr<nsISimpleEnumerator> profileArcs, installArcs;
|
||||
|
||||
GetArcs(profileDataSource, type, getter_AddRefs(profileArcs));
|
||||
GetArcs(installDataSource, type, getter_AddRefs(installArcs));
|
||||
|
||||
// Build an nsChromeEntryEnumerator and return it.
|
||||
*aResult = new nsChromeEntryEnumerator(profileArcs, installArcs);
|
||||
NS_ADDREF(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1465,3 +1479,56 @@ nsChromeRegistry::GetLocales(nsISimpleEnumerator** aResult)
|
|||
nsCAutoString type("locales");
|
||||
return GetEnumeratorForType(type, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::GetArcs(nsIRDFDataSource* aDataSource,
|
||||
const nsCAutoString& aType,
|
||||
nsISimpleEnumerator** aResult)
|
||||
{
|
||||
nsCOMPtr<nsIRDFContainer> container;
|
||||
nsresult rv = nsComponentManager::CreateInstance("component://netscape/rdf/container",
|
||||
nsnull,
|
||||
NS_GET_IID(nsIRDFContainer),
|
||||
getter_AddRefs(container));
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
nsCAutoString lookup("chrome:");
|
||||
lookup += aType;
|
||||
|
||||
// Get the chromeResource from this lookup string
|
||||
nsCOMPtr<nsIRDFResource> chromeResource;
|
||||
if (NS_FAILED(rv = GetPackageTypeResource(lookup, getter_AddRefs(chromeResource)))) {
|
||||
NS_ERROR("Unable to retrieve the resource corresponding to the chrome skin or content.");
|
||||
return rv;
|
||||
}
|
||||
nsAllocator::Free(lookup);
|
||||
|
||||
if (NS_FAILED(container->Init(aDataSource, chromeResource)))
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> arcs;
|
||||
if (NS_FAILED(container->GetElements(getter_AddRefs(arcs))))
|
||||
return NS_OK;
|
||||
|
||||
*aResult = arcs;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewChromeRegistry(nsIChromeRegistry** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsChromeRegistry* chromeRegistry = new nsChromeRegistry();
|
||||
if (chromeRegistry == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(chromeRegistry);
|
||||
*aResult = chromeRegistry;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "nsIComponentManager.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsIChromeEntry.h"
|
||||
#include "nscore.h"
|
||||
#include "rdf.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -33,6 +34,7 @@
|
|||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
static NS_DEFINE_CID(kGenericFactoryCID, NS_GENERICFACTORY_CID);
|
||||
static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID);
|
||||
static NS_DEFINE_CID(kChromeEntryCID, NS_CHROMEENTRY_CID);
|
||||
static NS_DEFINE_CID(kChromeProtocolHandlerCID, NS_CHROMEPROTOCOLHANDLER_CID);
|
||||
|
||||
static NS_IMETHODIMP
|
||||
|
@ -52,6 +54,24 @@ NS_ConstructChromeRegistry(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
|||
return rv;
|
||||
}
|
||||
|
||||
static NS_IMETHODIMP
|
||||
NS_ConstructChromeEntry(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ASSERTION(aOuter == nsnull, "no aggregation");
|
||||
nsIChromeEntry* chromeEntry;
|
||||
rv = NS_NewChromeEntry(&chromeEntry);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("Unable to construct chrome entry");
|
||||
return rv;
|
||||
}
|
||||
rv = chromeEntry->QueryInterface(aIID, aResult);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to find correct interface");
|
||||
NS_RELEASE(chromeEntry);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
// Module implementation
|
||||
class nsChromeModule : public nsIModule
|
||||
{
|
||||
|
@ -71,6 +91,7 @@ protected:
|
|||
PRBool mInitialized;
|
||||
nsCOMPtr<nsIGenericFactory> mChromeRegistryFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mChromeProtocolHandlerFactory;
|
||||
nsCOMPtr<nsIGenericFactory> mChromeEntryFactory;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -110,6 +131,7 @@ nsChromeModule::Shutdown()
|
|||
// Release the factory objects
|
||||
mChromeRegistryFactory = nsnull;
|
||||
mChromeProtocolHandlerFactory = nsnull;
|
||||
mChromeEntryFactory = nsnull;
|
||||
}
|
||||
|
||||
// Create a factory object for creating instances of aClass.
|
||||
|
@ -150,6 +172,17 @@ nsChromeModule::GetClassObject(nsIComponentManager *aCompMgr,
|
|||
}
|
||||
fact = mChromeRegistryFactory;
|
||||
}
|
||||
else if (aClass.Equals(kChromeEntryCID)) {
|
||||
if (!mChromeEntryFactory) {
|
||||
// Create and save away the factory object for creating
|
||||
// new instances of ChromeRegistry. This way if we are called
|
||||
// again for the factory, we won't need to create a new
|
||||
// one.
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(mChromeEntryFactory),
|
||||
NS_ConstructChromeEntry);
|
||||
}
|
||||
fact = mChromeRegistryFactory;
|
||||
}
|
||||
else if (aClass.Equals(kChromeProtocolHandlerCID)) {
|
||||
if (!mChromeProtocolHandlerFactory) {
|
||||
// Create and save away the factory object for creating
|
||||
|
@ -188,7 +221,9 @@ struct Components {
|
|||
// The list of components we register
|
||||
static Components gComponents[] = {
|
||||
{ "Chrome Registry", &kChromeRegistryCID,
|
||||
"component://netscape/chrome", },
|
||||
"component://netscape/chrome/chrome-registry", },
|
||||
{ "Chrome Entry", &kChromeEntryCID,
|
||||
"component://netscape/chrome/chrome-entry", },
|
||||
{ "Chrome Protocol Handler", &kChromeProtocolHandlerCID,
|
||||
NS_NETWORK_PROTOCOL_PROGID_PREFIX "chrome", },
|
||||
};
|
||||
|
|
|
@ -25,13 +25,21 @@
|
|||
[scriptable, uuid(C0E45041-A6C6-11d3-97FB-00400553EEF0)]
|
||||
interface nsIChromeEntry : nsISupports
|
||||
{
|
||||
readonly attribute wstring name;
|
||||
readonly attribute wstring displayText;
|
||||
readonly attribute wstring versionNumber;
|
||||
readonly attribute wstring author;
|
||||
readonly attribute wstring siteURL;
|
||||
readonly attribute wstring previewImageURL;
|
||||
attribute wstring name;
|
||||
attribute wstring displayText;
|
||||
attribute wstring versionNumber;
|
||||
attribute wstring author;
|
||||
attribute wstring siteURL;
|
||||
attribute wstring previewImageURL;
|
||||
};
|
||||
|
||||
%{ C++
|
||||
|
||||
// {96CF5BC2-A715-11d3-97FB-00400553EEF0}
|
||||
#define NS_CHROMEENTRY_CID \
|
||||
{ 0x96cf5bc2, 0xa715, 0x11d3, { 0x97, 0xfb, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } }
|
||||
|
||||
extern nsresult
|
||||
NS_NewChromeEntry(nsIChromeEntry** aResult);
|
||||
|
||||
%}
|
||||
|
|
|
@ -33,6 +33,7 @@ REQUIRES = chrome netlib rdf rdfutil raptor xpcom
|
|||
|
||||
CPPSRCS = \
|
||||
nsChromeRegistry.cpp \
|
||||
nsChromeEntry.cpp \
|
||||
nsChromeProtocolHandler.cpp \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ LIBRARY_NAME=chrome_s
|
|||
|
||||
CPP_OBJS=\
|
||||
.\$(OBJDIR)\nsChromeRegistry.obj \
|
||||
.\$(OBJDIR)\nsChromeEntry.obj \
|
||||
.\$(OBJDIR)\nsChromeProtocolHandler.obj \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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 Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIChromeEntry.h"
|
||||
|
||||
class nsChromeEntry : public nsIChromeEntry
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIChromeEntry methods:
|
||||
NS_DECL_NSICHROMEENTRY
|
||||
|
||||
// nsChromeEntry methods:
|
||||
nsChromeEntry();
|
||||
virtual ~nsChromeEntry();
|
||||
|
||||
protected:
|
||||
// Member vars
|
||||
};
|
||||
|
||||
nsChromeEntry::nsChromeEntry()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsChromeEntry::~nsChromeEntry()
|
||||
{}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsChromeEntry, nsIChromeEntry)
|
||||
|
||||
/* attribute wstring name; */
|
||||
NS_IMETHODIMP nsChromeEntry::GetName(PRUnichar * *aName) { return NS_OK; }
|
||||
NS_IMETHODIMP nsChromeEntry::SetName(const PRUnichar * aName) { return NS_OK; }
|
||||
|
||||
/* attribute wstring displayText; */
|
||||
NS_IMETHODIMP nsChromeEntry::GetDisplayText(PRUnichar * *aDisplayText) { return NS_OK; }
|
||||
NS_IMETHODIMP nsChromeEntry::SetDisplayText(const PRUnichar * aDisplayText) { return NS_OK; }
|
||||
|
||||
/* attribute wstring versionNumber; */
|
||||
NS_IMETHODIMP nsChromeEntry::GetVersionNumber(PRUnichar * *aVersionNumber) { return NS_OK; }
|
||||
NS_IMETHODIMP nsChromeEntry::SetVersionNumber(const PRUnichar * aVersionNumber) { return NS_OK; }
|
||||
|
||||
/* attribute wstring author; */
|
||||
NS_IMETHODIMP nsChromeEntry::GetAuthor(PRUnichar * *aAuthor) { return NS_OK; }
|
||||
NS_IMETHODIMP nsChromeEntry::SetAuthor(const PRUnichar * aAuthor) { return NS_OK; }
|
||||
|
||||
/* attribute wstring siteURL; */
|
||||
NS_IMETHODIMP nsChromeEntry::GetSiteURL(PRUnichar * *aSiteURL) { return NS_OK; }
|
||||
NS_IMETHODIMP nsChromeEntry::SetSiteURL(const PRUnichar * aSiteURL) { return NS_OK; }
|
||||
|
||||
/* attribute wstring previewImageURL; */
|
||||
NS_IMETHODIMP nsChromeEntry::GetPreviewImageURL(PRUnichar * *aPreviewImageURL) { return NS_OK; }
|
||||
NS_IMETHODIMP nsChromeEntry::SetPreviewImageURL(const PRUnichar * aPreviewImageURL) { return NS_OK; }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewChromeEntry(nsIChromeEntry** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsChromeEntry* chromeEntry = new nsChromeEntry();
|
||||
if (chromeEntry == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(chromeEntry);
|
||||
*aResult = chromeEntry;
|
||||
return NS_OK;
|
||||
}
|
|
@ -24,6 +24,7 @@
|
|||
#include "nsFileSpec.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsIChromeEntry.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFObserver.h"
|
||||
#include "nsIRDFRemoteDataSource.h"
|
||||
|
@ -77,7 +78,7 @@ DEFINE_RDF_VOCAB(CHROME_NAMESPACE_URI, CHROME, archive);
|
|||
DEFINE_RDF_VOCAB(CHROME_NAMESPACE_URI, CHROME, theme);
|
||||
DEFINE_RDF_VOCAB(CHROME_NAMESPACE_URI, CHROME, name);
|
||||
|
||||
// This nasty function should disappear when we land Necko completely and
|
||||
// XXX This nasty function should disappear when we land Necko completely and
|
||||
// change chrome://global/skin/foo to chrome://skin@global/foo
|
||||
//
|
||||
void BreakProviderAndRemainingFromPath(const char* i_path, char** o_provider, char** o_remaining);
|
||||
|
@ -234,6 +235,27 @@ NS_IMETHODIMP nsChromeEntryEnumerator::GetNext(nsISupports **aResult)
|
|||
nsCOMPtr<nsISupports> supports;
|
||||
mCurrentArcs->GetNext(getter_AddRefs(supports));
|
||||
|
||||
// The resource that we obtain is the name of the skin/locale/package with
|
||||
// "chrome:" prepended to it. It has arcs to simple literals
|
||||
// for each of the fields that should be in the chrome entry.
|
||||
// We need to construct a chrome entry and then fill in the
|
||||
// values by enumerating the arcs out of our resource (to the
|
||||
// literals)
|
||||
nsCOMPtr<nsIRDFResource> resource = do_QueryInterface(supports, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIChromeEntry> chromeEntry;
|
||||
rv = nsComponentManager::CreateInstance("component://netscape/chrome/chrome-entry",
|
||||
nsnull,
|
||||
NS_GET_IID(nsIChromeEntry),
|
||||
getter_AddRefs(chromeEntry));
|
||||
|
||||
// XXX Now that we have a resource, we must examine all of its outgoing
|
||||
// arcs and use the literals at the ends of the arcs to set the fields
|
||||
// of the chrome entry.
|
||||
|
||||
/*
|
||||
nsCOMPtr<nsIRDFLiteral> value = do_QueryInterface(supports, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
@ -242,15 +264,16 @@ NS_IMETHODIMP nsChromeEntryEnumerator::GetNext(nsISupports **aResult)
|
|||
rv = value->GetValueConst(&valueStr);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
/*
|
||||
*/
|
||||
|
||||
nsCOMPtr<nsISupports> sup;
|
||||
sup = do_QueryInterface(url, &rv);
|
||||
sup = do_QueryInterface(chromeEntry, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
*aResult = sup;
|
||||
NS_ADDREF(*aResult);
|
||||
*/
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -314,6 +337,10 @@ private:
|
|||
|
||||
NS_IMETHOD ProcessStyleSheet(nsIURL* aURL, nsICSSLoader* aLoader, nsIDocument* aDocument);
|
||||
|
||||
NS_IMETHOD GetArcs(nsIRDFDataSource* aDataSource,
|
||||
const nsCAutoString& aType,
|
||||
nsISimpleEnumerator** aResult);
|
||||
|
||||
};
|
||||
|
||||
PRUint32 nsChromeRegistry::gRefCnt ;
|
||||
|
@ -831,22 +858,6 @@ nsChromeRegistry::GetChromeResource(nsIRDFDataSource *aDataSource,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewChromeRegistry(nsIChromeRegistry** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsChromeRegistry* chromeRegistry = new nsChromeRegistry();
|
||||
if (chromeRegistry == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(chromeRegistry);
|
||||
*aResult = chromeRegistry;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
|
@ -1399,7 +1410,6 @@ nsChromeRegistry::GetEnumeratorForType(const nsCAutoString& type, nsISimpleEnume
|
|||
nsCOMPtr<nsIRDFRemoteDataSource> remoteProfile = do_QueryInterface(profileDataSource);
|
||||
nsCOMPtr<nsIRDFRemoteDataSource> remoteInstall = do_QueryInterface(installDataSource);
|
||||
|
||||
nsCAutoString fileURL;
|
||||
nsCOMPtr<nsIFileLocator> fl;
|
||||
|
||||
rv = nsComponentManager::CreateInstance("component://netscape/filelocator",
|
||||
|
@ -1411,12 +1421,10 @@ nsChromeRegistry::GetEnumeratorForType(const nsCAutoString& type, nsISimpleEnume
|
|||
return NS_OK;
|
||||
|
||||
// Build a fileSpec that points to the destination
|
||||
// (profile dir + chrome + package + provider + chrome.rdf)
|
||||
nsCOMPtr<nsIFileSpec> chromeFileInterface;
|
||||
fl->GetFileLocation(nsSpecialFileSpec::App_UserProfileDirectory50, getter_AddRefs(chromeFileInterface));
|
||||
nsFileSpec fileSpec;
|
||||
|
||||
PRBool exists = PR_FALSE;
|
||||
if (chromeFileInterface) {
|
||||
// Read in the profile data source (or try to anyway)
|
||||
chromeFileInterface->GetFileSpec(&fileSpec);
|
||||
|
@ -1439,9 +1447,15 @@ nsChromeRegistry::GetEnumeratorForType(const nsCAutoString& type, nsISimpleEnume
|
|||
remoteInstall->Refresh(PR_TRUE);
|
||||
|
||||
// Get some arcs from each data source.
|
||||
|
||||
// Build an nsChromeEntryEnumerator and return it.
|
||||
nsCOMPtr<nsISimpleEnumerator> profileArcs, installArcs;
|
||||
|
||||
GetArcs(profileDataSource, type, getter_AddRefs(profileArcs));
|
||||
GetArcs(installDataSource, type, getter_AddRefs(installArcs));
|
||||
|
||||
// Build an nsChromeEntryEnumerator and return it.
|
||||
*aResult = new nsChromeEntryEnumerator(profileArcs, installArcs);
|
||||
NS_ADDREF(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1465,3 +1479,56 @@ nsChromeRegistry::GetLocales(nsISimpleEnumerator** aResult)
|
|||
nsCAutoString type("locales");
|
||||
return GetEnumeratorForType(type, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeRegistry::GetArcs(nsIRDFDataSource* aDataSource,
|
||||
const nsCAutoString& aType,
|
||||
nsISimpleEnumerator** aResult)
|
||||
{
|
||||
nsCOMPtr<nsIRDFContainer> container;
|
||||
nsresult rv = nsComponentManager::CreateInstance("component://netscape/rdf/container",
|
||||
nsnull,
|
||||
NS_GET_IID(nsIRDFContainer),
|
||||
getter_AddRefs(container));
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
nsCAutoString lookup("chrome:");
|
||||
lookup += aType;
|
||||
|
||||
// Get the chromeResource from this lookup string
|
||||
nsCOMPtr<nsIRDFResource> chromeResource;
|
||||
if (NS_FAILED(rv = GetPackageTypeResource(lookup, getter_AddRefs(chromeResource)))) {
|
||||
NS_ERROR("Unable to retrieve the resource corresponding to the chrome skin or content.");
|
||||
return rv;
|
||||
}
|
||||
nsAllocator::Free(lookup);
|
||||
|
||||
if (NS_FAILED(container->Init(aDataSource, chromeResource)))
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> arcs;
|
||||
if (NS_FAILED(container->GetElements(getter_AddRefs(arcs))))
|
||||
return NS_OK;
|
||||
|
||||
*aResult = arcs;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewChromeRegistry(nsIChromeRegistry** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsChromeRegistry* chromeRegistry = new nsChromeRegistry();
|
||||
if (chromeRegistry == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(chromeRegistry);
|
||||
*aResult = chromeRegistry;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче