Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(484)

Unified Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 6538028: A proposal for an initial postMessage interface. This will allow JavaScript ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/plugins/ppapi/ppapi_plugin_instance.cc
===================================================================
--- webkit/plugins/ppapi/ppapi_plugin_instance.cc (revision 77328)
+++ webkit/plugins/ppapi/ppapi_plugin_instance.cc (working copy)
@@ -42,6 +42,7 @@
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/event_conversion.h"
#include "webkit/plugins/ppapi/fullscreen_container.h"
+#include "webkit/plugins/ppapi/message_channel.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/plugin_object.h"
@@ -99,7 +100,8 @@
namespace {
#define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, np_name) \
- COMPILE_ASSERT(int(WebCursorInfo::webkit_name) == int(np_name), \
+ COMPILE_ASSERT(static_cast<int>(WebCursorInfo::webkit_name) \
+ == static_cast<int>(np_name), \
mismatching_enums)
COMPILE_ASSERT_MATCHING_ENUM(TypePointer, PP_CURSORTYPE_POINTER);
@@ -201,12 +203,20 @@
return instance->ExecuteScript(script, exception);
}
+void PostMessage(PP_Instance instance_id, PP_Var message) {
+ PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
+ if (!instance)
+ return;
+ instance->PostMessage(message);
+}
+
const PPB_Instance ppb_instance = {
&GetWindowObject,
&GetOwnerElementObject,
&BindGraphics,
&IsFullFrame,
&ExecuteScript,
+ &PostMessage
};
void NumberOfFindResultsChanged(PP_Instance instance_id,
@@ -335,13 +345,15 @@
plugin_graphics_3d_interface_(NULL),
always_on_top_(false),
fullscreen_container_(NULL),
- fullscreen_(false) {
+ fullscreen_(false),
+ message_channel_(NULL) {
pp_instance_ = ResourceTracker::Get()->AddInstance(this);
memset(&current_print_settings_, 0, sizeof(current_print_settings_));
DCHECK(delegate);
module_->InstanceCreated(this);
delegate_->InstanceCreated(this);
+ message_channel_.reset(new MessageChannel(this));
}
PluginInstance::~PluginInstance() {
@@ -590,6 +602,10 @@
return ret;
}
+void PluginInstance::PostMessage(PP_Var message) {
+ message_channel_->PostMessageToJavaScript(message);
+}
+
void PluginInstance::Delete() {
// Keep a reference on the stack. See NOTE above.
scoped_refptr<PluginInstance> ref(this);
@@ -649,6 +665,13 @@
return rv;
}
+void PluginInstance::HandleMessage(PP_Var message) {
+ if ((instance_interface_ != NULL) &&
+ (instance_interface_->HandleMessage != NULL)) {
+ instance_interface_->HandleMessage(pp_instance(), message);
+ }
+}
+
PP_Var PluginInstance::GetInstanceObject() {
return instance_interface_->GetInstanceObject(pp_instance());
}

Powered by Google App Engine
This is Rietveld 408576698