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

Unified Diff: content/renderer/browser_plugin/browser_plugin.cc

Issue 11377089: browser-plugin: Send a JSON string for the detail data with the events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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: content/renderer/browser_plugin/browser_plugin.cc
diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc
index c917a2e9bf46915c4ec58a701d0bcb4adb2b3c81..63c9676f6fa074320f79578169d3b3d571cf6068 100644
--- a/content/renderer/browser_plugin/browser_plugin.cc
+++ b/content/renderer/browser_plugin/browser_plugin.cc
@@ -4,6 +4,7 @@
#include "content/renderer/browser_plugin/browser_plugin.h"
+#include "base/json/json_string_value_serializer.h"
#include "base/message_loop.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
@@ -319,21 +320,18 @@ void BrowserPlugin::TriggerEvent(const std::string& event_name,
std::map<std::string, base::Value*>* props) {
if (!container())
return;
- WebKit::WebFrame* frame = container()->element().document().frame();
v8::HandleScope handle_scope;
- v8::Local<v8::Context> context = frame->mainWorldScriptContext();
- v8::Context::Scope context_scope(context);
- v8::Local<v8::Object> detail = v8::Object::New();
-
+ std::string json_string;
if (props) {
- V8ValueConverterImpl converter;
+ base::DictionaryValue dict;
for (std::map<std::string, base::Value*>::iterator iter = props->begin(),
end = props->end(); iter != end; ++iter) {
- detail->Set(v8::String::New(iter->first.data(), iter->first.size()),
- converter.ToV8Value(iter->second, context),
- v8::ReadOnly);
+ dict.Set(iter->first, iter->second);
}
- STLDeleteValues(props);
+
+ JSONStringValueSerializer serializer(&json_string);
+ if (!serializer.Serialize(dict))
+ return;
}
// Setting properties on the |detail| object may have triggered JS code that
@@ -341,6 +339,7 @@ void BrowserPlugin::TriggerEvent(const std::string& event_name,
// frame to be destroyed. So do a check here for these.
if (!container() || !container()->element().document().frame())
return;
+ WebKit::WebFrame* frame = container()->element().document().frame();
WebKit::WebDOMEvent dom_event = frame->document().createEvent("CustomEvent");
WebKit::WebDOMCustomEvent event = dom_event.to<WebKit::WebDOMCustomEvent>();
std::string obfuscated_name = base::StringPrintf("-internal-%s",
@@ -348,7 +347,8 @@ void BrowserPlugin::TriggerEvent(const std::string& event_name,
event.initCustomEvent(
WebKit::WebString::fromUTF8(obfuscated_name.c_str()),
false, false,
- WebKit::WebSerializedScriptValue::serialize(detail));
+ WebKit::WebSerializedScriptValue::serialize(
+ v8::String::New(json_string.c_str())));
container()->element().dispatchEvent(event);
}
« no previous file with comments | « chrome/renderer/resources/extensions/web_view.js ('k') | content/renderer/browser_plugin/browser_plugin_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698