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

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: Revert to using the origin-safe method getters/setters to try to fix postMessage... 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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 origin_safe_method_getter(method, world_suffix) %}
514 {# TODO(dcheng): This shouldn't be necessary with cross-origin interceptors, but
515 v8 doesn't support querying the incumbent context. For now, always
516 incorrectly create per-realm representations. #}
514 static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::Prop ertyCallbackInfo<v8::Value>& info) { 517 static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::Prop ertyCallbackInfo<v8::Value>& info) {
515 static int domTemplateKey; // This address is used for a key to look up the do m template. 518 static int domTemplateKey; // This address is used for a key to look up the do m template.
516 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); 519 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
517 const DOMWrapperWorld& world = DOMWrapperWorld::world(info.GetIsolate()->GetCu rrentContext()); 520 const DOMWrapperWorld& world = DOMWrapperWorld::world(info.GetIsolate()->GetCu rrentContext());
518 v8::Local<v8::FunctionTemplate> interfaceTemplate = data->findInterfaceTemplat e(world, &{{v8_class}}::wrapperTypeInfo); 521 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); 522 v8::Local<v8::Signature> signature = v8::Signature::New(info.GetIsolate(), int erfaceTemplate);
520 523
521 v8::Local<v8::FunctionTemplate> methodTemplate = data->findOrCreateOperationTe mplate(world, &domTemplateKey, {{cpp_class}}V8Internal::{{method.name}}MethodCal lback{{world_suffix}}, v8Undefined(), signature, {{method.length}}); 524 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. 525 // Return the function by default, unless the user script has overwritten it.
523 v8SetReturnValue(info, methodTemplate->GetFunction(info.GetIsolate()->GetCurre ntContext()).ToLocalChecked()); 526 v8SetReturnValue(info, methodTemplate->GetFunction(info.GetIsolate()->GetCurre ntContext()).ToLocalChecked());
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 if method.overloads else 665 if method.overloads else
663 method.runtime_enabled_function) %} 666 method.runtime_enabled_function) %}
664 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}}; 667 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); 668 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration);
666 {% endfilter %}{# runtime_enabled() #} 669 {% endfilter %}{# runtime_enabled() #}
667 {% endfilter %}{# exposed() #} 670 {% endfilter %}{# exposed() #}
668 {% endfilter %}{# secure_context() #} 671 {% endfilter %}{# secure_context() #}
669 {% endfor %} 672 {% endfor %}
670 {% endif %} 673 {% endif %}
671 {%- endmacro %} 674 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698