Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(835)

Side by Side Diff: third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl

Issue 2439013002: Implement cross-origin attributes using access check interceptors. (Closed)
Patch Set: . Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t o_local_cpp_value %} 1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t o_local_cpp_value %}
2 2
3 {##############################################################################} 3 {##############################################################################}
4 {% macro generate_method(method, world_suffix) %} 4 {% macro generate_method(method, world_suffix) %}
5 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) { 5 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) {
6 {% filter format_remove_duplicates([ 6 {% filter format_remove_duplicates([
7 'ExceptionState exceptionState', 7 'ExceptionState exceptionState',
8 'ScriptState* scriptState = ']) %} 8 'ScriptState* scriptState = ']) %}
9 {% set define_exception_state -%} 9 {% set define_exception_state -%}
10 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCont ext, "{{interface_name}}", "{{method.name}}"); 10 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCont ext, "{{interface_name}}", "{{method.name}}");
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 {% elif method.is_post_message %} 503 {% elif method.is_post_message %}
504 postMessageImpl("{{interface_name}}", {{v8_class}}::toImpl(info.Holder()), inf o); 504 postMessageImpl("{{interface_name}}", {{v8_class}}::toImpl(info.Holder()), inf o);
505 {% else %} 505 {% else %}
506 {{cpp_class_or_partial}}V8Internal::{{method.name}}Method{{world_suffix}}(info ); 506 {{cpp_class_or_partial}}V8Internal::{{method.name}}Method{{world_suffix}}(info );
507 {% endif %} 507 {% endif %}
508 } 508 }
509 {% endmacro %} 509 {% endmacro %}
510 510
511 511
512 {##############################################################################} 512 {##############################################################################}
513 {% macro origin_safe_method_getter(method, world_suffix) %} 513 {% macro cross_origin_method_getter(method, world_suffix) %}
514 static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::Prop ertyCallbackInfo<v8::Value>& info) { 514 static void {{method.name}}CrossOriginMethodGetter{{world_suffix}}(const v8::Pro pertyCallbackInfo<v8::Value>& info) {
515 static int domTemplateKey; // This address is used for a key to look up the do m template. 515 static int domTemplateKey; // This address is used for a key to look up the do m template.
516 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); 516 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
517 const DOMWrapperWorld& world = DOMWrapperWorld::world(info.GetIsolate()->GetCu rrentContext()); 517 const DOMWrapperWorld& world = DOMWrapperWorld::world(info.GetIsolate()->GetCu rrentContext());
518 v8::Local<v8::FunctionTemplate> interfaceTemplate = data->findInterfaceTemplat e(world, &{{v8_class}}::wrapperTypeInfo); 518 v8::Local<v8::FunctionTemplate> interfaceTemplate = data->findInterfaceTemplat e(world, &{{v8_class}}::wrapperTypeInfo);
519 v8::Local<v8::Signature> signature = v8::Signature::New(info.GetIsolate(), int erfaceTemplate); 519 v8::Local<v8::Signature> signature = v8::Signature::New(info.GetIsolate(), int erfaceTemplate);
520 520
521 v8::Local<v8::FunctionTemplate> methodTemplate = data->findOrCreateOperationTe mplate(world, &domTemplateKey, {{cpp_class}}V8Internal::{{method.name}}MethodCal lback{{world_suffix}}, v8Undefined(), signature, {{method.length}}); 521 v8::Local<v8::FunctionTemplate> methodTemplate = data->findOrCreateOperationTe mplate(world, &domTemplateKey, {{cpp_class}}V8Internal::{{method.name}}MethodCal lback{{world_suffix}}, v8Undefined(), signature, {{method.length}});
522 // Return the function by default, unless the user script has overwritten it.
523 v8SetReturnValue(info, methodTemplate->GetFunction(info.GetIsolate()->GetCurre ntContext()).ToLocalChecked()); 522 v8SetReturnValue(info, methodTemplate->GetFunction(info.GetIsolate()->GetCurre ntContext()).ToLocalChecked());
524
525 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
526 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()), impl, BindingSecurity::ErrorReportOption::DoNotReport)) {
527 return;
528 }
529
530 v8::Local<v8::Value> hiddenValue = V8HiddenValue::getHiddenValue(ScriptState:: current(info.GetIsolate()), v8::Local<v8::Object>::Cast(info.Holder()), v8Atomic String(info.GetIsolate(), "{{method.name}}"));
531 if (!hiddenValue.IsEmpty()) {
532 v8SetReturnValue(info, hiddenValue);
533 }
534 }
535
536 void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Local<v8: :Name>, const v8::PropertyCallbackInfo<v8::Value>& info) {
537 {{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix}} (info);
538 } 523 }
539 {% endmacro %} 524 {% endmacro %}
540 525
541 526
542 {##############################################################################} 527 {##############################################################################}
543 {% macro method_implemented_in_private_script(method) %} 528 {% macro method_implemented_in_private_script(method) %}
544 bool {{v8_class}}::PrivateScript::{{method.name}}Method({{method.argument_declar ations_for_private_script | join(', ')}}) { 529 bool {{v8_class}}::PrivateScript::{{method.name}}Method({{method.argument_declar ations_for_private_script | join(', ')}}) {
545 if (!frame) 530 if (!frame)
546 return false; 531 return false;
547 v8::HandleScope handleScope(toIsolate(frame)); 532 v8::HandleScope handleScope(toIsolate(frame));
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 if method.overloads else 647 if method.overloads else
663 method.runtime_enabled_function) %} 648 method.runtime_enabled_function) %}
664 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}}; 649 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}};
665 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); 650 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration);
666 {% endfilter %}{# runtime_enabled() #} 651 {% endfilter %}{# runtime_enabled() #}
667 {% endfilter %}{# exposed() #} 652 {% endfilter %}{# exposed() #}
668 {% endfilter %}{# secure_context() #} 653 {% endfilter %}{# secure_context() #}
669 {% endfor %} 654 {% endfor %}
670 {% endif %} 655 {% endif %}
671 {%- endmacro %} 656 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698