Bug 576507: Forward the selected locale to content process to satisfy callers that want "some locale". r=jdm sr=bsmedberg a=a
authorChris Jones <jones.chris.g@gmail.com>
Tue, 11 Jan 2011 15:34:31 -0600
changeset 60319 95f32675752ff71f85f0d7d4dc276ec35f405142
parent 60318 556f7620b78fdd0d5b0714cc4b6fc472258d438d
child 60320 735dfa53d77994504211873a3135115d6c813782
push idunknown
push userunknown
push dateunknown
reviewersjdm, bsmedberg, a
bugs576507
milestone2.0b10pre
Bug 576507: Forward the selected locale to content process to satisfy callers that want "some locale". r=jdm sr=bsmedberg a=a
chrome/src/nsChromeRegistryChrome.cpp
chrome/src/nsChromeRegistryContent.cpp
chrome/src/nsChromeRegistryContent.h
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/PContent.ipdl
--- a/chrome/src/nsChromeRegistryChrome.cpp
+++ b/chrome/src/nsChromeRegistryChrome.cpp
@@ -504,17 +504,18 @@ nsChromeRegistryChrome::SendRegisteredCh
 
   //FIXME: Some substitutions are set up lazily and might not exist yet
   nsCOMPtr<nsIResProtocolHandler> irph (do_QueryInterface(ph));
   nsResProtocolHandler* rph = static_cast<nsResProtocolHandler*>(irph.get());
   rph->CollectSubstitutions(resources);
 
   mOverrideTable.EnumerateRead(&EnumerateOverride, &overrides);
 
-  bool success = aParent->SendRegisterChrome(packages, resources, overrides);
+  bool success = aParent->SendRegisterChrome(packages, resources, overrides,
+                                             mSelectedLocale);
   NS_ENSURE_TRUE(success, );
 }
 
 PLDHashOperator
 nsChromeRegistryChrome::CollectPackages(PLDHashTable *table,
                                   PLDHashEntryHdr *entry,
                                   PRUint32 number,
                                   void *arg)
--- a/chrome/src/nsChromeRegistryContent.cpp
+++ b/chrome/src/nsChromeRegistryContent.cpp
@@ -47,32 +47,38 @@ nsChromeRegistryContent::nsChromeRegistr
 {
   mPackagesHash.Init();
 }
 
 void
 nsChromeRegistryContent::RegisterRemoteChrome(
     const nsTArray<ChromePackage>& aPackages,
     const nsTArray<ResourceMapping>& aResources,
-    const nsTArray<OverrideMapping>& aOverrides)
+    const nsTArray<OverrideMapping>& aOverrides,
+    const nsACString& aLocale)
 {
+  NS_ABORT_IF_FALSE(mLocale == nsDependentCString(""),
+                    "RegisterChrome twice?");
+
   for (PRUint32 i = aPackages.Length(); i > 0; ) {
     --i;
     RegisterPackage(aPackages[i]);
   }
 
   for (PRUint32 i = aResources.Length(); i > 0; ) {
     --i;
     RegisterResource(aResources[i]);
   }
 
   for (PRUint32 i = aOverrides.Length(); i > 0; ) {
     --i;
     RegisterOverride(aOverrides[i]);
   }
+
+  mLocale = aLocale;
 }
 
 void
 nsChromeRegistryContent::RegisterPackage(const ChromePackage& aPackage)
 {
   nsCOMPtr<nsIIOService> io (do_GetIOService());
   if (!io)
     return;
@@ -238,17 +244,22 @@ nsChromeRegistryContent::IsLocaleRTL(con
 {
   CONTENT_NOT_IMPLEMENTED();
 }
 
 NS_IMETHODIMP
 nsChromeRegistryContent::GetSelectedLocale(const nsACString& aPackage,
                                            nsACString& aLocale)
 {
-  CONTENT_NOT_IMPLEMENTED();
+  if (aPackage != nsDependentCString("global")) {
+    NS_ERROR("Uh-oh, caller wanted something other than 'some local'");
+    return NS_ERROR_NOT_AVAILABLE;
+  }
+  aLocale = mLocale;
+  return NS_OK;
 }
   
 NS_IMETHODIMP
 nsChromeRegistryContent::Observe(nsISupports* aSubject, const char* aTopic,
                                  const PRUnichar* aData)
 {
   CONTENT_NOT_IMPLEMENTED();
 }
--- a/chrome/src/nsChromeRegistryContent.h
+++ b/chrome/src/nsChromeRegistryContent.h
@@ -50,17 +50,18 @@ struct OverrideMapping;
 
 class nsChromeRegistryContent : public nsChromeRegistry
 {
  public:
   nsChromeRegistryContent();
   
   void RegisterRemoteChrome(const nsTArray<ChromePackage>& aPackages,
                             const nsTArray<ResourceMapping>& aResources,
-                            const nsTArray<OverrideMapping>& aOverrides);
+                            const nsTArray<OverrideMapping>& aOverrides,
+                            const nsACString& aLocale);
 
   NS_OVERRIDE NS_IMETHOD GetLocalesForPackage(const nsACString& aPackage,
                                               nsIUTF8StringEnumerator* *aResult);
   NS_OVERRIDE NS_IMETHOD CheckForNewChrome();
   NS_OVERRIDE NS_IMETHOD CheckForOSAccessibility();
   NS_OVERRIDE NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
                                  const PRUnichar* aData);
   NS_OVERRIDE NS_IMETHOD IsLocaleRTL(const nsACString& package,
@@ -90,16 +91,17 @@ class nsChromeRegistryContent : public n
 
   NS_OVERRIDE void UpdateSelectedLocale();
   NS_OVERRIDE nsIURI* GetBaseURIFromPackage(const nsCString& aPackage,
                                  const nsCString& aProvider,
                                  const nsCString& aPath);
   NS_OVERRIDE nsresult GetFlagsFromPackage(const nsCString& aPackage, PRUint32* aFlags);
 
   nsClassHashtable<nsCStringHashKey, PackageEntry> mPackagesHash;
+  nsCString mLocale;
 
   virtual void ManifestContent(ManifestProcessingContext& cx, int lineno,
                                char *const * argv, bool platform,
                                bool contentaccessible);
   virtual void ManifestLocale(ManifestProcessingContext& cx, int lineno,
                               char *const * argv, bool platform,
                               bool contentaccessible);
   virtual void ManifestSkin(ManifestProcessingContext& cx, int lineno,
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -393,22 +393,23 @@ ContentChild::DeallocPStorage(PStorageCh
     StorageChild* child = static_cast<StorageChild*>(aActor);
     child->ReleaseIPDLReference();
     return true;
 }
 
 bool
 ContentChild::RecvRegisterChrome(const InfallibleTArray<ChromePackage>& packages,
                                  const InfallibleTArray<ResourceMapping>& resources,
-                                 const InfallibleTArray<OverrideMapping>& overrides)
+                                 const InfallibleTArray<OverrideMapping>& overrides,
+                                 const nsCString& locale)
 {
     nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
     nsChromeRegistryContent* chromeRegistry =
         static_cast<nsChromeRegistryContent*>(registrySvc.get());
-    chromeRegistry->RegisterRemoteChrome(packages, resources, overrides);
+    chromeRegistry->RegisterRemoteChrome(packages, resources, overrides, locale);
     return true;
 }
 
 bool
 ContentChild::RecvSetOffline(const PRBool& offline)
 {
   nsCOMPtr<nsIIOService> io (do_GetIOService());
   NS_ASSERTION(io, "IO Service can not be null");
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -104,17 +104,18 @@ public:
             const IPC::URI& aReferrer);
     virtual bool DeallocPExternalHelperApp(PExternalHelperAppChild *aService);
 
     virtual PStorageChild* AllocPStorage(const StorageConstructData& aData);
     virtual bool DeallocPStorage(PStorageChild* aActor);
 
     virtual bool RecvRegisterChrome(const InfallibleTArray<ChromePackage>& packages,
                                     const InfallibleTArray<ResourceMapping>& resources,
-                                    const InfallibleTArray<OverrideMapping>& overrides);
+                                    const InfallibleTArray<OverrideMapping>& overrides,
+                                    const nsCString& locale);
 
     virtual bool RecvSetOffline(const PRBool& offline);
 
     virtual bool RecvNotifyVisited(const IPC::URI& aURI);
     // auto remove when alertfinished is received.
     nsresult AddRemoteAlertObserver(const nsString& aData, nsIObserver* aObserver);
 
     virtual bool RecvPreferenceUpdate(const PrefTuple& aPref);
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -92,17 +92,17 @@ rpc protocol PContent
     manages PStorage;
 
 child:
     PBrowser(PRUint32 chromeFlags);
 
     PTestShell();
 
     RegisterChrome(ChromePackage[] packages, ResourceMapping[] resources,
-                   OverrideMapping[] overrides);
+                   OverrideMapping[] overrides, nsCString locale);
 
     async SetOffline(PRBool offline);
 
     async NotifyVisited(URI uri);
 
     PreferenceUpdate(PrefTuple pref);
     ClearUserPreference(nsCString prefName);