OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_EVENT_BINDINGS_H_ | 5 #ifndef EXTENSIONS_RENDERER_EVENT_BINDINGS_H_ |
6 #define EXTENSIONS_RENDERER_EVENT_BINDINGS_H_ | 6 #define EXTENSIONS_RENDERER_EVENT_BINDINGS_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // the browser we are no longer interested in that event. | 46 // the browser we are no longer interested in that event. |
47 void DetachEvent(const std::string& event_name, bool is_manual); | 47 void DetachEvent(const std::string& event_name, bool is_manual); |
48 | 48 |
49 // MatcherID AttachFilteredEvent(string event_name, object filter) | 49 // MatcherID AttachFilteredEvent(string event_name, object filter) |
50 // |event_name| Name of the event to attach. | 50 // |event_name| Name of the event to attach. |
51 // |filter| Which instances of the named event are we interested in. | 51 // |filter| Which instances of the named event are we interested in. |
52 // returns the id assigned to the listener, which will be returned from calls | 52 // returns the id assigned to the listener, which will be returned from calls |
53 // to MatchAgainstEventFilter where this listener matches. | 53 // to MatchAgainstEventFilter where this listener matches. |
54 void AttachFilteredEvent(const v8::FunctionCallbackInfo<v8::Value>& args); | 54 void AttachFilteredEvent(const v8::FunctionCallbackInfo<v8::Value>& args); |
55 | 55 |
| 56 // JavaScript handler which forwards to DetachFilteredEvent. |
56 // void DetachFilteredEvent(int id, bool manual) | 57 // void DetachFilteredEvent(int id, bool manual) |
57 // id - Id of the event to detach. | 58 // args[0] forwards to |matcher_id| |
58 // manual - false if this is part of the extension unload process where all | 59 // args[1] forwards to |is_manual| |
59 // listeners are automatically detached. | 60 void DetachFilteredEventHandler( |
60 void DetachFilteredEvent(const v8::FunctionCallbackInfo<v8::Value>& args); | 61 const v8::FunctionCallbackInfo<v8::Value>& args); |
| 62 |
| 63 // Detaches a filtered event. Unlike a normal event, a filtered event is |
| 64 // identified by a unique ID per filter, not its name. |
| 65 // |matcher_id| The ID of the filtered event. |
| 66 // |is_manual| false if this is part of the extension unload process where all |
| 67 // listeners are automatically detached. |
| 68 void DetachFilteredEvent(int matcher_id, bool is_manual); |
61 | 69 |
62 void MatchAgainstEventFilter(const v8::FunctionCallbackInfo<v8::Value>& args); | 70 void MatchAgainstEventFilter(const v8::FunctionCallbackInfo<v8::Value>& args); |
63 | 71 |
64 scoped_ptr<EventMatcher> ParseEventMatcher( | 72 scoped_ptr<EventMatcher> ParseEventMatcher( |
65 base::DictionaryValue* filter_dict); | 73 scoped_ptr<base::DictionaryValue> filter); |
66 | 74 |
67 // Called when our context, and therefore us, is invalidated. Run any cleanup. | 75 // Called when our context, and therefore us, is invalidated. Run any cleanup. |
68 void OnInvalidated(); | 76 void OnInvalidated(); |
69 | 77 |
70 // The set of attached events. Maintain this so that we can detch them on | 78 // The set of attached events and filtered events. Maintain these so that we |
71 // unload. | 79 // can detch them on unload. |
72 std::set<std::string> attached_event_names_; | 80 std::set<std::string> attached_event_names_; |
| 81 std::set<int> attached_matcher_ids_; |
73 | 82 |
74 DISALLOW_COPY_AND_ASSIGN(EventBindings); | 83 DISALLOW_COPY_AND_ASSIGN(EventBindings); |
75 }; | 84 }; |
76 | 85 |
77 } // namespace extensions | 86 } // namespace extensions |
78 | 87 |
79 #endif // EXTENSIONS_RENDERER_EVENT_BINDINGS_H_ | 88 #endif // EXTENSIONS_RENDERER_EVENT_BINDINGS_H_ |
OLD | NEW |