Back to index

lightning-sunbird  0.9+nobinonly
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
nsChromeRegistry Class Reference

#include <nsChromeRegistry.h>

Inheritance diagram for nsChromeRegistry:
Inheritance graph
[legend]
Collaboration diagram for nsChromeRegistry:
Collaboration graph
[legend]

List of all members.

Classes

class  nsProviderArray
class  OverlayListEntry
class  OverlayListHash
struct  PackageEntry
struct  ProviderEntry

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSICHROMEREGISTRY
NS_DECL_NSIXULCHROMEREGISTRY
NS_DECL_NSITOOLKITCHROMEREGISTRY
NS_DECL_NSIXULOVERLAYPROVIDER
NS_DECL_NSIOBSERVER 
nsChromeRegistry ()
 ~nsChromeRegistry ()
nsresult Init ()
NS_DECL_ISUPPORTS
NS_DECL_NSICHROMEREGISTRY
NS_DECL_NSIXULCHROMEREGISTRY
NS_DECL_NSIXULOVERLAYPROVIDER
NS_DECL_NSICHROMEREGISTRYSEA
NS_DECL_NSIOBSERVER 
nsChromeRegistry ()
virtual ~nsChromeRegistry ()
nsresult Init ()
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)
void selectLocaleForProfile (in ACString localeName, in wstring profilePath)
void selectSkinForProfile (in ACString skinName, in wstring profilePath)
void setRuntimeProvider (in boolean runtimeProvider)
boolean checkThemeVersion (in ACString skinName)
boolean checkLocaleVersion (in ACString localeName)
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)
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)
void setAllowOverlaysForPackage (in wstring packageName, in boolean allowOverlays)
void reloadChrome ()
ACString getSelectedLocale (in ACString packageName)
void refreshSkins ()
boolean allowScriptsForPackage (in nsIURI url)
 Installable skin XBL is not always granted the same privileges as other chrome.
nsIURI convertChromeURL (in nsIURI aChromeURL)
 Resolve a chrome URL to an loadable URI using the information in the registry.
void checkForNewChrome ()
 refresh the chrome list at runtime, looking for new packages/etc
nsISimpleEnumerator getXULOverlays (in nsIURI aURI)
 Get the XUL overlays for a particular chrome URI.
nsISimpleEnumerator getStyleOverlays (in nsIURI aURI)
 Get the style overlays for a particular chrome URI.
void observe (in nsISupports aSubject, in string aTopic, in wstring aData)
 Observe will be called when there is a notification for the topic |aTopic|.
void processContentsManifest (in nsIURI aOldManifestURI, in nsIURI aFile, in nsIURI aBaseURI, in boolean aAppend, in boolean aSkinOnly)
 The "canonical" manifest is a plaintext file which sits outside of a JAR file.
void checkForOSAccessibility ()
 If the OS has a "high-visibility" or "disabled-friendly" theme set, we want to force mozilla into the classic theme, which (for the most part obeys the system color/font settings.
nsIUTF8StringEnumerator getLocalesForPackage (in AUTF8String aPackage)
 Get a list of locales available for the specified package.

Static Public Member Functions

static nsresult Canonify (nsIURL *aChromeURL)
static nsresult Canonify (nsIURI *aChromeURL)
static nsresult FollowArc (nsIRDFDataSource *aDataSource, nsACString &aResult, nsIRDFResource *aChromeResource, nsIRDFResource *aProperty)
static nsresult UpdateArc (nsIRDFDataSource *aDataSource, nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aRemove)

Public Attributes

const PRInt32 NONE = 0
const PRInt32 PARTIAL = 1
const PRInt32 FULL = 2

Static Public Attributes

static nsChromeRegistrygChromeRegistry

Protected Member Functions

nsresult GetDynamicInfo (nsIURI *aChromeURL, PRBool aIsOverlay, nsISimpleEnumerator **aResult)
nsresult LoadInstallDataSource ()
nsresult LoadProfileDataSource ()
void FlushSkinCaches ()
void FlushAllCaches ()
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 aAllowUnsafeRules, nsICSSStyleSheet **aSheet)
nsresult LoadInstallDataSource ()
nsresult LoadProfileDataSource ()
void FlushSkinCaches ()
void FlushAllCaches ()

Static Protected Member Functions

static nsresult LoadStyleSheetWithURL (nsIURI *aURL, PRBool aAllowUnsafeRules, nsICSSStyleSheet **aSheet)

Protected Attributes

nsCString mProfileRoot
nsCString mInstallRoot
nsCOMPtr
< nsIRDFCompositeDataSource
mChromeDataSource
nsCOMPtr< nsIRDFDataSourcemInstallDirChromeDataSource
nsCOMPtr< nsIRDFDataSourcemUIDataSource
nsSupportsHashtable * mDataSourceTable
nsIRDFServicemRDFService
nsIRDFContainerUtilsmRDFContainerUtils
nsCOMPtr< nsIRDFResourcemSelectedSkin
nsCOMPtr< nsIRDFResourcemSelectedLocale
nsCOMPtr< nsIRDFResourcemBaseURL
nsCOMPtr< nsIRDFResourcemPackages
nsCOMPtr< nsIRDFResourcemPackage
nsCOMPtr< nsIRDFResourcemName
nsCOMPtr< nsIRDFResourcemImage
nsCOMPtr< nsIRDFResourcemLocType
nsCOMPtr< nsIRDFResourcemAllowScripts
nsCOMPtr< nsIRDFResourcemHasOverlays
nsCOMPtr< nsIRDFResourcemHasStylesheets
nsCOMPtr< nsIRDFResourcemSkinVersion
nsCOMPtr< nsIRDFResourcemLocaleVersion
nsCOMPtr< nsIRDFResourcemPackageVersion
nsCOMPtr< nsIRDFResourcemDisabled
nsCOMPtr< nsIRDFResourcemXPCNativeWrappers
nsCOMPtr< nsIZipReadermOverrideJAR
nsCString mOverrideJARURL
PRPackedBool mInstallInitialized
PRPackedBool mProfileInitialized
PRPackedBool mRuntimeProvider
PRPackedBool mBatchInstallFlushes
PRPackedBool mSearchedForOverride
PRPackedBool mLegacyOverlayinfo

Static Protected Attributes

static nsIAtomsCPrefix

Private Member Functions

 NS_HIDDEN_ (void) ProcessProvider(PRFileDesc *fd
 NS_HIDDEN_ (void) ProcessOverlays(PRFileDesc *fd
 NS_HIDDEN_ (nsresult) ProcessManifest(nsILocalFile *aManifest
 NS_HIDDEN_ (nsresult) ProcessManifestBuffer(char *aBuffer
 NS_HIDDEN_ (nsresult) ProcessNewChromeFile(nsILocalFile *aListFile
 NS_HIDDEN_ (nsresult) ProcessNewChromeBuffer(char *aBuffer
nsresult LoadDataSource (const nsACString &aFileName, nsIRDFDataSource **aResult, PRBool aUseProfileDirOnly=PR_FALSE, const char *aProfilePath=nsnull)
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)

Static Private Member Functions

static nsresult RefreshWindow (nsIDOMWindowInternal *aWindow)
static nsresult GetProviderAndPath (nsIURL *aChromeURL, nsACString &aProvider, nsACString &aPath)
static const voidGetKey (PLDHashTable *table, PLDHashEntryHdr *entry)
static PLDHashNumber HashKey (PLDHashTable *table, const void *key)
static PRBool MatchKey (PLDHashTable *table, const PLDHashEntryHdr *entry, const void *key)
static void ClearEntry (PLDHashTable *table, PLDHashEntryHdr *entry)
static PRBool InitEntry (PLDHashTable *table, PLDHashEntryHdr *entry, const void *key)
static nsresult GetProfileRoot (nsACString &aFileURL)
static nsresult GetInstallRoot (nsIFile **aFileURL)

Private Attributes

nsIRDFServiceaRDFs
nsIRDFService nsIRDFDataSourceds
nsIRDFService nsIRDFDataSource
nsIRDFResource
aRoot
nsIRDFService nsIRDFDataSource
nsIRDFResource PRBool 
aIsLocale
nsIRDFService nsIRDFDataSource
nsIRDFResource PRBool const
nsACString & 
aBaseURL
nsIRDFDataSourceds
nsIRDFDataSource nsIRDFResourceaRoot
nsIRDFDataSource
nsIRDFResource const
nsCSubstring
aType
PRBool aSkinOnly
PRInt32 aLength
PRInt32 nsILocalFileaManifest
PRInt32 nsILocalFile PRBool aSkinOnly
nsIURIaManifest
PRInt32 nsIURIaManifest
PRBool mInitialized
PLDHashTable mPackagesHash
OverlayListHash mOverlayHash
OverlayListHash mStyleHash
nsInterfaceHashtable
< nsURIHashKey, nsIURI
mOverrideTable
nsCString mSelectedLocale
nsCString mSelectedSkin

Static Private Attributes

static const PLDHashTableOps kTableOps

Detailed Description

Definition at line 70 of file nsChromeRegistry.h.


Constructor & Destructor Documentation

Definition at line 87 of file nsChromeRegistry.h.

Definition at line 424 of file nsChromeRegistry.cpp.

Here is the call graph for this function:

NS_DECL_ISUPPORTS NS_DECL_NSICHROMEREGISTRY NS_DECL_NSIXULCHROMEREGISTRY NS_DECL_NSIXULOVERLAYPROVIDER NS_DECL_NSICHROMEREGISTRYSEA NS_DECL_NSIOBSERVER nsChromeRegistry::nsChromeRegistry ( )
virtual nsChromeRegistry::~nsChromeRegistry ( ) [virtual]

Member Function Documentation

Definition at line 2959 of file nsChromeRegistry.cpp.

{
  nsresult rv = NS_OK;
  if (!mChromeDataSource) {
    mChromeDataSource = do_CreateInstance(
        "@mozilla.org/rdf/datasource;1?name=composite-datasource", &rv);
    if (NS_FAILED(rv))
      return rv;

    // Also create and hold on to our UI data source.
    rv = NS_NewChromeUIDataSource(mChromeDataSource, getter_AddRefs(mUIDataSource));
    if (NS_FAILED(rv)) return rv;
  }

  if (aUseProfile) {
    // Profiles take precedence.  Load them first.
    nsCOMPtr<nsIRDFDataSource> dataSource;
    LoadDataSource(kChromeFileName, getter_AddRefs(dataSource), PR_TRUE, nsnull);
    mChromeDataSource->AddDataSource(dataSource);
  }

  // Always load the install dir datasources
  LoadDataSource(kChromeFileName, getter_AddRefs(mInstallDirChromeDataSource), PR_FALSE, nsnull);
  mChromeDataSource->AddDataSource(mInstallDirChromeDataSource);

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Installable skin XBL is not always granted the same privileges as other chrome.

This asks the chrome registry whether scripts are allowed to be run for a particular chrome URI. Do not pass non-chrome URIs to this method.

nsresult nsChromeRegistry::Canonify ( nsIURI aChromeURL) [static]

Definition at line 463 of file nsChromeRegistry.cpp.

{
  // Canonicalize 'chrome:' URLs. We'll take any 'chrome:' URL
  // without a filename, and change it to a URL -with- a filename;
  // e.g., "chrome://navigator/content" to
  // "chrome://navigator/content/navigator.xul".
  if (! aChromeURI)
      return NS_ERROR_NULL_POINTER;

  PRBool modified = PR_TRUE; // default is we do canonification
  nsCAutoString package, provider, file;
  nsresult rv;
  rv = SplitURL(aChromeURI, package, provider, file, &modified);
  if (NS_FAILED(rv))
    return rv;

  if (!modified)
    return NS_OK;

  nsCAutoString canonical( kChromePrefix );
  canonical += package;
  canonical += "/";
  canonical += provider;
  canonical += "/";
  canonical += file;

  return aChromeURI->SetSpec(canonical);
}

Here is the call graph for this function:

nsresult nsChromeRegistry::Canonify ( nsIURL aChromeURL) [static]

Definition at line 637 of file nsChromeRegistry.cpp.

{
  NS_NAMED_LITERAL_CSTRING(kSlash, "/");

  nsresult rv;

  nsCAutoString provider, path;
  rv = GetProviderAndPath(aChromeURL, provider, path);
  NS_ENSURE_SUCCESS(rv, rv);

  if (path.IsEmpty()) {
    nsCAutoString package;
    rv = aChromeURL->GetHost(package);
    NS_ENSURE_SUCCESS(rv, rv);

    // we re-use the "path" local string to build a new URL path
    path.Assign(kSlash + provider + kSlash + package);
    if (provider.EqualsLiteral("content")) {
      path.AppendLiteral(".xul");
    }
    else if (provider.EqualsLiteral("locale")) {
      path.AppendLiteral(".dtd");
    }
    else if (provider.EqualsLiteral("skin")) {
      path.AppendLiteral(".css");
    }
    else {
      return NS_ERROR_INVALID_ARG;
    }
    aChromeURL->SetPath(path);
  }
  else {
    // prevent directory traversals ("..")
    // path is already unescaped once, but uris can get unescaped twice
    const char* pos = path.BeginReading();
    const char* end = path.EndReading();
    while (pos < end) {
      switch (*pos) {
        case ':':
          return NS_ERROR_DOM_BAD_URI;
        case '.':
          if (pos[1] == '.')
            return NS_ERROR_DOM_BAD_URI;
          break;
        case '%':
          // chrome: URIs with double-escapes are trying to trick us.
          // watch for %2e, and %25 in case someone triple unescapes
          if (pos[1] == '2' &&
               ( pos[2] == 'e' || pos[2] == 'E' || 
                 pos[2] == '5' ))
            return NS_ERROR_DOM_BAD_URI;
          break;
        case '?':
        case '#':
          // ignore query or ref part, we're done
          pos = end;
          continue;
      }
      ++pos;
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

refresh the chrome list at runtime, looking for new packages/etc

If the OS has a "high-visibility" or "disabled-friendly" theme set, we want to force mozilla into the classic theme, which (for the most part obeys the system color/font settings.

We cannot do this at initialization, because it depends on the toolkit (GTK2) being initialized, which is not the case in some embedding situations. Embedders have to manually call this method during the startup process.

boolean nsIChromeRegistrySea::checkLocaleVersion ( in ACString  localeName) [inherited]
nsresult nsChromeRegistry::CheckProviderVersion ( const nsACString &  aProviderType,
const nsACString &  aProviderName,
nsIRDFResource aSelectionArc,
PRBool aCompatible 
) [private]

Definition at line 3433 of file nsChromeRegistry.cpp.

{
  *aCompatible = PR_TRUE;

  // Build the provider resource str.
  // e.g., urn:mozilla:skin:aqua/1.0
  nsCAutoString resourceStr( "urn:mozilla:" );
  resourceStr += aProviderType;
  resourceStr += ":";
  resourceStr += aProviderName;

  // Obtain the provider resource.
  nsresult rv = NS_OK;
  nsCOMPtr<nsIRDFResource> resource;
  rv = GetResource(resourceStr, getter_AddRefs(resource));
  if (NS_FAILED(rv)) {
    NS_ERROR("Unable to obtain the package resource.");
    return rv;
  }

  // Follow the packages arc to the package resources.
  nsCOMPtr<nsIRDFNode> packageList;
  rv = mChromeDataSource->GetTarget(resource, mPackages, PR_TRUE, getter_AddRefs(packageList));
  if (NS_FAILED(rv)) {
    NS_ERROR("Unable to obtain the SEQ for the package list.");
    return rv;
  }
  // ok for packageList to be null here -- it just means that we haven't encountered that package yet

  nsCOMPtr<nsIRDFResource> packageSeq(do_QueryInterface(packageList, &rv));
  if (NS_FAILED(rv)) return rv;

  // Build an RDF container to wrap the SEQ
  nsCOMPtr<nsIRDFContainer> container =
      do_CreateInstance("@mozilla.org/rdf/container;1", &rv);
  if (NS_FAILED(rv))
    return rv;

  rv = container->Init(mChromeDataSource, packageSeq);
  if (NS_FAILED(rv))
    return rv;

  nsCOMPtr<nsISimpleEnumerator> arcs;

  rv = container->GetElements(getter_AddRefs(arcs));
  if (NS_FAILED(rv))
    return NS_OK;

  // For each skin-package entry, follow the arcs to the real package
  // resource.
  PRBool more;
  rv = arcs->HasMoreElements(&more);
  if (NS_FAILED(rv)) return rv;
  while (more) {
    nsCOMPtr<nsISupports> packageSkinEntry;
    rv = arcs->GetNext(getter_AddRefs(packageSkinEntry));
    if (NS_SUCCEEDED(rv) && packageSkinEntry) {
      nsCOMPtr<nsIRDFResource> entry = do_QueryInterface(packageSkinEntry);
      if (entry) {
        // Obtain the real package resource.
        nsCOMPtr<nsIRDFNode> packageNode;
        rv = mChromeDataSource->GetTarget(entry, mPackage, PR_TRUE, getter_AddRefs(packageNode));
        if (NS_FAILED(rv)) {
          NS_ERROR("Unable to obtain the package resource.");
          return rv;
        }

        nsCOMPtr<nsIRDFResource> packageResource(do_QueryInterface(packageNode));
        if (packageResource) {
          nsCOMPtr<nsIRDFNode> packageNameNode;
          mChromeDataSource->GetTarget(packageResource, mName, PR_TRUE,
                                       getter_AddRefs(packageNameNode));

          if (packageNameNode) {
            nsCOMPtr<nsIRDFNode> packageVersionNode;
            mChromeDataSource->GetTarget(packageResource, aSelectionArc, PR_TRUE,
                                         getter_AddRefs(packageVersionNode));

            if (packageVersionNode) {
              mChromeDataSource->HasAssertion(entry, aSelectionArc,
                                              packageVersionNode, PR_TRUE,
                                              aCompatible);
              // if just one theme package is NOT compatible, the theme will be disabled
              if (!*aCompatible)
                return NS_OK;
            }
          }
        }
      }
    }
    rv = arcs->HasMoreElements(&more);
    if (NS_FAILED(rv))
      return rv;
  }

  return NS_OK;
}

Here is the call graph for this function:

boolean nsIChromeRegistrySea::checkThemeVersion ( in ACString  skinName) [inherited]
void nsChromeRegistry::ClearEntry ( PLDHashTable table,
PLDHashEntryHdr entry 
) [static, private]

Definition at line 364 of file nsChromeRegistry.cpp.

{
  PackageEntry* pentry = NS_STATIC_CAST(PackageEntry*, entry);
  pentry->~PackageEntry();
}

Here is the call graph for this function:

nsIURI nsIChromeRegistry::convertChromeURL ( in nsIURI  aChromeURL) [inherited]

Resolve a chrome URL to an loadable URI using the information in the registry.

Does not modify aChromeURL.

Chrome URLs are allowed to be specified in "shorthand", leaving the "file" portion off. In that case, the URL is expanded to:

chrome://package/provider/package.ext

where "ext" is:

"xul" for a "content" package, "css" for a "skin" package, and "dtd" for a "locale" package.

Parameters:
aChromeURLthe URL that is to be converted.
void nsIChromeRegistrySea::deselectLocale ( in ACString  localeName,
in boolean  useProfile 
) [inherited]
void nsIChromeRegistrySea::deselectLocaleForPackage ( in ACString  localeName,
in wstring  packageName,
in boolean  useProfile 
) [inherited]
void nsIChromeRegistrySea::deselectSkin ( in ACString  skinName,
in boolean  useProfile 
) [inherited]
void nsIChromeRegistrySea::deselectSkinForPackage ( in ACString  skinName,
in wstring  packageName,
in boolean  useProfile 
) [inherited]
nsresult nsChromeRegistry::FindProvider ( const nsACString &  aPackage,
const nsACString &  aProvider,
nsIRDFResource aArc,
nsIRDFNode **  aSelectedProvider 
) [private]

Definition at line 813 of file nsChromeRegistry.cpp.

{
  *aSelectedProvider = nsnull;

  nsCAutoString rootStr("urn:mozilla:");
  nsresult rv = NS_OK;

  rootStr += aProvider;
  rootStr += ":root";

  // obtain the provider root resource
  nsCOMPtr<nsIRDFResource> resource;
  rv = GetResource(rootStr, getter_AddRefs(resource));
  if (NS_FAILED(rv)) {
    NS_ERROR("Unable to obtain the provider root resource.");
    return rv;
  }

  // wrap it in a container
  nsCOMPtr<nsIRDFContainer> container =
      do_CreateInstance("@mozilla.org/rdf/container;1", &rv);
  if (NS_FAILED(rv)) return rv;

  rv = container->Init(mChromeDataSource, resource);
  if (NS_FAILED(rv)) return rv;

  // step through its (seq) arcs
  nsCOMPtr<nsISimpleEnumerator> arcs;
  rv = container->GetElements(getter_AddRefs(arcs));
  if (NS_FAILED(rv)) return rv;

  // XXX This needs to be something other than random.  See bug 191957.
  PRBool moreElements;
  rv = arcs->HasMoreElements(&moreElements);
  if (NS_FAILED(rv)) return rv;
  for ( ; moreElements; arcs->HasMoreElements(&moreElements)) {

    // get next arc resource
    nsCOMPtr<nsISupports> supports;
    rv = arcs->GetNext(getter_AddRefs(supports));
    if (NS_FAILED(rv)) return rv;
    nsCOMPtr<nsIRDFResource> kid = do_QueryInterface(supports);

    if (kid) {
      // get its name
      nsCAutoString providerName;
      rv = FollowArc(mChromeDataSource, providerName, kid, mName);
      if (NS_FAILED(rv)) return rv;

      // get its package list
      nsCOMPtr<nsIRDFNode> packageNode;
      nsCOMPtr<nsIRDFResource> packageList;
      rv = mChromeDataSource->GetTarget(kid, mPackages, PR_TRUE, getter_AddRefs(packageNode));
      if (NS_SUCCEEDED(rv))
        packageList = do_QueryInterface(packageNode);
      if (!packageList)
        continue;

      // if aPackage is named in kid's package list, select it and we're done
      rv = SelectPackageInProvider(packageList, aPackage, aProvider, providerName,
                                   aArc, aSelectedProvider);
      if (NS_FAILED(rv))
        continue; // Don't let this be disastrous.  We may find another acceptable match.

      if (*aSelectedProvider)
        return NS_OK;
    }
  }
  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2988 of file nsChromeRegistry.cpp.

{
  nsresult rv;
  // List all packages that want XPC native wrappers
  nsCOMPtr<nsIXPConnect> xpc(do_GetService("@mozilla.org/js/xpc/XPConnect;1", &rv));
  NS_ENSURE_SUCCESS(rv, rv);
  nsCOMPtr<nsISimpleEnumerator> arcs;
  nsCOMPtr<nsIRDFLiteral> trueLiteral;
  mRDFService->GetLiteral(NS_LITERAL_STRING("true").get(), getter_AddRefs(trueLiteral));
  rv = mChromeDataSource->GetSources(mXPCNativeWrappers, trueLiteral, PR_TRUE,
                                     getter_AddRefs(arcs));
  if (NS_FAILED(rv)) return rv;

  nsCAutoString uri;
  PRBool more;
  rv = arcs->HasMoreElements(&more);
  if (NS_FAILED(rv)) return rv;
  while (more) {
    nsCOMPtr<nsISupports> supp;
    rv = arcs->GetNext(getter_AddRefs(supp));
    if (NS_FAILED(rv)) return rv;
    nsCOMPtr<nsIRDFResource> package(do_QueryInterface(supp));
    if (package) {
      const char urn[] = "urn:mozilla:package:";
      const char* source;
      package->GetValueConst(&source);
      if (!memcmp(source, urn, sizeof urn - 1)) {
        uri.AssignLiteral("chrome://");
        uri.Append(source + sizeof urn - 1);
        uri.Append('/');
        rv = xpc->FlagSystemFilenamePrefix(uri.get());
        NS_ENSURE_SUCCESS(rv, rv);
      }
    }
    rv = arcs->HasMoreElements(&more);
    if (NS_FAILED(rv)) return rv;
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1026 of file nsChromeRegistry.cpp.

{
  nsCOMPtr<nsIObserverService> obsSvc =
    do_GetService("@mozilla.org/observer-service;1");
  NS_ASSERTION(obsSvc, "Couldn't get observer service.");

  obsSvc->NotifyObservers((nsIChromeRegistry*) this,
                          NS_CHROME_FLUSH_TOPIC, nsnull);
}  

Here is the call graph for this function:

Definition at line 892 of file nsChromeRegistry.cpp.

{
  nsCOMPtr<nsIObserverService> obsSvc =
    do_GetService("@mozilla.org/observer-service;1");
  NS_ASSERTION(obsSvc, "Couldn't get observer service.");

  obsSvc->NotifyObservers(NS_STATIC_CAST(nsIChromeRegistry*, this),
                          NS_CHROME_FLUSH_SKINS_TOPIC, nsnull);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsChromeRegistry::FollowArc ( nsIRDFDataSource aDataSource,
nsACString &  aResult,
nsIRDFResource aChromeResource,
nsIRDFResource aProperty 
) [static]

Definition at line 1235 of file nsChromeRegistry.cpp.

{
  if (!aDataSource)
    return NS_ERROR_FAILURE;

  nsresult rv;

  nsCOMPtr<nsIRDFNode> chromeBase;
  rv = aDataSource->GetTarget(aChromeResource, aProperty, PR_TRUE, getter_AddRefs(chromeBase));
  if (NS_FAILED(rv)) {
    NS_ERROR("Unable to obtain a base resource.");
    return rv;
  }

  if (chromeBase == nsnull)
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsIRDFResource> resource(do_QueryInterface(chromeBase));

  if (resource) {
    nsXPIDLCString uri;
    rv = resource->GetValue(getter_Copies(uri));
    if (NS_FAILED(rv)) return rv;
    aResult.Assign(uri);
    return NS_OK;
  }

  nsCOMPtr<nsIRDFLiteral> literal(do_QueryInterface(chromeBase));
  if (literal) {
    const PRUnichar *s;
    rv = literal->GetValueConst(&s);
    if (NS_FAILED(rv)) return rv;
    CopyUTF16toUTF8(s, aResult);
  }
  else {
    // This should _never_ happen.
    NS_ERROR("uh, this isn't a resource or a literal!");
    return NS_ERROR_UNEXPECTED;
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsChromeRegistry::GetArcs ( nsIRDFDataSource aDataSource,
const nsACString &  aType,
nsISimpleEnumerator **  aResult 
) [private]

Definition at line 2925 of file nsChromeRegistry.cpp.

{
  nsresult rv;

  nsCOMPtr<nsIRDFContainer> container =
      do_CreateInstance("@mozilla.org/rdf/container;1", &rv);
  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 = GetResource(lookup, getter_AddRefs(chromeResource)))) {
    NS_ERROR("Unable to retrieve the resource corresponding to the chrome skin or content.");
    return rv;
  }

  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;
}

Here is the call graph for this function:

nsresult nsChromeRegistry::GetBaseURL ( const nsACString &  aPackage,
const nsACString &  aProvider,
nsACString &  aBaseURL 
) [private]

Definition at line 567 of file nsChromeRegistry.cpp.

{
  nsCOMPtr<nsIRDFResource> resource;

  nsCAutoString resourceStr("urn:mozilla:package:");
  resourceStr += aPackage;

  // Obtain the resource.
  nsresult rv = NS_OK;
  nsCOMPtr<nsIRDFResource> packageResource;
  rv = GetResource(resourceStr, getter_AddRefs(packageResource));
  if (NS_FAILED(rv)) {
    NS_ERROR("Unable to obtain the package resource.");
    return rv;
  }

  // Follow the "selectedSkin" or "selectedLocale" arc.
  nsCOMPtr<nsIRDFResource> arc;
  if (aProvider.EqualsLiteral("skin")) {
    arc = mSelectedSkin;
  }
  else if (aProvider.EqualsLiteral("locale")) {
    arc = mSelectedLocale;
  }
  else
    // We're a package.
    resource = packageResource;

  if (arc) {

    nsCOMPtr<nsIRDFNode> selectedProvider;
    if (NS_FAILED(rv = mChromeDataSource->GetTarget(packageResource, arc, PR_TRUE, getter_AddRefs(selectedProvider)))) {
      NS_ERROR("Unable to obtain the provider.");
      return rv;
    }

    resource = do_QueryInterface(selectedProvider);

    if (resource) {
      PRBool providerOK;
      rv = VerifyCompatibleProvider(packageResource, resource, arc, &providerOK);
      if (NS_FAILED(rv)) return rv;
      if (!providerOK) {
        // We had a selection but it was incompatible or not present.
        // That selection may have come from the profile, so check only
        // the part of the datasource in the install.  (If this succeeds,
        // we won't remember the choice, either, in case the user
        // switches back to a build where this theme does work.)
        if (NS_FAILED(rv = mInstallDirChromeDataSource->GetTarget(packageResource, arc, PR_TRUE, getter_AddRefs(selectedProvider)))) {
          NS_ERROR("Unable to obtain the provider.");
          return rv;
        }
        resource = do_QueryInterface(selectedProvider);
        if (resource) {
          rv = VerifyCompatibleProvider(packageResource, resource, arc, &providerOK);
          if (NS_FAILED(rv)) return rv;
          if (!providerOK) 
            selectedProvider = nsnull;
        }
      }
    }

    if (!selectedProvider) {
      // FindProvider will attempt to auto-select a version-compatible provider (skin).  If none
      // exist it will return nsnull in the selectedProvider variable.
      FindProvider(aPackage, aProvider, arc, getter_AddRefs(selectedProvider));
      resource = do_QueryInterface(selectedProvider);
    }

    if (!selectedProvider)
      return rv;

    if (!resource)
      return NS_ERROR_FAILURE;
  }

  // From this resource, follow the "baseURL" arc.
  return FollowArc(mChromeDataSource, aBaseURL, resource, mBaseURL);
}

Here is the call graph for this function:

nsresult nsChromeRegistry::GetDynamicDataSource ( nsIURI aChromeURL,
PRBool  aIsOverlay,
PRBool  aUseProfile,
PRBool  aCreateDS,
nsIRDFDataSource **  aResult 
) [protected]

Definition at line 962 of file nsChromeRegistry.cpp.

{
  *aResult = nsnull;

  nsresult rv;

  if (!mDataSourceTable)
    return NS_OK;

  // Obtain the package, provider and remaining from the URL
  nsCAutoString package, provider, remaining;

  rv = SplitURL(aChromeURL, package, provider, remaining);
  NS_ENSURE_SUCCESS(rv, rv);

  if (!aCreateDS) {
    // We are not supposed to create the data source, which means
    // we should first check our chrome.rdf file to see if this
    // package even has dynamic data.  Only if it claims to have
    // dynamic data are we willing to hand back a datasource.
    nsDependentCString dataSourceStr(kChromeFileName);
    nsCOMPtr<nsIRDFDataSource> mainDataSource;
    rv = LoadDataSource(dataSourceStr, getter_AddRefs(mainDataSource), aUseProfile, nsnull);
    NS_ENSURE_SUCCESS(rv, rv);
    
    // Now that we have the appropriate chrome.rdf file, we
    // must check the package resource for stylesheets or overlays.
    nsCOMPtr<nsIRDFResource> hasDynamicDataArc;
    if (aIsOverlay)
      hasDynamicDataArc = mHasOverlays;
    else
      hasDynamicDataArc = mHasStylesheets;
    
    // Obtain the resource for the package.
    nsCAutoString packageResourceStr("urn:mozilla:package:");
    packageResourceStr += package;
    nsCOMPtr<nsIRDFResource> packageResource;
    GetResource(packageResourceStr, getter_AddRefs(packageResource));
    
    // Follow the dynamic data arc to see if we should continue.
    // Only if it claims to have dynamic data do we even bother.
    nsCOMPtr<nsIRDFNode> hasDynamicDSNode;
    mainDataSource->GetTarget(packageResource, hasDynamicDataArc, PR_TRUE,
                              getter_AddRefs(hasDynamicDSNode));
    if (!hasDynamicDSNode)
      return NS_OK; // No data source exists.
  }

  // Retrieve the mInner data source.
  nsCAutoString overlayFile; 
  if (aUseProfile && mLegacyOverlayinfo)
  {
    overlayFile.AppendLiteral("overlayinfo/");
    overlayFile += package;
    if (aIsOverlay)
      overlayFile.AppendLiteral("/content/");
    else
      overlayFile.AppendLiteral("/skin/");
  }
  if (aIsOverlay)
    overlayFile.AppendLiteral("overlays.rdf");
  else
    overlayFile.AppendLiteral("stylesheets.rdf");

  return LoadDataSource(overlayFile, aResult, aUseProfile, nsnull);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsChromeRegistry::GetDynamicInfo ( nsIURI aChromeURL,
PRBool  aIsOverlay,
nsISimpleEnumerator **  aResult 
) [protected]

Definition at line 1099 of file nsChromeRegistry.cpp.

{
  *aResult = nsnull;

  nsresult rv;

  if (!mDataSourceTable)
    return NS_OK;

  nsCOMPtr<nsIRDFDataSource> installSource;
  rv = GetDynamicDataSource(aChromeURL, aIsOverlay, PR_FALSE, PR_FALSE,
                            getter_AddRefs(installSource));
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIRDFDataSource> profileSource;
  if (mProfileInitialized) {
    rv = GetDynamicDataSource(aChromeURL, aIsOverlay, PR_TRUE, PR_FALSE,
                              getter_AddRefs(profileSource));
    NS_ENSURE_SUCCESS(rv, rv);
  }

  nsCAutoString lookup;
  rv = aChromeURL->GetSpec(lookup);
  NS_ENSURE_SUCCESS(rv, rv);
   
  // Get the chromeResource from this lookup string
  nsCOMPtr<nsIRDFResource> chromeResource;
  rv = GetResource(lookup, getter_AddRefs(chromeResource));
  if (NS_FAILED(rv)) {
      NS_ERROR("Unable to retrieve the resource corresponding to the chrome skin or content.");
      return rv;
  }

  nsCOMArray<nsIURI> overlayURIs;

  if (installSource) {
    GetURIList(installSource, chromeResource, overlayURIs);
  }
  if (profileSource) {
    GetURIList(profileSource, chromeResource, overlayURIs);
  }

  return NS_NewArrayEnumerator(aResult, overlayURIs);
}

Here is the call graph for this function:

nsresult nsChromeRegistry::GetDynamicInfo ( nsIURI aChromeURL,
PRBool  aIsOverlay,
nsISimpleEnumerator **  aResult 
) [protected]
nsresult nsChromeRegistry::GetInstallRoot ( nsIFile **  aFileURL) [static, private]

Definition at line 2865 of file nsChromeRegistry.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

const void * nsChromeRegistry::GetKey ( PLDHashTable table,
PLDHashEntryHdr entry 
) [static, private]

Definition at line 341 of file nsChromeRegistry.cpp.

{
  PackageEntry* pentry = NS_STATIC_CAST(PackageEntry*, entry);
  return (nsACString*) &pentry->package;
}

Get a list of locales available for the specified package.

nsresult nsChromeRegistry::GetOverrideURL ( const nsACString &  aPackage,
const nsACString &  aProvider,
const nsACString &  aPath,
nsACString &  aResult 
) [private]

Definition at line 650 of file nsChromeRegistry.cpp.

{
  nsresult rv = InitOverrideJAR();
  if (NS_FAILED(rv)) return rv;

  // ok, if we get here, we have an override JAR

  aResult.SetCapacity(mOverrideJARURL.Length() +
                      aPackage.Length() +
                      aProvider.Length() +
                      aPath.Length() + 2);
  
  aResult = mOverrideJARURL;
  aResult += aPackage;
  aResult += '/';
  aResult += aProvider;
  aResult += '/';

  // skins and locales get their name tacked on, like
  // skin/modern/foo.css or
  // locale/en-US/navigator.properties
  if (aProvider.EqualsLiteral("skin") ||
      aProvider.EqualsLiteral("locale")) {

    // little hack here to get the right arc
    nsIRDFResource* providerArc;
    if (aProvider.Equals("skin"))
      providerArc = mSelectedSkin;
    else
      providerArc = mSelectedLocale;
    
    nsCAutoString selectedProvider;
    rv = GetSelectedProvider(aPackage, aProvider, providerArc, selectedProvider);

    if (NS_SUCCEEDED(rv)) {
      aResult += selectedProvider;
      aResult += '/';
    }
  }
  
  aResult += aPath;

  nsCOMPtr<nsIZipEntry> zipEntry;
  rv = mOverrideJAR->GetEntry(PromiseFlatCString(aResult).get(),
                              getter_AddRefs(zipEntry));
  if (NS_FAILED(rv)) {
    aResult.Truncate();
    return rv;
  }

  return NS_OK;
}

Here is the call graph for this function:

nsresult nsChromeRegistry::GetProfileRoot ( nsACString &  aFileURL) [static, private]

Definition at line 2809 of file nsChromeRegistry.cpp.

{
   nsresult rv;
   nsCOMPtr<nsIFile> userChromeDir;

   // Build a fileSpec that points to the destination
   // (profile dir + chrome)
   rv = NS_GetSpecialDirectory(NS_APP_USER_CHROME_DIR, getter_AddRefs(userChromeDir));
   if (NS_FAILED(rv) || !userChromeDir)
     return NS_ERROR_FAILURE;

   PRBool exists;
   rv = userChromeDir->Exists(&exists);
   if (NS_SUCCEEDED(rv) && !exists) {
     rv = userChromeDir->Create(nsIFile::DIRECTORY_TYPE, 0755);
     if (NS_SUCCEEDED(rv)) {
       // now we need to put the userContent.css and userChrome.css
       // stubs into place

       // first get the locations of the defaults
       nsCOMPtr<nsIFile> defaultUserContentFile;
       nsCOMPtr<nsIFile> defaultUserChromeFile;
       rv = NS_GetSpecialDirectory(NS_APP_PROFILE_DEFAULTS_50_DIR,
                                   getter_AddRefs(defaultUserContentFile));
       if (NS_FAILED(rv))
         rv = NS_GetSpecialDirectory(NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR,
                                     getter_AddRefs(defaultUserContentFile));
       if (NS_FAILED(rv))
         return(rv);
       rv = NS_GetSpecialDirectory(NS_APP_PROFILE_DEFAULTS_50_DIR,
                                   getter_AddRefs(defaultUserChromeFile));
       if (NS_FAILED(rv))
         rv = NS_GetSpecialDirectory(NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR,
                                     getter_AddRefs(defaultUserChromeFile));
       if (NS_FAILED(rv))
         return(rv);
       defaultUserContentFile->AppendNative(NS_LITERAL_CSTRING("chrome"));
       defaultUserContentFile->AppendNative(NS_LITERAL_CSTRING("userContent-example.css"));
       defaultUserChromeFile->AppendNative(NS_LITERAL_CSTRING("chrome"));
       defaultUserChromeFile->AppendNative(NS_LITERAL_CSTRING("userChrome-example.css"));

       const nsAFlatCString& empty = EmptyCString();

       // copy along
       // It aint an error if these files dont exist
       defaultUserContentFile->CopyToNative(userChromeDir, empty);
       defaultUserChromeFile->CopyToNative(userChromeDir, empty);
     }
   }
   if (NS_FAILED(rv))
     return rv;

   return NS_GetURLSpecFromFile(userChromeDir, aFileURL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsChromeRegistry::GetProviderAndPath ( nsIURL aChromeURL,
nsACString &  aProvider,
nsACString &  aPath 
) [static, private]

Definition at line 590 of file nsChromeRegistry.cpp.

{
  nsresult rv;

#ifdef DEBUG
  PRBool isChrome;
  aChromeURL->SchemeIs("chrome", &isChrome);
  NS_ASSERTION(isChrome, "Non-chrome URI?");
#endif

  nsCAutoString path;
  rv = aChromeURL->GetPath(path);
  NS_ENSURE_SUCCESS(rv, rv);

  if (path.Length() < 3) {
    LogMessage("Invalid chrome URI: %s", path.get());
    return NS_ERROR_FAILURE;
  }

  path.SetLength(nsUnescapeCount(path.BeginWriting()));
  NS_ASSERTION(path.First() == '/', "Path should always begin with a slash!");

  PRInt32 slash = path.FindChar('/', 1);
  if (slash == 1) {
    LogMessage("Invalid chrome URI: %s", path.get());
    return NS_ERROR_FAILURE;
  }

  if (slash == -1) {
    aPath.Truncate();
  }
  else {
    if (slash == (PRInt32) path.Length() - 1)
      aPath.Truncate();
    else
      aPath.Assign(path.get() + slash + 1, path.Length() - slash - 1);

    --slash;
  }

  aProvider.Assign(path.get() + 1, slash);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsChromeRegistry::GetProviderCount ( const nsACString &  aProviderType,
nsIRDFDataSource aDataSource 
) [private]

Definition at line 3365 of file nsChromeRegistry.cpp.

{
  nsresult rv;

  nsCAutoString rootStr("urn:mozilla:");
  rootStr += aProviderType;
  rootStr += ":root";

  // obtain the provider root resource
  nsCOMPtr<nsIRDFResource> resource;
  rv = GetResource(rootStr, getter_AddRefs(resource));
  if (NS_FAILED(rv))
    return 0;

  // wrap it in a container
  nsCOMPtr<nsIRDFContainer> container =
      do_CreateInstance("@mozilla.org/rdf/container;1", &rv);
  if (NS_FAILED(rv)) return 0;

  rv = container->Init(aDataSource, resource);
  if (NS_FAILED(rv)) return 0;

  PRInt32 count;
  container->GetCount(&count);
  return count;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsChromeRegistry::GetResource ( const nsACString &  aChromeType,
nsIRDFResource **  aResult 
) [protected]

Definition at line 1222 of file nsChromeRegistry.cpp.

{
  nsresult rv = NS_OK;
  if (NS_FAILED(rv = mRDFService->GetResource(aURL, aResult))) {
    NS_ERROR("Unable to retrieve a resource for this URL.");
    *aResult = nsnull;
    return rv;
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ACString nsIXULChromeRegistry::getSelectedLocale ( in ACString  packageName) [inherited]
nsresult nsChromeRegistry::GetSelectedProvider ( const nsACString &  aPackage,
const nsACString &  aProviderName,
nsIRDFResource aSelectionArc,
nsACString &  aResult 
) [private]

Definition at line 1770 of file nsChromeRegistry.cpp.

{
  // check if mChromeDataSource is null; do we need to apply this to every instance?
  // is there a better way to test if the data source is ready?
  if (!mChromeDataSource) {
    return NS_ERROR_FAILURE;
  }

  nsCAutoString resourceStr("urn:mozilla:package:");
  resourceStr += aPackageName;

  // Obtain the resource.
  nsresult rv = NS_OK;
  nsCOMPtr<nsIRDFResource> resource;
  rv = GetResource(resourceStr, getter_AddRefs(resource));
  if (NS_FAILED(rv)) {
    NS_ERROR("Unable to obtain the package resource.");
    return rv;
  }

  if (mChromeDataSource == nsnull)
    return NS_ERROR_NULL_POINTER;

  // Follow the "selectedLocale" arc.
  nsCOMPtr<nsIRDFNode> selectedProvider;
  if (NS_FAILED(rv = mChromeDataSource->GetTarget(resource, aSelectionArc, PR_TRUE, getter_AddRefs(selectedProvider)))) {
    NS_ERROR("Unable to obtain the provider.");
    return rv;
  }

  if (!selectedProvider) {
    rv = FindProvider(aPackageName, aProvider, aSelectionArc, getter_AddRefs(selectedProvider));
    if (!selectedProvider)
      return rv;
  }

  resource = do_QueryInterface(selectedProvider);
  if (!resource)
    return NS_ERROR_FAILURE;

  // selectedProvider.mURI now looks like "urn:mozilla:locale:ja-JP:navigator"
  const char *uri;
  if (NS_FAILED(rv = resource->GetValueConst(&uri)))
    return rv;

  // trim down to "urn:mozilla:locale:ja-JP"
  nsCAutoString packageStr(":");
  packageStr += aPackageName;

  nsCAutoString ustr(uri);
  PRInt32 pos = ustr.RFind(packageStr);
  nsCAutoString urn;
  ustr.Left(urn, pos);

  rv = GetResource(urn, getter_AddRefs(resource));
  if (NS_FAILED(rv)) {
    NS_ERROR("Unable to obtain the provider resource.");
    return rv;
  }

  // From this resource, follow the "name" arc.
  return FollowArc(mChromeDataSource, _retval, resource, mName);
}

Here is the call graph for this function:

Here is the caller graph for this function:

ACString nsIChromeRegistrySea::getSelectedSkin ( in ACString  packageName) [inherited]

Get the style overlays for a particular chrome URI.

Parameters:
aURIThe URI being loaded
Returns:
An enumerator of nsIURI for the overlays of this URI
nsresult nsChromeRegistry::GetURIList ( nsIRDFDataSource aDS,
nsIRDFResource aResource,
nsCOMArray< nsIURI > &  aArray 
) [protected]

Definition at line 1046 of file nsChromeRegistry.cpp.

{
  nsresult rv;
  nsCOMPtr<nsISimpleEnumerator> arcs;
  nsCOMPtr<nsIRDFContainer> container =
    do_CreateInstance("@mozilla.org/rdf/container;1", &rv);
  if (NS_FAILED(rv)) goto end_GetURIList;

  rv = container->Init(aSource, aResource);
  if (NS_FAILED(rv)) {
    rv = NS_OK;
    goto end_GetURIList;
  }

  rv = container->GetElements(getter_AddRefs(arcs));
  if (NS_FAILED(rv)) goto end_GetURIList;

  {
    nsCOMPtr<nsISupports> supports;
    nsCOMPtr<nsIRDFLiteral> value;
    nsCOMPtr<nsIURI> uri;
    PRBool hasMore;

    while (NS_SUCCEEDED(rv = arcs->HasMoreElements(&hasMore)) && hasMore) {
      rv = arcs->GetNext(getter_AddRefs(supports));
      if (NS_FAILED(rv)) break;

      value = do_QueryInterface(supports, &rv);
      if (NS_FAILED(rv)) continue;

      const PRUnichar* valueStr;
      rv = value->GetValueConst(&valueStr);
      if (NS_FAILED(rv)) continue;

      rv = NS_NewURI(getter_AddRefs(uri), NS_ConvertUTF16toUTF8(valueStr));
      if (NS_FAILED(rv)) continue;

      if (IsOverlayAllowed(uri)) {
        if (!aArray.AppendObject(uri)) {
          rv = NS_ERROR_OUT_OF_MEMORY;
          break;
        }
      }
    }
  }

end_GetURIList:
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Get the XUL overlays for a particular chrome URI.

Parameters:
aURIThe URI being loaded
Returns:
An enumerator of nsIURI for the overlays of this URI
PLHashNumber nsChromeRegistry::HashKey ( PLDHashTable table,
const void key 
) [static, private]

Definition at line 348 of file nsChromeRegistry.cpp.

{
  const nsACString& str = *NS_REINTERPRET_CAST(const nsACString*, key);
  return HashString(str);
}

Here is the call graph for this function:

Definition at line 458 of file nsChromeRegistry.cpp.

{
  nsresult rv;

  // these atoms appear in almost every chrome registry contents.rdf
  // in some form or another. making static atoms prevents the atoms
  // from constantly being created/destroyed during parsing
  
  static const nsStaticAtom atoms[] = {
    { "chrome",        nsnull },
    { "NC",            nsnull },
    { "allowScripts",  nsnull },
    { "package",       nsnull },
    { "packages",      nsnull },
    { "hasOverlays",   nsnull },
  };

  NS_RegisterStaticAtoms(atoms, NS_ARRAY_LENGTH(atoms));
  
  if (!PL_DHashTableInit(&mPackagesHash, &kTableOps,
                         nsnull, sizeof(PackageEntry), 16))
    return NS_ERROR_FAILURE;

  if (!mOverlayHash.Init() ||
      !mStyleHash.Init() ||
      !mOverrideTable.Init())
    return NS_ERROR_FAILURE;

  mSelectedLocale = NS_LITERAL_CSTRING("en-US");
  mSelectedSkin = NS_LITERAL_CSTRING("classic/1.0");

  // This initialization process is fairly complicated and may cause reentrant
  // getservice calls to resolve chrome URIs (especially locale files). We
  // don't want that, so we inform the protocol handler about our existence
  // before we are actually fully initialized.
  gChromeRegistry = this;

  PRBool safeMode = PR_FALSE;
  nsCOMPtr<nsIXULRuntime> xulrun (do_GetService(XULAPPINFO_SERVICE_CONTRACTID));
  if (xulrun)
    xulrun->GetInSafeMode(&safeMode);
  
  nsCOMPtr<nsIPrefService> prefserv (do_GetService(NS_PREFSERVICE_CONTRACTID));
  nsCOMPtr<nsIPrefBranch> prefs;

  if (safeMode)
    prefserv->GetDefaultBranch(nsnull, getter_AddRefs(prefs));
  else
    prefs = do_QueryInterface(prefserv);

  if (!prefs) {
    NS_WARNING("Could not get pref service!");
  }

  PRBool useLocalePref = PR_TRUE;

  if (prefs) {
    // check the pref first
    PRBool matchOS = PR_FALSE;
    rv = prefs->GetBoolPref(MATCH_OS_LOCALE_PREF, &matchOS);

    // match os locale
    if (NS_SUCCEEDED(rv) && matchOS) {
      // compute lang and region code only when needed!
      nsCAutoString uiLocale;
      rv = getUILangCountry(uiLocale);
      if (NS_SUCCEEDED(rv)) {
        useLocalePref = PR_FALSE;
        mSelectedLocale = uiLocale;
      }
    }
  }
      
  if (prefs) {
    nsXPIDLCString provider;

    rv = prefs->GetCharPref(SELECTED_SKIN_PREF, getter_Copies(provider));
    if (NS_SUCCEEDED(rv))
      mSelectedSkin = provider;

    nsCOMPtr<nsIPrefBranch2> prefs2 (do_QueryInterface(prefs));

    if (prefs2)
      rv = prefs2->AddObserver(SELECTED_SKIN_PREF, this, PR_TRUE);

    if (useLocalePref) {
      rv = prefs->GetCharPref(SELECTED_LOCALE_PREF, getter_Copies(provider));
      if (NS_SUCCEEDED(rv))
        mSelectedLocale = provider;
      
      if (prefs2)
        prefs2->AddObserver(SELECTED_LOCALE_PREF, this, PR_TRUE);
    }
  }

  CheckForNewChrome();

  mInitialized = PR_TRUE;

  return NS_OK;
}

Here is the call graph for this function:

PRBool nsChromeRegistry::InitEntry ( PLDHashTable table,
PLDHashEntryHdr entry,
const void key 
) [static, private]

Definition at line 371 of file nsChromeRegistry.cpp.

{
  const nsACString& str = *NS_REINTERPRET_CAST(const nsACString*, key);

  new (entry) PackageEntry(str);
  return PR_TRUE;
}

Definition at line 707 of file nsChromeRegistry.cpp.

{
  // generic failure if we know there's no override
  if (mSearchedForOverride && !mOverrideJAR)
    return NS_ERROR_FAILURE;

  mSearchedForOverride = PR_TRUE;

  nsresult rv;
  //
  // look for custom.jar
  //
  nsCOMPtr<nsIFile> overrideFile;
  rv = GetInstallRoot(getter_AddRefs(overrideFile));
  if (NS_FAILED(rv)) return rv;

  rv = overrideFile->AppendNative(NS_LITERAL_CSTRING("custom.jar"));
  if (NS_FAILED(rv)) return rv;

  PRBool exists;
  rv = overrideFile->Exists(&exists);
  if (NS_FAILED(rv)) return rv;

  // ok, if the file doesn't exist, its just a generic failure
  if (!exists)
    return NS_ERROR_FAILURE;

  //
  // cache the url so we can later append
  //
  mOverrideJARURL.Assign("jar:");
  nsCAutoString jarURL;
  rv = NS_GetURLSpecFromFile(overrideFile, jarURL);
  if (NS_FAILED(rv)) return rv;

  mOverrideJARURL.Append(jarURL);
  mOverrideJARURL.Append("!/");
  if (NS_FAILED(rv)) return rv;

  //
  // also cache the zip file itself
  //
  nsCOMPtr<nsIZipReaderCache> readerCache =
    do_CreateInstance("@mozilla.org/libjar/zip-reader-cache;1", &rv);
  if (NS_FAILED(rv)) return rv;

  rv = readerCache->Init(32);
  
  rv = readerCache->GetZip(overrideFile, getter_AddRefs(mOverrideJAR));
  if (NS_FAILED(rv)) {
    mOverrideJARURL.Truncate();
    return rv;
  }
  
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIChromeRegistrySea::installLocale ( in string  baseURL,
in boolean  useProfile 
) [inherited]
void nsIChromeRegistrySea::installPackage ( in string  baseURL,
in boolean  useProfile 
) [inherited]
nsresult nsChromeRegistry::InstallProvider ( const nsACString &  aProviderType,
const nsACString &  aBaseURL,
PRBool  aUseProfile,
PRBool  aAllowScripts,
PRBool  aRemove 
) [private]

Definition at line 2244 of file nsChromeRegistry.cpp.

{
  // XXX don't allow local chrome overrides of install chrome!
#ifdef DEBUG
  printf("*** Chrome Registration of %-7s: Checking for contents.rdf at %s\n", PromiseFlatCString(aProviderType).get(), PromiseFlatCString(aBaseURL).get());
#endif

  // Load the data source found at the base URL.
  nsresult rv;
  nsCOMPtr<nsIRDFDataSource> dataSource =
      do_CreateInstance(kRDFXMLDataSourceCID, &rv);
  if (NS_FAILED(rv)) return rv;

  nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(dataSource, &rv);
  if (NS_FAILED(rv)) return rv;

  // We need to read this synchronously.
  nsCAutoString key(aBaseURL);
  key += "contents.rdf";
  remote->Init(key.get());
  remote->Refresh(PR_TRUE);

  PRBool skinCount = GetProviderCount(NS_LITERAL_CSTRING("skin"), dataSource);
  PRBool localeCount = GetProviderCount(NS_LITERAL_CSTRING("locale"), dataSource);
  PRBool packageCount = GetProviderCount(NS_LITERAL_CSTRING("package"), dataSource);

  PRBool appendPackage = PR_FALSE;
  PRBool appendProvider = PR_FALSE;
  PRBool appendProviderName = PR_FALSE;

  if (skinCount == 0 && localeCount == 0 && packageCount == 0) {
    // Try the old-style manifest.rdf instead
    key = aBaseURL;
    key += "manifest.rdf";
    (void)remote->Init(key.get());      // ignore failure here
    rv = remote->Refresh(PR_TRUE);
    if (NS_FAILED(rv)) return rv;
    appendPackage = PR_TRUE;
    appendProvider = PR_TRUE;
    NS_WARNING("Trying old-style manifest.rdf. Please update to contents.rdf.");
  }
  else {
    if ((skinCount > 1 && aProviderType.Equals("skin")) ||
        (localeCount > 1 && aProviderType.Equals("locale")))
      appendProviderName = PR_TRUE;

    if (!appendProviderName && packageCount > 1) {
      appendPackage = PR_TRUE;
    }

    if (aProviderType.Equals("skin")) {
      if (!appendProviderName && (localeCount == 1 || packageCount != 0))
        appendProvider = PR_TRUE;
    }
    else if (aProviderType.Equals("locale")) {
      if (!appendProviderName && (skinCount == 1 || packageCount != 0))
        appendProvider = PR_TRUE;
    }
    else {
      // Package install.
      if (localeCount == 1 || skinCount == 1)
        appendProvider = PR_TRUE;
    }
  }

  // Load the install data source that we wish to manipulate.
  nsCOMPtr<nsIRDFDataSource> installSource;
  rv = LoadDataSource(kChromeFileName, getter_AddRefs(installSource), aUseProfile, nsnull);
  if (NS_FAILED(rv)) return rv;
  NS_ASSERTION(installSource, "failed to get installSource");

  // install our dynamic overlays
  if (aProviderType.Equals("package"))
    rv = UpdateDynamicDataSources(dataSource, PR_TRUE, aUseProfile, aRemove);
  else if (aProviderType.Equals("skin"))
    rv = UpdateDynamicDataSources(dataSource, PR_FALSE, aUseProfile, aRemove);
  if (NS_FAILED(rv)) return rv;

  // Get the literal for our loc type.
  nsAutoString locstr;
  if (aUseProfile)
    locstr.AssignLiteral("profile");
  else locstr.AssignLiteral("install");
  nsCOMPtr<nsIRDFLiteral> locLiteral;
  rv = mRDFService->GetLiteral(locstr.get(), getter_AddRefs(locLiteral));
  if (NS_FAILED(rv)) return rv;

  // Get the literal for our script access.
  nsCOMPtr<nsIRDFLiteral> scriptLiteral;
  rv = mRDFService->GetLiteral(NS_LITERAL_STRING("false").get(),
                               getter_AddRefs(scriptLiteral));
  if (NS_FAILED(rv)) return rv;

  // Build the prefix string. Only resources with this prefix string will have their
  // assertions copied.
  nsCAutoString prefix( "urn:mozilla:" );
  prefix += aProviderType;
  prefix += ":";

  // Get all the resources
  nsCOMPtr<nsISimpleEnumerator> resources;
  rv = dataSource->GetAllResources(getter_AddRefs(resources));
  if (NS_FAILED(rv)) return rv;

  // For each resource
  PRBool moreElements;
  rv = resources->HasMoreElements(&moreElements);
  if (NS_FAILED(rv)) return rv;

  while (moreElements) {
    nsCOMPtr<nsISupports> supports;
    rv = resources->GetNext(getter_AddRefs(supports));
    if (NS_FAILED(rv)) return rv;

    nsCOMPtr<nsIRDFResource> resource = do_QueryInterface(supports);

    // Check against the prefix string
    const char* value;
    rv = resource->GetValueConst(&value);
    if (NS_FAILED(rv)) return rv;
    nsCAutoString val(value);
    if (val.Find(prefix) == 0) {
      // It's valid.

      if (aProviderType.Equals("package") && !val.Equals("urn:mozilla:package:root")) {
        // Add arcs for the base url and loctype
        // Get the value of the base literal.
        nsCAutoString baseURL(aBaseURL);

        // Peel off the package.
        const char* val2;
        rv = resource->GetValueConst(&val2);
        if (NS_FAILED(rv)) return rv;
        nsCAutoString value2(val2);
        PRInt32 index = value2.RFind(":");
        nsCAutoString packageName;
        value2.Right(packageName, value2.Length() - index - 1);

        if (appendPackage) {
          baseURL += packageName;
          baseURL += "/";
        }
        if (appendProvider) {
          baseURL += "content/";
        }

        nsCOMPtr<nsIRDFLiteral> baseLiteral;
        mRDFService->GetLiteral(NS_ConvertASCIItoUCS2(baseURL).get(), getter_AddRefs(baseLiteral));

        rv = nsChromeRegistry::UpdateArc(installSource, resource, mBaseURL, baseLiteral, aRemove);
        if (NS_FAILED(rv)) return rv;
        rv = nsChromeRegistry::UpdateArc(installSource, resource, mLocType, locLiteral, aRemove);
        if (NS_FAILED(rv)) return rv;
      }

      nsCOMPtr<nsIRDFContainer> container =
          do_CreateInstance("@mozilla.org/rdf/container;1", &rv);
      if (NS_FAILED(rv)) return rv;
      rv = container->Init(dataSource, resource);
      if (NS_SUCCEEDED(rv)) {
        // XXX Deal with BAGS and ALTs? Aww, to hell with it. Who cares? I certainly don't.
        // We're a SEQ. Different rules apply. Do an AppendElement instead.
        // First do the decoration in the install data source.
        nsCOMPtr<nsIRDFContainer> installContainer;
        rv = mRDFContainerUtils->MakeSeq(installSource, resource, getter_AddRefs(installContainer));
        if (NS_FAILED(rv)) return rv;
        if (!installContainer) {
          // Already exists. Create a container instead.
          installContainer = do_CreateInstance("@mozilla.org/rdf/container;1", &rv);
          if (NS_FAILED(rv)) return rv;
          rv = installContainer->Init(installSource, resource);
          if (NS_FAILED(rv)) return rv;
        }

        // Put all our elements into the install container.
        nsCOMPtr<nsISimpleEnumerator> seqKids;
        rv = container->GetElements(getter_AddRefs(seqKids));
        if (NS_FAILED(rv)) return rv;
        PRBool moreKids;
        rv = seqKids->HasMoreElements(&moreKids);
        if (NS_FAILED(rv)) return rv;
        while (moreKids) {
          nsCOMPtr<nsISupports> supp;
          rv = seqKids->GetNext(getter_AddRefs(supp));
          if (NS_FAILED(rv)) return rv;
          nsCOMPtr<nsIRDFNode> kid = do_QueryInterface(supp);
          if (aRemove) {
            rv = installContainer->RemoveElement(kid, PR_TRUE);
            if (NS_FAILED(rv)) return rv;
          }
          else {
            PRInt32 index;
            rv = installContainer->IndexOf(kid, &index);
            if (NS_FAILED(rv)) return rv;
            if (index == -1) {
              rv = installContainer->AppendElement(kid);
              if (NS_FAILED(rv)) return rv;
            }
            rv = seqKids->HasMoreElements(&moreKids);
            if (NS_FAILED(rv)) return rv;
          }
        }

        // See if we're a packages seq in a skin/locale.  If so, we need to set up the baseURL, allowScripts
        // and package arcs.
        if (val.Find(":packages") != -1 && !aProviderType.EqualsLiteral("package")) {
          PRBool doAppendPackage = appendPackage;
          PRInt32 perProviderPackageCount;
          container->GetCount(&perProviderPackageCount);
          if (perProviderPackageCount > 1)
            doAppendPackage = PR_TRUE;

          // Iterate over our kids a second time.
          nsCOMPtr<nsISimpleEnumerator> seqKids2;
          rv = container->GetElements(getter_AddRefs(seqKids2));
          if (NS_FAILED(rv)) return rv;
          PRBool moreKids2;
          rv = seqKids2->HasMoreElements(&moreKids2);
          if (NS_FAILED(rv)) return rv;
          while (moreKids2) {
            nsCOMPtr<nsISupports> supp;
            rv = seqKids2->GetNext(getter_AddRefs(supp));
            if (NS_FAILED(rv)) return rv;
            nsCOMPtr<nsIRDFResource> entry(do_QueryInterface(supp));
            if (entry) {
              // Get the value of the base literal.
              nsCAutoString baseURL(aBaseURL);

              // Peel off the package and the provider.
              const char* val2;
              rv = entry->GetValueConst(&val2);
              if (NS_FAILED(rv)) return rv;
              nsCAutoString value2(val2);
              PRInt32 index = value2.RFind(":");
              nsCAutoString packageName;
              value2.Right(packageName, value2.Length() - index - 1);
              nsCAutoString remainder;
              value2.Left(remainder, index);

              nsCAutoString providerName;
              index = remainder.RFind(":");
              remainder.Right(providerName, remainder.Length() - index - 1);

              // Append them to the base literal and tack on a final slash.
              if (appendProviderName) {
                baseURL += providerName;
                baseURL += "/";
              }
              if (doAppendPackage) {
                baseURL += packageName;
                baseURL += "/";
              }
              if (appendProvider) {
                baseURL += aProviderType;
                baseURL += "/";
              }

              nsCOMPtr<nsIRDFLiteral> baseLiteral;
              mRDFService->GetLiteral(NS_ConvertASCIItoUCS2(baseURL).get(), getter_AddRefs(baseLiteral));

              rv = nsChromeRegistry::UpdateArc(installSource, entry, mBaseURL, baseLiteral, aRemove);
              if (NS_FAILED(rv)) return rv;
              if (aProviderType.EqualsLiteral("skin") && !aAllowScripts) {
                rv = nsChromeRegistry::UpdateArc(installSource, entry, mAllowScripts, scriptLiteral, aRemove);
                if (NS_FAILED(rv)) return rv;
              }

              // Now set up the package arc.
              if (index != -1) {
                // Peel off the package name.

                nsCAutoString resourceName("urn:mozilla:package:");
                resourceName += packageName;
                nsCOMPtr<nsIRDFResource> packageResource;
                rv = GetResource(resourceName, getter_AddRefs(packageResource));
                if (NS_FAILED(rv)) return rv;
                if (packageResource) {
                  rv = nsChromeRegistry::UpdateArc(installSource, entry, mPackage, packageResource, aRemove);
                  if (NS_FAILED(rv)) return rv;
                }
              }
            }

            rv = seqKids2->HasMoreElements(&moreKids2);
            if (NS_FAILED(rv)) return rv;
          }
        }
      }
      else {
        // We're not a seq. Get all of the arcs that go out.
        nsCOMPtr<nsISimpleEnumerator> arcs;
        rv = dataSource->ArcLabelsOut(resource, getter_AddRefs(arcs));
        if (NS_FAILED(rv)) return rv;

        PRBool moreArcs;
        rv = arcs->HasMoreElements(&moreArcs);
        if (NS_FAILED(rv)) return rv;
        while (moreArcs) {
          nsCOMPtr<nsISupports> supp;
          rv = arcs->GetNext(getter_AddRefs(supp));
          if (NS_FAILED(rv)) return rv;
          nsCOMPtr<nsIRDFResource> arc = do_QueryInterface(supp);

          if (arc == mPackages) {
            // We are the main entry for a skin/locale.
            // Set up our loctype and our script access
            rv = nsChromeRegistry::UpdateArc(installSource, resource, mLocType, locLiteral, aRemove);
            if (NS_FAILED(rv)) return rv;
          }

          nsCOMPtr<nsISimpleEnumerator> targets;
          rv = installSource->GetTargets(resource, arc, PR_TRUE, getter_AddRefs(targets));
          if (NS_FAILED(rv)) return rv;

          PRBool moreTargets;
          rv = targets->HasMoreElements(&moreTargets);
          if (NS_FAILED(rv)) return rv;

          while (moreTargets) {
            targets->GetNext(getter_AddRefs(supp));
            nsCOMPtr<nsIRDFNode> node(do_QueryInterface(supp));
            installSource->Unassert(resource, arc, node);

            rv = targets->HasMoreElements(&moreTargets);
            if (NS_FAILED(rv)) return rv;
          }

          if (!aRemove) {
            rv = dataSource->GetTargets(resource, arc, PR_TRUE, getter_AddRefs(targets));
            if (NS_FAILED(rv)) return rv;

            rv = targets->HasMoreElements(&moreTargets);
            if (NS_FAILED(rv)) return rv;

            while (moreTargets) {
              nsresult rv = targets->GetNext(getter_AddRefs(supp));
              if (NS_FAILED(rv)) return rv;
              nsCOMPtr<nsIRDFNode> newTarget(do_QueryInterface(supp));

              if (arc == mImage) {
                // We are an image URL.  Check to see if we're a relative URL.
                nsCOMPtr<nsIRDFLiteral> literal(do_QueryInterface(newTarget));
                if (literal) {
                  const PRUnichar* valueStr;
                  literal->GetValueConst(&valueStr);
                  nsAutoString imageURL(valueStr);
                  if (imageURL.FindChar(':') == -1) {
                    // We're relative. Prepend the base URL of the
                    // package.
                    NS_ConvertUTF8toUCS2 fullURL(aBaseURL);
                    fullURL += imageURL;
                    mRDFService->GetLiteral(fullURL.get(), getter_AddRefs(literal));
                    newTarget = do_QueryInterface(literal);
                  }
                }
              }

              rv = installSource->Assert(resource, arc, newTarget, PR_TRUE);
              if (NS_FAILED(rv)) return rv;

              rv = targets->HasMoreElements(&moreTargets);
              if (NS_FAILED(rv)) return rv;
            }
          }

          rv = arcs->HasMoreElements(&moreArcs);
          if (NS_FAILED(rv)) return rv;
        }
      }
    }
    rv = resources->HasMoreElements(&moreElements);
    if (NS_FAILED(rv)) return rv;
  }

  // Flush the install source
  nsCOMPtr<nsIRDFRemoteDataSource> remoteInstall = do_QueryInterface(installSource, &rv);
  if (NS_FAILED(rv))
    return NS_OK;

  if (!mBatchInstallFlushes) {
    rv = remoteInstall->Flush();
    // Explicitly ignore permissions failure since we sometimes try to write to
    // global chrome when we shouldn't.
    if (rv == NS_ERROR_FILE_ACCESS_DENIED ||
        rv == NS_ERROR_FILE_READ_ONLY ||
        rv == NS_ERROR_FILE_TOO_BIG)
      rv = NS_OK;
    if (NS_SUCCEEDED(rv) && aProviderType.Equals("package"))
      rv = FlagXPCNativeWrappers();
  }

  // XXX Handle the installation of overlays.

  return rv;
}

Here is the call graph for this function:

void nsIChromeRegistrySea::installSkin ( in string  baseURL,
in boolean  useProfile,
in boolean  allowScripts 
) [inherited]
PRInt32 nsIChromeRegistrySea::isLocaleSelected ( in ACString  localeName,
in boolean  useProfile 
) [inherited]
boolean nsIChromeRegistrySea::isLocaleSelectedForPackage ( in ACString  localeName,
in wstring  packageName,
in boolean  useProfile 
) [inherited]
PRBool nsChromeRegistry::IsOverlayAllowed ( nsIURI aChromeURI) [protected]

Definition at line 2681 of file nsChromeRegistry.cpp.

{
  nsCAutoString package, provider, file;
  nsresult rv = SplitURL(aChromeURL, package, provider, file);
  if (NS_FAILED(rv)) return PR_FALSE;

  // Get the chrome resource for the package.
  nsCAutoString rdfpackage( "urn:mozilla:package:" );
  rdfpackage.Append(package);

  // Obtain the package resource.
  nsCOMPtr<nsIRDFResource> packageResource;
  rv = GetResource(rdfpackage, getter_AddRefs(packageResource));
  if (NS_FAILED(rv) || !packageResource) {
    NS_ERROR("Unable to obtain the package resource.");
    return PR_FALSE;
  }

  // See if the disabled arc is set for the package.
  nsCOMPtr<nsIRDFNode> disabledNode;
  mChromeDataSource->GetTarget(packageResource, mDisabled, PR_TRUE,
                               getter_AddRefs(disabledNode));
  return !disabledNode;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsChromeRegistry::IsProviderSelected ( const nsACString &  aProvider,
const nsACString &  aProviderName,
nsIRDFResource aSelectionArc,
PRBool  aUseProfile,
PRInt32 aResult 
) [private]

Definition at line 2088 of file nsChromeRegistry.cpp.

{
  // Build the provider resource str.
  // e.g., urn:mozilla:skin:aqua/1.0
  *aResult = NONE;
  nsCAutoString resourceStr( "urn:mozilla:" );
  resourceStr += aProvider;
  resourceStr += ":";
  resourceStr += aProviderName;
  // Obtain the provider resource.
  nsresult rv = NS_OK;
  nsCOMPtr<nsIRDFResource> resource;
  rv = GetResource(resourceStr, getter_AddRefs(resource));
  if (NS_FAILED(rv)) {
    NS_ERROR("Unable to obtain the package resource.");
    return rv;
  }
  NS_ASSERTION(resource, "failed to GetResource");

  // Follow the packages arc to the package resources.
  nsCOMPtr<nsIRDFNode> packageList;
  rv = mChromeDataSource->GetTarget(resource, mPackages, PR_TRUE, getter_AddRefs(packageList));
  if (NS_FAILED(rv)) {
    NS_ERROR("Unable to obtain the SEQ for the package list.");
    return rv;
  }
  // ok for packageList to be null here -- it just means that we haven't encountered that package yet

  nsCOMPtr<nsIRDFResource> packageSeq(do_QueryInterface(packageList, &rv));
  if (NS_FAILED(rv)) return rv;

  // Build an RDF container to wrap the SEQ
  nsCOMPtr<nsIRDFContainer> container(do_CreateInstance("@mozilla.org/rdf/container;1"));
  if (NS_FAILED(container->Init(mChromeDataSource, packageSeq)))
    return NS_OK;

  nsCOMPtr<nsISimpleEnumerator> arcs;
  container->GetElements(getter_AddRefs(arcs));

  // For each skin/package entry, follow the arcs to the real package
  // resource.
  PRBool more;
  PRInt32 numSet = 0;
  PRInt32 numPackages = 0;
  rv = arcs->HasMoreElements(&more);
  if (NS_FAILED(rv)) return rv;
  while (more) {
    nsCOMPtr<nsISupports> packageSkinEntry;
    rv = arcs->GetNext(getter_AddRefs(packageSkinEntry));
    if (NS_SUCCEEDED(rv) && packageSkinEntry) {
      nsCOMPtr<nsIRDFResource> entry = do_QueryInterface(packageSkinEntry);
      if (entry) {
         // Obtain the real package resource.
         nsCOMPtr<nsIRDFNode> packageNode;
         rv = mChromeDataSource->GetTarget(entry, mPackage, PR_TRUE, getter_AddRefs(packageNode));
         if (NS_FAILED(rv)) {
           NS_ERROR("Unable to obtain the package resource.");
           return rv;
         }

         // Select the skin for this package resource.
         nsCOMPtr<nsIRDFResource> packageResource(do_QueryInterface(packageNode));
         if (packageResource) {
           PRBool isSet = PR_FALSE;
           rv = IsProviderSetForPackage(aProvider, packageResource, entry, aSelectionArc, aUseProfile, &isSet);
           if (NS_FAILED(rv)) {
             NS_ERROR("Unable to set provider for package resource.");
             return rv;
           }
           ++numPackages;
           if (isSet)
             ++numSet;
         }
      }
    }
    rv = arcs->HasMoreElements(&more);
    if (NS_FAILED(rv)) return rv;
  }
  if (numPackages == numSet)
    *aResult = FULL;
  else if (numSet)
    *aResult = PARTIAL;
  return NS_OK;
}

Here is the call graph for this function:

nsresult nsChromeRegistry::IsProviderSelectedForPackage ( const nsACString &  aProviderType,
const nsACString &  aProviderName,
const PRUnichar aPackageName,
nsIRDFResource aSelectionArc,
PRBool  aUseProfile,
PRBool aResult 
) [private]

Definition at line 2177 of file nsChromeRegistry.cpp.

{
  *aResult = PR_FALSE;
  nsCAutoString package( "urn:mozilla:package:" );
  AppendUTF16toUTF8(aPackageName, package);

  nsCAutoString provider( "urn:mozilla:" );
  provider += aProviderType;
  provider += ":";
  provider += aProviderName;
  provider += ":";
  AppendUTF16toUTF8(aPackageName, provider);

  // Obtain the package resource.
  nsresult rv = NS_OK;
  nsCOMPtr<nsIRDFResource> packageResource;
  rv = GetResource(package, getter_AddRefs(packageResource));
  if (NS_FAILED(rv)) {
    NS_ERROR("Unable to obtain the package resource.");
    return rv;
  }
  NS_ASSERTION(packageResource, "failed to get packageResource");

  // Obtain the provider resource.
  nsCOMPtr<nsIRDFResource> providerResource;
  rv = GetResource(provider, getter_AddRefs(providerResource));
  if (NS_FAILED(rv)) {
    NS_ERROR("Unable to obtain the provider resource.");
    return rv;
  }
  NS_ASSERTION(providerResource, "failed to get providerResource");

  return IsProviderSetForPackage(aProviderType, packageResource, providerResource, aSelectionArc,
                                 aUseProfile, aResult);
}

Here is the call graph for this function:

nsresult nsChromeRegistry::IsProviderSetForPackage ( const nsACString &  aProvider,
nsIRDFResource aPackageResource,
nsIRDFResource aProviderPackageResource,
nsIRDFResource aSelectionArc,
PRBool  aUseProfile,
PRBool aResult 
) [private]

Definition at line 2218 of file nsChromeRegistry.cpp.

{
  nsresult rv;
  // Figure out which file we're needing to modify, e.g., is it the install
  // dir or the profile dir, and get the right datasource.
  
  nsCOMPtr<nsIRDFDataSource> dataSource;
  rv = LoadDataSource(kChromeFileName, getter_AddRefs(dataSource), aUseProfile, nsnull);
  if (NS_FAILED(rv)) return rv;

  nsCOMPtr<nsIRDFNode> retVal;
  dataSource->GetTarget(aPackageResource, aSelectionArc, PR_TRUE, getter_AddRefs(retVal));
  if (retVal) {
    nsCOMPtr<nsIRDFNode> node(do_QueryInterface(aProviderPackageResource));
    if (node == retVal)
      *aResult = PR_TRUE;
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsIChromeRegistrySea::isSkinSelected ( in ACString  skinName,
in boolean  useProfile 
) [inherited]
boolean nsIChromeRegistrySea::isSkinSelectedForPackage ( in ACString  skinName,
in wstring  packageName,
in boolean  useProfile 
) [inherited]
nsresult nsChromeRegistry::LoadDataSource ( const nsACString &  aFileName,
nsIRDFDataSource **  aResult,
PRBool  aUseProfileDirOnly = PR_FALSE,
const char *  aProfilePath = nsnull 
) [private]

Definition at line 1146 of file nsChromeRegistry.cpp.

{
  // Init the data source to null.
  *aResult = nsnull;

  nsCAutoString key;

  // Try the profile root first.
  if (aUseProfileDir) {
    // use given profile path if non-null
    if (aProfilePath) {
      key = aProfilePath;
      key += "chrome/";
    }
    else
      key = mProfileRoot;

    key += aFileName;
  }
  else {
    key = mInstallRoot;
    key += aFileName;
  }

  if (mDataSourceTable)
  {
    nsCStringKey skey(key);
    nsCOMPtr<nsISupports> supports =
      getter_AddRefs(NS_STATIC_CAST(nsISupports*, mDataSourceTable->Get(&skey)));

    if (supports)
    {
      nsCOMPtr<nsIRDFDataSource> dataSource = do_QueryInterface(supports);
      if (dataSource)
      {
        *aResult = dataSource;
        NS_ADDREF(*aResult);
        return NS_OK;
      }
      return NS_ERROR_FAILURE;
    }
  }

  nsresult rv = CallCreateInstance(kRDFXMLDataSourceCID, aResult);
  if (NS_FAILED(rv)) return rv;

  // Seed the datasource with the ``chrome'' namespace
  nsCOMPtr<nsIRDFXMLSink> sink = do_QueryInterface(*aResult);
  if (sink)
    sink->AddNameSpace(sCPrefix, NS_ConvertASCIItoUCS2(CHROME_URI));

  nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(*aResult);
  if (! remote)
      return NS_ERROR_UNEXPECTED;

  if (!mDataSourceTable)
    mDataSourceTable = new nsSupportsHashtable;

  // We need to read this synchronously.
  rv = remote->Init(key.get());
  if (NS_SUCCEEDED(rv))
    rv = remote->Refresh(PR_TRUE);

  nsCOMPtr<nsISupports> supports = do_QueryInterface(remote);
  nsCStringKey skey(key);
  mDataSourceTable->Put(&skey, supports.get());

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3041 of file nsChromeRegistry.cpp.

Here is the call graph for this function:

Definition at line 3055 of file nsChromeRegistry.cpp.

{
  mLegacyOverlayinfo = PR_FALSE;
  nsresult rv = GetProfileRoot(mProfileRoot);
  if (NS_SUCCEEDED(rv)) {
    // Load the profile search path for skins, content, and locales
    // Prepend them to our list of substitutions.
    mProfileInitialized = mInstallInitialized = PR_TRUE;
    mChromeDataSource = nsnull;
    rv = AddToCompositeDataSource(PR_TRUE);
    if (NS_FAILED(rv)) return rv;
    rv = FlagXPCNativeWrappers();
    if (NS_FAILED(rv)) return rv;

    // XXX this sucks ASS. This is a temporary hack until we get
    // around to fixing the skin switching bugs.
    // Select and Remove skins based on a pref set in a previous session.
    nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
    if (prefBranch) {
      nsXPIDLCString skinToSelect;
      rv = prefBranch->GetCharPref("general.skins.selectedSkin", getter_Copies(skinToSelect));
      if (NS_SUCCEEDED(rv)) {
        rv = SelectSkin(skinToSelect, PR_TRUE);
        if (NS_SUCCEEDED(rv))
          prefBranch->DeleteBranch("general.skins.selectedSkin");
      }
    }

    // We have to flush the chrome skin cache...
    FlushSkinCaches();
    
    // make sure we don't lose any old profile overlayinfo
    // by checking the existence of the respective overlayinfo/ directory
    nsCOMPtr<nsIFile> overlayinfoDir;
    rv = NS_GetSpecialDirectory(NS_APP_USER_CHROME_DIR, getter_AddRefs(overlayinfoDir));
    if (NS_SUCCEEDED(rv))
    {
      rv = overlayinfoDir->AppendNative(NS_LITERAL_CSTRING("overlayinfo"));
      if (NS_SUCCEEDED(rv))
      {
        PRBool isLegacyOverlayinfo;
        rv = overlayinfoDir->IsDirectory(&isLegacyOverlayinfo);
        mLegacyOverlayinfo = NS_SUCCEEDED(rv) && isLegacyOverlayinfo;
      }
    }

  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsChromeRegistry::LoadStyleSheetWithURL ( nsIURI aURL,
PRBool  aAllowUnsafeRules,
nsICSSStyleSheet **  aSheet 
) [static, protected]

Definition at line 1080 of file nsChromeRegistry.cpp.

{
  *aSheet = nsnull;

  nsCOMPtr<nsICSSLoader_MOZILLA_1_8_BRANCH> cssLoader = do_GetService(kCSSLoaderCID);
  if (!cssLoader) return NS_ERROR_FAILURE;

  return cssLoader->LoadSheetSync(aURL, aEnableUnsafeRules, aSheet);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsChromeRegistry::LoadStyleSheetWithURL ( nsIURI aURL,
PRBool  aAllowUnsafeRules,
nsICSSStyleSheet **  aSheet 
) [protected]
PRBool nsChromeRegistry::MatchKey ( PLDHashTable table,
const PLDHashEntryHdr entry,
const void key 
) [static, private]

Definition at line 355 of file nsChromeRegistry.cpp.

{
  const nsACString& str = *NS_REINTERPRET_CAST(const nsACString*, key);
  const PackageEntry* pentry = NS_STATIC_CAST(const PackageEntry*, entry);
  return str.Equals(pentry->package);
}
void nsIObserver::observe ( in nsISupports  aSubject,
in string  aTopic,
in wstring  aData 
) [inherited]

Observe will be called when there is a notification for the topic |aTopic|.

This assumes that the object implementing this interface has been registered with an observer service such as the nsIObserverService.

If you expect multiple topics/subjects, the impl is responsible for filtering.

You should not modify, add, remove, or enumerate notifications in the implemention of observe.

Parameters:
aSubject: Notification specific interface pointer.
aTopic: The notification topic or subject.
aData: Notification specific wide string. subject event.
void nsIToolkitChromeRegistry::processContentsManifest ( in nsIURI  aOldManifestURI,
in nsIURI  aFile,
in nsIURI  aBaseURI,
in boolean  aAppend,
in boolean  aSkinOnly 
) [inherited]

The "canonical" manifest is a plaintext file which sits outside of a JAR file.

To provide backwards-compatibility with contents.rdf, we provide this function which reads a contents.rdf manifest and writes it to a file.

Parameters:
aOldManifestURIThe URI of an old manifest to read, without the trailing "contents.rdf", e.g. "jar:resource:///chrome/foo.jar!/content/foo/" or "file://path/to/contents/rdf/"
aFileThe URI of a manifest file to write. It's a good idea to use a resource: URI if possible.
aBaseURIThe base URI for relative path creation "jar:resource:///chrome/foo.jar!/content/foo/" this is a separate param from aOldManifestURI so the "contents.rdf" can be read outside of the jar to keep the zipreader cache from holding it open.
aAppendWhether we should append to an existing manifest or truncate and start empty.
aSkinOnlyOnly allow skin packages.
nsresult nsChromeRegistry::ProcessNewChromeBuffer ( char *  aBuffer,
PRInt32  aLength 
) [private]

Definition at line 1300 of file nsChromeRegistry.cpp.

{
  nsresult rv = NS_OK;
  char   *bufferEnd = aBuffer + aLength;
  char   *chromeType,      // "content", "locale" or "skin"
         *chromeProfile,   // "install" or "profile"
         *chromeLocType,   // type of location (local path or URL)
         *chromeLocation;  // base location of chrome (jar file)

  nsCOMPtr<nsIURI> baseURI;

  // process chromeType, chromeProfile, chromeLocType, chromeLocation
  while (aBuffer < bufferEnd) {
    // parse one line of installed-chrome.txt
    chromeType = aBuffer;
    while (aBuffer < bufferEnd && *aBuffer != ',')
      ++aBuffer;
    *aBuffer = '\0';

    chromeProfile = ++aBuffer;
    if (aBuffer >= bufferEnd)
      break;

    while (aBuffer < bufferEnd && *aBuffer != ',')
      ++aBuffer;
    *aBuffer = '\0';

    chromeLocType = ++aBuffer;
    if (aBuffer >= bufferEnd)
      break;

    while (aBuffer < bufferEnd && *aBuffer != ',')
      ++aBuffer;
    *aBuffer = '\0';

    chromeLocation = ++aBuffer;
    if (aBuffer >= bufferEnd)
      break;

    while (aBuffer < bufferEnd &&
           (*aBuffer != '\r' && *aBuffer != '\n' && *aBuffer != ' '))
      ++aBuffer;
    *aBuffer = '\0';

    // process the line
    // We don't do skin or locale selection from installed-chrome.txt since
    // ffox 0.9. Just ignore the "select" lines.
    if (strcmp(chromeLocType,"select")) {
      if (!strcmp(chromeLocType, "path")) {
        // location is a (full) path. convert it to an URL.

        /* this is some convoluted shit... this creates a file, inits it with
         * the path parsed above (chromeLocation), makes a url, and inits it
         * with the file created. the purpose of this is just to have the
         * canonical url of the stupid thing.
         */
        nsCOMPtr<nsILocalFile> chromeFile;
        rv = NS_NewNativeLocalFile(nsDependentCString(chromeLocation),
                                   PR_TRUE, getter_AddRefs(chromeFile));
        NS_ENSURE_SUCCESS(rv, rv);

        /* 
         * all we want here is the canonical url
         */
        rv = NS_NewFileURI(getter_AddRefs(baseURI), chromeFile);
        if (NS_FAILED(rv)) return rv;
      }
      else {
        rv = NS_NewURI(getter_AddRefs(baseURI), chromeLocation);
        if (NS_FAILED(rv)) return rv;
      }

      ProcessContentsManifest(baseURI, aManifest, baseURI, PR_TRUE,
                              strcmp(chromeType, "skin") == 0);
    }
    
    while (aBuffer < bufferEnd && (*aBuffer == '\0' || *aBuffer == ' ' || *aBuffer == '\r' || *aBuffer == '\n'))
      ++aBuffer;
  }

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 911 of file nsChromeRegistry.cpp.

{
  // Deal with our subframes first.
  nsCOMPtr<nsIDOMWindowCollection> frames;
  aWindow->GetFrames(getter_AddRefs(frames));
  PRUint32 length;
  frames->GetLength(&length);
  PRUint32 j;
  for (j = 0; j < length; j++) {
    nsCOMPtr<nsIDOMWindow> childWin;
    frames->Item(j, getter_AddRefs(childWin));
    nsCOMPtr<nsIDOMWindowInternal> childInt(do_QueryInterface(childWin));
    RefreshWindow(childInt);
  }

  nsresult rv;
  // Get the DOM document.
  nsCOMPtr<nsIDOMDocument> domDocument;
  aWindow->GetDocument(getter_AddRefs(domDocument));
  if (!domDocument)
    return NS_OK;

  nsCOMPtr<nsIDocument> document = do_QueryInterface(domDocument);
  if (!document)
    return NS_OK;

  // Deal with the agent sheets first.  Have to do all the style sets by hand.
  PRUint32 shellCount = document->GetNumberOfShells();
  for (PRUint32 k = 0; k < shellCount; k++) {
    nsIPresShell *shell = document->GetShellAt(k);

    // Reload only the chrome URL agent style sheets.
    nsCOMArray<nsIStyleSheet> agentSheets;
    rv = shell->GetAgentStyleSheets(agentSheets);
    NS_ENSURE_SUCCESS(rv, rv);

    nsCOMArray<nsIStyleSheet> newAgentSheets;
    for (PRInt32 l = 0; l < agentSheets.Count(); ++l) {
      nsIStyleSheet *sheet = agentSheets[l];

      nsCOMPtr<nsIURI> uri;
      rv = sheet->GetSheetURI(getter_AddRefs(uri));
      if (NS_FAILED(rv)) return rv;

      if (IsChromeURI(uri)) {
        // Reload the sheet.
        nsCOMPtr<nsICSSStyleSheet> newSheet;
        rv = LoadStyleSheetWithURL(uri, PR_TRUE, getter_AddRefs(newSheet));
        if (NS_FAILED(rv)) return rv;
        if (newSheet) {
          rv = newAgentSheets.AppendObject(newSheet) ? NS_OK : NS_ERROR_FAILURE;
          if (NS_FAILED(rv)) return rv;
        }
      }
      else {  // Just use the same sheet.
        rv = newAgentSheets.AppendObject(sheet) ? NS_OK : NS_ERROR_FAILURE;
        if (NS_FAILED(rv)) return rv;
      }
    }

    rv = shell->SetAgentStyleSheets(newAgentSheets);
    NS_ENSURE_SUCCESS(rv, rv);
  }

  // Build an array of nsIURIs of style sheets we need to load.
  nsCOMArray<nsIStyleSheet> oldSheets;
  nsCOMArray<nsIStyleSheet> newSheets;

  PRInt32 count = document->GetNumberOfStyleSheets();

  // Iterate over the style sheets.
  PRInt32 i;
  for (i = 0; i < count; i++) {
    // Get the style sheet
    nsIStyleSheet *styleSheet = document->GetStyleSheetAt(i);
    
    if (!oldSheets.AppendObject(styleSheet)) {
      return NS_ERROR_OUT_OF_MEMORY;
    }
  }

  // Iterate over our old sheets and kick off a sync load of the new 
  // sheet if and only if it's a chrome URL.
  for (i = 0; i < count; i++) {
    nsCOMPtr<nsIStyleSheet> sheet = oldSheets[i];
    nsCOMPtr<nsIURI> uri;
    rv = sheet->GetSheetURI(getter_AddRefs(uri));
    if (NS_FAILED(rv)) return rv;

    if (IsChromeURI(uri)) {
      // Reload the sheet.
#ifdef DEBUG
      nsCOMPtr<nsICSSStyleSheet> oldCSSSheet = do_QueryInterface(sheet);
      NS_ASSERTION(oldCSSSheet, "Don't know how to reload a non-CSS sheet");
#endif
      nsCOMPtr<nsICSSStyleSheet> newSheet;
      // XXX what about chrome sheets that have a title or are disabled?  This
      // only works by sheer dumb luck.
      // XXXbz this should really use the document's CSSLoader!
      LoadStyleSheetWithURL(uri, PR_FALSE, getter_AddRefs(newSheet));
      // Even if it's null, we put in in there.
      newSheets.AppendObject(newSheet);
    }
    else {
      // Just use the same sheet.
      newSheets.AppendObject(sheet);
    }
  }

  // Now notify the document that multiple sheets have been added and removed.
  document->UpdateStyleSheets(oldSheets, newSheets);
  return NS_OK;
}

Here is the call graph for this function:

void nsIChromeRegistrySea::selectLocale ( in ACString  localeName,
in boolean  useProfile 
) [inherited]
void nsIChromeRegistrySea::selectLocaleForPackage ( in ACString  localeName,
in wstring  packageName,
in boolean  useProfile 
) [inherited]
void nsIChromeRegistrySea::selectLocaleForProfile ( in ACString  localeName,
in wstring  profilePath 
) [inherited]
nsresult nsChromeRegistry::SelectPackageInProvider ( nsIRDFResource aPackageList,
const nsACString &  aPackage,
const nsACString &  aProvider,
const nsACString &  aProviderName,
nsIRDFResource aArc,
nsIRDFNode **  aSelectedProvider 
) [private]

Definition at line 888 of file nsChromeRegistry.cpp.

{
  *aSelectedProvider = nsnull;

  nsresult rv = NS_OK;

  // wrap aPackageList in a container
  nsCOMPtr<nsIRDFContainer> container =
      do_CreateInstance("@mozilla.org/rdf/container;1", &rv);
  if (NS_SUCCEEDED(rv))
    rv = container->Init(mChromeDataSource, aPackageList);
  if (NS_FAILED(rv))
    return rv;

  // step through its (seq) arcs
  nsCOMPtr<nsISimpleEnumerator> arcs;
  rv = container->GetElements(getter_AddRefs(arcs));
  if (NS_FAILED(rv)) return rv;

  PRBool moreElements;
  rv = arcs->HasMoreElements(&moreElements);
  if (NS_FAILED(rv)) return rv;
  for ( ; moreElements; arcs->HasMoreElements(&moreElements)) {

    // get next arc resource
    nsCOMPtr<nsISupports> supports;
    rv = arcs->GetNext(getter_AddRefs(supports));
    if (NS_FAILED(rv)) return rv;
    nsCOMPtr<nsIRDFResource> kid = do_QueryInterface(supports);

    if (kid) {
      // get its package resource
      nsCOMPtr<nsIRDFNode> packageNode;
      nsCOMPtr<nsIRDFResource> package;
      rv = mChromeDataSource->GetTarget(kid, mPackage, PR_TRUE, getter_AddRefs(packageNode));
      if (NS_SUCCEEDED(rv))
        package = do_QueryInterface(packageNode);
      if (!package)
        continue;

      // get its name
      nsCAutoString packageName;
      rv = FollowArc(mChromeDataSource, packageName, package, mName);
      if (NS_FAILED(rv))
        continue;       // don't fail if package has not yet been installed

      if (packageName.Equals(aPackage)) {
        PRBool useProfile = !mProfileRoot.IsEmpty();
        // XXXldb Do we really want to do this?  We risk crossing skins.
        if (packageName.Equals("global") || packageName.Equals("communicator"))
          useProfile = PR_FALSE; // Always force the auto-selection to be in the
                                 // install dir for the packages required to bring up the profile UI.
        rv = SelectProviderForPackage(aProvider,
                                      aProviderName,
                                      NS_ConvertASCIItoUCS2(packageName).get(),
                                      aArc, useProfile, PR_TRUE);
        if (NS_FAILED(rv))
          return NS_ERROR_FAILURE;

        *aSelectedProvider = kid;
        NS_ADDREF(*aSelectedProvider);
        return NS_OK;
      }
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsChromeRegistry::SelectProviderForPackage ( const nsACString &  aProviderType,
const nsACString &  aProviderName,
const PRUnichar aPackageName,
nsIRDFResource aSelectionArc,
PRBool  aUseProfile,
PRBool  aIsAdding 
) [private]

Definition at line 2022 of file nsChromeRegistry.cpp.

{
  nsCAutoString package( "urn:mozilla:package:" );
  AppendUTF16toUTF8(aPackageName, package);

  nsCAutoString provider( "urn:mozilla:" );
  provider += aProviderType;
  provider += ":";
  provider += aProviderName;
  provider += ":";
  AppendUTF16toUTF8(aPackageName, provider);

  // Obtain the package resource.
  nsresult rv = NS_OK;
  nsCOMPtr<nsIRDFResource> packageResource;
  rv = GetResource(package, getter_AddRefs(packageResource));
  if (NS_FAILED(rv)) {
    NS_ERROR("Unable to obtain the package resource.");
    return rv;
  }
  NS_ASSERTION(packageResource, "failed to get packageResource");

  // Obtain the provider resource.
  nsCOMPtr<nsIRDFResource> providerResource;
  rv = GetResource(provider, getter_AddRefs(providerResource));
  if (NS_FAILED(rv)) {
    NS_ERROR("Unable to obtain the provider resource.");
    return rv;
  }
  NS_ASSERTION(providerResource, "failed to get providerResource");

  // Version-check before selecting.  If this skin isn't a compatible version, then
  // don't allow the selection.
  PRBool acceptable;
  rv = VerifyCompatibleProvider(packageResource, providerResource,
                                aSelectionArc, &acceptable);
  if (NS_FAILED(rv))
    return rv;
  if (!acceptable)
    return NS_ERROR_FAILURE;

  rv = SetProviderForPackage(aProviderType, packageResource, providerResource, aSelectionArc,
                             aUseProfile, nsnull, aIsAdding);
  // always reset the flag
  mRuntimeProvider = PR_FALSE;

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIChromeRegistrySea::selectSkin ( in ACString  skinName,
in boolean  useProfile 
) [inherited]
void nsIChromeRegistrySea::selectSkinForPackage ( in ACString  skinName,
in wstring  packageName,
in boolean  useProfile 
) [inherited]
void nsIChromeRegistrySea::selectSkinForProfile ( in ACString  skinName,
in wstring  profilePath 
) [inherited]
void nsIChromeRegistrySea::setAllowOverlaysForPackage ( in wstring  packageName,
in boolean  allowOverlays 
) [inherited]
nsresult nsChromeRegistry::SetProvider ( const nsACString &  aProvider,
nsIRDFResource aSelectionArc,
const nsACString &  aProviderName,
PRBool  aAllUsers,
const char *  aProfilePath,
PRBool  aIsAdding 
) [private]

Definition at line 1852 of file nsChromeRegistry.cpp.

{
  // Build the provider resource str.
  // e.g., urn:mozilla:skin:aqua/1.0
  nsCAutoString resourceStr( "urn:mozilla:" );
  resourceStr += aProvider;
  resourceStr += ":";
  resourceStr += aProviderName;

  // Obtain the provider resource.
  nsresult rv = NS_OK;
  nsCOMPtr<nsIRDFResource> resource;
  rv = GetResource(resourceStr, getter_AddRefs(resource));
  if (NS_FAILED(rv)) {
    NS_ERROR("Unable to obtain the package resource.");
    return rv;
  }
  NS_ASSERTION(resource, "failed to GetResource");

  // Follow the packages arc to the package resources.
  nsCOMPtr<nsIRDFNode> packageList;
  rv = mChromeDataSource->GetTarget(resource, mPackages, PR_TRUE, getter_AddRefs(packageList));
  if (NS_FAILED(rv)) {
    NS_ERROR("Unable to obtain the SEQ for the package list.");
    return rv;
  }
  // ok for packageList to be null here -- it just means that we haven't encountered that package yet

  nsCOMPtr<nsIRDFResource> packageSeq(do_QueryInterface(packageList, &rv));
  if (NS_FAILED(rv)) return rv;

  // Build an RDF container to wrap the SEQ
  nsCOMPtr<nsIRDFContainer> container =
      do_CreateInstance("@mozilla.org/rdf/container;1", &rv);
  if (NS_FAILED(rv))
    return NS_OK;

  if (NS_FAILED(container->Init(mChromeDataSource, packageSeq)))
    return NS_OK;

  nsCOMPtr<nsISimpleEnumerator> arcs;
  if (NS_FAILED(container->GetElements(getter_AddRefs(arcs))))
    return NS_OK;

  // For each skin/package entry, follow the arcs to the real package
  // resource.
  PRBool more;
  rv = arcs->HasMoreElements(&more);
  if (NS_FAILED(rv)) return rv;
  while (more) {
    nsCOMPtr<nsISupports> packageSkinEntry;
    rv = arcs->GetNext(getter_AddRefs(packageSkinEntry));
    if (NS_SUCCEEDED(rv) && packageSkinEntry) {
      nsCOMPtr<nsIRDFResource> entry = do_QueryInterface(packageSkinEntry);
      if (entry) {
         // Obtain the real package resource.
         nsCOMPtr<nsIRDFNode> packageNode;
         rv = mChromeDataSource->GetTarget(entry, mPackage, PR_TRUE, getter_AddRefs(packageNode));
         if (NS_FAILED(rv)) {
           NS_ERROR("Unable to obtain the package resource.");
           return rv;
         }

         // Select the skin for this package resource.
         nsCOMPtr<nsIRDFResource> packageResource(do_QueryInterface(packageNode));
         if (packageResource) {
           rv = SetProviderForPackage(aProvider, packageResource, entry, aSelectionArc, aUseProfile, aProfilePath, aIsAdding);
           if (NS_FAILED(rv))
             continue; // Well, let's set as many sub-packages as we can...
         }
      }
    }
    rv = arcs->HasMoreElements(&more);
    if (NS_FAILED(rv)) return rv;
  }

  // always reset the flag
  mRuntimeProvider = PR_FALSE;

  return NS_OK;
}

Here is the call graph for this function:

nsresult nsChromeRegistry::SetProviderForPackage ( const nsACString &  aProvider,
nsIRDFResource aPackageResource,
nsIRDFResource aProviderPackageResource,
nsIRDFResource aSelectionArc,
PRBool  aAllUsers,
const char *  aProfilePath,
PRBool  aIsAdding 
) [private]

Definition at line 1939 of file nsChromeRegistry.cpp.

{
  nsresult rv;
  
  if (aUseProfile && !mProfileInitialized) {
    rv = LoadProfileDataSource();
    NS_ENSURE_TRUE(rv, rv);
  }

  // Figure out which file we're needing to modify, e.g., is it the install
  // dir or the profile dir, and get the right datasource.
  nsCOMPtr<nsIRDFDataSource> dataSource;
  rv = LoadDataSource(kChromeFileName, getter_AddRefs(dataSource), aUseProfile, aProfilePath);
  if (NS_FAILED(rv)) return rv;

  rv = nsChromeRegistry::UpdateArc(dataSource, aPackageResource, aSelectionArc, aProviderPackageResource, !aIsAdding);
  if (NS_FAILED(rv)) return rv;

  nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(dataSource, &rv);
  if (NS_FAILED(rv)) return rv;

  // add one more check: 
  //   assert the data source only when we are not setting runtime-only provider
  if (!mBatchInstallFlushes && !mRuntimeProvider)
    rv = remote->Flush();
  // Explicitly ignore permissions failure since we sometimes try to write to
  // global chrome when we shouldn't.
  if (rv == NS_ERROR_FILE_ACCESS_DENIED ||
      rv == NS_ERROR_FILE_READ_ONLY ||
      rv == NS_ERROR_FILE_TOO_BIG)
    rv = NS_OK;

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIChromeRegistrySea::setRuntimeProvider ( in boolean  runtimeProvider) [inherited]
void nsIChromeRegistrySea::uninstallLocale ( in ACString  localeName,
in boolean  useProfile 
) [inherited]
void nsIChromeRegistrySea::uninstallPackage ( in ACString  packageName,
in boolean  useProfile 
) [inherited]
nsresult nsChromeRegistry::UninstallProvider ( const nsACString &  aProviderType,
const nsACString &  aProviderName,
PRBool  aUseProfile 
) [private]

Definition at line 2751 of file nsChromeRegistry.cpp.

{
  // XXX We are going to simply do a snip of the arc from the seq ROOT to
  // the associated package.  waterson is going to provide the ability to name
  // roots in a datasource, and only resources that are reachable from the
  // root will be saved.
  nsresult rv = NS_OK;
  nsCAutoString prefix( "urn:mozilla:" );
  prefix += aProviderType;
  prefix += ":";

  // Obtain the root.
  nsCAutoString providerRoot(prefix);
  providerRoot += "root";

  // Obtain the child we wish to remove.
  nsCAutoString specificChild(prefix);
  specificChild += aProviderName;

  // Instantiate the data source we wish to modify.
  nsCOMPtr<nsIRDFDataSource> installSource;
  rv = LoadDataSource(kChromeFileName, getter_AddRefs(installSource), aUseProfile, nsnull);
  if (NS_FAILED(rv)) return rv;
  NS_ASSERTION(installSource, "failed to get installSource");

  // Now make a container out of the root seq.
  nsCOMPtr<nsIRDFContainer> container(do_CreateInstance("@mozilla.org/rdf/container;1"));

  // Get the resource for the root.
  nsCOMPtr<nsIRDFResource> chromeResource;
  if (NS_FAILED(rv = GetResource(providerRoot, getter_AddRefs(chromeResource)))) {
    NS_ERROR("Unable to retrieve the resource corresponding to the skin/locale root.");
    return rv;
  }

  if (NS_FAILED(container->Init(installSource, chromeResource)))
    return NS_ERROR_FAILURE;

  // Get the resource for the child.
  nsCOMPtr<nsIRDFResource> childResource;
  if (NS_FAILED(rv = GetResource(specificChild, getter_AddRefs(childResource)))) {
    NS_ERROR("Unable to retrieve the resource corresponding to the skin/locale child being removed.");
    return rv;
  }

  // Remove the child from the container.
  container->RemoveElement(childResource, PR_TRUE);

  // Now flush the datasource.
  nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(installSource);
  remote->Flush();

  return NS_OK;
}

Here is the call graph for this function:

void nsIChromeRegistrySea::uninstallSkin ( in ACString  skinName,
in boolean  useProfile 
) [inherited]
nsresult nsChromeRegistry::UpdateArc ( nsIRDFDataSource aDataSource,
nsIRDFResource aSource,
nsIRDFResource aProperty,
nsIRDFNode aTarget,
PRBool  aRemove 
) [static]

Definition at line 1282 of file nsChromeRegistry.cpp.

{
  nsresult rv;
  // Get the old targets
  nsCOMPtr<nsIRDFNode> retVal;
  rv = aDataSource->GetTarget(aSource, aProperty, PR_TRUE, getter_AddRefs(retVal));
  if (NS_FAILED(rv)) return rv;

  if (retVal) {
    if (!aRemove)
      aDataSource->Change(aSource, aProperty, retVal, aTarget);
    else
      aDataSource->Unassert(aSource, aProperty, aTarget);
  }
  else if (!aRemove)
    aDataSource->Assert(aSource, aProperty, aTarget, PR_TRUE);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsChromeRegistry::UpdateDynamicDataSource ( nsIRDFDataSource aDataSource,
nsIRDFResource aResource,
PRBool  aIsOverlay,
PRBool  aUseProfile,
PRBool  aRemove 
) [protected]

Definition at line 1610 of file nsChromeRegistry.cpp.

{
  nsresult rv;

  nsCOMPtr<nsIRDFContainer> container =
      do_CreateInstance("@mozilla.org/rdf/container;1", &rv);
  if (NS_FAILED(rv)) return rv;

  rv = container->Init(aDataSource, aResource);
  if (NS_FAILED(rv)) return rv;

  nsCOMPtr<nsISimpleEnumerator> arcs;
  rv = container->GetElements(getter_AddRefs(arcs));
  if (NS_FAILED(rv)) return rv;

  PRBool moreElements;
  rv = arcs->HasMoreElements(&moreElements);
  if (NS_FAILED(rv)) return rv;

  const char *value;
  rv = aResource->GetValueConst(&value);
  if (NS_FAILED(rv)) return rv;

  while (moreElements)
  {
    nsCOMPtr<nsISupports> supports;
    rv = arcs->GetNext(getter_AddRefs(supports));
    if (NS_FAILED(rv)) return rv;

    nsCOMPtr<nsIRDFLiteral> literal = do_QueryInterface(supports, &rv);

    if (NS_SUCCEEDED(rv))
    {
      const PRUnichar* valueStr;
      rv = literal->GetValueConst(&valueStr);
      if (NS_FAILED(rv)) return rv;

      rv = WriteInfoToDataSource(value, valueStr, aIsOverlay, aUseProfile, aRemove);
      if (NS_FAILED(rv)) return rv;
    }
    rv = arcs->HasMoreElements(&moreElements);
    if (NS_FAILED(rv)) return rv;
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsChromeRegistry::UpdateDynamicDataSources ( nsIRDFDataSource aDataSource,
PRBool  aIsOverlay,
PRBool  aUseProfile,
PRBool  aRemove 
) [protected]

Definition at line 1662 of file nsChromeRegistry.cpp.

{
  nsresult rv;
  nsCOMPtr<nsIRDFResource> resource;
  nsCAutoString root;
  if (aIsOverlay)
    root.Assign("urn:mozilla:overlays");
  else root.Assign("urn:mozilla:stylesheets");

  rv = GetResource(root, getter_AddRefs(resource));

  if (!resource)
    return NS_OK;

  nsCOMPtr<nsIRDFContainer> container(do_CreateInstance("@mozilla.org/rdf/container;1"));
  if (!container)
    return NS_OK;

  if (NS_FAILED(container->Init(aDataSource, resource)))
    return NS_OK;

  nsCOMPtr<nsISimpleEnumerator> arcs;
  if (NS_FAILED(container->GetElements(getter_AddRefs(arcs))))
    return NS_OK;

  PRBool moreElements;
  rv = arcs->HasMoreElements(&moreElements);
  if (NS_FAILED(rv)) return rv;

  while (moreElements)
  {
    nsCOMPtr<nsISupports> supports;
    rv = arcs->GetNext(getter_AddRefs(supports));
    if (NS_FAILED(rv)) return rv;

    nsCOMPtr<nsIRDFResource> resource2 = do_QueryInterface(supports, &rv);

    if (NS_SUCCEEDED(rv))
    {
      rv = UpdateDynamicDataSource(aDataSource, resource2, aIsOverlay, aUseProfile, aRemove);
      if (NS_FAILED(rv)) return rv;
    }

    rv = arcs->HasMoreElements(&moreElements);
    if (NS_FAILED(rv)) return rv;
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsChromeRegistry::VerifyCompatibleProvider ( nsIRDFResource aPackageResource,
nsIRDFResource aProviderResource,
nsIRDFResource aArc,
PRBool aAcceptable 
) [private]

Definition at line 765 of file nsChromeRegistry.cpp.

{
  // We found a selected provider, but now we need to verify that the version
  // specified by the package and the version specified by the provider are
  // one and the same.  If they aren't, then we cannot use this provider.
  nsCOMPtr<nsIRDFResource> versionArc;
  if (aArc == mSelectedSkin)
    versionArc = mSkinVersion;
  else // Locale arc
    versionArc = mLocaleVersion;

  nsCOMPtr<nsIRDFNode> packageVersionNode;
  mChromeDataSource->GetTarget(aPackageResource, versionArc, PR_TRUE,
                               getter_AddRefs(packageVersionNode));
  if (packageVersionNode) {
    // The package only wants providers (skins) that say they can work
    // with it.  Let's find out if our provider (skin) can work with it.
    mChromeDataSource->HasAssertion(aProviderResource, versionArc,
                                    packageVersionNode, PR_TRUE, aAcceptable);
    if (!*aAcceptable)
      return NS_OK;
  }
  
  // Ensure that the provider actually exists.
  // XXX This will have to change if we handle remote chrome.
  nsCAutoString providerBaseURL;
  nsresult rv = FollowArc(mChromeDataSource, providerBaseURL,
                          aProviderResource, mBaseURL);
  if (NS_FAILED(rv))
    return rv;
  nsCOMPtr<nsIFile> baseURLFile;
  rv = GetBaseURLFile(providerBaseURL, getter_AddRefs(baseURLFile));
  if (NS_FAILED(rv))
    return rv;
  rv = baseURLFile->Exists(aAcceptable);
#if DEBUG
  if (NS_FAILED(rv) || !*aAcceptable)
    printf("BaseURL %s cannot be found.\n",
           PromiseFlatCString(providerBaseURL).get());
#endif
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsChromeRegistry::WriteInfoToDataSource ( const char *  aDocURI,
const PRUnichar aOverlayURI,
PRBool  aIsOverlay,
PRBool  aUseProfile,
PRBool  aRemove 
) [protected]

Definition at line 1501 of file nsChromeRegistry.cpp.

{
  nsresult rv;
  nsCOMPtr<nsIURI> uri;
  nsCAutoString str(aDocURI);
  rv = NS_NewURI(getter_AddRefs(uri), str);
  if (NS_FAILED(rv)) return rv;

  if (!aRemove) {
    // We are installing a dynamic overlay or package.  
    // We must split the doc URI and obtain our package or skin.
    // We then annotate the chrome.rdf datasource in the appropriate
    // install/profile dir (based off aUseProfile) with the knowledge
    // that we have overlays or stylesheets.
    nsCAutoString package, provider, file;
    rv = SplitURL(uri, package, provider, file);
    if (NS_FAILED(rv)) return NS_OK;
    
    // Obtain our chrome data source.
    nsDependentCString dataSourceStr(kChromeFileName);
    nsCOMPtr<nsIRDFDataSource> mainDataSource;
    rv = LoadDataSource(dataSourceStr, getter_AddRefs(mainDataSource), aUseProfile, nsnull);
    if (NS_FAILED(rv)) return rv;
    
    // Now that we have the appropriate chrome.rdf file, we 
    // must annotate the package resource with the knowledge of
    // whether or not we have stylesheets or overlays.
    nsCOMPtr<nsIRDFResource> hasDynamicDataArc;
    if (aIsOverlay)
      hasDynamicDataArc = mHasOverlays;
    else
      hasDynamicDataArc = mHasStylesheets;
    
    // Obtain the resource for the package.
    nsCAutoString packageResourceStr("urn:mozilla:package:");
    packageResourceStr += package;
    nsCOMPtr<nsIRDFResource> packageResource;
    GetResource(packageResourceStr, getter_AddRefs(packageResource));
    
    // Now add the arc to the package.
    nsCOMPtr<nsIRDFLiteral> trueLiteral;
    mRDFService->GetLiteral(NS_LITERAL_STRING("true").get(), getter_AddRefs(trueLiteral));
    nsChromeRegistry::UpdateArc(mainDataSource, packageResource, 
                                hasDynamicDataArc, 
                                trueLiteral, PR_FALSE);
  }

  nsCOMPtr<nsIRDFDataSource> dataSource;
  rv = GetDynamicDataSource(uri, aIsOverlay, aUseProfile, PR_TRUE, getter_AddRefs(dataSource));
  if (NS_FAILED(rv)) return rv;

  if (!dataSource)
    return NS_OK;

  nsCOMPtr<nsIRDFResource> resource;
  rv = GetResource(str, getter_AddRefs(resource));

  if (NS_FAILED(rv))
    return NS_OK;

  nsCOMPtr<nsIRDFContainer> container;
  rv = mRDFContainerUtils->MakeSeq(dataSource, resource, getter_AddRefs(container));
  if (NS_FAILED(rv)) return rv;
  if (!container) {
    // Already exists. Create a container instead.
    container = do_CreateInstance("@mozilla.org/rdf/container;1", &rv);
    if (NS_FAILED(rv)) return rv;
    rv = container->Init(dataSource, resource);
    if (NS_FAILED(rv)) return rv;
  }

  nsAutoString unistr(aOverlayURI);
  nsCOMPtr<nsIRDFLiteral> literal;
  rv = mRDFService->GetLiteral(unistr.get(), getter_AddRefs(literal));
  if (NS_FAILED(rv)) return rv;

  if (aRemove) {
    rv = container->RemoveElement(literal, PR_TRUE);
    if (NS_FAILED(rv)) return rv;
  }
  else {
    PRInt32 index;
    rv = container->IndexOf(literal, &index);
    if (NS_FAILED(rv)) return rv;
    if (index == -1) {
      rv = container->AppendElement(literal);
      if (NS_FAILED(rv)) return rv;
    }
  }

  nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(dataSource, &rv);
  if (NS_SUCCEEDED(rv)) {
    rv = remote->Flush();
    // Explicitly ignore permissions failure since we sometimes try to write to
    // global chrome when we shouldn't.
    if (rv == NS_ERROR_FILE_ACCESS_DENIED ||
        rv == NS_ERROR_FILE_READ_ONLY ||
        rv == NS_ERROR_FILE_TOO_BIG)
      rv = NS_OK;
  }

  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 112 of file nsChromeRegistry.h.

Definition at line 112 of file nsChromeRegistry.h.

Definition at line 120 of file nsChromeRegistry.h.

Definition at line 120 of file nsChromeRegistry.h.

Definition at line 121 of file nsChromeRegistry.h.

Definition at line 122 of file nsChromeRegistry.h.

Definition at line 112 of file nsChromeRegistry.h.

Definition at line 112 of file nsChromeRegistry.h.

Definition at line 115 of file nsChromeRegistry.h.

Definition at line 119 of file nsChromeRegistry.h.

Definition at line 120 of file nsChromeRegistry.h.

Definition at line 115 of file nsChromeRegistry.h.

Definition at line 112 of file nsChromeRegistry.h.

Definition at line 115 of file nsChromeRegistry.h.

Definition at line 51 of file nsIChromeRegistry.idl.

Definition at line 92 of file nsChromeRegistry.h.

Definition at line 254 of file nsChromeRegistry.h.

Definition at line 248 of file nsChromeRegistry.h.

Definition at line 276 of file nsChromeRegistry.h.

Definition at line 237 of file nsChromeRegistry.h.

nsSupportsHashtable* nsChromeRegistry::mDataSourceTable [protected]

Definition at line 241 of file nsChromeRegistry.h.

Definition at line 260 of file nsChromeRegistry.h.

Definition at line 255 of file nsChromeRegistry.h.

Definition at line 256 of file nsChromeRegistry.h.

Definition at line 252 of file nsChromeRegistry.h.

Definition at line 231 of file nsChromeRegistry.h.

Definition at line 238 of file nsChromeRegistry.h.

Definition at line 269 of file nsChromeRegistry.h.

Definition at line 235 of file nsChromeRegistry.h.

Definition at line 283 of file nsChromeRegistry.h.

Definition at line 258 of file nsChromeRegistry.h.

Definition at line 253 of file nsChromeRegistry.h.

Definition at line 251 of file nsChromeRegistry.h.

Definition at line 238 of file nsChromeRegistry.h.

Definition at line 263 of file nsChromeRegistry.h.

Definition at line 264 of file nsChromeRegistry.h.

Definition at line 242 of file nsChromeRegistry.h.

Definition at line 250 of file nsChromeRegistry.h.

Definition at line 249 of file nsChromeRegistry.h.

Definition at line 234 of file nsChromeRegistry.h.

Definition at line 259 of file nsChromeRegistry.h.

Definition at line 270 of file nsChromeRegistry.h.

Definition at line 234 of file nsChromeRegistry.h.

Definition at line 243 of file nsChromeRegistry.h.

Definition at line 242 of file nsChromeRegistry.h.

Definition at line 272 of file nsChromeRegistry.h.

Definition at line 279 of file nsChromeRegistry.h.

Definition at line 244 of file nsChromeRegistry.h.

Definition at line 247 of file nsChromeRegistry.h.

Definition at line 245 of file nsChromeRegistry.h.

Definition at line 246 of file nsChromeRegistry.h.

Definition at line 257 of file nsChromeRegistry.h.

Definition at line 239 of file nsChromeRegistry.h.

Definition at line 239 of file nsChromeRegistry.h.

Definition at line 261 of file nsChromeRegistry.h.

Definition at line 49 of file nsIChromeRegistry.idl.

Definition at line 50 of file nsIChromeRegistry.idl.

nsIAtom * nsChromeRegistry::sCPrefix [static, protected]

Definition at line 267 of file nsChromeRegistry.h.


The documentation for this class was generated from the following files: