| 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_API_EVENT_HANDLER_H_ | 5 #ifndef EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_ |
| 6 #define EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_ | 6 #define EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // being dispatched to the event, and the function to dispatch the event to | 50 // being dispatched to the event, and the function to dispatch the event to |
| 51 // listeners. | 51 // listeners. |
| 52 void RegisterArgumentMassager(v8::Local<v8::Context> context, | 52 void RegisterArgumentMassager(v8::Local<v8::Context> context, |
| 53 const std::string& event_name, | 53 const std::string& event_name, |
| 54 v8::Local<v8::Function> function); | 54 v8::Local<v8::Function> function); |
| 55 | 55 |
| 56 // Returns the EventListeners for a given |event_name| and |context|. | 56 // Returns the EventListeners for a given |event_name| and |context|. |
| 57 size_t GetNumEventListenersForTesting(const std::string& event_name, | 57 size_t GetNumEventListenersForTesting(const std::string& event_name, |
| 58 v8::Local<v8::Context> context); | 58 v8::Local<v8::Context> context); |
| 59 | 59 |
| 60 // Invalidates listeners for the given |context|. It's a shame we have to |
| 61 // have this separately (as opposed to hooking into e.g. a PerContextData |
| 62 // destructor), but we need to do this before the context is fully removed |
| 63 // (because the associated extension ScriptContext needs to be valid). |
| 64 void InvalidateContext(v8::Local<v8::Context> context); |
| 65 |
| 60 private: | 66 private: |
| 61 // Method to run a given v8::Function. Curried in for testing. | 67 // Method to run a given v8::Function. Curried in for testing. |
| 62 binding::RunJSFunction call_js_; | 68 binding::RunJSFunction call_js_; |
| 63 | 69 |
| 64 EventListenersChangedMethod listeners_changed_; | 70 EventListenersChangedMethod listeners_changed_; |
| 65 | 71 |
| 66 DISALLOW_COPY_AND_ASSIGN(APIEventHandler); | 72 DISALLOW_COPY_AND_ASSIGN(APIEventHandler); |
| 67 }; | 73 }; |
| 68 | 74 |
| 69 } // namespace extensions | 75 } // namespace extensions |
| 70 | 76 |
| 71 #endif // EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_ | 77 #endif // EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_ |
| OLD | NEW |