OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/renderer/extensions/event_bindings.h" | 5 #include "chrome/renderer/extensions/event_bindings.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 new ExtensionHostMsg_RemoveFilteredListener(extension_id, event_name, | 258 new ExtensionHostMsg_RemoveFilteredListener(extension_id, event_name, |
259 *event_matcher->value(), | 259 *event_matcher->value(), |
260 lazy)); | 260 lazy)); |
261 } | 261 } |
262 | 262 |
263 event_filter.RemoveEventMatcher(matcher_id); | 263 event_filter.RemoveEventMatcher(matcher_id); |
264 } | 264 } |
265 | 265 |
266 void MatchAgainstEventFilter( | 266 void MatchAgainstEventFilter( |
267 const v8::FunctionCallbackInfo<v8::Value>& args) { | 267 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 268 v8::Isolate* isolate = args.GetIsolate(); |
268 typedef std::set<EventFilter::MatcherID> MatcherIDs; | 269 typedef std::set<EventFilter::MatcherID> MatcherIDs; |
269 EventFilter& event_filter = g_event_filter.Get(); | 270 EventFilter& event_filter = g_event_filter.Get(); |
270 std::string event_name = *v8::String::Utf8Value(args[0]->ToString()); | 271 std::string event_name = *v8::String::Utf8Value(args[0]->ToString()); |
271 EventFilteringInfo info = | 272 EventFilteringInfo info = |
272 ParseFromObject(args[1]->ToObject(), args.GetIsolate()); | 273 ParseFromObject(args[1]->ToObject(), isolate); |
273 // Only match events routed to this context's RenderView or ones that don't | 274 // Only match events routed to this context's RenderView or ones that don't |
274 // have a routingId in their filter. | 275 // have a routingId in their filter. |
275 MatcherIDs matched_event_filters = event_filter.MatchEvent( | 276 MatcherIDs matched_event_filters = event_filter.MatchEvent( |
276 event_name, info, context()->GetRenderView()->GetRoutingID()); | 277 event_name, info, context()->GetRenderView()->GetRoutingID()); |
277 v8::Handle<v8::Array> array( | 278 v8::Handle<v8::Array> array( |
278 v8::Array::New(args.GetIsolate(), matched_event_filters.size())); | 279 v8::Array::New(isolate, matched_event_filters.size())); |
279 int i = 0; | 280 int i = 0; |
280 for (MatcherIDs::iterator it = matched_event_filters.begin(); | 281 for (MatcherIDs::iterator it = matched_event_filters.begin(); |
281 it != matched_event_filters.end(); ++it) { | 282 it != matched_event_filters.end(); ++it) { |
282 array->Set(v8::Integer::New(i++), v8::Integer::New(*it)); | 283 array->Set(v8::Integer::New(isolate, i++), |
| 284 v8::Integer::New(isolate, *it)); |
283 } | 285 } |
284 args.GetReturnValue().Set(array); | 286 args.GetReturnValue().Set(array); |
285 } | 287 } |
286 | 288 |
287 static EventFilteringInfo ParseFromObject(v8::Handle<v8::Object> object, | 289 static EventFilteringInfo ParseFromObject(v8::Handle<v8::Object> object, |
288 v8::Isolate* isolate) { | 290 v8::Isolate* isolate) { |
289 EventFilteringInfo info; | 291 EventFilteringInfo info; |
290 v8::Handle<v8::String> url(v8::String::NewFromUtf8(isolate, "url")); | 292 v8::Handle<v8::String> url(v8::String::NewFromUtf8(isolate, "url")); |
291 if (object->Has(url)) { | 293 if (object->Has(url)) { |
292 v8::Handle<v8::Value> url_value(object->Get(url)); | 294 v8::Handle<v8::Value> url_value(object->Get(url)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 | 329 |
328 } // namespace | 330 } // namespace |
329 | 331 |
330 // static | 332 // static |
331 ChromeV8Extension* EventBindings::Create(Dispatcher* dispatcher, | 333 ChromeV8Extension* EventBindings::Create(Dispatcher* dispatcher, |
332 ChromeV8Context* context) { | 334 ChromeV8Context* context) { |
333 return new ExtensionImpl(dispatcher, context); | 335 return new ExtensionImpl(dispatcher, context); |
334 } | 336 } |
335 | 337 |
336 } // namespace extensions | 338 } // namespace extensions |
OLD | NEW |