Update devmode Firefox plugin to support Firefox 17 on 64-bit Linux.
(Other platforms coming soon.)

Review at http://gwt-code-reviews.appspot.com/1870803

Review by: mdempsky@google.com

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@11386 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/plugins/xpcom/ExternalWrapper.cpp b/plugins/xpcom/ExternalWrapper.cpp
index 62cc1b5..9bc40c8 100644
--- a/plugins/xpcom/ExternalWrapper.cpp
+++ b/plugins/xpcom/ExternalWrapper.cpp
@@ -398,7 +398,7 @@
   if (strEquals(methodName, "connect") || strEquals(methodName, "init")) {
     *_retval = cloneAllAccess();
   } else {
-    *_retval = nsnull;
+    *_retval = nullptr;
   }
   return NS_OK;
 }
@@ -406,12 +406,12 @@
 NS_IMETHODIMP ExternalWrapper::CanGetProperty(const nsIID * iid,
     const PRUnichar *propertyName, char **_retval) {
   Debug::log(Debug::Spam) << "ExternalWrapper::CanGetProperty" << Debug::flush;
-  *_retval = nsnull;
+  *_retval = nullptr;
   return NS_OK;
 }
 NS_IMETHODIMP ExternalWrapper::CanSetProperty(const nsIID * iid,
     const PRUnichar *propertyName, char **_retval) {
   Debug::log(Debug::Spam) << "ExternalWrapper::CanSetProperty" << Debug::flush;
-  *_retval = nsnull;
+  *_retval = nullptr;
   return NS_OK;
 }
diff --git a/plugins/xpcom/FFSessionHandler.cpp b/plugins/xpcom/FFSessionHandler.cpp
index 4cd9771..f966e92 100755
--- a/plugins/xpcom/FFSessionHandler.cpp
+++ b/plugins/xpcom/FFSessionHandler.cpp
@@ -40,6 +40,12 @@
 }
 #endif //GECKO_VERSION
 
+#if GECKO_VERSION >= 17000
+static inline void JS_NewNumberValue(JSContext *cx, double d, jsval *rval) {
+  *rval = JS_NumberValue(d);
+}
+#endif
+
 static JSContext* getJSContext() {
   // Get JSContext from stack.
   nsCOMPtr<nsIJSContextStack> stack =
@@ -53,7 +59,7 @@
     return NULL;
   }
 
-  if (cx == nsnull) {
+  if (cx == nullptr) {
     // TODO(jat): figure out why this can be null at plugin unload time
     Debug::log(Debug::Error) << "GWT Dev Plugin: Null JS context" << Debug::flush;
   }
diff --git a/plugins/xpcom/JSRunner.cpp b/plugins/xpcom/JSRunner.cpp
index f5b3a8a..635a2fa 100755
--- a/plugins/xpcom/JSRunner.cpp
+++ b/plugins/xpcom/JSRunner.cpp
@@ -52,7 +52,7 @@
     sgo = do_QueryInterface(priv);
   }
 
-  JSPrincipals *jsprin = nsnull;
+  JSPrincipals *jsprin = nullptr;
   std::string virtual_filename;
   nsresult nr;
 
@@ -102,7 +102,7 @@
   principal->GetJSPrincipals(ctx, &jsprin);
 #endif
 
-  if (jsprin == nsnull) {
+  if (jsprin == nullptr) {
     Debug::log(Debug::Error) << "Get JSPrincial failed at JSRunner::eval"
         << Debug::flush;
     return false;
diff --git a/plugins/xpcom/JavaObject.cpp b/plugins/xpcom/JavaObject.cpp
index 9940fa9..281b2e2 100644
--- a/plugins/xpcom/JavaObject.cpp
+++ b/plugins/xpcom/JavaObject.cpp
@@ -37,7 +37,7 @@
 #else
   JavaObject::getPropertyWrapper,
   JavaObject::setPropertyWrapper,
-#endif //GECHO_VERSION
+#endif
 
   reinterpret_cast<JSEnumerateOp>(JavaObject::enumerate), /* enumerate */
   JS_ResolveStub, /* resolve */
@@ -144,6 +144,15 @@
   return obj;
 }
 
+#if GECKO_VERSION >= 17000
+JSBool JavaObject::getPropertyWrapper(JSContext* ctx, JSHandleObject obj,
+    JSHandleId id, JSMutableHandleValue vp) {
+  jsval rval;
+  JSBool result = JavaObject::getProperty(ctx, obj.get(), id.get(), &rval);
+  vp.set(rval);
+  return result;
+}
+#else
 #if GECKO_VERSION >= 15000
 JSBool JavaObject::getPropertyWrapper(JSContext* ctx, JSHandleObject obj,
     JSHandleId id, jsval *vp) {
@@ -153,7 +162,8 @@
   return JavaObject::getProperty(ctx, obj.value(), id.value(), vp);
 #endif
 }
-#endif
+#endif // >= 15000
+#endif // not >= 17000
 
 JSBool JavaObject::getProperty(JSContext* ctx, JSObject* obj, jsid id,
     jsval* rval) {
@@ -206,6 +216,13 @@
   return JS_TRUE;
 }
 
+#if GECKO_VERSION >= 17000
+JSBool JavaObject::setPropertyWrapper(JSContext* ctx, JSHandleObject obj,
+    JSHandleId id, JSBool strict, JSMutableHandleValue vp) {
+  jsval rval = vp.get();
+  return JavaObject::setProperty(ctx, obj, id, strict, &rval);
+}
+#else
 #if GECKO_VERSION >= 15000
 JSBool JavaObject::setPropertyWrapper(JSContext* ctx, JSHandleObject obj,
     JSHandleId id, JSBool strict, jsval *vp) {
@@ -215,7 +232,8 @@
   return setProperty(ctx, obj.value(), id.value(), strict, vp);
 #endif
 }
-#endif
+#endif // >= 15000
+#endif // ! >= 17000
 
 #if GECKO_VERSION < 2000
 JSBool JavaObject::setProperty(JSContext* ctx, JSObject* obj, jsid id,
diff --git a/plugins/xpcom/JavaObject.h b/plugins/xpcom/JavaObject.h
index c2fcf00..9fc289c 100755
--- a/plugins/xpcom/JavaObject.h
+++ b/plugins/xpcom/JavaObject.h
@@ -63,11 +63,18 @@
   static JSBool toString20(JSContext* ctx, uintN argc, jsval* vp);
   static JSBool call20(JSContext* ctx, uintN argc, jsval* vp);
 #endif //GECKO_VERSION
+#if GECKO_VERSION >= 17000
+  static JSBool getPropertyWrapper(JSContext* ctx, JSHandleObject obj,
+      JSHandleId id, JSMutableHandleValue vp);
+  static JSBool setPropertyWrapper(JSContext* ctx, JSHandleObject obj,
+      JSHandleId id, JSBool strict, JSMutableHandleValue vp);
+#else
 #if GECKO_VERSION >= 15000
   static JSBool getPropertyWrapper(JSContext* ctx, JSHandleObject obj, JSHandleId id, jsval *vp);
   static JSBool setPropertyWrapper(JSContext* ctx, JSHandleObject obj, JSHandleId id,
       JSBool strict, jsval *vp);
 #endif
+#endif
 
 private:
   static SessionData* getSessionData(JSContext* ctx, JSObject* obj);
diff --git a/plugins/xpcom/Makefile b/plugins/xpcom/Makefile
index 37c5f92..4250ae2 100644
--- a/plugins/xpcom/Makefile
+++ b/plugins/xpcom/Makefile
@@ -49,7 +49,7 @@
 export FLAG32BIT
 
 ifeq ($(BROWSER),)
-$(warning Defaulting to FF3 build [set with BROWSER=ff3, ff3+, ff35, ff36, ff40, ff50, ff60, ff70, ff80, ff90, ff100, f110, ff120, ff130, ff140, ff150, ff160])
+$(warning Defaulting to FF3 build [set with BROWSER=ff3, ff3+, ff35, ff36, ff40, ff50, ff60, ff70, ff80, ff90, ff100, f110, ff120, ff130, ff140, ff150, ff160, ff170])
 BROWSER=ff3
 endif
 
@@ -178,7 +178,12 @@
 GECKO_VERSION   = 16.0.0
 CFLAGS += -DGECKO_VERSION=16000
 else
-$(error Unrecognized BROWSER of $(BROWSER) - options are ff3, ff3+, ff35, ff36, ff40, ff50, ff60, ff70, ff80, ff90, ff100, ff110, ff120, ff130, ff140, ff150)
+ifeq ($(BROWSER),ff170)
+GECKO_VERSION   = 17.0.0
+CFLAGS += -DGECKO_VERSION=17000
+else
+$(error Unrecognized BROWSER of $(BROWSER) - options are ff3, ff3+, ff35, ff36, ff40, ff50, ff60, ff70, ff80, ff90, ff100, ff110, ff120, ff130, ff140, ff150, ff160, ff170)
+endif
 endif
 endif
 endif
@@ -287,6 +292,7 @@
 	$(MAKE) lib BROWSER=ff140 ARCH=x86
 	$(MAKE) lib BROWSER=ff150 ARCH=x86
 	$(MAKE) lib BROWSER=ff160 ARCH=x86
+	$(MAKE) lib BROWSER=ff170 ARCH=x86
 	$(MAKE) lib BROWSER=ff3 ARCH=x86_64
 	$(MAKE) lib BROWSER=ff3+ ARCH=x86_64
 	$(MAKE) lib BROWSER=ff35 ARCH=x86_64
@@ -304,6 +310,7 @@
 	$(MAKE) lib BROWSER=ff140 ARCH=x86_64
 	$(MAKE) lib BROWSER=ff150 ARCH=x86_64
 	$(MAKE) lib BROWSER=ff160 ARCH=x86_64
+	$(MAKE) lib BROWSER=ff170 ARCH=x86_64
 
 macplatforms:
 	$(MAKE) lib BROWSER=ff3
diff --git a/plugins/xpcom/ModuleOOPHM.cpp b/plugins/xpcom/ModuleOOPHM.cpp
index 7e52bb1..a531d63 100644
--- a/plugins/xpcom/ModuleOOPHM.cpp
+++ b/plugins/xpcom/ModuleOOPHM.cpp
@@ -158,7 +158,7 @@
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = categoryManager->AddCategoryEntry("JavaScript global property",
-      "__gwt_HostedModePlugin", OOPHM_CONTRACTID, true, true, nsnull);
+      "__gwt_HostedModePlugin", OOPHM_CONTRACTID, true, true, nullptr);
 
   if (rv != NS_OK) {
     Debug::log(Debug::Error) << "ModuleOOPHM registerSelf returned " << rv
@@ -190,7 +190,7 @@
        unregisterSelf, /* unregister self */
        factoryDestructor, /* factory destructor */
        NS_CI_INTERFACE_GETTER_NAME(ExternalWrapper), /* get interfaces */
-       nsnull, /* language helper */
+       nullptr, /* language helper */
        &NS_CLASSINFO_NAME(ExternalWrapper), /* global class-info pointer */
        0 /* class flags */
     }
@@ -202,8 +202,8 @@
   ("ExternalWrapperModule"),
   (components),
   (sizeof(components) / sizeof(components[0])),
-  (nsnull),
-  (nsnull)
+  (nullptr),
+  (nullptr)
 };
 
 NSGETMODULE_ENTRY_POINT(ExternalWrapperModule) (nsIComponentManager *servMgr,
diff --git a/plugins/xpcom/install-template.rdf b/plugins/xpcom/install-template.rdf
index 81b8307..bb72386 100644
--- a/plugins/xpcom/install-template.rdf
+++ b/plugins/xpcom/install-template.rdf
@@ -12,7 +12,7 @@
       <Description>
         <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
         <em:minVersion>3.0</em:minVersion>
-        <em:maxVersion>16.0.*</em:maxVersion>
+        <em:maxVersion>17.0.*</em:maxVersion>
       </Description>
 
     <!-- TODO: This seems to break Firefox 3.6. With this on, FF gets into a
diff --git a/plugins/xpcom/mozincludes.h b/plugins/xpcom/mozincludes.h
index 80961cc..9e0e73c 100755
--- a/plugins/xpcom/mozincludes.h
+++ b/plugins/xpcom/mozincludes.h
@@ -27,4 +27,12 @@
 #define MOZ_JS_SetReservedSlot(cx, obj, index, v) JS_SetReservedSlot(cx, obj, index, v)
 #endif
 
+#include "nscore.h"
+// Fall back to nsnull for older Gecko versions
+#ifdef nsnull
+#ifndef nullptr
+#define nullptr nsnull
+#endif
+#endif
+
 #endif
diff --git a/plugins/xpcom/prebuilt/extension/chrome.manifest b/plugins/xpcom/prebuilt/extension/chrome.manifest
index bd114d1..424a77a 100644
--- a/plugins/xpcom/prebuilt/extension/chrome.manifest
+++ b/plugins/xpcom/prebuilt/extension/chrome.manifest
@@ -94,6 +94,8 @@
 binary-component lib/Darwin-gcc3/ff160/libgwt_dev_ff160.dylib ABI=Darwin_x86_64-gcc3 appversion<=16.0.*
 binary-component lib/Darwin-gcc3/ff160/libgwt_dev_ff160.dylib ABI=Darwin_x86-gcc3 appversion<=16.0.*
 
+# Firefox 17
+binary-component lib/Linux_x86_64-gcc3/ff170/libgwt_dev_ff170.so ABI=Linux_x86_64-gcc3 appversion<=17.0.*
 
 interfaces components/IOOPHM.xpt
 contract @gwt.google.com/ExternalWrapper;1 {028DD88B-6D65-401D-AAFD-17E497D15D09}
diff --git a/plugins/xpcom/prebuilt/extension/lib/Linux_x86_64-gcc3/ff170/libgwt_dev_ff170.so b/plugins/xpcom/prebuilt/extension/lib/Linux_x86_64-gcc3/ff170/libgwt_dev_ff170.so
new file mode 100755
index 0000000..b9c26b5
--- /dev/null
+++ b/plugins/xpcom/prebuilt/extension/lib/Linux_x86_64-gcc3/ff170/libgwt_dev_ff170.so
Binary files differ
diff --git a/plugins/xpcom/prebuilt/ff170/include/IOOPHM.h b/plugins/xpcom/prebuilt/ff170/include/IOOPHM.h
new file mode 100644
index 0000000..4a152ce
--- /dev/null
+++ b/plugins/xpcom/prebuilt/ff170/include/IOOPHM.h
@@ -0,0 +1,105 @@
+/*
+ * DO NOT EDIT.  THIS FILE IS GENERATED FROM IOOPHM.idl
+ */
+
+#ifndef __gen_IOOPHM_h__
+#define __gen_IOOPHM_h__
+
+
+#ifndef __gen_nsISupports_h__
+#include "nsISupports.h"
+#endif
+
+/* For IDL files that don't want to include root IDL files. */
+#ifndef NS_NO_VTABLE
+#define NS_NO_VTABLE
+#endif
+class nsIDOMWindow; /* forward declaration */
+
+
+/* starting interface:    IOOPHM */
+#define IOOPHM_IID_STR "90cef17b-c3fe-4251-af68-4381b3d938a0"
+
+#define IOOPHM_IID \
+  {0x90cef17b, 0xc3fe, 0x4251, \
+    { 0xaf, 0x68, 0x43, 0x81, 0xb3, 0xd9, 0x38, 0xa0 }}
+
+class NS_NO_VTABLE IOOPHM : public nsISupports {
+ public: 
+
+  NS_DECLARE_STATIC_IID_ACCESSOR(IOOPHM_IID)
+
+  /* boolean init (in nsIDOMWindow window); */
+  NS_IMETHOD Init(nsIDOMWindow *window, bool *_retval) = 0;
+
+  /* boolean connect (in ACString url, in ACString sessionKey, in ACString addr, in ACString moduleName, in ACString hostedHtmlVersion); */
+  NS_IMETHOD Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, bool *_retval) = 0;
+
+};
+
+  NS_DEFINE_STATIC_IID_ACCESSOR(IOOPHM, IOOPHM_IID)
+
+/* Use this macro when declaring classes that implement this interface. */
+#define NS_DECL_IOOPHM \
+  NS_IMETHOD Init(nsIDOMWindow *window, bool *_retval); \
+  NS_IMETHOD Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, bool *_retval); 
+
+/* Use this macro to declare functions that forward the behavior of this interface to another object. */
+#define NS_FORWARD_IOOPHM(_to) \
+  NS_IMETHOD Init(nsIDOMWindow *window, bool *_retval) { return _to Init(window, _retval); } \
+  NS_IMETHOD Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, bool *_retval) { return _to Connect(url, sessionKey, addr, moduleName, hostedHtmlVersion, _retval); } 
+
+/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
+#define NS_FORWARD_SAFE_IOOPHM(_to) \
+  NS_IMETHOD Init(nsIDOMWindow *window, bool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Init(window, _retval); } \
+  NS_IMETHOD Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, bool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Connect(url, sessionKey, addr, moduleName, hostedHtmlVersion, _retval); } 
+
+#if 0
+/* Use the code below as a template for the implementation class for this interface. */
+
+/* Header file */
+class _MYCLASS_ : public IOOPHM
+{
+public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_IOOPHM
+
+  _MYCLASS_();
+
+private:
+  ~_MYCLASS_();
+
+protected:
+  /* additional members */
+};
+
+/* Implementation file */
+NS_IMPL_ISUPPORTS1(_MYCLASS_, IOOPHM)
+
+_MYCLASS_::_MYCLASS_()
+{
+  /* member initializers and constructor code */
+}
+
+_MYCLASS_::~_MYCLASS_()
+{
+  /* destructor code */
+}
+
+/* boolean init (in nsIDOMWindow window); */
+NS_IMETHODIMP _MYCLASS_::Init(nsIDOMWindow *window, bool *_retval)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* boolean connect (in ACString url, in ACString sessionKey, in ACString addr, in ACString moduleName, in ACString hostedHtmlVersion); */
+NS_IMETHODIMP _MYCLASS_::Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, bool *_retval)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* End of implementation class template. */
+#endif
+
+
+#endif /* __gen_IOOPHM_h__ */
diff --git a/plugins/xpcom/prebuilt/update.rdf b/plugins/xpcom/prebuilt/update.rdf
index 03ea059..ad76151 100644
--- a/plugins/xpcom/prebuilt/update.rdf
+++ b/plugins/xpcom/prebuilt/update.rdf
@@ -14,7 +14,7 @@
               <Description>
                 <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
                 <em:minVersion>3.0</em:minVersion>
-                <em:maxVersion>16.0.*</em:maxVersion>
+                <em:maxVersion>17.0.*</em:maxVersion>
                 <em:updateLink>https://dl-ssl.google.com/gwt/plugins/firefox/gwt-dev-plugin.xpi</em:updateLink>
                 <em:updateInfoURL>https://dl-ssl.google.com/gwt/plugins/firefox/gwt-dev-plugin-info.xhtml?locale=%APP_LOCALE%</em:updateInfoURL>