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

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

Issue 2668753006: Special-case LocalDOMWindow for same-origin access in bindings. (Closed)
Patch Set: . 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 attribute_getter(attribute, world_suffix) %} 4 {% macro attribute_getter(attribute, world_suffix) %}
5 static void {{attribute.name}}AttributeGetter{{world_suffix}}( 5 static void {{attribute.name}}AttributeGetter{{world_suffix}}(
6 {%- if attribute.is_data_type_property %} 6 {%- if attribute.is_data_type_property %}
7 const v8::PropertyCallbackInfo<v8::Value>& info 7 const v8::PropertyCallbackInfo<v8::Value>& info
8 {%- else %} 8 {%- else %}
9 const v8::FunctionCallbackInfo<v8::Value>& info 9 const v8::FunctionCallbackInfo<v8::Value>& info
10 {%- endif %}) { 10 {%- endif %}) {
(...skipping 25 matching lines...) Expand all
36 { 36 {
37 v8::Local<v8::Value> v8Value = privateSameObject.get(info.GetIsolate()->GetC urrentContext(), holder); 37 v8::Local<v8::Value> v8Value = privateSameObject.get(info.GetIsolate()->GetC urrentContext(), holder);
38 if (!v8Value.IsEmpty()) { 38 if (!v8Value.IsEmpty()) {
39 v8SetReturnValue(info, v8Value); 39 v8SetReturnValue(info, v8Value);
40 return; 40 return;
41 } 41 }
42 } 42 }
43 {% endif %} 43 {% endif %}
44 44
45 {% if not attribute.is_static %} 45 {% if not attribute.is_static %}
46 {% if cpp_class_same_origin and not attribute.has_cross_origin_getter %}
47 {{cpp_class_same_origin}}* impl = to{{cpp_class_same_origin}}({{v8_class}}::to Impl(holder));
48 {% else %}
46 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); 49 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder);
47 {% endif %} 50 {% endif %}
51 {% endif %}
48 52
49 {% if attribute.cached_attribute_validation_method %} 53 {% if attribute.cached_attribute_validation_method %}
50 // [CachedAttribute] 54 // [CachedAttribute]
51 v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{attr ibute.name}}"); 55 v8::Local<v8::String> propertyName = v8AtomicString(info.GetIsolate(), "{{attr ibute.name}}");
52 if (!impl->{{attribute.cached_attribute_validation_method}}()) { 56 if (!impl->{{attribute.cached_attribute_validation_method}}()) {
53 v8::Local<v8::Value> v8Value = V8HiddenValue::getHiddenValue(ScriptState::fo rFunctionObject(info), holder, propertyName); 57 v8::Local<v8::Value> v8Value = V8HiddenValue::getHiddenValue(ScriptState::fo rFunctionObject(info), holder, propertyName);
54 if (!v8Value.IsEmpty() && !v8Value->IsUndefined()) { 58 if (!v8Value.IsEmpty() && !v8Value->IsUndefined()) {
55 v8SetReturnValue(info, v8Value); 59 v8SetReturnValue(info, v8Value);
56 return; 60 return;
57 } 61 }
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 {% endif %} 279 {% endif %}
276 280
277 {% if not attribute.is_static and not attribute.is_replaceable %} 281 {% if not attribute.is_static and not attribute.is_replaceable %}
278 v8::Local<v8::Object> holder = info.Holder(); 282 v8::Local<v8::Object> holder = info.Holder();
279 {% if attribute.is_put_forwards %} 283 {% if attribute.is_put_forwards %}
280 {{cpp_class}}* proxyImpl = {{v8_class}}::toImpl(holder); 284 {{cpp_class}}* proxyImpl = {{v8_class}}::toImpl(holder);
281 {{attribute.cpp_type}} impl = WTF::getPtr(proxyImpl->{{attribute.name}}()); 285 {{attribute.cpp_type}} impl = WTF::getPtr(proxyImpl->{{attribute.name}}());
282 if (!impl) 286 if (!impl)
283 return; 287 return;
284 {% else %} 288 {% else %}
289 {% if cpp_class_same_origin and not attribute.has_cross_origin_setter %}
290 {{cpp_class_same_origin}}* impl = to{{cpp_class_same_origin}}({{v8_class}}::to Impl(holder));
291 {% else %}
285 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); 292 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder);
286 {% endif %} 293 {% endif %}
287 {% endif %} 294 {% endif %}
295 {% endif %}
288 296
289 {% if attribute.is_check_security_for_receiver and not attribute.is_data_type_ property %} 297 {% if attribute.is_check_security_for_receiver and not attribute.is_data_type_ property %}
290 // Perform a security check for the receiver object. 298 // Perform a security check for the receiver object.
291 {{define_exception_state}} 299 {{define_exception_state}}
292 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()), impl, exceptionState)) { 300 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()), impl, exceptionState)) {
293 v8SetReturnValue(info, v8Value); 301 v8SetReturnValue(info, v8Value);
294 return; 302 return;
295 } 303 }
296 {% endif %} 304 {% endif %}
297 305
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 getter_callback_for_main_world, 467 getter_callback_for_main_world,
460 setter_callback_for_main_world, 468 setter_callback_for_main_world,
461 cached_accessor_callback, 469 cached_accessor_callback,
462 wrapper_type_info, 470 wrapper_type_info,
463 property_attribute, 471 property_attribute,
464 property_location(attribute), 472 property_location(attribute),
465 holder_check, 473 holder_check,
466 ] %} 474 ] %}
467 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} 475 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}}
468 {%- endmacro %} 476 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698