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/Protocol.txt b/plugins/Protocol.txt
new file mode 100644
index 0000000..4d980fc
--- /dev/null
+++ b/plugins/Protocol.txt
@@ -0,0 +1,46 @@
+Startup protocol changes for version 2:
+
+C->S S->C
+==== ====
+{later:
+GetRealPlugin(String pluginType, String platformId)
+
+ FatalError(String message)
+
+ RealPlugin(byte[] plugin)
+}
+
+
+CheckVersions(int minProtoVersion, int maxProtoVersion,
+ String hostedHtmlVersion)
+
+ FatalError(String message)
+
+ ProtocolVersion(int protoVersion)
+
+
+{may be ommitted if no other supported transports:
+ChooseTransport(String[] supportedTransports)
+
+ FatalError(String msg)
+
+ SwitchTransport(String transport, String transportArgs)
+
+ [If transport is not empty, all further communication should be
+ switched to the selected transport. transportArgs varies by the
+ transport.]
+}
+
+
+LoadModule(String url, String sessionKey, String userAgent, String moduleName)
+
+ [sessionKey is some arbitrary string to identify one group of modules as
+ being part of the same session of one application.]
+
+... as before
+
+
+
+The v1 protocol LoadModule message is still accepted, though with reduced
+functionality in the OOPHM UI. After the module is loaded, v1 and v2 are
+exactly the same, which makes supporting both versions easier.
diff --git a/plugins/common/AllowedConnections.cpp b/plugins/common/AllowedConnections.cpp
index 1f93f65..39b8a0e 100644
--- a/plugins/common/AllowedConnections.cpp
+++ b/plugins/common/AllowedConnections.cpp
@@ -1,12 +1,12 @@
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -15,17 +15,20 @@
*/
#include "Debug.h"
+#include <string>
+#include <cstring>
#include "AllowedConnections.h"
void AllowedConnections::init() {
}
-bool AllowedConnections::isAllowed(const std::string& target) {
- return true;
-}
-
bool AllowedConnections::isAllowed(const char* host, int port) {
+ // always allow localhost
+ if (!strcmp(host, "localhost") || !strcmp(host, "127.0.0.1")) {
+ return true;
+ }
+ // TODO(jat): allow specified IP addresses that are actually on this machine
return true;
}
diff --git a/plugins/common/AllowedConnections.h b/plugins/common/AllowedConnections.h
index 0dbed2e..ff48693 100644
--- a/plugins/common/AllowedConnections.h
+++ b/plugins/common/AllowedConnections.h
@@ -2,13 +2,13 @@
#define _H_AllowedConnections
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -19,14 +19,17 @@
#include <string>
/**
- * Manages rules to control access to other sites.
+ * Manages rules to control access to other sites from the plugin. This is
+ * important since arbitrary web pages could try and use the plugin to connect
+ * to hosts the browser's machine has access to, such as doing port scanning
+ * behind a firewall.
*/
class AllowedConnections {
public:
AllowedConnections() {
init();
}
-
+
AllowedConnections(const std::string& rule) {
init();
parseRule(rule);
@@ -34,14 +37,7 @@
/**
* Returns true if a connection to the requested target is allowed.
- *
- * @param target host or host:port to test
- */
- bool isAllowed(const std::string& target);
-
- /**
- * Returns true if a connection to the requested target is allowed.
- *
+ *
* @param host name or address to connect to
* @param port TCP port to connect to
*/
diff --git a/plugins/common/BrowserChannel.h b/plugins/common/BrowserChannel.h
index 0a65c62..ac91af5 100644
--- a/plugins/common/BrowserChannel.h
+++ b/plugins/common/BrowserChannel.h
@@ -5,7 +5,7 @@
*/
/* from BrowserChannel.BROWSERCHANNEL_PROTOCOL_VERSION */
-#define BROWSERCHANNEL_PROTOCOL_VERSION 1
+#define BROWSERCHANNEL_PROTOCOL_VERSION 2
/* from com.google.gwt.dev.shell.BrowserChannel.SpecialDispatchId */
#define SPECIAL_HAS_METHOD 0
@@ -16,11 +16,17 @@
/* from com.google.gwt.dev.shell.BrowserChannel.MessageType */
#define MESSAGE_TYPE_INVOKE 0
#define MESSAGE_TYPE_RETURN 1
-#define MESSAGE_TYPE_LOAD_MODULE 2
+#define MESSAGE_TYPE_OLD_LOAD_MODULE 2
#define MESSAGE_TYPE_QUIT 3
#define MESSAGE_TYPE_LOADJSNI 4
#define MESSAGE_TYPE_INVOKESPECIAL 5
#define MESSAGE_TYPE_FREEVALUE 6
+#define MESSAGE_TYPE_FATAL_ERROR 7
+#define MESSAGE_TYPE_CHECK_VERSIONS 8
+#define MESSAGE_TYPE_PROTOCOL_VERSION 9
+#define MESSAGE_TYPE_CHOOSE_TRANSPORT 10
+#define MESSAGE_TYPE_SWITCH_TRANSPORT 11
+#define MESSAGE_TYPE_LOAD_MODULE 12
/* from com.google.gwt.dev.shell.BrowserChannel.Value.ValueType */
#define VALUE_TYPE_NULL 0
diff --git a/plugins/common/CheckVersionsMessage.cpp b/plugins/common/CheckVersionsMessage.cpp
new file mode 100644
index 0000000..911cf38
--- /dev/null
+++ b/plugins/common/CheckVersionsMessage.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+#include "CheckVersionsMessage.h"
+#include "HostChannel.h"
+#include "scoped_ptr/scoped_ptr.h"
+
+CheckVersionsMessage::~CheckVersionsMessage() {
+}
+
+char CheckVersionsMessage::getType() const {
+ return TYPE;
+}
+
+/**
+ * Receive a CheckVersions message from the channel (note that the message
+ * type has already been read). Caller is responsible for destroying
+ * returned message. Returns null on error.
+ */
+CheckVersionsMessage* CheckVersionsMessage::receive(HostChannel& channel) {
+ int minVersion;
+ if (!channel.readInt(minVersion)) {
+ // TODO(jat): error handling
+ printf("Failed to read minimum version\n");
+ return 0;
+ }
+ int maxVersion;
+ if (!channel.readInt(maxVersion)) {
+ // TODO(jat): error handling
+ printf("Failed to read maximum version\n");
+ return 0;
+ }
+ std::string hostedHtmlVersion;
+ if (!channel.readString(hostedHtmlVersion)) {
+ // TODO(jat): error handling
+ printf("Failed to read hosted.html version\n");
+ return 0;
+ }
+ return new CheckVersionsMessage(minVersion, maxVersion, hostedHtmlVersion);
+}
+
+/**
+ * Send a fatal error message on the channel.
+ */
+bool CheckVersionsMessage::send(HostChannel& channel, int minVersion,
+ int maxVersion, const std::string& hostedHtmlVersion) {
+ if (!channel.sendByte(TYPE)) return false;
+ if (!channel.sendInt(minVersion)) return false;
+ if (!channel.sendInt(maxVersion)) return false;
+ if (!channel.sendString(hostedHtmlVersion)) return false;
+ return true;
+}
diff --git a/plugins/common/CheckVersionsMessage.h b/plugins/common/CheckVersionsMessage.h
new file mode 100644
index 0000000..10634ae
--- /dev/null
+++ b/plugins/common/CheckVersionsMessage.h
@@ -0,0 +1,56 @@
+#ifndef __CHECKVERSIONSMESSAGE_H
+#define __CHECKVERSIONSMESSAGE_H
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+#include <string>
+#include "Message.h"
+#include "BrowserChannel.h"
+#include "Value.h"
+
+class HostChannel;
+
+/**
+ * Class representing a CheckVersions message sent to the server.
+ *
+ * This message tells the server the range or protocol versions this plugin
+ * understands as well as the hosted.html version (so stale copies of it can
+ * be detected).
+ */
+class CheckVersionsMessage : public Message {
+public:
+ static const char TYPE = MESSAGE_TYPE_CHECK_VERSIONS;
+private:
+ int minVersion;
+ int maxVersion;
+ const std::string& hostedHtmlVersion;
+
+protected:
+ CheckVersionsMessage(int minVersion, int maxVersion,
+ const std::string& hostedHtmlVersion) : minVersion(minVersion),
+ maxVersion(maxVersion), hostedHtmlVersion(hostedHtmlVersion) {}
+
+public:
+ ~CheckVersionsMessage();
+ virtual char getType() const;
+
+ const std::string& getHostedHtmlVersion() const { return hostedHtmlVersion; }
+
+ static CheckVersionsMessage* receive(HostChannel& channel);
+ static bool send(HostChannel& channel, int minVersion, int maxVersion,
+ const std::string& hostedHtmlVersion);
+};
+#endif
diff --git a/plugins/common/ChooseTransportMessage.cpp b/plugins/common/ChooseTransportMessage.cpp
new file mode 100644
index 0000000..08c315f
--- /dev/null
+++ b/plugins/common/ChooseTransportMessage.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+#include <cstdarg>
+#include <vector>
+#include "ChooseTransportMessage.h"
+#include "HostChannel.h"
+#include "scoped_ptr/scoped_ptr.h"
+
+ChooseTransportMessage::~ChooseTransportMessage() {
+}
+
+char ChooseTransportMessage::getType() const {
+ return TYPE;
+}
+
+/**
+ * Receive an ChooseTransport message from the channel (note that the message
+ * type has already been read). Caller is responsible for destroying
+ * returned message. Returns null on error.
+ */
+ChooseTransportMessage* ChooseTransportMessage::receive(HostChannel& channel) {
+ int length;
+ if (!channel.readInt(length)) {
+ // TODO(jat): error handling
+ printf("Failed to read transport\n");
+ return 0;
+ }
+ std::vector<std::string> transports;
+ for (int i = 0; i < length; ++i) {
+ std::string transport;
+ if (!channel.readString(transport)) {
+ // TODO(jat): error handling
+ printf("Failed to read transport\n");
+ return 0;
+ }
+ transports.push_back(transport);
+ }
+ return new ChooseTransportMessage(transports);
+}
+
+/**
+ * Send this ChooseTransport message on the channel.
+ */
+bool ChooseTransportMessage::send(HostChannel& channel,
+ const std::vector<std::string>& transports) {
+ if (!channel.sendByte(TYPE)) return false;
+ int n = transports.size();
+ if (!channel.sendInt(n)) return false;
+ for (int i = 0; i < n; ++i) {
+ if (!channel.sendString(transports[i])) return false;
+ }
+ return true;
+}
diff --git a/plugins/common/ChooseTransportMessage.h b/plugins/common/ChooseTransportMessage.h
new file mode 100644
index 0000000..512185e
--- /dev/null
+++ b/plugins/common/ChooseTransportMessage.h
@@ -0,0 +1,55 @@
+#ifndef __CHOOSETRANSPORTMESSAGE_H
+#define __CHOOSETRANSPORTMESSAGE_H
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+#include <string>
+#include <vector>
+#include "Message.h"
+#include "BrowserChannel.h"
+#include "Value.h"
+
+class HostChannel;
+
+/**
+ * Class representing a ChooseTransport message to send to the server.
+ *
+ * This message type is a request for the server to choose an alternate
+ * transport from a provide list, such as a shared memory transport. The
+ * set of transport names is open-ended and thus requires mutual agreement
+ * on the names between the client and server.
+ */
+class ChooseTransportMessage : public Message {
+public:
+ static const char TYPE = MESSAGE_TYPE_CHOOSE_TRANSPORT;
+private:
+ std::vector<std::string> transports;
+
+protected:
+ ChooseTransportMessage(const std::vector<std::string>& transports)
+ : transports(transports) {}
+
+public:
+ ~ChooseTransportMessage();
+ virtual char getType() const;
+
+ const std::vector<std::string>& getTransports() const { return transports; }
+
+ static ChooseTransportMessage* receive(HostChannel& channel);
+ static bool send(HostChannel& channel,
+ const std::vector<std::string>& transport);
+};
+#endif
diff --git a/plugins/common/DebugLevel.h b/plugins/common/DebugLevel.h
index d172e99..b6f6a27 100644
--- a/plugins/common/DebugLevel.h
+++ b/plugins/common/DebugLevel.h
@@ -19,7 +19,7 @@
// Defines the default debug level if not defined -- see Debug.h
// Can also define GWT_DEBUGDISABLE to remove all traces of the debug code.
//#define GWT_DEBUGLEVEL Debugging
-#define GWT_DEBUGLEVEL Spam
+#define GWT_DEBUGLEVEL Info
//#define GWT_DEBUGDISABLE
#endif
diff --git a/plugins/common/FatalErrorMessage.cpp b/plugins/common/FatalErrorMessage.cpp
new file mode 100644
index 0000000..0b4b2d0
--- /dev/null
+++ b/plugins/common/FatalErrorMessage.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+#include "FatalErrorMessage.h"
+#include "HostChannel.h"
+#include "scoped_ptr/scoped_ptr.h"
+
+FatalErrorMessage::~FatalErrorMessage() {
+}
+
+char FatalErrorMessage::getType() const {
+ return TYPE;
+}
+
+/**
+ * Receive an FatalError message from the channel (note that the message
+ * type has already been read). Caller is responsible for destroying
+ * returned message. Returns null on error.
+ */
+FatalErrorMessage* FatalErrorMessage::receive(HostChannel& channel) {
+ std::string error;
+ if (!channel.readString(error)) {
+ // TODO(jat): error handling
+ printf("Failed to read error message\n");
+ return 0;
+ }
+ return new FatalErrorMessage(error);
+}
+
+/**
+ * Send a fatal error message on the channel.
+ */
+bool FatalErrorMessage::send(HostChannel& channel, const std::string& error) {
+ if (!channel.sendByte(TYPE)) return false;
+ if (!channel.sendString(error)) return false;
+ return true;
+}
diff --git a/plugins/common/FatalErrorMessage.h b/plugins/common/FatalErrorMessage.h
new file mode 100644
index 0000000..a80b9d1
--- /dev/null
+++ b/plugins/common/FatalErrorMessage.h
@@ -0,0 +1,54 @@
+#ifndef __FATALERRORMESSAGE_H
+#define __FATALERRORMESSAGE_H
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+#include <string>
+#include "Message.h"
+#include "BrowserChannel.h"
+#include "Value.h"
+
+class HostChannel;
+
+/**
+ * Class representing an FatalError message received from the server.
+ *
+ * This message indicates that a fatal error occurred during the processing
+ * of the previous message from the client and the connection should be
+ * aborted.
+ */
+class FatalErrorMessage : public Message {
+public:
+ static const char TYPE = MESSAGE_TYPE_FATAL_ERROR;
+private:
+ std::string error;
+
+protected:
+ /**
+ * @param error error message
+ */
+ FatalErrorMessage(const std::string& error) : error(error) {}
+
+public:
+ ~FatalErrorMessage();
+ virtual char getType() const;
+
+ const std::string& getError() const { return error; }
+
+ static FatalErrorMessage* receive(HostChannel& channel);
+ static bool send(HostChannel& channel, const std::string& error);
+};
+#endif
diff --git a/plugins/common/FreeValueMessage.h b/plugins/common/FreeValueMessage.h
index a8b7a64..3158f40 100644
--- a/plugins/common/FreeValueMessage.h
+++ b/plugins/common/FreeValueMessage.h
@@ -2,13 +2,13 @@
#define __H_FreeValueMessage
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -21,26 +21,35 @@
#include "BrowserChannel.h"
#include "HostChannel.h"
+/**
+ * Class representing an FreeValue message sent or received from the server.
+ *
+ * This message gives a list of object IDs which are no longer needed by the
+ * sending side. Note that there is no reply to this message, and it can
+ * only be sent when the other side is expecting to receive a return value or
+ * another invoke. Special care must be taken to ensure that any freed values
+ * referenced by the succeeding invoke/return are resurrected instead of freed.
+ */
class FreeValueMessage : public Message {
-public:
+public:
static const char TYPE = MESSAGE_TYPE_FREEVALUE;
private:
int idCount;
const int* ids;
-
+
FreeValueMessage(int idCount, const int* ids) : idCount(idCount), ids(ids) {}
-
+
public:
~FreeValueMessage();
virtual char getType() const {
return TYPE;
}
-
+
int getIdCount() const {
return idCount;
}
-
+
const int* const getIds() const {
return ids;
}
diff --git a/plugins/common/HostChannel.cpp b/plugins/common/HostChannel.cpp
index 896667e..53272da 100644
--- a/plugins/common/HostChannel.cpp
+++ b/plugins/common/HostChannel.cpp
@@ -37,6 +37,11 @@
#include "Platform.h"
#include "ByteOrder.h"
+#include "CheckVersionsMessage.h"
+#include "ProtocolVersionMessage.h"
+#include "ChooseTransportMessage.h"
+#include "SwitchTransportMessage.h"
+#include "FatalErrorMessage.h"
#include "FreeValueMessage.h"
#include "HostChannel.h"
#include "LoadJsniMessage.h"
@@ -65,6 +70,51 @@
return sock.connect(host, port);
}
+bool HostChannel::init(SessionHandler* handler, int minProtoVers,
+ int maxProtoVers, const std::string& hostedHtmlVers) {
+ Debug::log(Debug::Info) << "initializing connection: proto=" << minProtoVers
+ << "-" << maxProtoVers << ", hostedHtmlVersion=" << hostedHtmlVers
+ << Debug::flush;
+ // TODO(jat): support transport selection
+ CheckVersionsMessage::send(*this, minProtoVers, maxProtoVers, hostedHtmlVers);
+ flush();
+ char type;
+ if (!readByte(type)) {
+ handler->fatalError(*this, "Failed to receive message type");
+ Debug::log(Debug::Error) << "Failed to receive message type" << Debug::flush;
+ disconnectFromHost();
+ return false;
+ }
+ switch (type) {
+ case MESSAGE_TYPE_PROTOCOL_VERSION:
+ {
+ scoped_ptr<ProtocolVersionMessage> imsg(ProtocolVersionMessage
+ ::receive(*this));
+ if (!imsg.get()) {
+ Debug::log(Debug::Error) << "Failed to receive protocol version message"
+ << Debug::flush;
+ return false;
+ }
+ // TODO(jat): save selected protocol version when we support a range
+ break;
+ }
+ case MESSAGE_TYPE_FATAL_ERROR:
+ {
+ scoped_ptr<FatalErrorMessage> imsg(FatalErrorMessage::receive(*this));
+ if (!imsg.get()) {
+ Debug::log(Debug::Error) << "Failed to receive fatal error message"
+ << Debug::flush;
+ return false;
+ }
+ handler->fatalError(*this, imsg.get()->getError());
+ return false;
+ }
+ default:
+ return false;
+ }
+ return true;
+}
+
bool HostChannel::disconnectFromHost() {
Debug::log(Debug::Debugging) << "Disconnecting channel" << Debug::flush;
if (!isConnected()) {
@@ -189,9 +239,13 @@
char type;
while (true) {
flush();
- Debug::log(Debug::Spam) << "Waiting for response, flushed output" << Debug::flush;
+ Debug::log(Debug::Spam) << "Waiting for response, flushed output"
+ << Debug::flush;
if (!readByte(type)) {
- Debug::log(Debug::Error) << "Failed to receive message type" << Debug::flush;
+ if (isConnected()) {
+ Debug::log(Debug::Error) << "Failed to receive message type"
+ << Debug::flush;
+ }
return 0;
}
switch (type) {
diff --git a/plugins/common/HostChannel.h b/plugins/common/HostChannel.h
index 0097b6d..8facabe 100644
--- a/plugins/common/HostChannel.h
+++ b/plugins/common/HostChannel.h
@@ -44,9 +44,15 @@
Debug::log(Debug::Debugging) << "HostChannel destroyed" << Debug::flush;
}
+ // Connects to the OOPHM server (socket operations only).
bool connectToHost(const char* host, unsigned port);
+
+ // Negotiates protocol version and transport selection.
+ bool init(SessionHandler* handler, int minVersion, int maxVersion,
+ const std::string& hostedHtmlVersion);
+
bool disconnectFromHost();
-
+
bool isConnected() const {
return sock.isConnected();
}
diff --git a/plugins/common/InvokeSpecialMessage.h b/plugins/common/InvokeSpecialMessage.h
index 196baa5..5888cc1 100644
--- a/plugins/common/InvokeSpecialMessage.h
+++ b/plugins/common/InvokeSpecialMessage.h
@@ -25,8 +25,8 @@
class HostChannel;
/**
- * Class representing an InvokeSpecialMessage received from the server, and a way
- * to send an invoke message to the server.
+ * Class representing an InvokeSpecial message received from the server, and a
+ * way to send an invoke message to the server.
*/
class InvokeSpecialMessage : public Message {
public:
diff --git a/plugins/common/LoadModuleMessage.cpp b/plugins/common/LoadModuleMessage.cpp
index a436961..1ee4ab3 100644
--- a/plugins/common/LoadModuleMessage.cpp
+++ b/plugins/common/LoadModuleMessage.cpp
@@ -26,16 +26,22 @@
return LoadModuleMessage::TYPE;
}
-bool LoadModuleMessage::send(HostChannel& channel, uint32_t version, const char* moduleName,
- const uint32_t moduleNameLen, const char* userAgent, SessionHandler* handler) {
- Debug::log(Debug::Spam) << "LoadModule(module=\"" << moduleName << "\",vers="
- << version << ")" << Debug::flush;
- if (!channel.sendByte(TYPE) || !channel.sendInt(version)
- || !channel.sendString(moduleName, moduleNameLen)
- || !channel.sendString(userAgent, static_cast<uint32_t>(strlen(userAgent)))) {
+bool LoadModuleMessage::send(HostChannel& channel, const std::string& url,
+ const std::string& tabKey, const std::string& sessionKey,
+ const std::string& moduleName, const std::string& userAgent,
+ SessionHandler* handler) {
+ Debug::log(Debug::Spam) << "LoadModule(url=\"" << url << "\", tabKey=\""
+ << "\", sessionKey=\"" << sessionKey << "\", module=\"" << moduleName
+ << "\")" << Debug::flush;
+ if (!channel.sendByte(TYPE) || !channel.sendString(url)
+ || !channel.sendString(tabKey)
+ || !channel.sendString(sessionKey)
+ || !channel.sendString(moduleName)
+ || !channel.sendString(userAgent)) {
return false;
}
- scoped_ptr<ReturnMessage> ret(channel.reactToMessagesWhileWaitingForReturn(handler));
+ scoped_ptr<ReturnMessage> ret(channel.reactToMessagesWhileWaitingForReturn(
+ handler));
if (!ret.get()) {
return false;
}
diff --git a/plugins/common/LoadModuleMessage.h b/plugins/common/LoadModuleMessage.h
index 3091c46..4a331cb 100644
--- a/plugins/common/LoadModuleMessage.h
+++ b/plugins/common/LoadModuleMessage.h
@@ -2,13 +2,13 @@
#define __LOADMODULEMESSAGE_H
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -25,22 +25,37 @@
class HostChannel;
+/**
+ * Class representing a LoadModule message sent to the server.
+ *
+ * This message requests that the server load the requested module. A return
+ * message is not sent until the module is unloaded or fails to load.
+ */
+
class LoadModuleMessage : public Message {
static const char TYPE = MESSAGE_TYPE_LOAD_MODULE;
-public:
- LoadModuleMessage(int version, std::string& moduleName, std::string& userAgent) :
- version(version), moduleName(moduleName), userAgent(userAgent) { }
+public:
+ LoadModuleMessage(const std::string& url, const std::string& tabKey,
+ const std::string& sessionKey, const std::string& moduleName,
+ const std::string& userAgent) : url(url), tabKey(tabKey),
+ sessionKey(sessionKey), moduleName(moduleName), userAgent(userAgent) { }
- int getVersion() const { return version; }
+ const std::string& getUrl() const { return url; }
+ const std::string& getTabKey() const { return tabKey; }
+ const std::string& getSessionKey() const { return sessionKey; }
const std::string& getModuleName() const { return moduleName; }
const std::string& getUserAgent() const { return userAgent; }
virtual char getType() const;
-
- static bool send(HostChannel& channel, uint32_t version, const char* moduleName,
- uint32_t moduleNameLen, const char* userAgent, SessionHandler* handler);
+
+ static bool send(HostChannel& channel, const std::string& url,
+ const std::string& tabKey, const std::string& sessionKey,
+ const std::string& moduleName, const std::string& userAgent,
+ SessionHandler* handler);
private:
- int version;
+ std::string url;
+ std::string tabKey;
+ std::string sessionKey;
std::string moduleName;
std::string userAgent;
};
diff --git a/plugins/common/Makefile b/plugins/common/Makefile
index b22fd27..abfd933 100644
--- a/plugins/common/Makefile
+++ b/plugins/common/Makefile
@@ -18,12 +18,16 @@
ReturnMessage.h Value.h BrowserChannel.h Debug.h DebugLevel.h \
SessionHandler.h ServerMethods.h Socket.h AllowedConnections.h \
LoadJsniMessage.h InvokeSpecialMessage.h FreeValueMessage.h \
- ByteOrder.h
+ ByteOrder.h FatalErrorMessage.h CheckVersionsMessage.h \
+ ChooseTransportMessage.h SwitchTransportMessage.h \
+ ProtocolVersionMessage.h
SRCS= HostChannel.cpp LoadModuleMessage.cpp InvokeMessage.cpp \
ReturnMessage.cpp ServerMethods.cpp Debug.cpp Socket.cpp \
AllowedConnections.cpp LoadJsniMessage.cpp InvokeSpecialMessage.cpp \
- FreeValueMessage.cpp
+ FreeValueMessage.cpp FatalErrorMessage.cpp CheckVersionsMessage.cpp \
+ ChooseTransportMessage.cpp SwitchTransportMessage.cpp \
+ ProtocolVersionMessage.cpp
LIBCOMMON= libcommon$(FLAG32BIT).a
OBJDIR= obj$(FLAG32BIT)
@@ -55,9 +59,11 @@
# DO NOT DELETE
HostChannel.o: HostChannel.cpp Debug.h Platform.h DebugLevel.h \
- ByteOrder.h FreeValueMessage.h Message.h BrowserChannel.h HostChannel.h \
- Socket.h AllowedConnections.h ReturnMessage.h Value.h SessionHandler.h \
- LoadJsniMessage.h InvokeMessage.h InvokeSpecialMessage.h QuitMessage.h \
+ ByteOrder.h CheckVersionsMessage.h Message.h BrowserChannel.h Value.h \
+ ProtocolVersionMessage.h ChooseTransportMessage.h \
+ SwitchTransportMessage.h FreeValueMessage.h HostChannel.h Socket.h \
+ AllowedConnections.h ReturnMessage.h SessionHandler.h LoadJsniMessage.h \
+ InvokeMessage.h InvokeSpecialMessage.h QuitMessage.h \
scoped_ptr/scoped_ptr.h
LoadModuleMessage.o: LoadModuleMessage.cpp Debug.h Platform.h \
DebugLevel.h LoadModuleMessage.h Message.h BrowserChannel.h \
@@ -91,3 +97,26 @@
BrowserChannel.h HostChannel.h Debug.h Platform.h DebugLevel.h \
ByteOrder.h Socket.h AllowedConnections.h ReturnMessage.h Value.h \
SessionHandler.h scoped_ptr/scoped_ptr.h
+FatalErrorMessage.o: FatalErrorMessage.cpp FatalErrorMessage.h Message.h \
+ BrowserChannel.h Value.h Debug.h Platform.h DebugLevel.h HostChannel.h \
+ ByteOrder.h Socket.h AllowedConnections.h ReturnMessage.h \
+ SessionHandler.h scoped_ptr/scoped_ptr.h
+CheckVersionsMessage.o: CheckVersionsMessage.cpp CheckVersionsMessage.h \
+ Message.h BrowserChannel.h Value.h Debug.h Platform.h DebugLevel.h \
+ HostChannel.h ByteOrder.h Socket.h AllowedConnections.h ReturnMessage.h \
+ SessionHandler.h scoped_ptr/scoped_ptr.h
+ChooseTransportMessage.o: ChooseTransportMessage.cpp \
+ ChooseTransportMessage.h Message.h BrowserChannel.h Value.h Debug.h \
+ Platform.h DebugLevel.h HostChannel.h ByteOrder.h Socket.h \
+ AllowedConnections.h ReturnMessage.h SessionHandler.h \
+ scoped_ptr/scoped_ptr.h
+SwitchTransportMessage.o: SwitchTransportMessage.cpp \
+ SwitchTransportMessage.h Message.h BrowserChannel.h Value.h Debug.h \
+ Platform.h DebugLevel.h HostChannel.h ByteOrder.h Socket.h \
+ AllowedConnections.h ReturnMessage.h SessionHandler.h \
+ scoped_ptr/scoped_ptr.h
+ProtocolVersionMessage.o: ProtocolVersionMessage.cpp \
+ ProtocolVersionMessage.h Message.h BrowserChannel.h Value.h Debug.h \
+ Platform.h DebugLevel.h HostChannel.h ByteOrder.h Socket.h \
+ AllowedConnections.h ReturnMessage.h SessionHandler.h \
+ scoped_ptr/scoped_ptr.h
diff --git a/plugins/common/ProtocolVersionMessage.cpp b/plugins/common/ProtocolVersionMessage.cpp
new file mode 100644
index 0000000..e2db3f9
--- /dev/null
+++ b/plugins/common/ProtocolVersionMessage.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+#include "ProtocolVersionMessage.h"
+#include "HostChannel.h"
+#include "scoped_ptr/scoped_ptr.h"
+
+ProtocolVersionMessage::~ProtocolVersionMessage() {
+}
+
+char ProtocolVersionMessage::getType() const {
+ return TYPE;
+}
+
+/**
+ * Receive a ProtocolVersion message from the server.
+ */
+ProtocolVersionMessage* ProtocolVersionMessage::receive(HostChannel& channel) {
+ int version;
+ if (!channel.readInt(version)) {
+ // TODO(jat): error handling
+ printf("Failed to read version\n");
+ return 0;
+ }
+ return new ProtocolVersionMessage(version);
+}
+
+/**
+ * Send a ProtocolVersion message on the channel.
+ */
+bool ProtocolVersionMessage::send(HostChannel& channel, int version) {
+ if (!channel.sendByte(TYPE)) return false;
+ if (!channel.sendInt(version)) return false;
+ return true;
+}
diff --git a/plugins/common/ProtocolVersionMessage.h b/plugins/common/ProtocolVersionMessage.h
new file mode 100644
index 0000000..db6f770
--- /dev/null
+++ b/plugins/common/ProtocolVersionMessage.h
@@ -0,0 +1,54 @@
+#ifndef __PROTOCOLVERSIONMESSAGE_H
+#define __PROTOCOLVERSIONMESSAGE_H
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+#include <string>
+#include "Message.h"
+#include "BrowserChannel.h"
+#include "Value.h"
+
+class HostChannel;
+
+/**
+ * Class representing a ProtocolVersion message received from the server, and a
+ * way to send one.
+ *
+ * This message indicates which version of the protocol the server has chosen
+ * for the remainder of the communication.
+ */
+class ProtocolVersionMessage : public Message {
+public:
+ static const char TYPE = MESSAGE_TYPE_PROTOCOL_VERSION;
+private:
+ int version;
+
+protected:
+ /**
+ * @param version selected protocol version
+ */
+ ProtocolVersionMessage(int version) : version(version) {}
+
+public:
+ ~ProtocolVersionMessage();
+ virtual char getType() const;
+
+ int getVersion() const { return version; }
+
+ static ProtocolVersionMessage* receive(HostChannel& channel);
+ static bool send(HostChannel& channel, int version);
+};
+#endif
diff --git a/plugins/common/QuitMessage.h b/plugins/common/QuitMessage.h
index 344612f..f8f9b80 100644
--- a/plugins/common/QuitMessage.h
+++ b/plugins/common/QuitMessage.h
@@ -2,13 +2,13 @@
#define __H_QuitMessage
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -20,17 +20,21 @@
#include "Message.h"
#include "BrowserChannel.h"
+/**
+ * This class represents a Quit message sent to the server, indicating the
+ * channel should be closed down.
+ */
class QuitMessage : public Message {
-public:
+public:
static const char TYPE = MESSAGE_TYPE_QUIT;
private:
QuitMessage() {}
-
-public:
+
+public:
virtual char getType() const {
return TYPE;
}
-
+
static bool send(HostChannel& channel) {
return channel.sendByte(TYPE);
}
diff --git a/plugins/common/ReturnMessage.h b/plugins/common/ReturnMessage.h
index fddf9ec..374b9fe 100644
--- a/plugins/common/ReturnMessage.h
+++ b/plugins/common/ReturnMessage.h
@@ -2,13 +2,13 @@
#define __RETURNMESSAGE_H
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -23,20 +23,27 @@
class HostChannel;
+/**
+ * Class representing a Return message received from the server, and a way
+ * to send one.
+ *
+ * This message gives the return value of a previous Invoke or LoadModule
+ * message (for the latter, only the exception state is important).
+ */
class ReturnMessage : public Message {
static const char TYPE = MESSAGE_TYPE_RETURN;
private:
bool bisException;
Value retval;
-
-public:
+
+public:
ReturnMessage(bool isException, const Value& retValue) : bisException(isException),
retval(retValue) {}
bool isException() const { return bisException; }
const Value& getReturnValue() const { return retval; }
virtual char getType() const;
-
+
static ReturnMessage* receive(HostChannel& channel);
static bool send(HostChannel& channel, bool isException, const Value& retValue);
};
diff --git a/plugins/common/ServerMethods.cpp b/plugins/common/ServerMethods.cpp
index 5a18bcb..0be51b0 100644
--- a/plugins/common/ServerMethods.cpp
+++ b/plugins/common/ServerMethods.cpp
@@ -1,12 +1,12 @@
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -29,6 +29,11 @@
Value ServerMethods::getProperty(HostChannel& channel, SessionHandler* handler, int objectRef,
int dispatchId) {
+ if (!channel.isConnected()) {
+ Debug::log(Debug::Debugging) << "Ignoring getProperty after disconnect"
+ << Debug::flush;
+ return Value();
+ }
Value args[2];
args[0].setInt(objectRef);
args[1].setInt(dispatchId);
@@ -52,6 +57,11 @@
// only JSNI-style names and toString are valid
return -1;
}
+ if (!channel.isConnected()) {
+ Debug::log(Debug::Debugging) << "Ignoring hasMethod after disconnect"
+ << Debug::flush;
+ return -2;
+ }
Value arg;
arg.setString(name);
if (!InvokeSpecialMessage::send(channel, SPECIAL_HAS_METHOD, 1, &arg)) {
@@ -74,6 +84,11 @@
// only JSNI-style names and toString are valid
return -1;
}
+ if (!channel.isConnected()) {
+ Debug::log(Debug::Debugging) << "Ignoring hasProperty after disconnect"
+ << Debug::flush;
+ return -2;
+ }
Value arg;
arg.setString(name);
if (!InvokeSpecialMessage::send(channel, SPECIAL_HAS_PROPERTY, 1, &arg)) {
@@ -92,6 +107,11 @@
bool ServerMethods::setProperty(HostChannel& channel, SessionHandler* handler, int objectRef,
int dispatchId, const Value& value) {
+ if (!channel.isConnected()) {
+ Debug::log(Debug::Debugging) << "Ignoring setProperty after disconnect"
+ << Debug::flush;
+ return false;
+ }
// TODO(jat): error handling?
Value args[3];
args[0].setInt(objectRef);
diff --git a/plugins/common/SessionHandler.h b/plugins/common/SessionHandler.h
index 217dce4..2cb011f 100644
--- a/plugins/common/SessionHandler.h
+++ b/plugins/common/SessionHandler.h
@@ -2,13 +2,13 @@
#define _H_SessionHandler
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -23,18 +23,18 @@
/**
* Interface for session-handling needs.
- *
+ *
* Note that if this is being "added" onto a class which extends a C structure, the inheritance
* chain leading to the plain C object must be first in the inheritance list.
- *
+ *
* For example:
- *
+ *
* extern "C" {
* typedef struct PlainCstruct {
* ... data only members here
* } PlainCstruct;
* };
- *
+ *
* class MyWrapper: public PlainCstruct, SessionHandler {
* ... virtual functions ok here
* };
@@ -49,6 +49,13 @@
SetProperty = SPECIAL_SET_PROPERTY
};
protected:
+
+ /**
+ * Report a fatal error -- the channel will be closed after this method
+ * returns.
+ */
+ virtual void fatalError(HostChannel& channel, const std::string& message) = 0;
+
virtual void freeValue(HostChannel& channel, int idCount, const int* ids) = 0;
virtual void loadJsni(HostChannel& channel, const std::string& js) = 0;
@@ -56,16 +63,16 @@
/**
* Does not own any of its args -- must copy them if it wants them and should not free the
* ones passed in.
- *
+ *
* Returns true if an exception occurred.
*/
virtual bool invoke(HostChannel& channel, const Value& thisObj, const std::string& methodName,
int numArgs, const Value* const args, Value* returnValue)=0;
-
+
/**
* Invoke a plugin-provided method with the given args. As above, this method does not own
* any of its args.
- *
+ *
* Returns true if an exception occurred.
*/
virtual bool invokeSpecial(HostChannel& channel, SpecialMethodId method, int numArgs,
diff --git a/plugins/common/SwitchTransportMessage.cpp b/plugins/common/SwitchTransportMessage.cpp
new file mode 100644
index 0000000..ccb5520
--- /dev/null
+++ b/plugins/common/SwitchTransportMessage.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+#include "SwitchTransportMessage.h"
+#include "HostChannel.h"
+#include "scoped_ptr/scoped_ptr.h"
+
+SwitchTransportMessage::~SwitchTransportMessage() {
+}
+
+char SwitchTransportMessage::getType() const {
+ return TYPE;
+}
+
+/**
+ * Receive a SwitchTransport message from the server.
+ */
+SwitchTransportMessage* SwitchTransportMessage::receive(HostChannel& channel) {
+ std::string transport;
+ if (!channel.readString(transport)) {
+ // TODO(jat): error handling
+ printf("Failed to read transport\n");
+ return 0;
+ }
+ return new SwitchTransportMessage(transport);
+}
+
+/**
+ * Send a fatal error message on the channel.
+ */
+bool SwitchTransportMessage::send(HostChannel& channel,
+ const std::string& transport) {
+ if (!channel.sendByte(TYPE)) return false;
+ if (!channel.sendString(transport)) return false;
+ return true;
+}
diff --git a/plugins/common/SwitchTransportMessage.h b/plugins/common/SwitchTransportMessage.h
new file mode 100644
index 0000000..0dad82a
--- /dev/null
+++ b/plugins/common/SwitchTransportMessage.h
@@ -0,0 +1,53 @@
+#ifndef __SWITCHTRANSPORTMESSAGE_H
+#define __SWITCHTRANSPORTMESSAGE_H
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+#include <string>
+#include "Message.h"
+#include "BrowserChannel.h"
+#include "Value.h"
+
+class HostChannel;
+
+/**
+ * Class representing an SwitchTransport message received from the server, and a
+ * way to send one.
+ *
+ * The SwitchTransport message is sent by the server in response to a
+ * ChooseTransport message, and will select one of the available transports
+ * advertised by the client. The empty string represents the in-band channel,
+ * and is always an acceptable response.
+ */
+class SwitchTransportMessage : public Message {
+public:
+ static const char TYPE = MESSAGE_TYPE_SWITCH_TRANSPORT;
+private:
+ std::string transport;
+
+protected:
+ SwitchTransportMessage(const std::string& transport) : transport(transport) {}
+
+public:
+ ~SwitchTransportMessage();
+ virtual char getType() const;
+
+ const std::string& getTransport() const { return transport; }
+
+ static SwitchTransportMessage* receive(HostChannel& channel);
+ static bool send(HostChannel& channel, const std::string& transport);
+};
+#endif
diff --git a/plugins/ie/oophm/oophm/IESessionHandler.cpp b/plugins/ie/oophm/oophm/IESessionHandler.cpp
index 9c08363..cd0ec68 100644
--- a/plugins/ie/oophm/oophm/IESessionHandler.cpp
+++ b/plugins/ie/oophm/oophm/IESessionHandler.cpp
@@ -1,12 +1,12 @@
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -44,8 +44,15 @@
channel->disconnectFromHost();
}
+
+void IESessionHandler::fatalError(HostChannel& channel,
+ const std::string& messsage) {
+ // TODO: better way of reporting error?
+ Debug::log(Debug::Error) << "Fatal error: " << message << Debug::flush;
+}
+
void IESessionHandler::freeJavaObject(unsigned int objId) {
- // Remove the now-defunt object from the lookup table
+ // Remove the now-defunct object from the lookup table
javaObjectsById.erase(objId);
// and add it to the set of objects to free on the server
@@ -376,7 +383,7 @@
case Value::STRING:
// The copy-constructor does not correctly handle embedded nulls
- retVal.bstrVal = UTF8ToBSTR(value.getString().length(),
+ retVal.bstrVal = UTF8ToBSTR(value.getString().length(),
value.getString().c_str()).Detach();
retVal.vt = VT_BSTR;
break;
diff --git a/plugins/ie/oophm/oophm/IESessionHandler.h b/plugins/ie/oophm/oophm/IESessionHandler.h
index e8cdf92..8c035ba 100644
--- a/plugins/ie/oophm/oophm/IESessionHandler.h
+++ b/plugins/ie/oophm/oophm/IESessionHandler.h
@@ -1,12 +1,12 @@
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -36,6 +36,7 @@
virtual void makeValueRef(_variant_t& value, const Value& in);
protected:
+ virtual void fatalError(HostChannel& channel, const std::string& messsage);
virtual void freeValue(HostChannel& channel, int idCount, const int* ids);
virtual void loadJsni(HostChannel& channel, const std::string& js);
virtual bool invoke(HostChannel& channel, const Value& thisObj, const std::string& methodName,
diff --git a/plugins/ie/oophm/oophm/oophm.idl b/plugins/ie/oophm/oophm/oophm.idl
index 3b64a60..841f804 100644
--- a/plugins/ie/oophm/oophm/oophm.idl
+++ b/plugins/ie/oophm/oophm/oophm.idl
@@ -46,8 +46,9 @@
pointer_default(unique)
]
interface Iplugin : IDispatch{
- [id(1), helpstring("OOPHM connect")] HRESULT connect([in] BSTR url, [in] BSTR moduleName, [in] IDispatch* jsniContext, [out,retval] VARIANT_BOOL* ret);
+ [id(1), helpstring("OOPHM connect")] HRESULT connect([in] BSTR url, [in] BSTR sessionKey, [in] BSTR hostedServer, [in] BSTR moduleName, [in] hostedHtmlVersion, [out,retval] VARIANT_BOOL* ret);
[id(2), helpstring("method testObject")] HRESULT testObject([out,retval] IDispatch** ret);
+ [id(3), helpstring("OOPHM init")] HRESULT init([in] IDispatch* jsniContext, [out,retval] VARIANT_BOOL* ret);
};
[
diff --git a/plugins/ie/oophm/oophm/plugin.cpp b/plugins/ie/oophm/oophm/plugin.cpp
index cf8b7f2..5132421 100644
--- a/plugins/ie/oophm/oophm/plugin.cpp
+++ b/plugins/ie/oophm/oophm/plugin.cpp
@@ -1,12 +1,12 @@
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -18,6 +18,7 @@
#include "stdafx.h"
#include "comutil.h"
#include "plugin.h"
+#include "BrowserChannel.h"
#include "JavaObject.h"
#include "HostChannel.h"
#include "IESessionHandler.h"
@@ -26,7 +27,8 @@
// Cplugin
-STDMETHODIMP Cplugin::connect(BSTR burl, BSTR bmoduleName, IDispatch* jsniContext, VARIANT_BOOL* ret)
+STDMETHODIMP Cplugin::connect(BSTR burl, BSTR sessionKey, BSTR bhostedServer,
+ BSTR bmoduleName, BSTR bhostedHtmlVersion, VARIANT_BOOL* ret)
{
// TODO: Add your implementation code here
LPOLECLIENTSITE site;
@@ -42,26 +44,38 @@
doc->get_parentWindow(&window);
doc->Release();
- std::string url = BSTRToUTF8(burl);
- size_t index = url.find(':');
+ std::string hostedServer = BSTRToUTF8(bhostedServer);
+ size_t index = hostedServer.find(':');
if (index == std::string::npos) {
*ret = false;
return S_OK;
}
- std::string hostPart = url.substr(0, index);
- std::string portPart = url.substr(index + 1);
+ std::string hostPart = hostedServer.substr(0, index);
+ std::string portPart = hostedServer.substr(index + 1);
HostChannel* channel = new HostChannel();
- // TODO : Update HostChannel to take a const char*
if (!channel->connectToHost(
- const_cast<char*>(hostPart.c_str()),
+ hostPart.c_str(),
atoi(portPart.c_str()))) {
*ret = false;
return S_OK;
}
sessionHandler.reset(new IESessionHandler(channel, window));
+
+ std::string hostedHtmlVersion = BSTRToUTF8(bhostedHtmlVersion);
+
+ // TODO: add support for a range of protocol versions when we add them
+ if (!channel->init(sessionHandler.get(), BROWSERCHANNEL_PROTOCOL_VERSION,
+ BROWSERCHANNEL_PROTOCOL_VERSION, hostedHtmlVersion)) {
+ *ret = false;
+ return S_OK;
+ }
+
+ std::string url = BSTRToUTF8(burl);
+ std::string tabKey = ""; // TODO(jat): add support for tab identity
+ std::string sessionKey = BSTRToUTF8(bsessionKey);
std::string moduleName = BSTRToUTF8(bmoduleName);
IOmNavigator* navigator;
_bstr_t userAgent;
@@ -69,10 +83,8 @@
window->get_navigator(&navigator);
navigator->get_userAgent(userAgent.GetAddress());
- LoadModuleMessage::send(*channel, 1,
- moduleName.c_str(), moduleName.length(),
- BSTRToUTF8(userAgent).c_str(),
- sessionHandler.get());
+ LoadModuleMessage::send(*channel, url, tabKey, sessionKey, moduleName,
+ BSTRToUTF8(userAgent), sessionHandler.get());
navigator->Release();
@@ -80,6 +92,11 @@
return S_OK;
}
+STDMETHODIMP CPlugin::init(IDispatch* jsniContext, VARIANT_BOOL* ret) {
+ *ret = true;
+ return S_OK;
+}
+
STDMETHODIMP Cplugin::testObject(IDispatch** ret)
{
IJavaObject* toRet;
diff --git a/plugins/ie/oophm/oophm/plugin.h b/plugins/ie/oophm/oophm/plugin.h
index ea91ab0..ef73913 100644
--- a/plugins/ie/oophm/oophm/plugin.h
+++ b/plugins/ie/oophm/oophm/plugin.h
@@ -1,12 +1,12 @@
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -213,7 +213,9 @@
Debug::log(Debug::Debugging) << "OOPHM plugin FinalRelease" << Debug::flush;
}
- STDMETHOD(connect)(BSTR url, BSTR moduleName, IDispatch* jsniContext, VARIANT_BOOL* ret);
+ STDMETHOD(connect)(BSTR url, BSTR sessionKey, BSTR hostedServer,
+ BSTR moduleName, BSTR hostedHtmlVersion, VARIANT_BOOL* ret);
+ STDMETHOD(init)(IDispatch* jsniContext, VARIANT_BOOL* ret);
STDMETHOD(testObject)(IDispatch** ret);
private:
scoped_ptr<IESessionHandler> sessionHandler;
diff --git a/plugins/webkit/Core/WebScriptSessionHandler.cpp b/plugins/webkit/Core/WebScriptSessionHandler.cpp
index 95caff5..82fb820 100644
--- a/plugins/webkit/Core/WebScriptSessionHandler.cpp
+++ b/plugins/webkit/Core/WebScriptSessionHandler.cpp
@@ -1,12 +1,12 @@
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -24,7 +24,7 @@
WebScriptSessionHandler::WebScriptSessionHandler(HostChannel* channel,
JSGlobalContextRef contextRef,
- CrashHandlerRef crashHandler) :
+ CrashHandlerRef crashHandler) :
SessionData(channel, contextRef, this), jsObjectId(1), crashHandler(crashHandler) {
JSClassDefinition def = kJSClassDefinitionEmpty;
@@ -36,7 +36,7 @@
def.setProperty = JavaObjectSetProperty;
javaObjectWrapperClass = JSClassCreate(&def);
JSClassRetain(javaObjectWrapperClass);
-
+
// Get the String constructor function to tell Strings from other Objects
JSStringRef stringString = JSStringCreateWithUTF8CString("String");
JSValueRef stringConstructorValue = JSObjectGetProperty(contextRef,
@@ -45,19 +45,19 @@
stringConstructor = JSValueToObject(contextRef, stringConstructorValue, NULL);
JSValueProtect(contextRef, stringConstructor);
JSStringRelease(stringString);
-
+
// Call out to the utility __gwt_makeResult function to create the return array
JSStringRef makeResultString = JSStringCreateWithUTF8CString("__gwt_makeResult");
JSValueRef makeResultValue = JSObjectGetProperty(contextRef, JSContextGetGlobalObject(contextRef), makeResultString, NULL);
JSStringRelease(makeResultString);
-
+
if (!JSValueIsObject(contextRef, makeResultValue)) {
crashHandler->crash(__PRETTY_FUNCTION__, "Could not find __gwt_makeResult");
} else {
makeResultFunction = JSValueToObject(contextRef, makeResultValue, NULL);
JSValueProtect(contextRef, makeResultFunction);
}
-
+
pthread_mutexattr_t mutexAttrs;
pthread_mutexattr_init(&mutexAttrs);
// This behaves basically like the Java synchronized keyword
@@ -68,29 +68,35 @@
WebScriptSessionHandler::~WebScriptSessionHandler() {
std::map<int, JSObjectRef>::iterator i;
-
+
pthread_mutex_lock(&javaObjectsLock);
while ((i = javaObjectsById.begin()) != javaObjectsById.end()) {
JavaObjectFinalize(i->second);
}
pthread_mutex_unlock(&javaObjectsLock);
-
+
for (i = jsObjectsById.begin(); i != jsObjectsById.end(); i++) {
JSObjectRef ref = i->second;
delete static_cast<TrackingDataRef>(JSObjectGetPrivate(ref));
JSObjectSetPrivate(ref, NULL);
JSValueUnprotect(contextRef, i->second);
}
-
+
JSClassRelease(javaObjectWrapperClass);
-
+
JSValueUnprotect(contextRef, stringConstructor);
JSValueUnprotect(contextRef, makeResultFunction);
-
+
JSGarbageCollect(contextRef);
pthread_mutex_destroy(&javaObjectsLock);
}
+void WebScriptSessionHandler::fatalError(HostChannel& channel,
+ const std::string& messsage) {
+ // TODO: better way of reporting error?
+ Debug::log(Debug::Error) << "Fatal error: " << message << Debug::flush;
+}
+
void WebScriptSessionHandler::freeJavaObjects() {
pthread_mutex_lock(&javaObjectsLock);
int idCount = javaObjectsToFree.size();
@@ -98,7 +104,7 @@
pthread_mutex_unlock(&javaObjectsLock);
return;
}
-
+
int ids[idCount];
std::set<int>::iterator it = javaObjectsToFree.begin();
for (int i = 0; i < idCount; it++) {
@@ -118,16 +124,16 @@
if (idCount == 0) {
return;
}
-
+
for (int i = 0; i < idCount; i++) {
int objId = ids[i];
-
+
std::map<int, JSObjectRef>::iterator i = jsObjectsById.find(objId);
if (i == jsObjectsById.end()) {
Debug::log(Debug::Error) << "Unknown object id " << objId << Debug::flush;
continue;
}
-
+
JSObjectRef ref = i->second;
jsObjectsById.erase(objId);
jsIdsByObject.erase(ref);
@@ -147,45 +153,45 @@
JSValueRef argsJS[numArgs];
JSValueRef localException = NULL;
- JSStringRef methodNameJS = JSStringCreateWithUTF8CString(methodName.c_str());
+ JSStringRef methodNameJS = JSStringCreateWithUTF8CString(methodName.c_str());
JSObjectRef thisObjJs;
-
+
if (thisObj.isNull()) {
thisObjJs = JSContextGetGlobalObject(contextRef);
} else {
thisObjJs = (JSObjectRef) makeValueRef(thisObj);
}
-
+
JSValueRef functionValueJS = JSObjectGetProperty(contextRef, JSContextGetGlobalObject(contextRef),
methodNameJS, &localException);
JSStringRelease(methodNameJS);
-
+
if (!JSValueIsObject(contextRef, functionValueJS)) {
char message[512];
snprintf(message, sizeof(message), "Could not find method for property name %s on %s", methodName.c_str(), thisObj.toString().c_str());
makeExceptionValue(*returnValue, message);
return true;
}
-
+
JSObjectRef functionJS = JSValueToObject(contextRef, functionValueJS,
&localException);
if (localException) {
makeValue(*returnValue, localException);
return true;
}
-
+
// Convert the arguments
for (int i = 0; i < numArgs; i++) {
argsJS[i] = makeValueRef(args[i]);
}
-
+
JSValueRef retVal = JSObjectCallAsFunction(contextRef, functionJS,
thisObjJs, numArgs, argsJS,
&localException);
-
+
// It's safe to free remote objects before sending an Invoke or a Return message
freeJavaObjects();
-
+
if (localException) {
Debug::log(Debug::Spam) << "Returning exception to server" << Debug::flush;
makeValue(*returnValue, localException);
@@ -210,14 +216,14 @@
makeExceptionValue(*returnValue, message);
return true;
}
-
+
JSObjectRef jsObj = i->second;
if (args[1].isString()) {
JSStringRef asString = JSValueToStringCopy(contextRef, jsObj, NULL);
int maxLength = JSStringGetMaximumUTF8CStringSize(asString);
scoped_array<char> asChars(new char[maxLength]);
JSStringGetUTF8CString(asString, asChars.get(), maxLength);
-
+
JSValueRef localException = NULL;
JSStringRef str = JSStringCreateWithUTF8CString(args[1].getString().c_str());
JSValueRef value = JSObjectGetProperty(contextRef, jsObj, str, &localException);
@@ -232,7 +238,7 @@
} else if (args[1].isInt()) {
JSValueRef localException = NULL;
JSValueRef value = JSObjectGetPropertyAtIndex(contextRef, jsObj, args[1].getInt(), &localException);
-
+
if (localException) {
makeValue(*returnValue, localException);
return true;
@@ -251,7 +257,7 @@
Debug::log(Debug::Error) << "Unhandled invokeSpecial " << method << Debug::flush;
makeExceptionValue(*returnValue, "Unhandled invokeSpecial");
return true;
- }
+ }
}
JSValueRef WebScriptSessionHandler::javaFunctionCallbackImpl (int dispatchId,
@@ -265,7 +271,7 @@
* throw the exception.
*/
Debug::log(Debug::Debugging) << "Java method " << dispatchId << " invoked" << Debug::flush;
-
+
/*
* If a JS function is evaluated without an meaningful this object or the global
* object is implicitly used as the this object, we'll assume that the
@@ -278,30 +284,30 @@
} else {
makeValue(thisValue, thisObject);
}
-
+
// Argument conversion is straightforward
Value args[argumentCount];
for (int i = 0; i < argumentCount; i++) {
makeValue(args[i], arguments[i]);
}
-
+
if (!InvokeMessage::send(*channel, thisValue, dispatchId,
argumentCount, args)) {
initiateAutodestructSequence(__PRETTY_FUNCTION__, "Unable to send invocation message");
*exception = makeException("Unable to send invocation message");
return JSValueMakeUndefined(contextRef);
}
-
+
scoped_ptr<ReturnMessage> ret(channel->reactToMessagesWhileWaitingForReturn(sessionHandler));
-
+
if (!ret.get()) {
initiateAutodestructSequence(__PRETTY_FUNCTION__, "Unable to receive return message");
*exception = makeException("Unable to receive return message");
return JSValueMakeUndefined(contextRef);
}
-
+
Value v = ret->getReturnValue();
-
+
JSValueRef toReturn;
if (ret->isException()) {
*exception = makeValueRef(v);
@@ -309,7 +315,7 @@
} else {
toReturn = makeValueRef(v);
}
-
+
JSValueRef makeResultArguments[] = {JSValueMakeBoolean(contextRef, false), toReturn};
return JSObjectCallAsFunction(contextRef, makeResultFunction, NULL, 2, makeResultArguments, exception);
}
@@ -331,13 +337,13 @@
JSValueRef WebScriptSessionHandler::javaObjectGetPropertyImpl (TrackingDataRef tracker, JSObjectRef object,
JSStringRef propertyName, JSValueRef* exception) {
*exception = NULL;
-
+
// Convert the name
int maxLength = JSStringGetMaximumUTF8CStringSize(propertyName);
scoped_array<char> propertyNameChars(new char[maxLength]);
JSStringGetUTF8CString(propertyName, propertyNameChars.get(), maxLength);
- JSValueRef toReturn;
-
+ JSValueRef toReturn;
+
if (!strcmp(propertyNameChars.get(), "toString")) {
// We'll call out to the JSNI tear-off support function
JSStringRef tearOffName =JSStringCreateWithUTF8CString("__gwt_makeTearOff");
@@ -345,13 +351,13 @@
JSStringRelease(tearOffName);
if (*exception) {
return JSValueMakeUndefined(contextRef);
- }
-
+ }
+
JSObjectRef makeTearOff = JSValueToObject(contextRef, makeTearOffValue, exception);
if (*exception) {
return JSValueMakeUndefined(contextRef);
}
-
+
JSValueRef arguments[3];
arguments[0] = object;
arguments[1] = JSValueMakeNumber(contextRef, 0);
@@ -360,7 +366,7 @@
} else {
char* endptr;
int dispatchId = strtol(propertyNameChars.get(), &endptr, 10);
-
+
if (*endptr != '\0') {
Debug::log(Debug::Error) << "Unable to parse dispatch id " << propertyNameChars.get() << Debug::flush;
*exception = makeException("Unable to parse dispatch id");
@@ -372,7 +378,7 @@
toReturn = makeValueRef(v);
}
}
-
+
return toReturn;
}
@@ -384,10 +390,10 @@
if (!strcmp(propertyNameChars.get(), "toString")) {
return true;
}
-
+
char* endptr;
int dispatchId = strtol(propertyNameChars.get(), &endptr, 10);
-
+
if (*endptr != '\0') {
return false;
} else if (dispatchId < 0) {
@@ -404,10 +410,10 @@
scoped_array<char> propertyNameChars(new char[maxLength]);
JSStringGetUTF8CString(propertyName, propertyNameChars.get(), maxLength);
Value value;
-
+
char* endptr;
int dispatchId = strtol(propertyNameChars.get(), &endptr, 10);
-
+
if (*endptr != '\0') {
// TODO Figure out the right policy here; when we throw a Java object, JSCore wants to
// add expandos to record stack information. It would be possible to map the limited
@@ -417,16 +423,16 @@
Debug::log(Debug::Error) << "Dispatch ids may not be negative" << Debug::flush;
*exception = makeException("Dispatch ids may not be negative");
} else {
-
+
makeValue(value, jsValue);
-
+
if (!ServerMethods::setProperty(*channel, this, tracker->getObjectId(), dispatchId, value)) {
char message[50];
snprintf(message, sizeof(message), "Unable to set value object %i dispatchId %i", tracker->getObjectId(), dispatchId);
*exception = makeException(message);
}
}
-
+
// true means to not try to follow the prototype chain; not an indication of success
return true;
}
@@ -434,11 +440,11 @@
void WebScriptSessionHandler::loadJsni(HostChannel& channel, const std::string& js) {
Debug::log(Debug::Spam) << "loadJsni " << js << Debug::flush;
JSValueRef localException = NULL;
-
+
JSStringRef script = JSStringCreateWithUTF8CString(js.c_str());
JSEvaluateScript(contextRef, script, NULL, NULL, NULL, &localException);
JSStringRelease(script);
-
+
if (localException) {
// TODO Exception handling
Debug::log(Debug::Error) << "Exception thrown during loadJsni" << Debug::flush;
@@ -450,28 +456,28 @@
JSValueRef WebScriptSessionHandler::makeException(const char* message) {
JSValueRef localException = NULL;
JSObjectRef global = JSContextGetGlobalObject(contextRef);
-
+
JSStringRef errorName = JSStringCreateWithUTF8CString("Error");
JSValueRef errorValue = JSObjectGetProperty(contextRef, global, errorName, &localException);
JSStringRelease(errorName);
-
+
if (!JSValueIsObject(contextRef, errorValue)) {
initiateAutodestructSequence(__PRETTY_FUNCTION__, "Could not get reference to Error");
return JSValueMakeUndefined(contextRef);
}
-
+
JSObjectRef errorObject = (JSObjectRef) errorValue;
-
+
if (!JSObjectIsFunction(contextRef, errorObject)) {
initiateAutodestructSequence(__PRETTY_FUNCTION__, "Error was not a function");
return JSValueMakeUndefined(contextRef);
}
-
+
JSValueRef args[1];
JSStringRef messageJs = JSStringCreateWithUTF8CString(message);
args[0] = JSValueMakeString(contextRef, messageJs);
JSStringRelease(messageJs);
-
+
return JSObjectCallAsConstructor(contextRef, errorObject, 1, args, &localException);
}
@@ -481,7 +487,7 @@
JSObjectRef WebScriptSessionHandler::makeJavaWrapper(int objId) {
Debug::log(Debug::Spam) << "Creating wrapper for Java object " << objId << Debug::flush;
-
+
TrackingDataRef data = new TrackingData(this, objId);
return JSObjectMake(contextRef, javaObjectWrapperClass,
const_cast<TrackingData*>(data));
@@ -492,35 +498,35 @@
switch (v.getType()) {
case Value::NULL_TYPE:
return JSValueMakeNull(contextRef);
-
+
case Value::BOOLEAN:
return JSValueMakeBoolean(contextRef, v.getBoolean());
-
+
case Value::BYTE:
return JSValueMakeNumber(contextRef, v.getByte());
-
+
case Value::CHAR:
return JSValueMakeNumber(contextRef, v.getChar());
-
+
case Value::SHORT:
return JSValueMakeNumber(contextRef, v.getShort());
-
+
case Value::INT:
return JSValueMakeNumber(contextRef, v.getInt());
-
+
case Value::LONG:
return JSValueMakeNumber(contextRef, v.getLong());
-
+
case Value::FLOAT:
return JSValueMakeNumber(contextRef, v.getFloat());
-
+
case Value::DOUBLE:
return JSValueMakeNumber(contextRef, v.getDouble());
-
+
case Value::STRING:
{
std::string stringValue = v.getString();
-
+
// We need to handle the conversion ourselves to be able to get both
// UTF8 encoding as well as explicit control over the length of the string
// due to the possibility of null characters being part of the data
@@ -533,14 +539,14 @@
CFRelease(cfString);
return toReturn;
}
-
+
case Value::JAVA_OBJECT:
unsigned javaId = v.getJavaObjectId();
JSObjectRef ref;
-
+
pthread_mutex_lock(&javaObjectsLock);
i = javaObjectsById.find(javaId);
-
+
/*
* It's possible that we've already finalized the JsObjectRef that
* represented the object with the given id. If so, we must remove it
@@ -548,7 +554,7 @@
* the object on the server.
*/
javaObjectsToFree.erase(javaId);
-
+
if (i == javaObjectsById.end()) {
/*
* We don't call JSValueProtect so that the JavaObject peer can be
@@ -560,33 +566,33 @@
* NB: The act of creating the wrapper may trigger a GC.
*/
ref = makeJavaWrapper(javaId);
-
+
javaObjectsById[javaId] = ref;
-
+
} else {
ref = i->second;
}
pthread_mutex_unlock(&javaObjectsLock);
-
-
+
+
return ref;
-
+
case Value::JS_OBJECT:
int jsId = v.getJsObjectId();
-
+
i = jsObjectsById.find(jsId);
if (i == jsObjectsById.end()) {
char errMsg[50];
snprintf(errMsg, sizeof(errMsg), "Missing JsObject with id %i", jsId);
return makeException(errMsg);
-
+
} else {
return i->second;
}
-
+
case Value::UNDEFINED:
return JSValueMakeUndefined(contextRef);
-
+
default:
char message[50];
snprintf(message, sizeof(message), "Could not convert %s", v.toString().c_str());
@@ -597,16 +603,16 @@
bool WebScriptSessionHandler::makeValue(Value& ret, JSValueRef v) {
JSValueRef localException = NULL;
-
+
if (JSValueIsNull(contextRef, v)) {
ret.setNull();
-
+
} else if (JSValueIsUndefined(contextRef, v)) {
ret.setUndefined();
-
+
} else if (JSValueIsBoolean(contextRef, v)) {
ret.setBoolean(JSValueToBoolean(contextRef, v));
-
+
} else if (JSValueIsNumber(contextRef, v)) {
double d = JSValueToNumber(contextRef, v, &localException);
int i = round(d);
@@ -615,22 +621,22 @@
} else {
ret.setDouble(d);
}
-
+
} else if (JSValueIsString(contextRef, v) ||
JSValueIsInstanceOfConstructor(contextRef, v, stringConstructor, &localException)) {
return makeValueFromString(ret, v);
-
+
} else if (JSValueIsObjectOfClass(contextRef, v, javaObjectWrapperClass)) {
// It's one of our Java object proxies
JSObjectRef objectRef = JSValueToObject(contextRef, v, &localException);
-
+
if (!localException) {
TrackingDataRef tracker = (TrackingDataRef) JSObjectGetPrivate(objectRef);
int objId = tracker->getObjectId();
ret.setJavaObject(objId);
Debug::log(Debug::Spam) << "Made a Java object Value " << objId << Debug::flush;
}
-
+
} else if (JSValueIsObject(contextRef, v)) {
JSObjectRef objectRef = JSValueToObject(contextRef, v, &localException);
if (!localException) {
@@ -648,10 +654,10 @@
// Allocate a new id
int objId = ++jsObjectId;
JSValueProtect(contextRef, objectRef);
-
+
jsObjectsById[objId] = objectRef;
jsIdsByObject[objectRef] = objId;
-
+
ret.setJsObjectId(objId);
Debug::log(Debug::Spam) << "Made JS Value " << objId << Debug::flush;
}
@@ -660,7 +666,7 @@
Debug::log(Debug::Error) << "Unhandled JSValueRef -> Value conversion in plugin" << Debug::flush;
ret.setString("Unhandled JSValueRef -> Value conversion in plugin");
}
-
+
if (localException) {
makeValue(ret, localException);
return true;
@@ -671,25 +677,25 @@
bool WebScriptSessionHandler::makeValueFromString(Value& ret, JSValueRef value) {
JSValueRef localException = NULL;
-
+
JSStringRef jsString = JSValueToStringCopy(contextRef, value, &localException);
if (localException) {
makeValue(ret, localException);
return true;
}
-
+
CFStringRef cfString = JSStringCopyCFString(NULL, jsString);
JSStringRelease(jsString);
-
+
CFIndex cfLength = CFStringGetLength(cfString);
CFIndex maxLength = CFStringGetMaximumSizeForEncoding(cfLength, kCFStringEncodingUTF8);
scoped_array<char> utf8(new char[maxLength]);
-
+
CFIndex numBytes;
CFStringGetBytes(cfString, CFRangeMake(0, cfLength), kCFStringEncodingUTF8,
- 0, false, (UInt8*) utf8.get(), maxLength, &numBytes);
+ 0, false, (UInt8*) utf8.get(), maxLength, &numBytes);
CFRelease(cfString);
-
+
ret.setString(utf8.get(), numBytes);
Debug::log(Debug::Spam) << "Made a string Value " << ret.getString() << Debug::flush;
return false;
diff --git a/plugins/webkit/Core/WebScriptSessionHandler.h b/plugins/webkit/Core/WebScriptSessionHandler.h
index fc9795d..ba6a9c6 100644
--- a/plugins/webkit/Core/WebScriptSessionHandler.h
+++ b/plugins/webkit/Core/WebScriptSessionHandler.h
@@ -1,12 +1,12 @@
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -37,12 +37,12 @@
public:
WebScriptSessionHandler(HostChannel* channel, JSGlobalContextRef contextRef,
CrashHandler* crashHandler);
-
+
/*
* Invoking the destructor will perform a clean shutdown of the OOPHM session.
*/
~WebScriptSessionHandler();
-
+
/*
* This is a panic method for shutting down the OOPHM debugging session due
* to unrecoverable errors.
@@ -57,44 +57,45 @@
size_t argumentCount,
const JSValueRef arguments[],
JSValueRef* exception);
-
+
/*
* Finalize a Javo object proxy.
*/
void javaObjectFinalizeImpl(int objId);
-
+
/*
* Determine if a Java class has a named property.
*/
bool javaObjectHasPropertyImpl(TrackingDataRef tracker, JSObjectRef object,
JSStringRef propertyName);
-
+
/*
* Obtain the value of named property of an object.
*/
JSValueRef javaObjectGetPropertyImpl(TrackingDataRef tracker, JSObjectRef object,
JSStringRef propertyName, JSValueRef* exception);
-
+
/*
* Set the value of a named property on a Java object.
*/
bool javaObjectSetPropertyImpl(TrackingDataRef tracker, JSObjectRef object,
JSStringRef propertyName, JSValueRef value,
JSValueRef* exception);
-
+
/*
* Create a JavaScript Error object with the given message.
*/
JSValueRef makeException(const char* message);
-
+
protected:
+ virtual void fatalError(HostChannel& channel, const std::string& messsage);
virtual void freeValue(HostChannel& channel, int idCount, const int* ids);
virtual void loadJsni(HostChannel& channel, const std::string& js);
virtual bool invoke(HostChannel& channel, const Value& thisObj, const std::string& methodName,
int numArgs, const Value* const args, Value* returnValue);
virtual bool invokeSpecial(HostChannel& channel, SpecialMethodId method, int numArgs,
const Value* const args, Value* returnValue);
-
+
private:
CrashHandlerRef const crashHandler;
int jsObjectId;
@@ -104,29 +105,29 @@
std::map<int, JSObjectRef> jsObjectsById;
std::map<JSObjectRef, int> jsIdsByObject;
JSClassRef javaObjectWrapperClass;
-
+
/* A reference to __gwt_makeResult, which we use constantly */
JSObjectRef makeResultFunction;
-
+
/* The String() function */
JSObjectRef stringConstructor;
-
+
/*
* Free server-side references.
*/
void freeJavaObjects();
-
+
/*
* Create a exception Value that contains the given message.
*/
void makeExceptionValue(Value& value, const char* message);
-
+
/*
* Create a Java object proxy to be passed into the JavaScript execution
* environment.
*/
JSObjectRef makeJavaWrapper(int objId);
-
+
/*
* Convert a value from the JavaScript into something that can be sent back
* to the OOPHM host.
@@ -134,7 +135,7 @@
* Returns true if an exception was encountered.
*/
bool makeValue(Value& ret, JSValueRef value);
-
+
/*
* Convert a string-like object to something that can be sent back to the OOPHM
* host.
@@ -142,7 +143,7 @@
* Returns true if an exception was encountered.
*/
bool makeValueFromString(Value& ret, JSValueRef value);
-
+
/*
* Convert a value from the OOPHM host into something that can be passed into
* the JavaScript execution environment.
diff --git a/plugins/webkit/Plugin/OophmWebScriptObject.h b/plugins/webkit/Plugin/OophmWebScriptObject.h
index 28f52ce..02d790d 100644
--- a/plugins/webkit/Plugin/OophmWebScriptObject.h
+++ b/plugins/webkit/Plugin/OophmWebScriptObject.h
@@ -1,12 +1,12 @@
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -31,9 +31,12 @@
+ (OophmWebScriptObject*)scriptObjectWithContext: (JSGlobalContextRef)context
withWebView: (WebView*) webView;
+ (NSString*)webScriptNameForSelector: (SEL)selector;
-- (BOOL)connectWithHost: (NSString*) host
- withModuleName: (NSString*) moduleName
- withJsniContext: (WebScriptObject*) jsniContext;
+- (BOOL)initForWebScriptWithJsniContext: (WebScriptObject*) jsniContext;
+- (BOOL)connectWithUrl: (NSString*) url
+ withSessionKey: (NSString*) sessionKey
+ withHost: (NSString*) host
+ withModuleName: (NSString*) moduleName
+ withHostedHtmlVersion: (NSString*) hostedHtmlVersion;
- (void)crashWithMessage: (NSString*)message;
- (void)dealloc;
- (void)finalizeForWebScript;
diff --git a/plugins/webkit/Plugin/OophmWebScriptObject.mm b/plugins/webkit/Plugin/OophmWebScriptObject.mm
index f737fd8..d5c452f 100644
--- a/plugins/webkit/Plugin/OophmWebScriptObject.mm
+++ b/plugins/webkit/Plugin/OophmWebScriptObject.mm
@@ -64,7 +64,9 @@
}
+ (BOOL)isSelectorExcludedFromWebScript:(SEL)selector {
- if (selector == @selector(connectWithHost:withModuleName:withJsniContext:)) {
+ if (selector == @selector(initForWebScriptWithJsniContext:)) {
+ return NO;
+ } else if (selector == @selector(connectWithUrl:withSessionKey:withHost:withModuleName:withHostedHtmlVersion:)) {
return NO;
} else if (selector == @selector(crashWithMessage:)) {
return NO;
@@ -83,7 +85,9 @@
}
+ (NSString*)webScriptNameForSelector: (SEL)selector {
- if (selector == @selector(connectWithHost:withModuleName:withJsniContext:)) {
+ if (selector == @selector(initForWebScriptWithJsniContext:)) {
+ return @"init";
+ } else if (selector == @selector(connectWithUrl:withSessionKey:withHost:withModuleName:withHostedHtmlVersion:)) {
return @"connect";
} else if (selector == @selector(crashWithMessage:)) {
return @"crash";
@@ -91,19 +95,29 @@
return nil;
}
-- (BOOL)connectWithHost: (NSString*) host
- withModuleName: (NSString*) moduleName
- withJsniContext: (WebScriptObject*) jsniContext {
+// Simply return true to indicate the plugin was successfully loaded and
+// reachable.
+- (BOOL)initForWebScriptWithJsniContext: (WebScriptObject*) jsniContext {
+ return YES;
+}
+
+- (BOOL)connectWithUrl: (NSString*) url
+ withSessionKey: (NSString*) sessionKey
+ withHost: (NSString*) host
+ withModuleName: (NSString*) moduleName
+ withHostedHtmlVersion: (NSString*) hostedHtmlVersion {
// TODO remove this for production builds
Debug::log(Debug::Warning) << "ACLs are currently disabled" << Debug::flush;
- return [self doConnectWithHost:host withModule:moduleName];
+ return [self doConnectWithUrl:url withSessonKey: withHost:host
+ withModule:moduleName withHostedHtmlVersion];
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
// See if authentication has been bypassed
if ([defaults boolForKey:@"allowAll"]) {
- return [self doConnectWithHost:host withModule:moduleName];
+ return [self doConnectWithUrl:url withSessonKey: withHost:host
+ withModule:moduleName withHostedHtmlVersion];
}
// Otherwise, check for an explicit entry
@@ -247,8 +261,11 @@
[self doConnectWithHost:host withModule:moduleName];
}
-- (BOOL)doConnectWithHost:(NSString*) host
- withModule:(NSString*) moduleName {
+- (BOOL)doConnectWithUrl: (NSString*) url
+ withSessionKey: (NSString*) sessionKey
+ withHost: (NSString*) host
+ withModule: (NSString*) moduleName
+ withHostedHtmlVersion: (NSString*) hostedHtmlVersion {
Debug::log(Debug::Debugging) << "connect : " << [host UTF8String] << " " <<
[moduleName UTF8String] << Debug::flush;
@@ -282,13 +299,28 @@
return NO;
}
- const char *moduleNameChars = [moduleName UTF8String];
-
_crashHandler = new PluginCrashHandler(self);
_sessionHandler = new WebScriptSessionHandler(_hostChannel, _contextRef, _crashHandler);
-
- if (!LoadModuleMessage::send(*_hostChannel, BROWSERCHANNEL_PROTOCOL_VERSION,
- moduleNameChars, strlen(moduleNameChars),
+
+ std::string hostedHtmlVersionStr([hostedHtmlVersion UTF8String]);
+ // TODO: add support for a range of protocol versions when more are added.
+ if (!_hostChannel->init(_sessionHandler, BROWSERCHANNEL_PROTOCOL_VERSION,
+ BROWSERCHANNEL_PROTOCOL_VERSION, hostedHtmlVersionStr)) {
+ [OophmWebScriptObject logAndThrowString:@"HostChannel failed to initialize"];
+ _hostChannel->disconnectFromHost();
+ delete _hostChannel;
+ _hostChannel = NULL;
+ return NO;
+ }
+
+ const std::string urlStr = [url UTF8String];
+ // TODO(jat): add support for tab identity
+ const std::string tabKeyStr = "";
+ const std::string sessionKeyStr = [sessionKey UTF8String];
+ const std::string moduleNameStr = [moduleName UTF8String];
+
+ if (!LoadModuleMessage::send(*_hostChannel, urlStr, tabKeyStr,
+ sessionKeyStr, moduleNameStr,
"Safari OOPHM", _sessionHandler)) {
_hostChannel->disconnectFromHost();
delete _hostChannel;
diff --git a/plugins/xpcom/ExternalWrapper.cpp b/plugins/xpcom/ExternalWrapper.cpp
index 9ce0103..1d54747 100644
--- a/plugins/xpcom/ExternalWrapper.cpp
+++ b/plugins/xpcom/ExternalWrapper.cpp
@@ -1,12 +1,12 @@
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -29,6 +29,7 @@
#include "LoadModuleMessage.h"
#include "ServerMethods.h"
+#include "BrowserChannel.h"
NS_IMPL_ISUPPORTS2_CI(ExternalWrapper, IOOPHM, nsISecurityCheckedComponent)
@@ -59,35 +60,57 @@
}
// TODO: handle context object passed in (currently nsIDOMWindow below)
-NS_IMETHODIMP ExternalWrapper::Connect(const nsACString & aAddr, const nsACString & aModuleName, nsIDOMWindow* domWindow, PRBool *_retval) {
- Debug::log(Debug::Spam) << "Address: " << aAddr << " Module: " << aModuleName << Debug::flush;
+NS_IMETHODIMP ExternalWrapper::Init(nsIDOMWindow* domWindow, PRBool *_retval) {
+ Debug::log(Debug::Spam) << "Init" << Debug::flush;
+ *_retval = true;
+ return NS_OK;
+}
+
+NS_IMETHODIMP ExternalWrapper::Connect(const nsACString& url,
+ const nsACString& sessionKey, const nsACString& aAddr,
+ const nsACString& aModuleName, const nsACString& hostedHtmlVersion,
+ PRBool *_retval) {
+ Debug::log(Debug::Spam) << "Connect(url=" << url << ", sessionKey="
+ << sessionKey << ", address=" << aAddr << ", module=" << aModuleName
+ << ", hostedHtmlVersion=" << hostedHtmlVersion << Debug::flush;
// TODO: string utilities?
- nsCString addrAutoStr(aAddr), moduleAutoStr(aModuleName);
- std::string url(addrAutoStr.get());
-
- size_t index = url.find(':');
+ nsCString urlAutoStr(url);
+ nsCString sessionKeyAutoStr(sessionKey);
+ nsCString addrAutoStr(aAddr);
+ nsCString moduleAutoStr(aModuleName);
+ nsCString hostedHtmlVersionAutoStr(hostedHtmlVersion);
+ std::string hostedUrl(addrAutoStr.get());
+
+ size_t index = hostedUrl.find(':');
if (index == std::string::npos) {
*_retval = false;
return NS_OK;
}
- std::string hostPart = url.substr(0, index);
- std::string portPart = url.substr(index + 1);
+ std::string hostPart = hostedUrl.substr(0, index);
+ std::string portPart = hostedUrl.substr(index + 1);
HostChannel* channel = new HostChannel();
Debug::log(Debug::Debugging) << "Connecting..." << Debug::flush;
- if (!channel->connectToHost(
- const_cast<char*>(hostPart.c_str()),
+ if (!channel->connectToHost(hostPart.c_str(),
atoi(portPart.c_str()))) {
*_retval = false;
return NS_OK;
}
Debug::log(Debug::Debugging) << "...Connected" << Debug::flush;
-
sessionHandler.reset(new FFSessionHandler(channel/*, ctx*/));
+
+ std::string hostedHtmlVersionStr(hostedHtmlVersionAutoStr.get());
+ if (!channel->init(sessionHandler.get(), BROWSERCHANNEL_PROTOCOL_VERSION,
+ BROWSERCHANNEL_PROTOCOL_VERSION,
+ hostedHtmlVersionStr)) {
+ *_retval = false;
+ return NS_OK;
+ }
+
std::string moduleName(moduleAutoStr.get());
std::string userAgent;
@@ -97,10 +120,12 @@
return res;
}
- LoadModuleMessage::send(*channel, 1,
- moduleName.c_str(), moduleName.length(),
- userAgent.c_str(),
- sessionHandler.get());
+ std::string urlStr(urlAutoStr.get());
+ std::string tabKeyStr(""); // TODO(jat): add support for tab identity
+ std::string sessionKeyStr(sessionKeyAutoStr.get());
+
+ LoadModuleMessage::send(*channel, urlStr, tabKeyStr, sessionKeyStr,
+ moduleName, userAgent, sessionHandler.get());
// TODO: return session object?
*_retval = true;
@@ -127,7 +152,7 @@
NS_IMETHODIMP ExternalWrapper::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval) {
Debug::log(Debug::Spam) << "ExternalWrapper::CanCallMethod" << Debug::flush;
- if (strEquals(methodName, "connect")) {
+ if (strEquals(methodName, "connect") || strEquals(methodName, "init")) {
*_retval = cloneAllAccess();
} else {
*_retval = nsnull;
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;
+}
diff --git a/plugins/xpcom/FFSessionHandler.h b/plugins/xpcom/FFSessionHandler.h
index 0583031..b456dcd 100755
--- a/plugins/xpcom/FFSessionHandler.h
+++ b/plugins/xpcom/FFSessionHandler.h
@@ -2,13 +2,13 @@
#define _H_FFSessionHandler
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -47,10 +47,12 @@
virtual bool invokeSpecial(HostChannel& channel, SpecialMethodId method, int numArgs,
const Value* const args, Value* returnValue);
virtual void sendFreeValues(HostChannel& channel);
+ virtual void fatalError(HostChannel& channel, const std::string& message);
private:
void getStringObjectClass(JSContext* ctx);
void getToStringTearOff(JSContext* ctx);
+ void* identityFromObject(JSObject* obj);
int jsObjectId;
@@ -61,7 +63,7 @@
JSObject* jsObjectsById;
JSClass* stringObjectClass;
- std::map<JSObject*, int> jsIdsByObject;
+ std::map<void*, int> jsIdsByObject;
};
inline Debug::DebugStream& operator<<(Debug::DebugStream& dbg, JSString* str) {
diff --git a/plugins/xpcom/IOOPHM.idl b/plugins/xpcom/IOOPHM.idl
index fdd206e..1aeea54 100644
--- a/plugins/xpcom/IOOPHM.idl
+++ b/plugins/xpcom/IOOPHM.idl
@@ -5,5 +5,7 @@
[scriptable, uuid(90CEF17B-C3FE-4251-AF68-4381B3D938A0)]
interface IOOPHM : nsISupports
{
- boolean connect( in ACString addr, in ACString moduleName, in nsIDOMWindow window );
+ boolean init(in nsIDOMWindow window);
+ boolean connect(in ACString url, in ACString sessionKey, in ACString addr,
+ in ACString moduleName, in ACString hostedHtmlVersion);
};
diff --git a/plugins/xpcom/JavaObject.cpp b/plugins/xpcom/JavaObject.cpp
index fd2af9f..638094f 100644
--- a/plugins/xpcom/JavaObject.cpp
+++ b/plugins/xpcom/JavaObject.cpp
@@ -135,6 +135,12 @@
*rval = INT_TO_JSVAL(objectRef);
return JS_TRUE;
}
+ if ((JS_GetStringLength(str) == 16) && !strncmp("__noSuchMethod__",
+ JS_GetStringBytes(str), 16)) {
+ // Avoid error spew if we are disconnected
+ *rval = JSVAL_VOID;
+ return JS_TRUE;
+ }
Debug::log(Debug::Error) << "Getting unexpected string property "
<< dumpJsVal(ctx, id) << Debug::flush;
// TODO: throw a better exception here
@@ -354,13 +360,13 @@
data->makeValueFromJsval(args[i], ctx, jsargs[i]);
}
if (!InvokeMessage::send(*channel, javaThis, dispId, numArgs, args.get())) {
- Debug::log(Debug::Error) << "JavaObject::call failed to send invoke message" << Debug::flush;
+ Debug::log(Debug::Debugging) << "JavaObject::call failed to send invoke message" << Debug::flush;
return false;
}
Debug::log(Debug::Spam) << " return from invoke" << Debug::flush;
scoped_ptr<ReturnMessage> retMsg(channel->reactToMessagesWhileWaitingForReturn(handler));
if (!retMsg.get()) {
- Debug::log(Debug::Error) << "JavaObject::call failed to get return value" << Debug::flush;
+ Debug::log(Debug::Debugging) << "JavaObject::call failed to get return value" << Debug::flush;
return false;
}
Value returnValue = retMsg->getReturnValue();
diff --git a/plugins/xpcom/Makefile b/plugins/xpcom/Makefile
index b4f0711..a1e8186 100644
--- a/plugins/xpcom/Makefile
+++ b/plugins/xpcom/Makefile
@@ -119,7 +119,7 @@
INC += -I$(GECKO_PLAT_INC) -I$(GECKO_SDK)/include -I$(dir $(FF_HEADER))
-VERSION=0.0.$(shell ./getversion).$(shell date +%Y%m%d%H%M%S)
+VERSION=0.9.$(shell ./getversion).$(shell date +%Y%m%d%H%M%S)
.PHONY: all xpi lib common browser clean depend install install-platform find-ff-libs
diff --git a/plugins/xpcom/ModuleOOPHM.cpp b/plugins/xpcom/ModuleOOPHM.cpp
index 33c5d73..919d2b3 100644
--- a/plugins/xpcom/ModuleOOPHM.cpp
+++ b/plugins/xpcom/ModuleOOPHM.cpp
@@ -129,7 +129,7 @@
nsCString gecko_version;
app_info->GetPlatformVersion(gecko_version);
- Debug::log(Debug::Debugging) << " gecko version = "
+ Debug::log(Debug::Info) << " gecko version = "
<< gecko_version.BeginReading() << Debug::flush;
#if defined(BROWSER_FF2)
if (strncmp(gecko_version.BeginReading(), "1.8", 3) != 0) {
diff --git a/plugins/xpcom/install-template-ff3+.rdf b/plugins/xpcom/install-template-ff3+.rdf
index aaee998..84a16f9 100644
--- a/plugins/xpcom/install-template-ff3+.rdf
+++ b/plugins/xpcom/install-template-ff3+.rdf
@@ -3,15 +3,15 @@
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
- <em:id>oophm-xpcom-ff3@gwt.google.com</em:id>
- <em:name>GWT Development Mode Plugin (XPCOM) for FF v3.x</em:name>
+ <em:id>oophm-xpcom-ff3p@gwt.google.com</em:id>
+ <em:name>GWT Development Mode Plugin (XPCOM) for FF v3.x (alt libraries)</em:name>
<em:version>GWT_OOPHM_VERSION</em:version>
<em:type>2</em:type>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>3</em:minVersion>
- <em:maxVersion>3.*</em:maxVersion>
+ <em:maxVersion>3.3.*</em:maxVersion>
</Description>
</em:targetApplication>
diff --git a/plugins/xpcom/install-template-ff3.rdf b/plugins/xpcom/install-template-ff3.rdf
index aaee998..9082d32 100644
--- a/plugins/xpcom/install-template-ff3.rdf
+++ b/plugins/xpcom/install-template-ff3.rdf
@@ -11,7 +11,7 @@
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>3</em:minVersion>
- <em:maxVersion>3.*</em:maxVersion>
+ <em:maxVersion>3.3.*</em:maxVersion>
</Description>
</em:targetApplication>
diff --git a/plugins/xpcom/prebuilt/extension-ff2/components/IOOPHM.xpt b/plugins/xpcom/prebuilt/extension-ff2/components/IOOPHM.xpt
index 4be87b7..683c881 100644
--- a/plugins/xpcom/prebuilt/extension-ff2/components/IOOPHM.xpt
+++ b/plugins/xpcom/prebuilt/extension-ff2/components/IOOPHM.xpt
Binary files differ
diff --git a/plugins/xpcom/prebuilt/extension-ff2/platform/Linux_x86-gcc3/components/liboophm_ff2.so b/plugins/xpcom/prebuilt/extension-ff2/platform/Linux_x86-gcc3/components/liboophm_ff2.so
index 65b6dd9..eedbabb 100755
--- a/plugins/xpcom/prebuilt/extension-ff2/platform/Linux_x86-gcc3/components/liboophm_ff2.so
+++ b/plugins/xpcom/prebuilt/extension-ff2/platform/Linux_x86-gcc3/components/liboophm_ff2.so
Binary files differ
diff --git a/plugins/xpcom/prebuilt/extension-ff2/platform/Linux_x86_64-gcc3/components/liboophm_ff2.so b/plugins/xpcom/prebuilt/extension-ff2/platform/Linux_x86_64-gcc3/components/liboophm_ff2.so
index f9dd5d3..cf54702 100755
--- a/plugins/xpcom/prebuilt/extension-ff2/platform/Linux_x86_64-gcc3/components/liboophm_ff2.so
+++ b/plugins/xpcom/prebuilt/extension-ff2/platform/Linux_x86_64-gcc3/components/liboophm_ff2.so
Binary files differ
diff --git a/plugins/xpcom/prebuilt/extension-ff3+/components/IOOPHM.xpt b/plugins/xpcom/prebuilt/extension-ff3+/components/IOOPHM.xpt
index 4be87b7..683c881 100644
--- a/plugins/xpcom/prebuilt/extension-ff3+/components/IOOPHM.xpt
+++ b/plugins/xpcom/prebuilt/extension-ff3+/components/IOOPHM.xpt
Binary files differ
diff --git a/plugins/xpcom/prebuilt/extension-ff3+/platform/Linux_x86_64-gcc3/components/liboophm_ff3+.so b/plugins/xpcom/prebuilt/extension-ff3+/platform/Linux_x86_64-gcc3/components/liboophm_ff3+.so
index 2361279..e1f5935 100755
--- a/plugins/xpcom/prebuilt/extension-ff3+/platform/Linux_x86_64-gcc3/components/liboophm_ff3+.so
+++ b/plugins/xpcom/prebuilt/extension-ff3+/platform/Linux_x86_64-gcc3/components/liboophm_ff3+.so
Binary files differ
diff --git a/plugins/xpcom/prebuilt/extension-ff3/components/IOOPHM.xpt b/plugins/xpcom/prebuilt/extension-ff3/components/IOOPHM.xpt
index 4be87b7..683c881 100644
--- a/plugins/xpcom/prebuilt/extension-ff3/components/IOOPHM.xpt
+++ b/plugins/xpcom/prebuilt/extension-ff3/components/IOOPHM.xpt
Binary files differ
diff --git a/plugins/xpcom/prebuilt/extension-ff3/platform/Linux_x86-gcc3/components/liboophm_ff3.so b/plugins/xpcom/prebuilt/extension-ff3/platform/Linux_x86-gcc3/components/liboophm_ff3.so
index a8705e0..76ace0d 100755
--- a/plugins/xpcom/prebuilt/extension-ff3/platform/Linux_x86-gcc3/components/liboophm_ff3.so
+++ b/plugins/xpcom/prebuilt/extension-ff3/platform/Linux_x86-gcc3/components/liboophm_ff3.so
Binary files differ
diff --git a/plugins/xpcom/prebuilt/extension-ff3/platform/Linux_x86_64-gcc3/components/liboophm_ff3.so b/plugins/xpcom/prebuilt/extension-ff3/platform/Linux_x86_64-gcc3/components/liboophm_ff3.so
index cb26cbe..99db367 100755
--- a/plugins/xpcom/prebuilt/extension-ff3/platform/Linux_x86_64-gcc3/components/liboophm_ff3.so
+++ b/plugins/xpcom/prebuilt/extension-ff3/platform/Linux_x86_64-gcc3/components/liboophm_ff3.so
Binary files differ
diff --git a/plugins/xpcom/prebuilt/extension-ff35/components/IOOPHM.xpt b/plugins/xpcom/prebuilt/extension-ff35/components/IOOPHM.xpt
index 4be87b7..683c881 100644
--- a/plugins/xpcom/prebuilt/extension-ff35/components/IOOPHM.xpt
+++ b/plugins/xpcom/prebuilt/extension-ff35/components/IOOPHM.xpt
Binary files differ
diff --git a/plugins/xpcom/prebuilt/extension-ff35/platform/Linux_x86_64-gcc3/components/liboophm_ff35.so b/plugins/xpcom/prebuilt/extension-ff35/platform/Linux_x86_64-gcc3/components/liboophm_ff35.so
index 1027a07..a65b4e6 100755
--- a/plugins/xpcom/prebuilt/extension-ff35/platform/Linux_x86_64-gcc3/components/liboophm_ff35.so
+++ b/plugins/xpcom/prebuilt/extension-ff35/platform/Linux_x86_64-gcc3/components/liboophm_ff35.so
Binary files differ
diff --git a/plugins/xpcom/prebuilt/extension/components/IOOPHM.xpt b/plugins/xpcom/prebuilt/extension/components/IOOPHM.xpt
index 4be87b7..683c881 100644
--- a/plugins/xpcom/prebuilt/extension/components/IOOPHM.xpt
+++ b/plugins/xpcom/prebuilt/extension/components/IOOPHM.xpt
Binary files differ
diff --git a/plugins/xpcom/prebuilt/ff2/include/IOOPHM.h b/plugins/xpcom/prebuilt/ff2/include/IOOPHM.h
index 9ab769d..12acdc1 100644
--- a/plugins/xpcom/prebuilt/ff2/include/IOOPHM.h
+++ b/plugins/xpcom/prebuilt/ff2/include/IOOPHM.h
@@ -29,22 +29,28 @@
NS_DEFINE_STATIC_IID_ACCESSOR(IOOPHM_IID)
- /* boolean connect (in ACString addr, in ACString moduleName, in nsIDOMWindow window); */
- NS_IMETHOD Connect(const nsACString & addr, const nsACString & moduleName, nsIDOMWindow *window, PRBool *_retval) = 0;
+ /* boolean init (in nsIDOMWindow window); */
+ NS_IMETHOD Init(nsIDOMWindow *window, PRBool *_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, PRBool *_retval) = 0;
};
/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_IOOPHM \
- NS_IMETHOD Connect(const nsACString & addr, const nsACString & moduleName, nsIDOMWindow *window, PRBool *_retval);
+ NS_IMETHOD Init(nsIDOMWindow *window, PRBool *_retval); \
+ NS_IMETHOD Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, PRBool *_retval);
/* Use this macro to declare functions that forward the behavior of this interface to another object. */
#define NS_FORWARD_IOOPHM(_to) \
- NS_IMETHOD Connect(const nsACString & addr, const nsACString & moduleName, nsIDOMWindow *window, PRBool *_retval) { return _to Connect(addr, moduleName, window, _retval); }
+ NS_IMETHOD Init(nsIDOMWindow *window, PRBool *_retval) { return _to Init(window, _retval); } \
+ NS_IMETHOD Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, PRBool *_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 Connect(const nsACString & addr, const nsACString & moduleName, nsIDOMWindow *window, PRBool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Connect(addr, moduleName, window, _retval); }
+ NS_IMETHOD Init(nsIDOMWindow *window, PRBool *_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, PRBool *_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. */
@@ -78,8 +84,14 @@
/* destructor code */
}
-/* boolean connect (in ACString addr, in ACString moduleName, in nsIDOMWindow window); */
-NS_IMETHODIMP _MYCLASS_::Connect(const nsACString & addr, const nsACString & moduleName, nsIDOMWindow *window, PRBool *_retval)
+/* boolean init (in nsIDOMWindow window); */
+NS_IMETHODIMP _MYCLASS_::Init(nsIDOMWindow *window, PRBool *_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, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
diff --git a/plugins/xpcom/prebuilt/ff3+/include/IOOPHM.h b/plugins/xpcom/prebuilt/ff3+/include/IOOPHM.h
index ba6f481..169598e 100644
--- a/plugins/xpcom/prebuilt/ff3+/include/IOOPHM.h
+++ b/plugins/xpcom/prebuilt/ff3+/include/IOOPHM.h
@@ -29,8 +29,11 @@
NS_DECLARE_STATIC_IID_ACCESSOR(IOOPHM_IID)
- /* boolean connect (in ACString addr, in ACString moduleName, in nsIDOMWindow window); */
- NS_SCRIPTABLE NS_IMETHOD Connect(const nsACString & addr, const nsACString & moduleName, nsIDOMWindow *window, PRBool *_retval) = 0;
+ /* boolean init (in nsIDOMWindow window); */
+ NS_SCRIPTABLE NS_IMETHOD Init(nsIDOMWindow *window, PRBool *_retval) = 0;
+
+ /* boolean connect (in ACString url, in ACString sessionKey, in ACString addr, in ACString moduleName, in ACString hostedHtmlVersion); */
+ NS_SCRIPTABLE NS_IMETHOD Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, PRBool *_retval) = 0;
};
@@ -38,15 +41,18 @@
/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_IOOPHM \
- NS_SCRIPTABLE NS_IMETHOD Connect(const nsACString & addr, const nsACString & moduleName, nsIDOMWindow *window, PRBool *_retval);
+ NS_SCRIPTABLE NS_IMETHOD Init(nsIDOMWindow *window, PRBool *_retval); \
+ NS_SCRIPTABLE NS_IMETHOD Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, PRBool *_retval);
/* Use this macro to declare functions that forward the behavior of this interface to another object. */
#define NS_FORWARD_IOOPHM(_to) \
- NS_SCRIPTABLE NS_IMETHOD Connect(const nsACString & addr, const nsACString & moduleName, nsIDOMWindow *window, PRBool *_retval) { return _to Connect(addr, moduleName, window, _retval); }
+ NS_SCRIPTABLE NS_IMETHOD Init(nsIDOMWindow *window, PRBool *_retval) { return _to Init(window, _retval); } \
+ NS_SCRIPTABLE NS_IMETHOD Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, PRBool *_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_SCRIPTABLE NS_IMETHOD Connect(const nsACString & addr, const nsACString & moduleName, nsIDOMWindow *window, PRBool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Connect(addr, moduleName, window, _retval); }
+ NS_SCRIPTABLE NS_IMETHOD Init(nsIDOMWindow *window, PRBool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Init(window, _retval); } \
+ NS_SCRIPTABLE NS_IMETHOD Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, PRBool *_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. */
@@ -80,8 +86,14 @@
/* destructor code */
}
-/* boolean connect (in ACString addr, in ACString moduleName, in nsIDOMWindow window); */
-NS_IMETHODIMP _MYCLASS_::Connect(const nsACString & addr, const nsACString & moduleName, nsIDOMWindow *window, PRBool *_retval)
+/* boolean init (in nsIDOMWindow window); */
+NS_IMETHODIMP _MYCLASS_::Init(nsIDOMWindow *window, PRBool *_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, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
diff --git a/plugins/xpcom/prebuilt/ff3/include/IOOPHM.h b/plugins/xpcom/prebuilt/ff3/include/IOOPHM.h
index ba6f481..169598e 100644
--- a/plugins/xpcom/prebuilt/ff3/include/IOOPHM.h
+++ b/plugins/xpcom/prebuilt/ff3/include/IOOPHM.h
@@ -29,8 +29,11 @@
NS_DECLARE_STATIC_IID_ACCESSOR(IOOPHM_IID)
- /* boolean connect (in ACString addr, in ACString moduleName, in nsIDOMWindow window); */
- NS_SCRIPTABLE NS_IMETHOD Connect(const nsACString & addr, const nsACString & moduleName, nsIDOMWindow *window, PRBool *_retval) = 0;
+ /* boolean init (in nsIDOMWindow window); */
+ NS_SCRIPTABLE NS_IMETHOD Init(nsIDOMWindow *window, PRBool *_retval) = 0;
+
+ /* boolean connect (in ACString url, in ACString sessionKey, in ACString addr, in ACString moduleName, in ACString hostedHtmlVersion); */
+ NS_SCRIPTABLE NS_IMETHOD Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, PRBool *_retval) = 0;
};
@@ -38,15 +41,18 @@
/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_IOOPHM \
- NS_SCRIPTABLE NS_IMETHOD Connect(const nsACString & addr, const nsACString & moduleName, nsIDOMWindow *window, PRBool *_retval);
+ NS_SCRIPTABLE NS_IMETHOD Init(nsIDOMWindow *window, PRBool *_retval); \
+ NS_SCRIPTABLE NS_IMETHOD Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, PRBool *_retval);
/* Use this macro to declare functions that forward the behavior of this interface to another object. */
#define NS_FORWARD_IOOPHM(_to) \
- NS_SCRIPTABLE NS_IMETHOD Connect(const nsACString & addr, const nsACString & moduleName, nsIDOMWindow *window, PRBool *_retval) { return _to Connect(addr, moduleName, window, _retval); }
+ NS_SCRIPTABLE NS_IMETHOD Init(nsIDOMWindow *window, PRBool *_retval) { return _to Init(window, _retval); } \
+ NS_SCRIPTABLE NS_IMETHOD Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, PRBool *_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_SCRIPTABLE NS_IMETHOD Connect(const nsACString & addr, const nsACString & moduleName, nsIDOMWindow *window, PRBool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Connect(addr, moduleName, window, _retval); }
+ NS_SCRIPTABLE NS_IMETHOD Init(nsIDOMWindow *window, PRBool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Init(window, _retval); } \
+ NS_SCRIPTABLE NS_IMETHOD Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, PRBool *_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. */
@@ -80,8 +86,14 @@
/* destructor code */
}
-/* boolean connect (in ACString addr, in ACString moduleName, in nsIDOMWindow window); */
-NS_IMETHODIMP _MYCLASS_::Connect(const nsACString & addr, const nsACString & moduleName, nsIDOMWindow *window, PRBool *_retval)
+/* boolean init (in nsIDOMWindow window); */
+NS_IMETHODIMP _MYCLASS_::Init(nsIDOMWindow *window, PRBool *_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, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
diff --git a/plugins/xpcom/prebuilt/ff35/include/IOOPHM.h b/plugins/xpcom/prebuilt/ff35/include/IOOPHM.h
index 47d62d2..0e7be5d 100644
--- a/plugins/xpcom/prebuilt/ff35/include/IOOPHM.h
+++ b/plugins/xpcom/prebuilt/ff35/include/IOOPHM.h
@@ -29,8 +29,11 @@
NS_DECLARE_STATIC_IID_ACCESSOR(IOOPHM_IID)
- /* boolean connect (in ACString addr, in ACString moduleName, in nsIDOMWindow window); */
- NS_SCRIPTABLE NS_IMETHOD Connect(const nsACString & addr, const nsACString & moduleName, nsIDOMWindow *window, PRBool *_retval NS_OUTPARAM) = 0;
+ /* boolean init (in nsIDOMWindow window); */
+ NS_SCRIPTABLE NS_IMETHOD Init(nsIDOMWindow *window, PRBool *_retval NS_OUTPARAM) = 0;
+
+ /* boolean connect (in ACString url, in ACString sessionKey, in ACString addr, in ACString moduleName, in ACString hostedHtmlVersion); */
+ NS_SCRIPTABLE NS_IMETHOD Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, PRBool *_retval NS_OUTPARAM) = 0;
};
@@ -38,15 +41,18 @@
/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_IOOPHM \
- NS_SCRIPTABLE NS_IMETHOD Connect(const nsACString & addr, const nsACString & moduleName, nsIDOMWindow *window, PRBool *_retval NS_OUTPARAM);
+ NS_SCRIPTABLE NS_IMETHOD Init(nsIDOMWindow *window, PRBool *_retval NS_OUTPARAM); \
+ NS_SCRIPTABLE NS_IMETHOD Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, PRBool *_retval NS_OUTPARAM);
/* Use this macro to declare functions that forward the behavior of this interface to another object. */
#define NS_FORWARD_IOOPHM(_to) \
- NS_SCRIPTABLE NS_IMETHOD Connect(const nsACString & addr, const nsACString & moduleName, nsIDOMWindow *window, PRBool *_retval NS_OUTPARAM) { return _to Connect(addr, moduleName, window, _retval); }
+ NS_SCRIPTABLE NS_IMETHOD Init(nsIDOMWindow *window, PRBool *_retval NS_OUTPARAM) { return _to Init(window, _retval); } \
+ NS_SCRIPTABLE NS_IMETHOD Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, PRBool *_retval NS_OUTPARAM) { 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_SCRIPTABLE NS_IMETHOD Connect(const nsACString & addr, const nsACString & moduleName, nsIDOMWindow *window, PRBool *_retval NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->Connect(addr, moduleName, window, _retval); }
+ NS_SCRIPTABLE NS_IMETHOD Init(nsIDOMWindow *window, PRBool *_retval NS_OUTPARAM) { return !_to ? NS_ERROR_NULL_POINTER : _to->Init(window, _retval); } \
+ NS_SCRIPTABLE NS_IMETHOD Connect(const nsACString & url, const nsACString & sessionKey, const nsACString & addr, const nsACString & moduleName, const nsACString & hostedHtmlVersion, PRBool *_retval NS_OUTPARAM) { 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. */
@@ -80,8 +86,14 @@
/* destructor code */
}
-/* boolean connect (in ACString addr, in ACString moduleName, in nsIDOMWindow window); */
-NS_IMETHODIMP _MYCLASS_::Connect(const nsACString & addr, const nsACString & moduleName, nsIDOMWindow *window, PRBool *_retval NS_OUTPARAM)
+/* boolean init (in nsIDOMWindow window); */
+NS_IMETHODIMP _MYCLASS_::Init(nsIDOMWindow *window, PRBool *_retval NS_OUTPARAM)
+{
+ 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, PRBool *_retval NS_OUTPARAM)
{
return NS_ERROR_NOT_IMPLEMENTED;
}