OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef EXTENSIONS_RENDERER_DECLARATIVE_CONTENT_HOOKS_DELEGATE_H_ |
| 6 #define EXTENSIONS_RENDERER_DECLARATIVE_CONTENT_HOOKS_DELEGATE_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/macros.h" |
| 13 #include "extensions/renderer/api_binding_hooks_delegate.h" |
| 14 #include "v8/include/v8.h" |
| 15 |
| 16 namespace extensions { |
| 17 class APITypeReferenceMap; |
| 18 class ArgumentSpec; |
| 19 |
| 20 // Custom hooks for the declarativeContent API. |
| 21 class DeclarativeContentHooksDelegate : public APIBindingHooksDelegate { |
| 22 public: |
| 23 // The callback type for handling an API call. |
| 24 using HandlerCallback = |
| 25 base::Callback<void(const v8::FunctionCallbackInfo<v8::Value>&)>; |
| 26 |
| 27 DeclarativeContentHooksDelegate(); |
| 28 ~DeclarativeContentHooksDelegate() override; |
| 29 |
| 30 void InitializeTemplate(v8::Isolate* isolate, |
| 31 v8::Local<v8::ObjectTemplate> object_template, |
| 32 const APITypeReferenceMap& type_refs) override; |
| 33 |
| 34 private: |
| 35 void HandleCall(const ArgumentSpec* spec, |
| 36 const APITypeReferenceMap* type_refs, |
| 37 const std::string& type_name, |
| 38 const v8::FunctionCallbackInfo<v8::Value>& info); |
| 39 |
| 40 // The owned callbacks for the constructor functions. Since these pointers |
| 41 // are passed to v8::External, we need to use unique_ptrs rather than just |
| 42 // storing the callback directly in a vector. |
| 43 std::vector<std::unique_ptr<HandlerCallback>> callbacks_; |
| 44 |
| 45 DISALLOW_COPY_AND_ASSIGN(DeclarativeContentHooksDelegate); |
| 46 }; |
| 47 |
| 48 } // namespace extensions |
| 49 |
| 50 #endif // EXTENSIONS_RENDERER_DECLARATIVE_CONTENT_HOOKS_DELEGATE_H_ |
OLD | NEW |