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

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: Just special case DOMWindow 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 LocalDOMWindow* impl = toLocalDOMWindow({{v8_class}}::toImpl(info.Holder()));
34 {% else %}
32 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 35 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
33 {% endif %} 36 {% endif %}
37 {% endif %}
34 38
35 {# Security checks #} 39 {# Security checks #}
36 {% if method.is_check_security_for_receiver %} 40 {% if method.is_check_security_for_receiver %}
37 {{define_exception_state}} 41 {{define_exception_state}}
38 {% if interface_name == 'EventTarget' %} 42 {% if interface_name == 'EventTarget' %}
39 // Performance hack for EventTarget. Checking whether it's a Window or not 43 // Performance hack for EventTarget. Checking whether it's a Window or not
40 // prior to the call to BindingSecurity::shouldAllowAccessTo increases 30% 44 // prior to the call to BindingSecurity::shouldAllowAccessTo increases 30%
41 // of speed performance on Android Nexus 7 as of Dec 2015. ALWAYS_INLINE 45 // of speed performance on Android Nexus 7 as of Dec 2015. ALWAYS_INLINE
42 // didn't work in this case. 46 // didn't work in this case.
43 if (const DOMWindow* window = impl->toDOMWindow()) { 47 if (const DOMWindow* window = impl->toDOMWindow()) {
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 if method.overloads else 643 if method.overloads else
640 method.runtime_enabled_feature_name) %} 644 method.runtime_enabled_feature_name) %}
641 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}}; 645 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); 646 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration);
643 {% endfilter %}{# runtime_enabled() #} 647 {% endfilter %}{# runtime_enabled() #}
644 {% endfilter %}{# exposed() #} 648 {% endfilter %}{# exposed() #}
645 {% endfilter %}{# secure_context() #} 649 {% endfilter %}{# secure_context() #}
646 {% endfor %} 650 {% endfor %}
647 {% endif %} 651 {% endif %}
648 {%- endmacro %} 652 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698