Index: chrome/renderer/extensions/generated_bindings.h.tmpl |
diff --git a/chrome/renderer/extensions/generated_bindings.h.tmpl b/chrome/renderer/extensions/generated_bindings.h.tmpl |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3293e0a713d7218c5c8e1ad08005136923ddf03f |
--- /dev/null |
+++ b/chrome/renderer/extensions/generated_bindings.h.tmpl |
@@ -0,0 +1,79 @@ |
+// Copyright (c) $year 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. |
+ |
+// This file is generated. Don't edit it. The source is here: |
+// |
+// chrome/renderer/extensions/generated_bindings.h.tmpl |
+ |
+\#ifndef $guard |
+\#define $guard |
+\#pragma once |
+ |
+\#include "base/stringprintf.h" |
+\#include "chrome/common/extensions/api/generated_messages.h" |
+\#include "chrome/renderer/extensions/extension_dispatcher.h" |
+\#include "chrome/renderer/extensions/schema_generated_bindings.h" |
+\#include "content/public/renderer/render_view.h" |
+ |
+class GeneratedBindings { |
+public: |
+ static bool Handle(content::RenderView* renderview, |
+ const std::string& name, |
+ int request_id, |
+ ListValue* value_args) { |
+#for $family in $families |
+#for $function in $family.functions |
+ if (name == "$function.dotted_name") { |
+#for $arg in $function.arguments |
+ $arg.mapped_type() $arg.name; |
+#end for |
+ renderview->Send(new ExtensionAPIHostMsg_${function.class_name}( |
+ renderview->GetRoutingId(), request_id#for $arg in $function.arguments#, |
+ $arg.name#end for#)); |
+ return true; |
+ } |
+#end for |
+#end for |
+ return false; |
+ } |
+}; |
+ |
+class GeneratedExtensionHelper { |
+ public: |
+ GeneratedExtensionHelper(ExtensionDispatcher* extension_dispatcher) |
+ : extension_dispatcher_(extension_dispatcher) { |
+ } |
+ |
+ bool OnMessageReceived(const IPC::Message& message) { |
+ bool handled = true; |
+ IPC_BEGIN_MESSAGE_MAP(GeneratedExtensionHelper, message) |
+#for $family in $families |
+#for $function in $family.functions |
+ IPC_MESSAGE_HANDLER(ExtensionAPIViewMsg_${function.class_name}Response, On${function.class_name}Response) |
+#end for |
+#end for |
+ IPC_MESSAGE_UNHANDLED(handled = false) |
+ IPC_END_MESSAGE_MAP() |
+ return handled; |
+ } |
+ |
+ private: |
+#for $family in $families |
+#for $function in $family.functions |
+ void On${function.class_name}Response( |
+ int request_id, |
+ int result) { |
+ std::string extension_id; |
+ extensions::SchemaGeneratedBindings::HandleResponse( |
+ extension_dispatcher_->v8_context_set(), request_id, true, |
+ base::StringPrintf("%d", result), "", &extension_id); |
+} |
+ |
+#end for |
+#end for |
+ |
+ ExtensionDispatcher* extension_dispatcher_; |
+}; |
+ |
+\#endif // $guard |