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

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

Issue 1417023006: bindings: Refactors BindingSecurity::shouldAllowAccessToXXX. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the assertion condition. Created 5 years 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 {% include 'copyright_block.txt' %} 1 {% include 'copyright_block.txt' %}
2 #include "config.h" 2 #include "config.h"
3 {% filter conditional(conditional_string) %} 3 {% filter conditional(conditional_string) %}
4 #include "{{v8_class_or_partial}}.h" 4 #include "{{v8_class_or_partial}}.h"
5 5
6 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %} 6 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %}
7 #include "{{filename}}" 7 #include "{{filename}}"
8 {% endfor %} 8 {% endfor %}
9 9
10 namespace blink { 10 namespace blink {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 {# Attributes #} 56 {# Attributes #}
57 {% block replaceable_attribute_setter_and_callback %} 57 {% block replaceable_attribute_setter_and_callback %}
58 {% if has_replaceable_attributes or has_constructor_attributes %} 58 {% if has_replaceable_attributes or has_constructor_attributes %}
59 template<class CallbackInfo> 59 template<class CallbackInfo>
60 static bool {{cpp_class}}CreateDataProperty(v8::Local<v8::Name> name, v8::Local< v8::Value> v8Value, const CallbackInfo& info) 60 static bool {{cpp_class}}CreateDataProperty(v8::Local<v8::Name> name, v8::Local< v8::Value> v8Value, const CallbackInfo& info)
61 { 61 {
62 {% if is_check_security %} 62 {% if is_check_security %}
63 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 63 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
64 v8::String::Utf8Value attributeName(name); 64 v8::String::Utf8Value attributeName(name);
65 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "{{interface_name}}", info.Holder(), info.GetIsolate()); 65 ExceptionState exceptionState(ExceptionState::SetterContext, *attributeName, "{{interface_name}}", info.Holder(), info.GetIsolate());
66 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), callingDOM Window(info.GetIsolate()), impl->frame(), exceptionState)) { 66 if (!BindingSecurity::shouldAllowAccessTo(info.GetIsolate(), callingDOMWindo w(info.GetIsolate()), impl, exceptionState)) {
67 exceptionState.throwIfNeeded(); 67 exceptionState.throwIfNeeded();
68 return false; 68 return false;
69 } 69 }
70 {% endif %} 70 {% endif %}
71 ASSERT(info.This()->IsObject()); 71 ASSERT(info.This()->IsObject());
72 return v8CallBoolean(v8::Local<v8::Object>::Cast(info.This())->CreateDataPro perty(info.GetIsolate()->GetCurrentContext(), name, v8Value)); 72 return v8CallBoolean(v8::Local<v8::Object>::Cast(info.This())->CreateDataPro perty(info.GetIsolate()->GetCurrentContext(), name, v8Value));
73 } 73 }
74 74
75 {% if has_constructor_attributes %} 75 {% if has_constructor_attributes %}
76 static void {{cpp_class}}ConstructorAttributeSetterCallback(v8::Local<v8::Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) 76 static void {{cpp_class}}ConstructorAttributeSetterCallback(v8::Local<v8::Name>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 {{constructor_getter_callback(attribute, world_suffix)}} 125 {{constructor_getter_callback(attribute, world_suffix)}}
126 {% endfor %} 126 {% endfor %}
127 {% endfor %} 127 {% endfor %}
128 {##############################################################################} 128 {##############################################################################}
129 {% block security_check_functions %} 129 {% block security_check_functions %}
130 {% if has_access_check_callbacks %} 130 {% if has_access_check_callbacks %}
131 bool securityCheck(v8::Local<v8::Context> accessingContext, v8::Local<v8::Object > accessedObject) 131 bool securityCheck(v8::Local<v8::Context> accessingContext, v8::Local<v8::Object > accessedObject)
132 { 132 {
133 // TODO(jochen): Take accessingContext into account. 133 // TODO(jochen): Take accessingContext into account.
134 {{cpp_class}}* impl = {{v8_class}}::toImpl(accessedObject); 134 {{cpp_class}}* impl = {{v8_class}}::toImpl(accessedObject);
135 return BindingSecurity::shouldAllowAccessToFrame(v8::Isolate::GetCurrent(), callingDOMWindow(v8::Isolate::GetCurrent()), impl->frame(), DoNotReportSecurityE rror); 135 return BindingSecurity::shouldAllowAccessTo(v8::Isolate::GetCurrent(), calli ngDOMWindow(v8::Isolate::GetCurrent()), impl, DoNotReportSecurityError);
136 } 136 }
137 137
138 {% endif %} 138 {% endif %}
139 {% endblock %} 139 {% endblock %}
140 {##############################################################################} 140 {##############################################################################}
141 {# Methods #} 141 {# Methods #}
142 {% from 'methods.cpp' import generate_method, overload_resolution_method, 142 {% from 'methods.cpp' import generate_method, overload_resolution_method,
143 method_callback, origin_safe_method_getter, generate_constructor, 143 method_callback, origin_safe_method_getter, generate_constructor,
144 method_implemented_in_private_script, generate_post_message_impl, 144 method_implemented_in_private_script, generate_post_message_impl,
145 runtime_determined_length_method, runtime_determined_maxarg_method 145 runtime_determined_length_method, runtime_determined_maxarg_method
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 {% endfor %} 461 {% endfor %}
462 {% for attribute in attributes if attribute.is_implemented_in_private_script %} 462 {% for attribute in attributes if attribute.is_implemented_in_private_script %}
463 {{attribute_getter_implemented_in_private_script(attribute)}} 463 {{attribute_getter_implemented_in_private_script(attribute)}}
464 {% if attribute.has_setter %} 464 {% if attribute.has_setter %}
465 {{attribute_setter_implemented_in_private_script(attribute)}} 465 {{attribute_setter_implemented_in_private_script(attribute)}}
466 {% endif %} 466 {% endif %}
467 {% endfor %} 467 {% endfor %}
468 {% block partial_interface %}{% endblock %} 468 {% block partial_interface %}{% endblock %}
469 } // namespace blink 469 } // namespace blink
470 {% endfilter %} 470 {% endfilter %}
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/templates/interface.cpp ('k') | third_party/WebKit/Source/bindings/templates/methods.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698