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

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

Issue 2668753006: Special-case LocalDOMWindow for same-origin access in bindings. (Closed)
Patch Set: Rebase and address comments. Created 3 years, 10 months 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 11 matching lines...) Expand all
22 22
23 {% if not method.is_static %} 23 {% if not method.is_static %}
24 {% if method.returns_promise %} 24 {% if method.returns_promise %}
25 // V8DOMConfiguration::DoNotCheckHolder 25 // V8DOMConfiguration::DoNotCheckHolder
26 // Make sure that info.Holder() really points to an instance of the type. 26 // Make sure that info.Holder() really points to an instance of the type.
27 if (!{{v8_class}}::hasInstance(info.Holder(), info.GetIsolate())) { 27 if (!{{v8_class}}::hasInstance(info.Holder(), info.GetIsolate())) {
28 {{throw_type_error(method, '"Illegal invocation"')}} 28 {{throw_type_error(method, '"Illegal invocation"')}}
29 return; 29 return;
30 } 30 }
31 {% endif %} 31 {% endif %}
32 {% if interface_name == 'Window' and not method.is_cross_origin %}
33 // Same-origin methods are never exposed via the cross-origin interceptors.
34 // Since same-origin access requires a LocalDOMWindow, it is safe to downcast
35 // here.
36 LocalDOMWindow* impl = toLocalDOMWindow({{v8_class}}::toImpl(info.Holder()));
37 {% else %}
32 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 38 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
33 {% endif %} 39 {% endif %}
40 {% endif %}
34 41
35 {# Security checks #} 42 {# Security checks #}
36 {% if method.is_check_security_for_receiver %} 43 {% if method.is_check_security_for_receiver %}
37 {{define_exception_state}} 44 {{define_exception_state}}
38 {% if interface_name == 'EventTarget' %} 45 {% if interface_name == 'EventTarget' %}
39 // Performance hack for EventTarget. Checking whether it's a Window or not 46 // Performance hack for EventTarget. Checking whether it's a Window or not
40 // prior to the call to BindingSecurity::shouldAllowAccessTo increases 30% 47 // prior to the call to BindingSecurity::shouldAllowAccessTo increases 30%
41 // of speed performance on Android Nexus 7 as of Dec 2015. ALWAYS_INLINE 48 // of speed performance on Android Nexus 7 as of Dec 2015. ALWAYS_INLINE
42 // didn't work in this case. 49 // didn't work in this case.
43 if (const DOMWindow* window = impl->toDOMWindow()) { 50 if (const DOMWindow* window = impl->toDOMWindow()) {
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 if method.overloads else 646 if method.overloads else
640 method.runtime_enabled_feature_name) %} 647 method.runtime_enabled_feature_name) %}
641 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}}; 648 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}};
642 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); 649 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration);
643 {% endfilter %}{# runtime_enabled() #} 650 {% endfilter %}{# runtime_enabled() #}
644 {% endfilter %}{# exposed() #} 651 {% endfilter %}{# exposed() #}
645 {% endfilter %}{# secure_context() #} 652 {% endfilter %}{# secure_context() #}
646 {% endfor %} 653 {% endfor %}
647 {% endif %} 654 {% endif %}
648 {%- endmacro %} 655 {%- endmacro %}
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/templates/attributes.cpp.tmpl ('k') | third_party/WebKit/Source/core/frame/DOMWindow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698