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

Unified Diff: chrome/renderer/extensions/extension_process_bindings.cc

Issue 251093: Modify extension request IPC messages to pass a ListValue instead of a string. (Closed)
Patch Set: notreached messages Created 11 years, 2 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 | « chrome/renderer/extensions/extension_api_client_unittest.cc ('k') | chrome/renderer/render_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/extensions/extension_process_bindings.cc
diff --git a/chrome/renderer/extensions/extension_process_bindings.cc b/chrome/renderer/extensions/extension_process_bindings.cc
index 66035823fa0573b160a6518123f2ca11c16e3312..e083c7c29192948af927c637e8609b94d2931e8c 100644
--- a/chrome/renderer/extensions/extension_process_bindings.cc
+++ b/chrome/renderer/extensions/extension_process_bindings.cc
@@ -9,6 +9,7 @@
#include "chrome/renderer/extensions/extension_process_bindings.h"
+#include "base/json_reader.h"
#include "base/singleton.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_message_bundle.h"
@@ -352,17 +353,33 @@ class ExtensionImpl : public ExtensionBase {
return ExtensionProcessBindings::ThrowPermissionDeniedException(name);
}
- std::string json_args = *v8::String::Utf8Value(args[1]);
+ std::string str_args = *v8::String::Utf8Value(args[1]);
int request_id = args[2]->Int32Value();
bool has_callback = args[3]->BooleanValue();
+ ListValue args_holder;
+ JSONReader reader;
+ Value* json_args = reader.JsonToValue(str_args, false, false);
+
+ // Since we do the serialization in the v8 extension, we should always get
+ // valid JSON.
+ if (!json_args) {
+ NOTREACHED() << "Invalid JSON passed to StartRequest.";
+ return v8::Undefined();
+ }
+
+ // Put the args in a 1-element list for easier serialization. Maybe all
+ // requests should have a list of args?
+ args_holder.Append(json_args);
+
v8::Persistent<v8::Context> current_context =
v8::Persistent<v8::Context>::New(v8::Context::GetCurrent());
DCHECK(!current_context.IsEmpty());
GetPendingRequestMap()[request_id].reset(new PendingRequest(
current_context, name));
- renderview->SendExtensionRequest(name, json_args, request_id, has_callback);
+ renderview->SendExtensionRequest(name, args_holder,
+ request_id, has_callback);
return v8::Undefined();
}
« no previous file with comments | « chrome/renderer/extensions/extension_api_client_unittest.cc ('k') | chrome/renderer/render_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698