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 #include "extensions/renderer/event_bindings.h" | 5 #include "extensions/renderer/event_bindings.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 scoped_ptr<base::DictionaryValue> filter; | 258 scoped_ptr<base::DictionaryValue> filter; |
259 { | 259 { |
260 scoped_ptr<content::V8ValueConverter> converter( | 260 scoped_ptr<content::V8ValueConverter> converter( |
261 content::V8ValueConverter::create()); | 261 content::V8ValueConverter::create()); |
262 scoped_ptr<base::Value> filter_value(converter->FromV8Value( | 262 scoped_ptr<base::Value> filter_value(converter->FromV8Value( |
263 v8::Local<v8::Object>::Cast(args[1]), context()->v8_context())); | 263 v8::Local<v8::Object>::Cast(args[1]), context()->v8_context())); |
264 if (!filter_value || !filter_value->IsType(base::Value::TYPE_DICTIONARY)) { | 264 if (!filter_value || !filter_value->IsType(base::Value::TYPE_DICTIONARY)) { |
265 args.GetReturnValue().Set(static_cast<int32_t>(-1)); | 265 args.GetReturnValue().Set(static_cast<int32_t>(-1)); |
266 return; | 266 return; |
267 } | 267 } |
268 filter.reset(static_cast<base::DictionaryValue*>(filter_value.release())); | 268 filter = base::DictionaryValue::From(filter_value.Pass()); |
269 } | 269 } |
270 | 270 |
271 // Hold onto a weak reference to |filter| so that it can be used after passing | 271 // Hold onto a weak reference to |filter| so that it can be used after passing |
272 // ownership to |event_filter|. | 272 // ownership to |event_filter|. |
273 base::DictionaryValue* filter_weak = filter.get(); | 273 base::DictionaryValue* filter_weak = filter.get(); |
274 int id = g_event_filter.Get().AddEventMatcher( | 274 int id = g_event_filter.Get().AddEventMatcher( |
275 event_name, ParseEventMatcher(filter.Pass())); | 275 event_name, ParseEventMatcher(filter.Pass())); |
276 attached_matcher_ids_.insert(id); | 276 attached_matcher_ids_.insert(id); |
277 | 277 |
278 // Only send IPCs the first time a filter gets added. | 278 // Only send IPCs the first time a filter gets added. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 // Same for filtered events. | 356 // Same for filtered events. |
357 std::set<int> attached_matcher_ids_safe = attached_matcher_ids_; | 357 std::set<int> attached_matcher_ids_safe = attached_matcher_ids_; |
358 for (int matcher_id : attached_matcher_ids_safe) { | 358 for (int matcher_id : attached_matcher_ids_safe) { |
359 DetachFilteredEvent(matcher_id, false /* is_manual */); | 359 DetachFilteredEvent(matcher_id, false /* is_manual */); |
360 } | 360 } |
361 DCHECK(attached_matcher_ids_.empty()) | 361 DCHECK(attached_matcher_ids_.empty()) |
362 << "Filtered events cannot be attached during invalidation"; | 362 << "Filtered events cannot be attached during invalidation"; |
363 } | 363 } |
364 | 364 |
365 } // namespace extensions | 365 } // namespace extensions |
OLD | NEW |