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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 gin::StringToSymbol(isolate, enum_entry.first)); | 369 gin::StringToSymbol(isolate, enum_entry.first)); |
370 } | 370 } |
371 object_template->Set(isolate, entry.first.c_str(), enum_object); | 371 object_template->Set(isolate, entry.first.c_str(), enum_object); |
372 } | 372 } |
373 | 373 |
374 if (property_definitions_) { | 374 if (property_definitions_) { |
375 DecorateTemplateWithProperties(isolate, object_template, | 375 DecorateTemplateWithProperties(isolate, object_template, |
376 *property_definitions_); | 376 *property_definitions_); |
377 } | 377 } |
378 | 378 |
| 379 // Allow custom bindings a chance to tweak the template, such as to add |
| 380 // additional properties or types. |
| 381 binding_hooks_->InitializeTemplate(isolate, object_template, *type_refs_); |
| 382 |
379 object_template_.Set(isolate, object_template); | 383 object_template_.Set(isolate, object_template); |
380 } | 384 } |
381 | 385 |
382 void APIBinding::DecorateTemplateWithProperties( | 386 void APIBinding::DecorateTemplateWithProperties( |
383 v8::Isolate* isolate, | 387 v8::Isolate* isolate, |
384 v8::Local<v8::ObjectTemplate> object_template, | 388 v8::Local<v8::ObjectTemplate> object_template, |
385 const base::DictionaryValue& properties) { | 389 const base::DictionaryValue& properties) { |
386 static const char kValueKey[] = "value"; | 390 static const char kValueKey[] = "value"; |
387 for (base::DictionaryValue::Iterator iter(properties); !iter.IsAtEnd(); | 391 for (base::DictionaryValue::Iterator iter(properties); !iter.IsAtEnd(); |
388 iter.Advance()) { | 392 iter.Advance()) { |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 arguments->ThrowTypeError("Invalid invocation"); | 584 arguments->ThrowTypeError("Invalid invocation"); |
581 return; | 585 return; |
582 } | 586 } |
583 | 587 |
584 request_handler_->StartRequest(context, name, std::move(converted_arguments), | 588 request_handler_->StartRequest(context, name, std::move(converted_arguments), |
585 callback, custom_callback, | 589 callback, custom_callback, |
586 binding::RequestThread::UI); | 590 binding::RequestThread::UI); |
587 } | 591 } |
588 | 592 |
589 } // namespace extensions | 593 } // namespace extensions |
OLD | NEW |