Chromium Code Reviews| Index: Source/bindings/templates/methods.cpp | 
| diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp | 
| index 1d95f3625437db5339c56cb8d94e8458d4523ee5..1a76c3e270e17a7b8227d3b33926637b8605668c 100644 | 
| --- a/Source/bindings/templates/methods.cpp | 
| +++ b/Source/bindings/templates/methods.cpp | 
| @@ -215,3 +215,47 @@ static void {{method.name}}MethodCallback{{world_suffix}}(const v8::FunctionCall | 
| } | 
| {% endfilter %} | 
| {% endmacro %} | 
| + | 
| + | 
| +{##############################################################################} | 
| +{% macro domain_safe_method_getter(method, world_suffix) %} | 
| +static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::PropertyCallbackInfo<v8::Value>& info) | 
| +{ | 
| + // 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()); | 
| 
 
haraken
2013/11/21 10:13:05
Nit: We want to avoid calling info.GetIsolate() a
 
Nils Barth (inactive)
2013/11/22 03:17:52
As above: should I just add a local |isolate| vari
 
 | 
| + {# 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()) { | 
| + // can only reach here by 'object.__proto__.func', and it should passed | 
| + // domain security check already | 
| + 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 %} |