Bug 683245 - Make navigator.buildID and navigator.version work in content processes. r=bsmedberg

This commit is contained in:
Jiten Thakkar 2011-10-04 16:31:00 -04:00
parent fdd4bfc148
commit c77efb58c1
6 changed files with 60 additions and 1 deletions

View File

@ -789,5 +789,13 @@ ContentChild::RecvCycleCollect()
return true;
}
bool
ContentChild::RecvAppInfo(const nsCString& version, const nsCString& buildID)
{
mAppInfo.version.Assign(version);
mAppInfo.buildID.Assign(buildID);
return true;
}
} // namespace dom
} // namespace mozilla

View File

@ -64,6 +64,12 @@ public:
ContentChild();
virtual ~ContentChild();
struct AppInfo
{
nsCString version;
nsCString buildID;
};
bool Init(MessageLoop* aIOLoop,
base::ProcessHandle aParentHandle,
IPC::Channel* aChannel);
@ -74,6 +80,10 @@ public:
return sSingleton;
}
const AppInfo& GetAppInfo() {
return mAppInfo;
}
/* if you remove this, please talk to cjones or dougt */
virtual bool RecvDummy(Shmem& foo) { return true; }
@ -154,6 +164,8 @@ public:
virtual bool RecvGarbageCollect();
virtual bool RecvCycleCollect();
virtual bool RecvAppInfo(const nsCString& version, const nsCString& buildID);
#ifdef ANDROID
gfxIntSize GetScreenSize() { return mScreenSize; }
#endif
@ -181,6 +193,8 @@ private:
gfxIntSize mScreenSize;
#endif
AppInfo mAppInfo;
static ContentChild* sSingleton;
DISALLOW_EVIL_CONSTRUCTORS(ContentChild);

View File

@ -71,6 +71,7 @@
#include "nsIScriptError.h"
#include "nsConsoleMessage.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsAppRunner.h"
#include "IDBFactory.h"
#if defined(MOZ_SYDNEYAUDIO)
#include "AudioParent.h"
@ -427,6 +428,14 @@ ContentParent::ContentParent()
static_cast<nsChromeRegistryChrome*>(registrySvc.get());
chromeRegistry->SendRegisteredChrome(this);
mMessageManager = nsFrameMessageManager::NewProcessMessageManager(this);
if (gAppData) {
nsCString version(gAppData->version);
nsCString buildID(gAppData->buildID);
//Sending all information to content process
SendAppInfo(version, buildID);
}
}
ContentParent::~ContentParent()

View File

@ -107,6 +107,7 @@ LOCAL_INCLUDES += \
-I$(srcdir)/../indexedDB \
-I$(topsrcdir)/extensions/cookie \
-I$(topsrcdir)/dom/base \
-I$(topsrcdir)/toolkit/xre \
$(NULL)
DEFINES += -DBIN_SUFFIX='"$(BIN_SUFFIX)"'

View File

@ -143,6 +143,8 @@ child:
*/
ActivateA11y();
AppInfo(nsCString version, nsCString buildID);
parent:
PNecko();

View File

@ -60,6 +60,7 @@
#endif // MOZ_WIDGET_QT
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/ContentChild.h"
#include "nsAppRunner.h"
#include "nsUpdateDriver.h"
@ -253,6 +254,7 @@ static char **gQtOnlyArgv;
#include "BinaryPath.h"
using mozilla::dom::ContentParent;
using mozilla::dom::ContentChild;
// Save literal putenv string to environment variable.
static void
@ -607,7 +609,8 @@ NS_INTERFACE_MAP_BEGIN(nsXULAppInfo)
#ifdef MOZ_CRASHREPORTER
NS_INTERFACE_MAP_ENTRY(nsICrashReporter)
#endif
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIXULAppInfo, gAppData)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIXULAppInfo, gAppData ||
XRE_GetProcessType() == GeckoProcessType_Content)
NS_INTERFACE_MAP_END
NS_IMETHODIMP_(nsrefcnt)
@ -625,6 +628,10 @@ nsXULAppInfo::Release()
NS_IMETHODIMP
nsXULAppInfo::GetVendor(nsACString& aResult)
{
if (XRE_GetProcessType() == GeckoProcessType_Content) {
NS_WARNING("Attempt to get unavailable information in content process.");
return NS_ERROR_NOT_AVAILABLE;
}
aResult.Assign(gAppData->vendor);
return NS_OK;
@ -633,6 +640,10 @@ nsXULAppInfo::GetVendor(nsACString& aResult)
NS_IMETHODIMP
nsXULAppInfo::GetName(nsACString& aResult)
{
if (XRE_GetProcessType() == GeckoProcessType_Content) {
NS_WARNING("Attempt to get unavailable information in content process.");
return NS_ERROR_NOT_AVAILABLE;
}
aResult.Assign(gAppData->name);
return NS_OK;
@ -641,6 +652,10 @@ nsXULAppInfo::GetName(nsACString& aResult)
NS_IMETHODIMP
nsXULAppInfo::GetID(nsACString& aResult)
{
if (XRE_GetProcessType() == GeckoProcessType_Content) {
NS_WARNING("Attempt to get unavailable information in content process.");
return NS_ERROR_NOT_AVAILABLE;
}
aResult.Assign(gAppData->ID);
return NS_OK;
@ -649,6 +664,11 @@ nsXULAppInfo::GetID(nsACString& aResult)
NS_IMETHODIMP
nsXULAppInfo::GetVersion(nsACString& aResult)
{
if (XRE_GetProcessType() == GeckoProcessType_Content) {
ContentChild* cc = ContentChild::GetSingleton();
aResult = cc->GetAppInfo().version;
return NS_OK;
}
aResult.Assign(gAppData->version);
return NS_OK;
@ -665,6 +685,11 @@ nsXULAppInfo::GetPlatformVersion(nsACString& aResult)
NS_IMETHODIMP
nsXULAppInfo::GetAppBuildID(nsACString& aResult)
{
if (XRE_GetProcessType() == GeckoProcessType_Content) {
ContentChild* cc = ContentChild::GetSingleton();
aResult = cc->GetAppInfo().buildID;
return NS_OK;
}
aResult.Assign(gAppData->buildID);
return NS_OK;