Bug 452486 - Create components when we actually have a profile
authorShawn Wilsher <sdwilsh@shawnwilsher.com>
Fri, 29 Aug 2008 16:40:05 -0400
changeset 18528 7a679b9335f3d720f73f0530df220efaa6ac30bd
parent 18527 f1bb365372c6d7f74e199deea15cc6c632c5d180
child 18529 0885656b0f70ddee3b13a158e925e119290fab0b
push idunknown
push userunknown
push dateunknown
bugs452486
milestone1.9.1b1pre
Bug 452486 - Create components when we actually have a profile This changeset allows components to register for the profile-after-change category in the category manager such that they will be initialized when this topic would normally be dispatched. r=bsmedberg
caps/src/nsNullPrincipalURI.cpp
toolkit/xre/nsXREDirProvider.cpp
--- a/caps/src/nsNullPrincipalURI.cpp
+++ b/caps/src/nsNullPrincipalURI.cpp
@@ -135,18 +135,17 @@ NS_IMETHODIMP
 nsNullPrincipalURI::SetPassword(const nsACString &aPassword)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 nsNullPrincipalURI::GetPath(nsACString &_path)
 {
-  // We want to give a full copy of the string and not share a string buffer
-  _path = nsDependentCString(mPath);
+  _path = mPath;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNullPrincipalURI::SetPath(const nsACString &aPath)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -168,18 +167,17 @@ NS_IMETHODIMP
 nsNullPrincipalURI::SetPort(PRInt32 aPort)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 nsNullPrincipalURI::GetScheme(nsACString &_scheme)
 {
-  // We want to give a full copy of the string and not share a string buffer
-  _scheme = nsDependentCString(mScheme);
+  _scheme = mScheme;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNullPrincipalURI::SetScheme(const nsACString &aScheme)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -234,18 +232,17 @@ nsNullPrincipalURI::Clone(nsIURI **_newU
 NS_IMETHODIMP
 nsNullPrincipalURI::Equals(nsIURI *aOther, PRBool *_equals)
 {
   *_equals = PR_FALSE;
   nsNullPrincipalURI *otherURI;
   nsresult rv = aOther->QueryInterface(kNullPrincipalURIImplementationCID,
                                        (void **)&otherURI);
   if (NS_SUCCEEDED(rv)) {
-    *_equals = (0 == strcmp(mScheme.get(), otherURI->mScheme.get()) &&
-                0 == strcmp(mPath.get(), otherURI->mPath.get()));
+    *_equals = (mScheme == otherURI->mScheme && mPath == otherURI->mPath);
     NS_RELEASE(otherURI);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNullPrincipalURI::Resolve(const nsACString &aRelativePath,
                             nsACString &_resolvedURI)
--- a/toolkit/xre/nsXREDirProvider.cpp
+++ b/toolkit/xre/nsXREDirProvider.cpp
@@ -51,16 +51,17 @@
 #include "nsIProfileChangeStatus.h"
 #include "nsISimpleEnumerator.h"
 #include "nsIToolkitChromeRegistry.h"
 
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsXULAppAPI.h"
+#include "nsCategoryManagerUtils.h"
 
 #include "nsINIParser.h"
 #include "nsDependentString.h"
 #include "nsCOMArray.h"
 #include "nsArrayEnumerator.h"
 #include "nsEnumeratorUtils.h"
 #include "nsReadableUtils.h"
 
@@ -797,16 +798,21 @@ nsXREDirProvider::DoStartup()
       (do_GetService("@mozilla.org/observer-service;1"));
     if (!obsSvc) return NS_ERROR_FAILURE;
 
     mProfileNotified = PR_TRUE;
 
     static const PRUnichar kStartup[] = {'s','t','a','r','t','u','p','\0'};
     obsSvc->NotifyObservers(nsnull, "profile-do-change", kStartup);
     obsSvc->NotifyObservers(nsnull, "profile-after-change", kStartup);
+
+    // Any component that has registered for the profile-after-change category
+    // should also be created at this time.
+    (void)NS_CreateServicesFromCategory("profile-after-change", nsnull,
+                                        "profile-after-change");
   }
   return NS_OK;
 }
 
 class ProfileChangeStatusImpl : public nsIProfileChangeStatus
 {
 public:
   NS_DECL_ISUPPORTS