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

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

Issue 61383003: Pass pepper apps API calls through the existing js apps API bindings. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years 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: chrome/renderer/extensions/pepper_request_natives.cc
diff --git a/chrome/renderer/extensions/pepper_request_natives.cc b/chrome/renderer/extensions/pepper_request_natives.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fde2a14bc77e4d19173161a8999e56f555e9e2fc
--- /dev/null
+++ b/chrome/renderer/extensions/pepper_request_natives.cc
@@ -0,0 +1,46 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/extensions/pepper_request_natives.h"
+
+#include <string>
+
+#include "base/logging.h"
+#include "base/values.h"
+#include "chrome/renderer/extensions/chrome_v8_context.h"
+#include "content/public/renderer/v8_value_converter.h"
+
+namespace extensions {
+
+PepperRequestNatives::PepperRequestNatives(ChromeV8Context* context)
+ : ObjectBackedNativeHandler(context) {
+ RouteFunction(
+ "SendResponse",
+ base::Bind(&PepperRequestNatives::SendResponse, base::Unretained(this)));
+}
+
+void PepperRequestNatives::SendResponse(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ DCHECK_EQ(3, args.Length());
+ DCHECK(args[0]->IsInt32());
+ DCHECK(args[1]->IsArray());
+ int request_id = args[0]->Int32Value();
+ if (args[2]->IsString()) {
+ context()->pepper_request_proxy()->OnResponseReceived(
+ request_id, false, base::ListValue(), *v8::String::Utf8Value(args[2]));
+ return;
+ }
+
+ scoped_ptr<content::V8ValueConverter> converter(
+ content::V8ValueConverter::create());
+ scoped_ptr<const base::Value> result(
+ converter->FromV8Value(args[1], context()->v8_context()));
+ DCHECK(result);
+ const base::ListValue* result_list = NULL;
+ CHECK(result->GetAsList(&result_list));
+ context()->pepper_request_proxy()->OnResponseReceived(
+ request_id, true, *result_list, "");
+}
+
+} // namespace extensions
« no previous file with comments | « chrome/renderer/extensions/pepper_request_natives.h ('k') | chrome/renderer/extensions/pepper_request_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698