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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: Source/bindings/templates/methods.cpp
diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp
index 1d95f3625437db5339c56cb8d94e8458d4523ee5..e740a656244320100223419fcb74b747f7247f22 100644
--- a/Source/bindings/templates/methods.cpp
+++ b/Source/bindings/templates/methods.cpp
@@ -215,3 +215,48 @@ static void {{method.name}}MethodCallback{{world_suffix}}(const v8::FunctionCall
}
{% endfilter %}
{% endmacro %}
+
+
+{##############################################################################}
+{% macro origin_safe_method_getter(method, world_suffix) %}
+static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::PropertyCallbackInfo<v8::Value>& info)
+{
+ {# FIXME: don't call GetIsolate() so often #}
+ // This is only for getting a unique pointer which we can pass to privateTemplate.
+ static int privateTemplateUniqueKey;
+ WrapperWorldType currentWorldType = worldType(info.GetIsolate());
+ V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
+ {# FIXME: 1 case of [DoNotCheckSignature] in Window.idl may differ #}
+ v8::Handle<v8::FunctionTemplate> privateTemplate = data->privateTemplate(currentWorldType, &privateTemplateUniqueKey, {{cpp_class_name}}V8Internal::{{method.name}}MethodCallback{{world_suffix}}, v8Undefined(), v8::Signature::New(V8PerIsolateData::from(info.GetIsolate())->rawTemplate(&{{v8_class_name}}::wrapperTypeInfo, currentWorldType)), {{method.number_of_required_or_variadic_arguments}});
+
+ v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain({{v8_class_name}}::GetTemplate(info.GetIsolate(), currentWorldType));
+ if (holder.IsEmpty()) {
+ // This is only reachable via |object.__proto__.func|, in which case it
+ // has already passed the same origin security check
+ v8SetReturnValue(info, privateTemplate->GetFunction());
+ return;
+ }
+ {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(holder);
+ if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSecurityError)) {
+ static int sharedTemplateUniqueKey;
+ v8::Handle<v8::FunctionTemplate> sharedTemplate = data->privateTemplate(currentWorldType, &sharedTemplateUniqueKey, {{cpp_class_name}}V8Internal::{{method.name}}MethodCallback{{world_suffix}}, v8Undefined(), v8::Signature::New(V8PerIsolateData::from(info.GetIsolate())->rawTemplate(&{{v8_class_name}}::wrapperTypeInfo, currentWorldType)), {{method.number_of_required_or_variadic_arguments}});
+ v8SetReturnValue(info, sharedTemplate->GetFunction());
+ return;
+ }
+
+ v8::Local<v8::Value> hiddenValue = info.This()->GetHiddenValue(v8::String::NewSymbol("{{method.name}}"));
+ if (!hiddenValue.IsEmpty()) {
+ v8SetReturnValue(info, hiddenValue);
+ return;
+ }
+
+ v8SetReturnValue(info, privateTemplate->GetFunction());
+}
+
+static void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
+ {{cpp_class_name}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix}}(info);
+ TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
+}
+{% endmacro %}
« 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