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_NATIVE_EXTENSION_BINDINGS_SYSTEM_H_ | 5 #ifndef EXTENSIONS_RENDERER_NATIVE_EXTENSION_BINDINGS_SYSTEM_H_ |
6 #define EXTENSIONS_RENDERER_NATIVE_EXTENSION_BINDINGS_SYSTEM_H_ | 6 #define EXTENSIONS_RENDERER_NATIVE_EXTENSION_BINDINGS_SYSTEM_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 // be a plug-and-play version for use in the Extensions system. | 27 // be a plug-and-play version for use in the Extensions system. |
28 // Designed to be used in a single thread, but for all contexts on that thread. | 28 // Designed to be used in a single thread, but for all contexts on that thread. |
29 class NativeExtensionBindingsSystem : public ExtensionBindingsSystem { | 29 class NativeExtensionBindingsSystem : public ExtensionBindingsSystem { |
30 public: | 30 public: |
31 using SendRequestIPCMethod = | 31 using SendRequestIPCMethod = |
32 base::Callback<void(ScriptContext*, | 32 base::Callback<void(ScriptContext*, |
33 const ExtensionHostMsg_Request_Params&)>; | 33 const ExtensionHostMsg_Request_Params&)>; |
34 using SendEventListenerIPCMethod = | 34 using SendEventListenerIPCMethod = |
35 base::Callback<void(binding::EventListenersChanged, | 35 base::Callback<void(binding::EventListenersChanged, |
36 ScriptContext*, | 36 ScriptContext*, |
37 const std::string& event_name)>; | 37 const std::string& event_name, |
| 38 const base::DictionaryValue* filter)>; |
38 | 39 |
39 NativeExtensionBindingsSystem( | 40 NativeExtensionBindingsSystem( |
40 const SendRequestIPCMethod& send_request_ipc, | 41 const SendRequestIPCMethod& send_request_ipc, |
41 const SendEventListenerIPCMethod& send_event_listener_ipc); | 42 const SendEventListenerIPCMethod& send_event_listener_ipc); |
42 ~NativeExtensionBindingsSystem() override; | 43 ~NativeExtensionBindingsSystem() override; |
43 | 44 |
44 // ExtensionBindingsSystem: | 45 // ExtensionBindingsSystem: |
45 void DidCreateScriptContext(ScriptContext* context) override; | 46 void DidCreateScriptContext(ScriptContext* context) override; |
46 void WillReleaseScriptContext(ScriptContext* context) override; | 47 void WillReleaseScriptContext(ScriptContext* context) override; |
47 void UpdateBindingsForContext(ScriptContext* context) override; | 48 void UpdateBindingsForContext(ScriptContext* context) override; |
(...skipping 10 matching lines...) Expand all Loading... |
58 private: | 59 private: |
59 // Handles sending a given |request|, forwarding it on to the send_ipc_ after | 60 // Handles sending a given |request|, forwarding it on to the send_ipc_ after |
60 // adding additional info. | 61 // adding additional info. |
61 void SendRequest(std::unique_ptr<APIRequestHandler::Request> request, | 62 void SendRequest(std::unique_ptr<APIRequestHandler::Request> request, |
62 v8::Local<v8::Context> context); | 63 v8::Local<v8::Context> context); |
63 | 64 |
64 // Called when listeners for a given event have changed, and forwards it along | 65 // Called when listeners for a given event have changed, and forwards it along |
65 // to |send_event_listener_ipc_|. | 66 // to |send_event_listener_ipc_|. |
66 void OnEventListenerChanged(const std::string& event_name, | 67 void OnEventListenerChanged(const std::string& event_name, |
67 binding::EventListenersChanged change, | 68 binding::EventListenersChanged change, |
| 69 const base::DictionaryValue* filter, |
68 v8::Local<v8::Context> context); | 70 v8::Local<v8::Context> context); |
69 | 71 |
70 // Getter callback for an extension API, since APIs are constructed lazily. | 72 // Getter callback for an extension API, since APIs are constructed lazily. |
71 static void BindingAccessor(v8::Local<v8::Name> name, | 73 static void BindingAccessor(v8::Local<v8::Name> name, |
72 const v8::PropertyCallbackInfo<v8::Value>& info); | 74 const v8::PropertyCallbackInfo<v8::Value>& info); |
73 | 75 |
74 // Creates and returns the API binding for the given |name|. | 76 // Creates and returns the API binding for the given |name|. |
75 static v8::Local<v8::Object> GetAPIHelper(v8::Local<v8::Context> context, | 77 static v8::Local<v8::Object> GetAPIHelper(v8::Local<v8::Context> context, |
76 v8::Local<v8::String> name); | 78 v8::Local<v8::String> name); |
77 | 79 |
(...skipping 24 matching lines...) Expand all Loading... |
102 v8::Eternal<v8::FunctionTemplate> get_internal_api_; | 104 v8::Eternal<v8::FunctionTemplate> get_internal_api_; |
103 | 105 |
104 base::WeakPtrFactory<NativeExtensionBindingsSystem> weak_factory_; | 106 base::WeakPtrFactory<NativeExtensionBindingsSystem> weak_factory_; |
105 | 107 |
106 DISALLOW_COPY_AND_ASSIGN(NativeExtensionBindingsSystem); | 108 DISALLOW_COPY_AND_ASSIGN(NativeExtensionBindingsSystem); |
107 }; | 109 }; |
108 | 110 |
109 } // namespace extensions | 111 } // namespace extensions |
110 | 112 |
111 #endif // EXTENSIONS_RENDERER_NATIVE_EXTENSION_BINDINGS_SYSTEM_H_ | 113 #endif // EXTENSIONS_RENDERER_NATIVE_EXTENSION_BINDINGS_SYSTEM_H_ |
OLD | NEW |