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

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

Issue 77453002: IDL compiler: [CheckSecurity=Frame] interface + [DoNotCheckSecurity] members (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 {##############################################################################} 1 {##############################################################################}
2 {% macro generate_method(method, world_suffix) %} 2 {% macro generate_method(method, world_suffix) %}
3 {% filter conditional(method.conditional_string) %} 3 {% filter conditional(method.conditional_string) %}
4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) 4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info)
5 { 5 {
6 {% if method.name in ['addEventListener', 'removeEventListener'] %} 6 {% if method.name in ['addEventListener', 'removeEventListener'] %}
7 {{add_remove_event_listener_method(method.name) | indent}} 7 {{add_remove_event_listener_method(method.name) | indent}}
8 {% else %} 8 {% else %}
9 {% if method.number_of_required_arguments %} 9 {% if method.number_of_required_arguments %}
10 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { 10 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) {
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 {% endif %} 208 {% endif %}
209 {% if method.is_custom %} 209 {% if method.is_custom %}
210 {{v8_class_name}}::{{method.name}}MethodCustom(info); 210 {{v8_class_name}}::{{method.name}}MethodCustom(info);
211 {% else %} 211 {% else %}
212 {{cpp_class_name}}V8Internal::{{method.name}}Method{{world_suffix}}(info); 212 {{cpp_class_name}}V8Internal::{{method.name}}Method{{world_suffix}}(info);
213 {% endif %} 213 {% endif %}
214 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 214 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
215 } 215 }
216 {% endfilter %} 216 {% endfilter %}
217 {% endmacro %} 217 {% endmacro %}
218
219
220 {##############################################################################}
221 {% macro origin_safe_method_getter(method, world_suffix) %}
222 static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::Prop ertyCallbackInfo<v8::Value>& info)
223 {
224 {# FIXME: don't call GetIsolate() so often #}
225 // This is only for getting a unique pointer which we can pass to privateTem plate.
226 static int privateTemplateUniqueKey;
227 WrapperWorldType currentWorldType = worldType(info.GetIsolate());
228 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
229 {# FIXME: 1 case of [DoNotCheckSignature] in Window.idl may differ #}
230 v8::Handle<v8::FunctionTemplate> privateTemplate = data->privateTemplate(cur rentWorldType, &privateTemplateUniqueKey, {{cpp_class_name}}V8Internal::{{method .name}}MethodCallback{{world_suffix}}, v8Undefined(), v8::Signature::New(V8PerIs olateData::from(info.GetIsolate())->rawTemplate(&{{v8_class_name}}::wrapperTypeI nfo, currentWorldType)), {{method.number_of_required_or_variadic_arguments}});
231
232 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain({{ v8_class_name}}::GetTemplate(info.GetIsolate(), currentWorldType));
233 if (holder.IsEmpty()) {
234 // This is only reachable via |object.__proto__.func|, in which case it
235 // has already passed the same origin security check
236 v8SetReturnValue(info, privateTemplate->GetFunction());
237 return;
238 }
239 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(holder);
240 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecu rityError)) {
241 static int sharedTemplateUniqueKey;
242 v8::Handle<v8::FunctionTemplate> sharedTemplate = data->privateTemplate( currentWorldType, &sharedTemplateUniqueKey, {{cpp_class_name}}V8Internal::{{meth od.name}}MethodCallback{{world_suffix}}, v8Undefined(), v8::Signature::New(V8Per IsolateData::from(info.GetIsolate())->rawTemplate(&{{v8_class_name}}::wrapperTyp eInfo, currentWorldType)), {{method.number_of_required_or_variadic_arguments}});
243 v8SetReturnValue(info, sharedTemplate->GetFunction());
244 return;
245 }
246
247 v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8::String::N ewSymbol("{{method.name}}"));
248 if (!hiddenValue.IsEmpty()) {
249 v8SetReturnValue(info, hiddenValue);
250 return;
251 }
252
253 v8SetReturnValue(info, privateTemplate->GetFunction());
254 }
255
256 static void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Lo cal<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
257 {
258 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
259 {{cpp_class_name}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_s uffix}}(info);
260 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
261 }
262 {% endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/templates/interface_base.cpp ('k') | Source/bindings/tests/idls/TestCheckSecurityInterface.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698