Update browser plugins to support v2 wire protocol, and checkin some prebuilt
libraries for them. The XPI files are *not* checked in here until all
platforms are rebuilt with the changes -- otherwise, users would no longer
be able to use platforms that were left out. Log levels were changed in a
few places in the XPCOM plugin to reduce spaminess, especially in the event
the development mode server connection goes away while the page is still
running.
The Safari plugin changes have had only minimal changes, and the IE plugin
changes are completely untested. They are checked in anyway since they were
never brought up to common code changes made last year, and therefore can't
be built from trunk anyway, so they are certainly no worse off this way.
When Bob is in town next week, we will test the Safari plugin more thoroughly
(including building an install image) and get the IE plugin built/tested.
Patch by: jat
Review by: bobv
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@5998 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/plugins/xpcom/FFSessionHandler.cpp b/plugins/xpcom/FFSessionHandler.cpp
index 908e755..09fa9e1 100755
--- a/plugins/xpcom/FFSessionHandler.cpp
+++ b/plugins/xpcom/FFSessionHandler.cpp
@@ -125,7 +125,7 @@
dbg << objId << " ";
jsval toRemove;
if (JS_GetElement(ctx, jsObjectsById, objId, &toRemove) && JSVAL_IS_OBJECT(toRemove)) {
- jsIdsByObject.erase(JSVAL_TO_OBJECT(toRemove));
+ jsIdsByObject.erase(identityFromObject(JSVAL_TO_OBJECT(toRemove)));
JS_DeleteElement(ctx, jsObjectsById, objId);
} else {
Debug::log(Debug::Error) << "Error deleting js objId=" << objId << Debug::flush;
@@ -158,6 +158,11 @@
}
}
+void FFSessionHandler::fatalError(HostChannel& channel,
+ const std::string& message) {
+ // TODO(jat): implement
+}
+
bool FFSessionHandler::invoke(HostChannel& channel, const Value& thisObj, const std::string& methodName,
int numArgs, const Value* const args, Value* returnValue) {
Debug::log(Debug::Spam) << "FFSessionHandler::invoke " << thisObj.toString()
@@ -176,7 +181,7 @@
<< Debug::flush;
return true;
}
-
+
jsval jsThis;
if (thisObj.isNull()) {
jsThis = OBJECT_TO_JSVAL(global);
@@ -257,7 +262,10 @@
/**
* Convert UTF16 string to UTF8-encoded std::string.
- *
+ *
+ * This is implemented here because the Mozilla libraries mangle certain UTF8
+ * strings.
+ *
* @return UTF8-encoded string.
*/
static std::string utf8String(const jschar* str, unsigned len) {
@@ -290,7 +298,10 @@
/**
* Creates a JSString from a UTF8-encoded std::string.
- *
+ *
+ * This is implemented here because the Mozilla libraries mangle certain UTF8
+ * strings.
+ *
* @return the JSString object, which owns its memory buffer.
*/
static JSString* stringUtf8(JSContext* ctx, const std::string& utf8str) {
@@ -406,14 +417,15 @@
// str will be garbage-collected, does not need to be freed
} else {
// It's a plain-old JavaScript Object
- std::map<JSObject*, int>::iterator it = jsIdsByObject.find(obj);
+ void* objKey = identityFromObject(obj);
+ std::map<void*, int>::iterator it = jsIdsByObject.find(objKey);
if (it != jsIdsByObject.end()) {
retVal.setJsObjectId(it->second);
} else {
// Allocate a new id
int objId = ++jsObjectId;
JS_SetElement(ctx, jsObjectsById, objId, const_cast<jsval*>(&value));
- jsIdsByObject[obj] = objId;
+ jsIdsByObject[objKey] = objId;
retVal.setJsObjectId(objId);
}
}
@@ -552,3 +564,16 @@
channel->disconnectFromHost();
}
}
+
+void* FFSessionHandler::identityFromObject(JSObject* obj) {
+ JSContext* ctx = getJSContext();
+ jsval rval;
+ void* returnValue = obj;
+ if (JS_GetProperty(ctx, obj, "wrappedJSObject", &rval)
+ && JSVAL_IS_OBJECT(rval)) {
+ returnValue = JSVAL_TO_OBJECT(rval);
+ Debug::log(Debug::Info) << "identityFromObject mapped " << obj << " to "
+ << returnValue << Debug::flush;
+ }
+ return returnValue;
+}