[email protected] | 701a94e | 2014-04-17 04:37:37 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
[email protected] | 4f1633f | 2013-03-09 14:26:24 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 701a94e | 2014-04-17 04:37:37 | [diff] [blame] | 5 | #ifndef EXTENSIONS_RENDERER_BINDING_GENERATING_NATIVE_HANDLER_H_ |
6 | #define EXTENSIONS_RENDERER_BINDING_GENERATING_NATIVE_HANDLER_H_ | ||||
[email protected] | 4f1633f | 2013-03-09 14:26:24 | [diff] [blame] | 7 | |
8 | #include <string> | ||||
9 | |||||
10 | #include "base/compiler_specific.h" | ||||
[email protected] | b8ce52f | 2014-04-04 22:45:15 | [diff] [blame] | 11 | #include "extensions/renderer/native_handler.h" |
[email protected] | 4f1633f | 2013-03-09 14:26:24 | [diff] [blame] | 12 | |
13 | namespace extensions { | ||||
14 | |||||
bashi | 61ca3c7 | 2015-06-26 00:40:10 | [diff] [blame] | 15 | class ScriptContext; |
[email protected] | 4f1633f | 2013-03-09 14:26:24 | [diff] [blame] | 16 | |
17 | // Generates API bindings based on the JSON/IDL schemas. This is done by | ||||
18 | // creating a |Binding| (from binding.js) for the schema and generating the | ||||
19 | // bindings from that. | ||||
20 | class BindingGeneratingNativeHandler : public NativeHandler { | ||||
21 | public: | ||||
22 | // Generates binding for |api_name|, and sets the |bind_to| property on the | ||||
23 | // Object returned by |NewInstance| to the generated binding. | ||||
bashi | 61ca3c7 | 2015-06-26 00:40:10 | [diff] [blame] | 24 | BindingGeneratingNativeHandler(ScriptContext* context, |
[email protected] | 4f1633f | 2013-03-09 14:26:24 | [diff] [blame] | 25 | const std::string& api_name, |
26 | const std::string& bind_to); | ||||
27 | |||||
Devlin Cronin | d9ea834 | 2018-01-27 06:00:04 | [diff] [blame] | 28 | void Initialize() final; |
Devlin Cronin | 6fed7f0 | 2018-01-31 22:38:20 | [diff] [blame] | 29 | bool IsInitialized() final; |
tfarina | f85316f | 2015-04-29 17:03:40 | [diff] [blame] | 30 | v8::Local<v8::Object> NewInstance() override; |
[email protected] | 4f1633f | 2013-03-09 14:26:24 | [diff] [blame] | 31 | |
32 | private: | ||||
bashi | 61ca3c7 | 2015-06-26 00:40:10 | [diff] [blame] | 33 | ScriptContext* context_; |
[email protected] | 4f1633f | 2013-03-09 14:26:24 | [diff] [blame] | 34 | std::string api_name_; |
35 | std::string bind_to_; | ||||
36 | }; | ||||
37 | |||||
[email protected] | b8ce52f | 2014-04-04 22:45:15 | [diff] [blame] | 38 | } // namespace extensions |
[email protected] | 4f1633f | 2013-03-09 14:26:24 | [diff] [blame] | 39 | |
[email protected] | 701a94e | 2014-04-17 04:37:37 | [diff] [blame] | 40 | #endif // EXTENSIONS_RENDERER_BINDING_GENERATING_NATIVE_HANDLER_H_ |