| Index: chrome/browser/extensions/api/generated_api_functions.h.tmpl
|
| diff --git a/chrome/browser/extensions/api/generated_api_functions.h.tmpl b/chrome/browser/extensions/api/generated_api_functions.h.tmpl
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ce2d3961002463c846d19f4c43ad335ae0a48bb5
|
| --- /dev/null
|
| +++ b/chrome/browser/extensions/api/generated_api_functions.h.tmpl
|
| @@ -0,0 +1,90 @@
|
| +// 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.
|
| +
|
| +\#ifndef $guard
|
| +\#define $guard
|
| +\#pragma once
|
| +
|
| +\#include <string>
|
| +
|
| +\#include "chrome/browser/extensions/api/api_function.h"
|
| +\#include "chrome/browser/extensions/extension_factory_registry.h"
|
| +\#include "chrome/browser/extensions/extension_function.h"
|
| +\#include "chrome/browser/extensions/extension_function_dispatcher.h"
|
| +\#include "chrome/common/extensions/api/generated_messages.h"
|
| +\#include "content/browser/renderer_host/render_view_host.h"
|
| +\#include "content/public/browser/web_contents_observer.h"
|
| +\#include "ipc/ipc_message.h"
|
| +
|
| +#for $family in $families
|
| +\#include "${family.header_path}"
|
| +#end for
|
| +
|
| +namespace extensions {
|
| +
|
| +// Keys used in API responses.
|
| +#for $family in $families
|
| +#for $function in $family.functions
|
| +#for $return_value in $function.return_values
|
| +extern const char k${$return_value.name}Key[];
|
| +#end for
|
| +#end for
|
| +#end for
|
| +
|
| +class ExtensionAPIHost :
|
| + public content::WebContentsObserver {
|
| + public:
|
| + ExtensionAPIHost(
|
| + RenderViewHost* render_view_host,
|
| + ExtensionFunctionDispatcher* extension_function_dispatcher) :
|
| + render_view_host_(render_view_host),
|
| + extension_function_dispatcher_(extension_function_dispatcher) {
|
| + }
|
| +
|
| + bool OnMessageReceived(const IPC::Message& message) {
|
| + bool handled = true;
|
| + IPC_BEGIN_MESSAGE_MAP(ExtensionAPIHost, message)
|
| +#for $family in $families
|
| +#for $function in $family.functions
|
| + IPC_MESSAGE_HANDLER(ExtensionAPIHostMsg_${function.class_name}, On${function.class_name})
|
| +#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}(
|
| + int request_id#for $argument in $function.arguments#,
|
| + $argument.mapped_arg_type $argument.name#end for#) {
|
| + render_view_host_->Send(
|
| + new ExtensionAPIViewMsg_${function.class_name}Response(
|
| + render_view_host_->routing_id(), request_id, 42));
|
| + }
|
| +#end for
|
| +#end for
|
| +
|
| + RenderViewHost* render_view_host_;
|
| + ExtensionFunctionDispatcher* extension_function_dispatcher_;
|
| +};
|
| +
|
| +class GeneratedAPIFunctionRegistry {
|
| + public:
|
| + static void RegisterAll(FactoryRegistry* registry) {
|
| +#for $family in $families
|
| +#for $f in $family.functions
|
| + registry->RegisterFunction<${f.class_name}Function>();
|
| +#end for
|
| +#end for
|
| + }
|
| +};
|
| +
|
| +} // namespace extensions
|
| +
|
| +\#endif // $guard
|
|
|