| 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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 CHECK_EQ(2, args.Length()); | 269 CHECK_EQ(2, args.Length()); |
| 270 CHECK(args[0]->IsString()); | 270 CHECK(args[0]->IsString()); |
| 271 CHECK(args[1]->IsObject()); | 271 CHECK(args[1]->IsObject()); |
| 272 | 272 |
| 273 std::string event_name = *v8::String::Utf8Value(args[0]); | 273 std::string event_name = *v8::String::Utf8Value(args[0]); |
| 274 if (!context()->HasAccessOrThrowError(event_name)) | 274 if (!context()->HasAccessOrThrowError(event_name)) |
| 275 return; | 275 return; |
| 276 | 276 |
| 277 std::unique_ptr<base::DictionaryValue> filter; | 277 std::unique_ptr<base::DictionaryValue> filter; |
| 278 { | 278 { |
| 279 std::unique_ptr<content::V8ValueConverter> converter( | 279 std::unique_ptr<base::Value> filter_value = |
| 280 content::V8ValueConverter::create()); | 280 content::V8ValueConverter::Create()->FromV8Value( |
| 281 std::unique_ptr<base::Value> filter_value(converter->FromV8Value( | 281 v8::Local<v8::Object>::Cast(args[1]), context()->v8_context()); |
| 282 v8::Local<v8::Object>::Cast(args[1]), context()->v8_context())); | |
| 283 if (!filter_value || !filter_value->IsType(base::Value::Type::DICTIONARY)) { | 282 if (!filter_value || !filter_value->IsType(base::Value::Type::DICTIONARY)) { |
| 284 args.GetReturnValue().Set(static_cast<int32_t>(-1)); | 283 args.GetReturnValue().Set(static_cast<int32_t>(-1)); |
| 285 return; | 284 return; |
| 286 } | 285 } |
| 287 filter = base::DictionaryValue::From(std::move(filter_value)); | 286 filter = base::DictionaryValue::From(std::move(filter_value)); |
| 288 } | 287 } |
| 289 | 288 |
| 290 int id = g_event_filter.Get().AddEventMatcher( | 289 int id = g_event_filter.Get().AddEventMatcher( |
| 291 event_name, ParseEventMatcher(std::move(filter))); | 290 event_name, ParseEventMatcher(std::move(filter))); |
| 292 if (id == -1) { | 291 if (id == -1) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 // Same for filtered events. | 388 // Same for filtered events. |
| 390 std::set<int> attached_matcher_ids_safe = attached_matcher_ids_; | 389 std::set<int> attached_matcher_ids_safe = attached_matcher_ids_; |
| 391 for (int matcher_id : attached_matcher_ids_safe) { | 390 for (int matcher_id : attached_matcher_ids_safe) { |
| 392 DetachFilteredEvent(matcher_id, false /* is_manual */); | 391 DetachFilteredEvent(matcher_id, false /* is_manual */); |
| 393 } | 392 } |
| 394 DCHECK(attached_matcher_ids_.empty()) | 393 DCHECK(attached_matcher_ids_.empty()) |
| 395 << "Filtered events cannot be attached during invalidation"; | 394 << "Filtered events cannot be attached during invalidation"; |
| 396 } | 395 } |
| 397 | 396 |
| 398 } // namespace extensions | 397 } // namespace extensions |
| OLD | NEW |