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

Side by Side Diff: Source/bindings/templates/interface.cpp

Issue 61523003: IDL compiler: [CheckSecurity=Frame] interfaces (initial) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Revised Created 7 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 | Annotate | Revision Log
OLDNEW
1 {% extends 'interface_base.cpp' %} 1 {% extends 'interface_base.cpp' %}
2 2
3 3
4 {##############################################################################} 4 {##############################################################################}
5 {% macro attribute_configuration(attribute) %} 5 {% macro attribute_configuration(attribute) %}
6 {% set getter_callback_name = 6 {% set getter_callback_name =
7 '%sV8Internal::%sAttributeGetterCallback' % 7 '%sV8Internal::%sAttributeGetterCallback' %
8 (interface_name, attribute.name) 8 (interface_name, attribute.name)
9 if not attribute.constructor_type else 9 if not attribute.constructor_type else
10 '{0}V8Internal::{0}ConstructorGetter'.format(interface_name) %} 10 '{0}V8Internal::{0}ConstructorGetter'.format(interface_name) %}
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 static void {{interface_name}}ReplaceableAttributeSetterCallback(v8::Local<v8::S tring> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 72 static void {{interface_name}}ReplaceableAttributeSetterCallback(v8::Local<v8::S tring> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
73 { 73 {
74 {{interface_name}}V8Internal::{{interface_name}}ReplaceableAttributeSetter(n ame, jsValue, info); 74 {{interface_name}}V8Internal::{{interface_name}}ReplaceableAttributeSetter(n ame, jsValue, info);
75 } 75 }
76 76
77 {% endif %} 77 {% endif %}
78 {% endblock %} 78 {% endblock %}
79 79
80 80
81 {##############################################################################} 81 {##############################################################################}
82 {% block security_check_functions %}
83 {% if is_check_security and interface_name != 'Window' %}
84 bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::Access Type type, v8::Local<v8::Value>)
85 {
86 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(host);
87 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe curityError);
88 }
89
90 bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8 ::AccessType type, v8::Local<v8::Value>)
91 {
92 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(host);
93 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe curityError);
94 }
95
96 {% endif %}
97 {% endblock %}
98
99
100 {##############################################################################}
82 {% block class_attributes %} 101 {% block class_attributes %}
83 {# FIXME: rename to install_attributes and put into configure_class_template #} 102 {# FIXME: rename to install_attributes and put into configure_class_template #}
84 {% if attributes %} 103 {% if attributes %}
85 static const V8DOMConfiguration::AttributeConfiguration {{v8_class_name}}Attribu tes[] = { 104 static const V8DOMConfiguration::AttributeConfiguration {{v8_class_name}}Attribu tes[] = {
86 {% for attribute in attributes 105 {% for attribute in attributes
87 if not (attribute.is_expose_js_accessors or 106 if not (attribute.is_expose_js_accessors or
88 attribute.is_static or 107 attribute.is_static or
89 attribute.runtime_enabled_function_name or 108 attribute.runtime_enabled_function_name or
90 attribute.per_context_enabled_function_name) %} 109 attribute.per_context_enabled_function_name) %}
91 {% filter conditional(attribute.conditional_string) %} 110 {% filter conditional(attribute.conditional_string) %}
(...skipping 16 matching lines...) Expand all
108 {% endfor %} 127 {% endfor %}
109 }; 128 };
110 129
111 {% endif %} 130 {% endif %}
112 {% endblock %} 131 {% endblock %}
113 132
114 133
115 {##############################################################################} 134 {##############################################################################}
116 {% block class_methods %} 135 {% block class_methods %}
117 {# FIXME: rename to install_methods and put into configure_class_template #} 136 {# FIXME: rename to install_methods and put into configure_class_template #}
118 {% if methods %} 137 {% if has_method_configuration %}
119 static const V8DOMConfiguration::MethodConfiguration {{v8_class_name}}Methods[] = { 138 static const V8DOMConfiguration::MethodConfiguration {{v8_class_name}}Methods[] = {
120 {% for method in methods 139 {% for method in methods if method.do_generate_method_configuration %}
121 if method.do_not_check_signature and
122 not method.per_context_enabled_function_name and
123 (not method.overload_index or method.overload_index == 1) %}
124 {# For overloaded methods, only generate one accessor #}
125 {% filter conditional(method.conditional_string) %} 140 {% filter conditional(method.conditional_string) %}
126 {{method_configuration(method)}}, 141 {{method_configuration(method)}},
127 {% endfilter %} 142 {% endfilter %}
128 {% endfor %} 143 {% endfor %}
129 }; 144 };
130 145
131 {% endif %} 146 {% endif %}
132 {% endblock %} 147 {% endblock %}
133 148
134 149
(...skipping 11 matching lines...) Expand all
146 ('%sAttributes' % v8_class_name, 161 ('%sAttributes' % v8_class_name,
147 'WTF_ARRAY_LENGTH(%sAttributes)' % v8_class_name) 162 'WTF_ARRAY_LENGTH(%sAttributes)' % v8_class_name)
148 if attributes else (0, 0) %} 163 if attributes else (0, 0) %}
149 {% set accessors_name, accessors_length = 164 {% set accessors_name, accessors_length =
150 ('%sAccessors' % v8_class_name, 165 ('%sAccessors' % v8_class_name,
151 'WTF_ARRAY_LENGTH(%sAccessors)' % v8_class_name) 166 'WTF_ARRAY_LENGTH(%sAccessors)' % v8_class_name)
152 if has_accessors else (0, 0) %} 167 if has_accessors else (0, 0) %}
153 {% set methods_name, methods_length = 168 {% set methods_name, methods_length =
154 ('%sMethods' % v8_class_name, 169 ('%sMethods' % v8_class_name,
155 'WTF_ARRAY_LENGTH(%sMethods)' % v8_class_name) 170 'WTF_ARRAY_LENGTH(%sMethods)' % v8_class_name)
156 if methods else (0, 0) %} 171 if has_method_configuration else (0, 0) %}
157 {{attributes_name}}, {{attributes_length}}, 172 {{attributes_name}}, {{attributes_length}},
158 {{accessors_name}}, {{accessors_length}}, 173 {{accessors_name}}, {{accessors_length}},
159 {{methods_name}}, {{methods_length}}, 174 {{methods_name}}, {{methods_length}},
160 isolate, currentWorldType); 175 isolate, currentWorldType);
161 UNUSED_PARAM(defaultSignature); 176 UNUSED_PARAM(defaultSignature);
162 v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceT emplate(); 177 v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceT emplate();
163 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->Prototyp eTemplate(); 178 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->Prototyp eTemplate();
164 UNUSED_PARAM(instanceTemplate); 179 UNUSED_PARAM(instanceTemplate);
165 UNUSED_PARAM(prototypeTemplate); 180 UNUSED_PARAM(prototypeTemplate);
181 {% if is_check_security and interface_name != 'Window' %}
182 instanceTemplate->SetAccessCheckCallbacks({{cpp_class_name}}V8Internal::name dSecurityCheck, {{cpp_class_name}}V8Internal::indexedSecurityCheck, v8::External ::New(isolate, const_cast<WrapperTypeInfo*>(&{{v8_class_name}}::wrapperTypeInfo) ));
183 {% endif %}
166 {% for attribute in attributes if attribute.runtime_enabled_function_name %} 184 {% for attribute in attributes if attribute.runtime_enabled_function_name %}
167 {% filter conditional(attribute.conditional_string) %} 185 {% filter conditional(attribute.conditional_string) %}
168 if ({{attribute.runtime_enabled_function_name}}()) { 186 if ({{attribute.runtime_enabled_function_name}}()) {
169 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\ 187 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\
170 {{attribute_configuration(attribute)}}; 188 {{attribute_configuration(attribute)}};
171 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate , attributeConfiguration, isolate, currentWorldType); 189 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate , attributeConfiguration, isolate, currentWorldType);
172 } 190 }
173 {% endfilter %} 191 {% endfilter %}
174 {% endfor %} 192 {% endfor %}
175 {% for method in methods if not method.do_not_check_signature %} 193 {% for method in methods if not method.do_not_check_signature %}
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &wrapperTy peInfo, wrapper, isolate, {{wrapper_configuration}}); 390 V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &wrapperTy peInfo, wrapper, isolate, {{wrapper_configuration}});
373 return wrapper; 391 return wrapper;
374 } 392 }
375 393
376 void {{v8_class_name}}::derefObject(void* object) 394 void {{v8_class_name}}::derefObject(void* object)
377 { 395 {
378 fromInternalPointer(object)->deref(); 396 fromInternalPointer(object)->deref();
379 } 397 }
380 398
381 {% endblock %} 399 {% endblock %}
OLDNEW
« no previous file with comments | « Source/bindings/scripts/unstable/v8_methods.py ('k') | Source/bindings/templates/interface_base.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698