OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/api_binding.h" | 5 #include "extensions/renderer/api_binding.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 // TODO(devlin): enums should always be exposed, but there may be events that | 304 // TODO(devlin): enums should always be exposed, but there may be events that |
305 // are restricted. Investigate. | 305 // are restricted. Investigate. |
306 for (const auto& key_value : methods_) { | 306 for (const auto& key_value : methods_) { |
307 if (!is_available.Run(key_value.second->full_name)) { | 307 if (!is_available.Run(key_value.second->full_name)) { |
308 v8::Maybe<bool> success = object->Delete( | 308 v8::Maybe<bool> success = object->Delete( |
309 context, gin::StringToSymbol(isolate, key_value.first)); | 309 context, gin::StringToSymbol(isolate, key_value.first)); |
310 CHECK(success.IsJust()); | 310 CHECK(success.IsJust()); |
311 CHECK(success.FromJust()); | 311 CHECK(success.FromJust()); |
312 } | 312 } |
313 } | 313 } |
| 314 for (const auto& event : events_) { |
| 315 if (!is_available.Run(event->full_name)) { |
| 316 v8::Maybe<bool> success = object->Delete( |
| 317 context, gin::StringToSymbol(isolate, event->exposed_name)); |
| 318 CHECK(success.IsJust()); |
| 319 CHECK(success.FromJust()); |
| 320 } |
| 321 } |
314 | 322 |
315 return object; | 323 return object; |
316 } | 324 } |
317 | 325 |
318 void APIBinding::InitializeTemplate(v8::Isolate* isolate) { | 326 void APIBinding::InitializeTemplate(v8::Isolate* isolate) { |
319 DCHECK(object_template_.IsEmpty()); | 327 DCHECK(object_template_.IsEmpty()); |
320 v8::Local<v8::ObjectTemplate> object_template = | 328 v8::Local<v8::ObjectTemplate> object_template = |
321 v8::ObjectTemplate::New(isolate); | 329 v8::ObjectTemplate::New(isolate); |
322 | 330 |
323 for (const auto& key_value : methods_) { | 331 for (const auto& key_value : methods_) { |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 arguments->ThrowTypeError("Invalid invocation"); | 568 arguments->ThrowTypeError("Invalid invocation"); |
561 return; | 569 return; |
562 } | 570 } |
563 | 571 |
564 request_handler_->StartRequest(context, name, std::move(converted_arguments), | 572 request_handler_->StartRequest(context, name, std::move(converted_arguments), |
565 callback, custom_callback, | 573 callback, custom_callback, |
566 binding::RequestThread::UI); | 574 binding::RequestThread::UI); |
567 } | 575 } |
568 | 576 |
569 } // namespace extensions | 577 } // namespace extensions |
OLD | NEW |