| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef EXTENSIONS_RENDERER_BINDINGS_API_BINDING_H_ | 5 #ifndef EXTENSIONS_RENDERER_BINDINGS_API_BINDING_H_ |
| 6 #define EXTENSIONS_RENDERER_BINDINGS_API_BINDING_H_ | 6 #define EXTENSIONS_RENDERER_BINDINGS_API_BINDING_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 v8::Local<v8::Object> CreateInstance(v8::Local<v8::Context> context); | 75 v8::Local<v8::Object> CreateInstance(v8::Local<v8::Context> context); |
| 76 | 76 |
| 77 APIBindingHooks* hooks() { return binding_hooks_.get(); } | 77 APIBindingHooks* hooks() { return binding_hooks_.get(); } |
| 78 | 78 |
| 79 private: | 79 private: |
| 80 // Initializes the object_template_ for this API. Called lazily when the | 80 // Initializes the object_template_ for this API. Called lazily when the |
| 81 // first instance is created. | 81 // first instance is created. |
| 82 void InitializeTemplate(v8::Isolate* isolate); | 82 void InitializeTemplate(v8::Isolate* isolate); |
| 83 | 83 |
| 84 // Decorates |object_template| with the properties specified by |properties|. | 84 // Decorates |object_template| with the properties specified by |properties|. |
| 85 // |path| represents the current path the object from the API root. |
| 85 void DecorateTemplateWithProperties( | 86 void DecorateTemplateWithProperties( |
| 86 v8::Isolate* isolate, | 87 v8::Isolate* isolate, |
| 87 v8::Local<v8::ObjectTemplate> object_template, | 88 v8::Local<v8::ObjectTemplate> object_template, |
| 88 const base::DictionaryValue& properties); | 89 const base::DictionaryValue& properties, |
| 90 const std::string& path); |
| 89 | 91 |
| 90 // Handler for getting the v8::Object associated with an event on the API. | 92 // Handler for getting the v8::Object associated with an event on the API. |
| 91 static void GetEventObject(v8::Local<v8::Name>, | 93 static void GetEventObject(v8::Local<v8::Name>, |
| 92 const v8::PropertyCallbackInfo<v8::Value>& info); | 94 const v8::PropertyCallbackInfo<v8::Value>& info); |
| 93 | 95 |
| 94 // Handler for getting the v8::Object associated with a custom property on the | 96 // Handler for getting the v8::Object associated with a custom property on the |
| 95 // API. | 97 // API. |
| 96 static void GetCustomPropertyObject( | 98 static void GetCustomPropertyObject( |
| 97 v8::Local<v8::Name> property, | 99 v8::Local<v8::Name> property, |
| 98 const v8::PropertyCallbackInfo<v8::Value>& info); | 100 const v8::PropertyCallbackInfo<v8::Value>& info); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 v8::Eternal<v8::ObjectTemplate> object_template_; | 156 v8::Eternal<v8::ObjectTemplate> object_template_; |
| 155 | 157 |
| 156 base::WeakPtrFactory<APIBinding> weak_factory_; | 158 base::WeakPtrFactory<APIBinding> weak_factory_; |
| 157 | 159 |
| 158 DISALLOW_COPY_AND_ASSIGN(APIBinding); | 160 DISALLOW_COPY_AND_ASSIGN(APIBinding); |
| 159 }; | 161 }; |
| 160 | 162 |
| 161 } // namespace extensions | 163 } // namespace extensions |
| 162 | 164 |
| 163 #endif // EXTENSIONS_RENDERER_BINDINGS_API_BINDING_H_ | 165 #endif // EXTENSIONS_RENDERER_BINDINGS_API_BINDING_H_ |
| OLD | NEW |