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

Side by Side Diff: Source/bindings/scripts/code_generator_v8.pm

Issue 77743002: Rename *AttributeGetter => *OriginSafeMethodGetter and DomainSafeFunctionSetter => OriginSafeMethod… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Domain => Origin 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
« no previous file with comments | « no previous file | Source/bindings/tests/results/V8TestCheckSecurityInterface.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> 2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com>
3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> 3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> 4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org>
5 # Copyright (C) 2006 Apple Computer, Inc. 5 # Copyright (C) 2006 Apple Computer, Inc.
6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. 6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc.
7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved.
9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 # Copyright (C) 2012 Ericsson AB. All rights reserved. 10 # Copyright (C) 2012 Ericsson AB. All rights reserved.
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 my $functionLength = GetFunctionLength($function); 1203 my $functionLength = GetFunctionLength($function);
1204 my $signature = "v8::Signature::New(V8PerIsolateData::from(info.GetIsolate() )->rawTemplate(&" . $v8ClassName . "::wrapperTypeInfo, currentWorldType))"; 1204 my $signature = "v8::Signature::New(V8PerIsolateData::from(info.GetIsolate() )->rawTemplate(&" . $v8ClassName . "::wrapperTypeInfo, currentWorldType))";
1205 if ($function->extendedAttributes->{"DoNotCheckSignature"}) { 1205 if ($function->extendedAttributes->{"DoNotCheckSignature"}) {
1206 $signature = "v8::Local<v8::Signature>()"; 1206 $signature = "v8::Local<v8::Signature>()";
1207 } 1207 }
1208 1208
1209 my $newTemplateParams = "${implClassName}V8Internal::${funcName}MethodCallba ck${forMainWorldSuffix}, v8Undefined(), $signature"; 1209 my $newTemplateParams = "${implClassName}V8Internal::${funcName}MethodCallba ck${forMainWorldSuffix}, v8Undefined(), $signature";
1210 1210
1211 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 1211 AddToImplIncludes("bindings/v8/BindingSecurity.h");
1212 $implementation{nameSpaceInternal}->add(<<END); 1212 $implementation{nameSpaceInternal}->add(<<END);
1213 static void ${funcName}AttributeGetter${forMainWorldSuffix}(const v8::PropertyCa llbackInfo<v8::Value>& info) 1213 static void ${funcName}OriginSafeMethodGetter${forMainWorldSuffix}(const v8::Pro pertyCallbackInfo<v8::Value>& info)
1214 { 1214 {
1215 // This is only for getting a unique pointer which we can pass to privateTem plate. 1215 // This is only for getting a unique pointer which we can pass to privateTem plate.
1216 static int privateTemplateUniqueKey; 1216 static int privateTemplateUniqueKey;
1217 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); 1217 WrapperWorldType currentWorldType = worldType(info.GetIsolate());
1218 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); 1218 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
1219 v8::Handle<v8::FunctionTemplate> privateTemplate = data->privateTemplate(cur rentWorldType, &privateTemplateUniqueKey, $newTemplateParams, $functionLength); 1219 v8::Handle<v8::FunctionTemplate> privateTemplate = data->privateTemplate(cur rentWorldType, &privateTemplateUniqueKey, $newTemplateParams, $functionLength);
1220 1220
1221 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${ v8ClassName}::GetTemplate(info.GetIsolate(), currentWorldType)); 1221 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${ v8ClassName}::GetTemplate(info.GetIsolate(), currentWorldType));
1222 if (holder.IsEmpty()) { 1222 if (holder.IsEmpty()) {
1223 // can only reach here by 'object.__proto__.func', and it should passed 1223 // can only reach here by 'object.__proto__.func', and it should passed
(...skipping 13 matching lines...) Expand all
1237 if (!hiddenValue.IsEmpty()) { 1237 if (!hiddenValue.IsEmpty()) {
1238 v8SetReturnValue(info, hiddenValue); 1238 v8SetReturnValue(info, hiddenValue);
1239 return; 1239 return;
1240 } 1240 }
1241 1241
1242 v8SetReturnValue(info, privateTemplate->GetFunction()); 1242 v8SetReturnValue(info, privateTemplate->GetFunction());
1243 } 1243 }
1244 1244
1245 END 1245 END
1246 $implementation{nameSpaceInternal}->add(<<END); 1246 $implementation{nameSpaceInternal}->add(<<END);
1247 static void ${funcName}AttributeGetterCallback${forMainWorldSuffix}(v8::Local<v8 ::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 1247 static void ${funcName}OriginSafeMethodGetterCallback${forMainWorldSuffix}(v8::L ocal<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
1248 { 1248 {
1249 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 1249 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
1250 ${implClassName}V8Internal::${funcName}AttributeGetter${forMainWorldSuffix}( info); 1250 ${implClassName}V8Internal::${funcName}OriginSafeMethodGetter${forMainWorldS uffix}(info);
1251 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 1251 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
1252 } 1252 }
1253 1253
1254 END 1254 END
1255 } 1255 }
1256 1256
1257 sub GenerateDomainSafeFunctionSetter 1257 sub GenerateDomainSafeFunctionSetter
1258 { 1258 {
1259 my $interface = shift; 1259 my $interface = shift;
1260 1260
1261 my $implClassName = GetImplName($interface); 1261 my $implClassName = GetImplName($interface);
1262 my $v8ClassName = GetV8ClassName($interface); 1262 my $v8ClassName = GetV8ClassName($interface);
1263 1263
1264 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 1264 AddToImplIncludes("bindings/v8/BindingSecurity.h");
1265 AddToImplIncludes("bindings/v8/ExceptionState.h"); 1265 AddToImplIncludes("bindings/v8/ExceptionState.h");
1266 $implementation{nameSpaceInternal}->add(<<END); 1266 $implementation{nameSpaceInternal}->add(<<END);
1267 static void ${implClassName}DomainSafeFunctionSetter(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 1267 static void ${implClassName}OriginSafeMethodSetter(v8::Local<v8::String> name, v 8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
1268 { 1268 {
1269 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${ v8ClassName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); 1269 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${ v8ClassName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate())));
1270 if (holder.IsEmpty()) 1270 if (holder.IsEmpty())
1271 return; 1271 return;
1272 ${implClassName}* imp = ${v8ClassName}::toNative(holder); 1272 ${implClassName}* imp = ${v8ClassName}::toNative(holder);
1273 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); 1273 ExceptionState exceptionState(info.Holder(), info.GetIsolate());
1274 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) { 1274 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) {
1275 exceptionState.throwIfNeeded(); 1275 exceptionState.throwIfNeeded();
1276 return; 1276 return;
1277 } 1277 }
(...skipping 2045 matching lines...) Expand 10 before | Expand all | Expand 10 after
3323 $conditional4 = "if (${runtimeEnabledFunction}())\n "; 3323 $conditional4 = "if (${runtimeEnabledFunction}())\n ";
3324 } 3324 }
3325 if ($attrExt->{"PerContextEnabled"}) { 3325 if ($attrExt->{"PerContextEnabled"}) {
3326 # Only call Set()/SetAccessor() if this method should be enabled 3326 # Only call Set()/SetAccessor() if this method should be enabled
3327 my $contextEnabledFunction = GetContextEnabledFunctionName($function); 3327 my $contextEnabledFunction = GetContextEnabledFunctionName($function);
3328 $conditional4 = "if (${contextEnabledFunction}(impl->document()))\n "; 3328 $conditional4 = "if (${contextEnabledFunction}(impl->document()))\n ";
3329 } 3329 }
3330 $conditional8 = $conditional4 . " " if $conditional4 ne ""; 3330 $conditional8 = $conditional4 . " " if $conditional4 ne "";
3331 3331
3332 if ($interface->extendedAttributes->{"CheckSecurity"} && $attrExt->{"DoNotCh eckSecurity"}) { 3332 if ($interface->extendedAttributes->{"CheckSecurity"} && $attrExt->{"DoNotCh eckSecurity"}) {
3333 my $setter = $attrExt->{"ReadOnly"} ? "0" : "${implClassName}V8Internal: :${implClassName}DomainSafeFunctionSetter"; 3333 my $setter = $attrExt->{"ReadOnly"} ? "0" : "${implClassName}V8Internal: :${implClassName}OriginSafeMethodSetter";
3334 # Functions that are marked DoNotCheckSecurity are always readable but i f they are changed 3334 # Functions that are marked DoNotCheckSecurity are always readable but i f they are changed
3335 # and then accessed on a different domain we do not return the underlyin g value but instead 3335 # and then accessed on a different domain we do not return the underlyin g value but instead
3336 # return a new copy of the original function. This is achieved by storin g the changed value 3336 # return a new copy of the original function. This is achieved by storin g the changed value
3337 # as hidden property. 3337 # as hidden property.
3338 $code .= <<END; 3338 $code .= <<END;
3339 3339
3340 // $commentInfo 3340 // $commentInfo
3341 END 3341 END
3342 if ($function->extendedAttributes->{"PerWorldBindings"}) { 3342 if ($function->extendedAttributes->{"PerWorldBindings"}) {
3343 $code .= <<END; 3343 $code .= <<END;
3344 if (currentWorldType == MainWorld) { 3344 if (currentWorldType == MainWorld) {
3345 ${conditional8}$template->SetAccessor(v8::String::NewSymbol("$name"), ${ implClassName}V8Internal::${name}AttributeGetterCallbackForMainWorld, ${setter}, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>($property_a ttributes)); 3345 ${conditional8}$template->SetAccessor(v8::String::NewSymbol("$name"), ${ implClassName}V8Internal::${name}OriginSafeMethodGetterCallbackForMainWorld, ${s etter}, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>($pro perty_attributes));
3346 } else { 3346 } else {
3347 ${conditional8}$template->SetAccessor(v8::String::NewSymbol("$name"), ${ implClassName}V8Internal::${name}AttributeGetterCallback, ${setter}, v8Undefined (), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>($property_attributes)); 3347 ${conditional8}$template->SetAccessor(v8::String::NewSymbol("$name"), ${ implClassName}V8Internal::${name}OriginSafeMethodGetterCallback, ${setter}, v8Un defined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>($property_attrib utes));
3348 } 3348 }
3349 END 3349 END
3350 } else { 3350 } else {
3351 $code .= " ${conditional4}$template->SetAccessor(v8::String::NewS ymbol(\"$name\"), ${implClassName}V8Internal::${name}AttributeGetterCallback, ${ setter}, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>($pr operty_attributes));\n"; 3351 $code .= " ${conditional4}$template->SetAccessor(v8::String::NewS ymbol(\"$name\"), ${implClassName}V8Internal::${name}OriginSafeMethodGetterCallb ack, ${setter}, v8Undefined(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribu te>($property_attributes));\n";
3352 } 3352 }
3353 3353
3354 return $code; 3354 return $code;
3355 } 3355 }
3356 3356
3357 my $signature = "defaultSignature"; 3357 my $signature = "defaultSignature";
3358 if ($attrExt->{"DoNotCheckSignature"} || $function->isStatic) { 3358 if ($attrExt->{"DoNotCheckSignature"} || $function->isStatic) {
3359 $signature = "v8::Local<v8::Signature>()"; 3359 $signature = "v8::Local<v8::Signature>()";
3360 } 3360 }
3361 3361
(...skipping 2961 matching lines...) Expand 10 before | Expand all | Expand 10 after
6323 my $interface = shift; 6323 my $interface = shift;
6324 6324
6325 return 1 if $interface->extendedAttributes->{"CustomToV8"}; 6325 return 1 if $interface->extendedAttributes->{"CustomToV8"};
6326 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; 6326 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"};
6327 return 1 if InheritsInterface($interface, "Document"); 6327 return 1 if InheritsInterface($interface, "Document");
6328 6328
6329 return 0; 6329 return 0;
6330 } 6330 }
6331 6331
6332 1; 6332 1;
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/tests/results/V8TestCheckSecurityInterface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698