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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <memory> | 10 #include <memory> |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 std::string event_name = *v8::String::Utf8Value(args[0]); | 257 std::string event_name = *v8::String::Utf8Value(args[0]); |
258 if (!context()->HasAccessOrThrowError(event_name)) | 258 if (!context()->HasAccessOrThrowError(event_name)) |
259 return; | 259 return; |
260 | 260 |
261 std::unique_ptr<base::DictionaryValue> filter; | 261 std::unique_ptr<base::DictionaryValue> filter; |
262 { | 262 { |
263 std::unique_ptr<content::V8ValueConverter> converter( | 263 std::unique_ptr<content::V8ValueConverter> converter( |
264 content::V8ValueConverter::create()); | 264 content::V8ValueConverter::create()); |
265 std::unique_ptr<base::Value> filter_value(converter->FromV8Value( | 265 std::unique_ptr<base::Value> filter_value(converter->FromV8Value( |
266 v8::Local<v8::Object>::Cast(args[1]), context()->v8_context())); | 266 v8::Local<v8::Object>::Cast(args[1]), context()->v8_context())); |
267 if (!filter_value || !filter_value->IsType(base::Value::TYPE_DICTIONARY)) { | 267 if (!filter_value || !filter_value->IsType(base::Value::Type::DICTIONARY)) { |
268 args.GetReturnValue().Set(static_cast<int32_t>(-1)); | 268 args.GetReturnValue().Set(static_cast<int32_t>(-1)); |
269 return; | 269 return; |
270 } | 270 } |
271 filter = base::DictionaryValue::From(std::move(filter_value)); | 271 filter = base::DictionaryValue::From(std::move(filter_value)); |
272 } | 272 } |
273 | 273 |
274 int id = g_event_filter.Get().AddEventMatcher( | 274 int id = g_event_filter.Get().AddEventMatcher( |
275 event_name, ParseEventMatcher(std::move(filter))); | 275 event_name, ParseEventMatcher(std::move(filter))); |
276 if (id == -1) { | 276 if (id == -1) { |
277 args.GetReturnValue().Set(static_cast<int32_t>(-1)); | 277 args.GetReturnValue().Set(static_cast<int32_t>(-1)); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 // Same for filtered events. | 363 // Same for filtered events. |
364 std::set<int> attached_matcher_ids_safe = attached_matcher_ids_; | 364 std::set<int> attached_matcher_ids_safe = attached_matcher_ids_; |
365 for (int matcher_id : attached_matcher_ids_safe) { | 365 for (int matcher_id : attached_matcher_ids_safe) { |
366 DetachFilteredEvent(matcher_id, false /* is_manual */); | 366 DetachFilteredEvent(matcher_id, false /* is_manual */); |
367 } | 367 } |
368 DCHECK(attached_matcher_ids_.empty()) | 368 DCHECK(attached_matcher_ids_.empty()) |
369 << "Filtered events cannot be attached during invalidation"; | 369 << "Filtered events cannot be attached during invalidation"; |
370 } | 370 } |
371 | 371 |
372 } // namespace extensions | 372 } // namespace extensions |
OLD | NEW |