Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: extensions/renderer/event_bindings.h

Issue 2924683002: [Extensions Bindings] Avoid passing the event filter to JS (Closed)
Patch Set: remove extra '.' Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "extensions/renderer/object_backed_native_handler.h" 13 #include "extensions/renderer/object_backed_native_handler.h"
14 #include "v8/include/v8.h" 14 #include "v8/include/v8.h"
15 15
16 namespace IPC { 16 namespace IPC {
17 class Sender; 17 class Sender;
18 } 18 }
19 19
20 namespace base { 20 namespace base {
21 class DictionaryValue; 21 class DictionaryValue;
22 class ListValue;
22 } 23 }
23 24
24 namespace extensions { 25 namespace extensions {
25 class EventMatcher; 26 class EventMatcher;
26 27
27 // This class deals with the javascript bindings related to Event objects. 28 // This class deals with the javascript bindings related to Event objects.
28 class EventBindings : public ObjectBackedNativeHandler { 29 class EventBindings : public ObjectBackedNativeHandler {
29 public: 30 public:
30 explicit EventBindings(ScriptContext* context); 31 explicit EventBindings(ScriptContext* context);
31 ~EventBindings() override; 32 ~EventBindings() override;
32 33
34 // Dispatches the event in the given |context| with the provided
35 // |event_args| and |filtering_info|.
36 static void DispatchEventInContext(
37 const std::string& event_name,
38 const base::ListValue* event_args,
39 const base::DictionaryValue* filtering_info,
40 ScriptContext* context);
41
33 private: 42 private:
34 // JavaScript handler which forwards to AttachEvent(). 43 // JavaScript handler which forwards to AttachEvent().
35 // args[0] forwards to |event_name|. 44 // args[0] forwards to |event_name|.
36 void AttachEventHandler(const v8::FunctionCallbackInfo<v8::Value>& args); 45 void AttachEventHandler(const v8::FunctionCallbackInfo<v8::Value>& args);
37 46
38 // Attach an event name to an object. 47 // Attach an event name to an object.
39 // |event_name| The name of the event to attach. 48 // |event_name| The name of the event to attach.
40 void AttachEvent(const std::string& event_name); 49 void AttachEvent(const std::string& event_name);
41 50
42 // JavaScript handler which forwards to DetachEvent(). 51 // JavaScript handler which forwards to DetachEvent().
(...skipping 22 matching lines...) Expand all
65 void DetachFilteredEventHandler( 74 void DetachFilteredEventHandler(
66 const v8::FunctionCallbackInfo<v8::Value>& args); 75 const v8::FunctionCallbackInfo<v8::Value>& args);
67 76
68 // Detaches a filtered event. Unlike a normal event, a filtered event is 77 // Detaches a filtered event. Unlike a normal event, a filtered event is
69 // identified by a unique ID per filter, not its name. 78 // identified by a unique ID per filter, not its name.
70 // |matcher_id| The ID of the filtered event. 79 // |matcher_id| The ID of the filtered event.
71 // |is_manual| false if this is part of the extension unload process where all 80 // |is_manual| false if this is part of the extension unload process where all
72 // listeners are automatically detached. 81 // listeners are automatically detached.
73 void DetachFilteredEvent(int matcher_id, bool is_manual); 82 void DetachFilteredEvent(int matcher_id, bool is_manual);
74 83
75 void MatchAgainstEventFilter(const v8::FunctionCallbackInfo<v8::Value>& args);
76
77 std::unique_ptr<EventMatcher> ParseEventMatcher( 84 std::unique_ptr<EventMatcher> ParseEventMatcher(
78 std::unique_ptr<base::DictionaryValue> filter); 85 std::unique_ptr<base::DictionaryValue> filter);
79 86
80 IPC::Sender* GetIPCSender(); 87 IPC::Sender* GetIPCSender();
81 88
82 // Called when our context, and therefore us, is invalidated. Run any cleanup. 89 // Called when our context, and therefore us, is invalidated. Run any cleanup.
83 void OnInvalidated(); 90 void OnInvalidated();
84 91
85 // The set of attached events and filtered events. Maintain these so that we 92 // The set of attached events and filtered events. Maintain these so that we
86 // can detch them on unload. 93 // can detch them on unload.
87 std::set<std::string> attached_event_names_; 94 std::set<std::string> attached_event_names_;
88 std::set<int> attached_matcher_ids_; 95 std::set<int> attached_matcher_ids_;
89 96
90 DISALLOW_COPY_AND_ASSIGN(EventBindings); 97 DISALLOW_COPY_AND_ASSIGN(EventBindings);
91 }; 98 };
92 99
93 } // namespace extensions 100 } // namespace extensions
94 101
95 #endif // EXTENSIONS_RENDERER_EVENT_BINDINGS_H_ 102 #endif // EXTENSIONS_RENDERER_EVENT_BINDINGS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698