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

Unified Diff: content/renderer/render_view_impl.cc

Issue 332693004: Add a content API for postMessage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address jochen's review Created 6 years, 5 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
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_view_impl.cc
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 44bacadc7560bdecf8bc389ba02da93ba067e479..815eaf06c7da3f5c73684af89dee886d880b374a 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -160,6 +160,7 @@
#include "third_party/WebKit/public/web/WebHistoryItem.h"
#include "third_party/WebKit/public/web/WebInputElement.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
+#include "third_party/WebKit/public/web/WebKit.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebMediaPlayerAction.h"
#include "third_party/WebKit/public/web/WebNavigationPolicy.h"
@@ -2969,6 +2970,22 @@ void RenderViewImpl::OnPostMessageEvent(
base::MessageLoopProxy::current().get());
}
+ WebSerializedScriptValue serialized_script_value;
+ if (params.is_data_raw_string) {
+ v8::HandleScope handle_scope(blink::mainThreadIsolate());
+ v8::Local<v8::Context> context = frame->mainWorldScriptContext();
+ v8::Context::Scope context_scope(context);
+ V8ValueConverterImpl converter;
+ converter.SetDateAllowed(true);
+ converter.SetRegExpAllowed(true);
+ scoped_ptr<base::Value> value(new base::StringValue(params.data));
+ v8::Handle<v8::Value> result_value = converter.ToV8Value(value.get(),
+ context);
+ serialized_script_value = WebSerializedScriptValue::serialize(result_value);
+ } else {
+ serialized_script_value = WebSerializedScriptValue::fromString(params.data);
+ }
+
// Create an event with the message. The final parameter to initMessageEvent
// is the last event ID, which is not used with postMessage.
WebDOMEvent event = frame->document().createEvent("MessageEvent");
@@ -2976,7 +2993,7 @@ void RenderViewImpl::OnPostMessageEvent(
msg_event.initMessageEvent("message",
// |canBubble| and |cancellable| are always false
false, false,
- WebSerializedScriptValue::fromString(params.data),
+ serialized_script_value,
params.source_origin, source_frame, "", channels);
// We must pass in the target_origin to do the security check on this side,
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698