| 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 30 matching lines...) Expand all Loading... |
| 41 // Notifies all listeners of the event with the given |event_name| in the | 41 // Notifies all listeners of the event with the given |event_name| in the |
| 42 // specified |context|, sending the included |arguments|. | 42 // specified |context|, sending the included |arguments|. |
| 43 void FireEventInContext(const std::string& event_name, | 43 void FireEventInContext(const std::string& event_name, |
| 44 v8::Local<v8::Context> context, | 44 v8::Local<v8::Context> context, |
| 45 const base::ListValue& arguments); | 45 const base::ListValue& arguments); |
| 46 | 46 |
| 47 // Returns the EventListeners for a given |event_name| and |context|. | 47 // Returns the EventListeners for a given |event_name| and |context|. |
| 48 size_t GetNumEventListenersForTesting(const std::string& event_name, | 48 size_t GetNumEventListenersForTesting(const std::string& event_name, |
| 49 v8::Local<v8::Context> context); | 49 v8::Local<v8::Context> context); |
| 50 | 50 |
| 51 // Invalidates listeners for the given |context|. It's a shame we have to |
| 52 // have this separately (as opposed to hooking into e.g. a PerContextData |
| 53 // destructor), but we need to do this before the context is fully removed |
| 54 // (because the associated extension ScriptContext needs to be valid). |
| 55 void InvalidateContext(v8::Local<v8::Context> context); |
| 56 |
| 51 private: | 57 private: |
| 52 // Method to run a given v8::Function. Curried in for testing. | 58 // Method to run a given v8::Function. Curried in for testing. |
| 53 binding::RunJSFunction call_js_; | 59 binding::RunJSFunction call_js_; |
| 54 | 60 |
| 55 EventListenersChangedMethod listeners_changed_; | 61 EventListenersChangedMethod listeners_changed_; |
| 56 | 62 |
| 57 DISALLOW_COPY_AND_ASSIGN(APIEventHandler); | 63 DISALLOW_COPY_AND_ASSIGN(APIEventHandler); |
| 58 }; | 64 }; |
| 59 | 65 |
| 60 } // namespace extensions | 66 } // namespace extensions |
| 61 | 67 |
| 62 #endif // EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_ | 68 #endif // EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_ |
| OLD | NEW |