Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 { | 91 { |
| 92 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(host); | 92 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(host); |
| 93 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe curityError); | 93 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe curityError); |
| 94 } | 94 } |
| 95 | 95 |
| 96 {% endif %} | 96 {% endif %} |
| 97 {% endblock %} | 97 {% endblock %} |
| 98 | 98 |
| 99 | 99 |
| 100 {##############################################################################} | 100 {##############################################################################} |
| 101 {% block domain_safe_method_setter %} | |
|
haraken
2013/11/20 05:04:54
domain_safe_method_setter => attribute_setter_with
Nils Barth (inactive)
2013/11/20 06:11:03
Got it; will do all the renames in a followup.
| |
| 102 {% if has_domain_safe_method_setter %} | |
|
haraken
2013/11/20 05:04:54
has_domain_safe_method_setter => has_attribute_set
Nils Barth (inactive)
2013/11/20 06:11:03
Per above, in followup.
| |
| 103 static void {{cpp_class_name}}DomainSafeFunctionSetter(v8::Local<v8::String> nam e, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) | |
|
haraken
2013/11/20 05:04:54
DomainSafeFunctionSetter => AttributeSetterWithSec
Nils Barth (inactive)
2013/11/20 06:11:03
Per above, in followup.
| |
| 104 { | |
| 105 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain({{ v8_class_name}}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); | |
| 106 if (holder.IsEmpty()) | |
| 107 return; | |
| 108 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(holder); | |
| 109 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); | |
| 110 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) { | |
| 111 exceptionState.throwIfNeeded(); | |
| 112 return; | |
| 113 } | |
| 114 | |
| 115 info.This()->SetHiddenValue(name, jsValue); | |
| 116 } | |
| 117 | |
| 118 {% endif %} | |
| 119 {% endblock %} | |
| 120 | |
| 121 | |
| 122 {##############################################################################} | |
| 101 {% block class_attributes %} | 123 {% block class_attributes %} |
| 102 {# FIXME: rename to install_attributes and put into configure_class_template #} | 124 {# FIXME: rename to install_attributes and put into configure_class_template #} |
| 103 {% if attributes %} | 125 {% if attributes %} |
| 104 static const V8DOMConfiguration::AttributeConfiguration {{v8_class_name}}Attribu tes[] = { | 126 static const V8DOMConfiguration::AttributeConfiguration {{v8_class_name}}Attribu tes[] = { |
| 105 {% for attribute in attributes | 127 {% for attribute in attributes |
| 106 if not (attribute.is_expose_js_accessors or | 128 if not (attribute.is_expose_js_accessors or |
| 107 attribute.is_static or | 129 attribute.is_static or |
| 108 attribute.runtime_enabled_function_name or | 130 attribute.runtime_enabled_function_name or |
| 109 attribute.per_context_enabled_function_name) %} | 131 attribute.per_context_enabled_function_name) %} |
| 110 {% filter conditional(attribute.conditional_string) %} | 132 {% filter conditional(attribute.conditional_string) %} |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 | 219 |
| 198 // Custom Signature '{{method.name}}' | 220 // Custom Signature '{{method.name}}' |
| 199 const int {{method.name}}Argc = {{method.arguments | length}}; | 221 const int {{method.name}}Argc = {{method.arguments | length}}; |
| 200 v8::Handle<v8::FunctionTemplate> {{method.name}}Argv[{{method.name}}Argc] = { {{method.custom_signature}} }; | 222 v8::Handle<v8::FunctionTemplate> {{method.name}}Argv[{{method.name}}Argc] = { {{method.custom_signature}} }; |
| 201 v8::Handle<v8::Signature> {{method.name}}Signature = v8::Signature::New(func tionTemplate, {{method.name}}Argc, {{method.name}}Argv); | 223 v8::Handle<v8::Signature> {{method.name}}Signature = v8::Signature::New(func tionTemplate, {{method.name}}Argc, {{method.name}}Argv); |
| 202 {% endif %} | 224 {% endif %} |
| 203 {# install_custom_signature #} | 225 {# install_custom_signature #} |
| 204 {% if not method.overload_index or method.overload_index == 1 %} | 226 {% if not method.overload_index or method.overload_index == 1 %} |
| 205 {# For overloaded methods, only generate one accessor #} | 227 {# For overloaded methods, only generate one accessor #} |
| 206 {% filter conditional(method.conditional_string) %} | 228 {% filter conditional(method.conditional_string) %} |
| 229 {% if method.is_do_not_check_security %} | |
| 230 {% if method.is_per_world_bindings %} | |
| 231 if (currentWorldType == MainWorld) { | |
| 232 {{install_do_not_check_security_signature(method, 'ForMainWorld')}} | |
| 233 } else { | |
| 234 {{install_do_not_check_security_signature(method)}} | |
| 235 } | |
| 236 {% else %} | |
| 237 {{install_do_not_check_security_signature(method)}} | |
| 238 {% endif %} | |
| 239 {% else %}{# is_do_not_check_security #} | |
| 207 {% if method.is_per_world_bindings %} | 240 {% if method.is_per_world_bindings %} |
| 208 if (currentWorldType == MainWorld) { | 241 if (currentWorldType == MainWorld) { |
| 209 {% filter runtime_enabled(method.runtime_enabled_function_name) %} | 242 {% filter runtime_enabled(method.runtime_enabled_function_name) %} |
| 210 {{install_custom_signature(method, 'ForMainWorld')}} | 243 {{install_custom_signature(method, 'ForMainWorld')}} |
| 211 {% endfilter %} | 244 {% endfilter %} |
| 212 } else { | 245 } else { |
| 213 {% filter runtime_enabled(method.runtime_enabled_function_name) %} | 246 {% filter runtime_enabled(method.runtime_enabled_function_name) %} |
| 214 {{install_custom_signature(method)}} | 247 {{install_custom_signature(method)}} |
| 215 {% endfilter %} | 248 {% endfilter %} |
| 216 } | 249 } |
| 217 {% else %} | 250 {% else %} |
| 218 {% filter runtime_enabled(method.runtime_enabled_function_name) %} | 251 {% filter runtime_enabled(method.runtime_enabled_function_name) %} |
| 219 {{install_custom_signature(method)}} | 252 {{install_custom_signature(method)}} |
| 220 {% endfilter %} | 253 {% endfilter %} |
| 221 {% endif %} | 254 {% endif %} |
| 255 {% endif %}{# is_do_not_check_security #} | |
| 222 {% endfilter %} | 256 {% endfilter %} |
| 223 {% endif %}{# install_custom_signature #} | 257 {% endif %}{# install_custom_signature #} |
| 224 {% endfor %} | 258 {% endfor %} |
| 225 {% for attribute in attributes if attribute.is_static %} | 259 {% for attribute in attributes if attribute.is_static %} |
| 226 {% set getter_callback_name = '%sV8Internal::%sAttributeGetterCallback' % | 260 {% set getter_callback_name = '%sV8Internal::%sAttributeGetterCallback' % |
| 227 (interface_name, attribute.name) %} | 261 (interface_name, attribute.name) %} |
| 228 functionTemplate->SetNativeDataProperty(v8::String::NewSymbol("{{attribute.n ame}}"), {{getter_callback_name}}, {{attribute.setter_callback_name}}, v8::Exter nal::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v 8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); | 262 functionTemplate->SetNativeDataProperty(v8::String::NewSymbol("{{attribute.n ame}}"), {{getter_callback_name}}, {{attribute.setter_callback_name}}, v8::Exter nal::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v 8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); |
| 229 {% endfor %} | 263 {% endfor %} |
| 230 {% if constants %} | 264 {% if constants %} |
| 231 {{install_constants() | indent}} | 265 {{install_constants() | indent}} |
| 232 {% endif %} | 266 {% endif %} |
| 233 | 267 |
| 234 // Custom toString template | 268 // Custom toString template |
| 235 functionTemplate->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::c urrent()->toStringTemplate()); | 269 functionTemplate->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::c urrent()->toStringTemplate()); |
| 236 return functionTemplate; | 270 return functionTemplate; |
| 237 } | 271 } |
| 238 | 272 |
| 239 {% endblock %} | 273 {% endblock %} |
| 240 | 274 |
| 241 | 275 |
| 242 {######################################} | 276 {######################################} |
| 277 {% macro install_do_not_check_security_signature(method, world_suffix) %} | |
| 278 {# Methods that are [DoNotCheckSecurity] are always readable, but if they are | |
| 279 changed and then accessed on a different domain, we do not return the | |
| 280 underlying value, but instead return a new copy of the original function. | |
|
haraken
2013/11/20 05:04:54
I got confused with the name "DoNotCheckSecurity",
Nils Barth (inactive)
2013/11/20 06:11:03
[DoNotCheckSecurity] is only used in Location.idl
haraken
2013/11/20 06:35:58
On the other hand, you're doing the security check
Nils Barth (inactive)
2013/11/20 07:10:49
Done in:
[DoNotCheckSecurity=Getter] => [DoNotChec
| |
| 281 This is achieved by storing the changed value as a hidden property. #} | |
| 282 {% set callback_name = '%sV8Internal::%sAttributeGetterCallback%s' % | |
| 283 (cpp_class_name, method.name, world_suffix) %} | |
| 284 {% set setter = | |
| 285 '{0}V8Internal::{0}DomainSafeFunctionSetter'.format(cpp_class_name) | |
|
haraken
2013/11/20 05:04:54
We want to have SetterCallback just like the Gette
Nils Barth (inactive)
2013/11/20 06:11:03
I'm happy to do this, but I don't see how it would
haraken
2013/11/20 06:35:58
I might want to fix the naming and SetterCallback
Nils Barth (inactive)
2013/11/20 07:10:49
Prep CLs will certainly make the history a bit cle
| |
| 286 if not method.is_read_only else '0' %} | |
| 287 {% set property_attribute = | |
| 288 'static_cast<v8::PropertyAttribute>(%s)' % | |
| 289 ' | '.join(method.property_attributes or ['v8::DontDelete']) %} | |
|
Nils Barth (inactive)
2013/11/20 03:39:30
This |or ['v8::DontDelete']| replaces a *really* u
| |
| 290 {{method.function_template}}->SetAccessor(v8::String::NewSymbol("{{method.name}} "), {{callback_name}}, {{setter}}, v8Undefined(), v8::ALL_CAN_READ, {{property_a ttribute}}); | |
|
haraken
2013/11/20 05:04:54
This should also be moved to V8DOMConfigratoin. A
Nils Barth (inactive)
2013/11/20 06:11:03
Added FIXME, will do in followup.
| |
| 291 {%- endmacro %} | |
| 292 | |
| 293 | |
| 294 {######################################} | |
| 243 {% macro install_custom_signature(method, world_suffix) %} | 295 {% macro install_custom_signature(method, world_suffix) %} |
| 244 {# FIXME: move to V8DOMConfiguration::installDOMCallbacksWithCustomSignature #} | 296 {# FIXME: move to V8DOMConfiguration::installDOMCallbacksWithCustomSignature #} |
| 245 {% set callback_name = '%sV8Internal::%sMethodCallback%s' % | 297 {% set callback_name = '%sV8Internal::%sMethodCallback%s' % |
| 246 (interface_name, method.name, world_suffix) %} | 298 (interface_name, method.name, world_suffix) %} |
| 247 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % | 299 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % |
| 248 ' | '.join(method.property_attributes) %} | 300 ' | '.join(method.property_attributes) %} |
| 249 {{method.function_template}}->Set(v8::String::NewSymbol("{{method.name}}"), v8:: FunctionTemplate::New({{callback_name}}, v8Undefined(), {{method.signature}}, {{ method.number_of_required_or_variadic_arguments}}){% if method.property_attribut es %}, {{property_attribute}}{% endif %}); | 301 {{method.function_template}}->Set(v8::String::NewSymbol("{{method.name}}"), v8:: FunctionTemplate::New({{callback_name}}, v8Undefined(), {{method.signature}}, {{ method.number_of_required_or_variadic_arguments}}){% if method.property_attribut es %}, {{property_attribute}}{% endif %}); |
| 250 {%- endmacro %} | 302 {%- endmacro %} |
| 251 | 303 |
| 252 | 304 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 390 V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &wrapperTy peInfo, wrapper, isolate, {{wrapper_configuration}}); | 442 V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &wrapperTy peInfo, wrapper, isolate, {{wrapper_configuration}}); |
| 391 return wrapper; | 443 return wrapper; |
| 392 } | 444 } |
| 393 | 445 |
| 394 void {{v8_class_name}}::derefObject(void* object) | 446 void {{v8_class_name}}::derefObject(void* object) |
| 395 { | 447 { |
| 396 fromInternalPointer(object)->deref(); | 448 fromInternalPointer(object)->deref(); |
| 397 } | 449 } |
| 398 | 450 |
| 399 {% endblock %} | 451 {% endblock %} |
| OLD | NEW |