| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 void installAttributeInternal( | 40 void installAttributeInternal( |
| 41 v8::Isolate* isolate, | 41 v8::Isolate* isolate, |
| 42 v8::Local<v8::ObjectTemplate> instanceTemplate, | 42 v8::Local<v8::ObjectTemplate> instanceTemplate, |
| 43 v8::Local<v8::ObjectTemplate> prototypeTemplate, | 43 v8::Local<v8::ObjectTemplate> prototypeTemplate, |
| 44 const V8DOMConfiguration::AttributeConfiguration& attribute, | 44 const V8DOMConfiguration::AttributeConfiguration& attribute, |
| 45 const DOMWrapperWorld& world) { | 45 const DOMWrapperWorld& world) { |
| 46 if (attribute.exposeConfiguration == | |
| 47 V8DOMConfiguration::OnlyExposedToPrivateScript && | |
| 48 !world.isPrivateScriptIsolatedWorld()) | |
| 49 return; | |
| 50 | |
| 51 v8::Local<v8::Name> name = v8AtomicString(isolate, attribute.name); | 46 v8::Local<v8::Name> name = v8AtomicString(isolate, attribute.name); |
| 52 v8::AccessorNameGetterCallback getter = attribute.getter; | 47 v8::AccessorNameGetterCallback getter = attribute.getter; |
| 53 v8::AccessorNameSetterCallback setter = attribute.setter; | 48 v8::AccessorNameSetterCallback setter = attribute.setter; |
| 54 if (world.isMainWorld()) { | 49 if (world.isMainWorld()) { |
| 55 if (attribute.getterForMainWorld) | 50 if (attribute.getterForMainWorld) |
| 56 getter = attribute.getterForMainWorld; | 51 getter = attribute.getterForMainWorld; |
| 57 if (attribute.setterForMainWorld) | 52 if (attribute.setterForMainWorld) |
| 58 setter = attribute.setterForMainWorld; | 53 setter = attribute.setterForMainWorld; |
| 59 } | 54 } |
| 60 v8::Local<v8::Value> data = | 55 v8::Local<v8::Value> data = |
| (...skipping 15 matching lines...) Expand all Loading... |
| 76 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInterface) | 71 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInterface) |
| 77 NOTREACHED(); | 72 NOTREACHED(); |
| 78 } | 73 } |
| 79 | 74 |
| 80 void installAttributeInternal( | 75 void installAttributeInternal( |
| 81 v8::Isolate* isolate, | 76 v8::Isolate* isolate, |
| 82 v8::Local<v8::Object> instance, | 77 v8::Local<v8::Object> instance, |
| 83 v8::Local<v8::Object> prototype, | 78 v8::Local<v8::Object> prototype, |
| 84 const V8DOMConfiguration::AttributeConfiguration& attribute, | 79 const V8DOMConfiguration::AttributeConfiguration& attribute, |
| 85 const DOMWrapperWorld& world) { | 80 const DOMWrapperWorld& world) { |
| 86 if (attribute.exposeConfiguration == | |
| 87 V8DOMConfiguration::OnlyExposedToPrivateScript && | |
| 88 !world.isPrivateScriptIsolatedWorld()) | |
| 89 return; | |
| 90 | |
| 91 v8::Local<v8::Name> name = v8AtomicString(isolate, attribute.name); | 81 v8::Local<v8::Name> name = v8AtomicString(isolate, attribute.name); |
| 92 | 82 |
| 93 // This method is only being used for installing interfaces which are | 83 // This method is only being used for installing interfaces which are |
| 94 // enabled through origin trials. Assert here that it is being called with | 84 // enabled through origin trials. Assert here that it is being called with |
| 95 // an attribute configuration for a constructor. | 85 // an attribute configuration for a constructor. |
| 96 // TODO(iclelland): Relax this constraint and allow arbitrary data-type | 86 // TODO(iclelland): Relax this constraint and allow arbitrary data-type |
| 97 // properties to be added here. | 87 // properties to be added here. |
| 98 DCHECK_EQ(&v8ConstructorAttributeGetter, attribute.getter); | 88 DCHECK_EQ(&v8ConstructorAttributeGetter, attribute.getter); |
| 99 | 89 |
| 100 V8PerContextData* perContextData = | 90 V8PerContextData* perContextData = |
| (...skipping 17 matching lines...) Expand all Loading... |
| 118 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInterface) | 108 if (attribute.propertyLocationConfiguration & V8DOMConfiguration::OnInterface) |
| 119 NOTREACHED(); | 109 NOTREACHED(); |
| 120 } | 110 } |
| 121 | 111 |
| 122 void installLazyDataAttributeInternal( | 112 void installLazyDataAttributeInternal( |
| 123 v8::Isolate* isolate, | 113 v8::Isolate* isolate, |
| 124 v8::Local<v8::ObjectTemplate> instanceTemplate, | 114 v8::Local<v8::ObjectTemplate> instanceTemplate, |
| 125 v8::Local<v8::ObjectTemplate> prototypeTemplate, | 115 v8::Local<v8::ObjectTemplate> prototypeTemplate, |
| 126 const V8DOMConfiguration::AttributeConfiguration& attribute, | 116 const V8DOMConfiguration::AttributeConfiguration& attribute, |
| 127 const DOMWrapperWorld& world) { | 117 const DOMWrapperWorld& world) { |
| 128 if (attribute.exposeConfiguration == | |
| 129 V8DOMConfiguration::OnlyExposedToPrivateScript && | |
| 130 !world.isPrivateScriptIsolatedWorld()) | |
| 131 return; | |
| 132 | |
| 133 v8::Local<v8::Name> name = v8AtomicString(isolate, attribute.name); | 118 v8::Local<v8::Name> name = v8AtomicString(isolate, attribute.name); |
| 134 v8::AccessorNameGetterCallback getter = attribute.getter; | 119 v8::AccessorNameGetterCallback getter = attribute.getter; |
| 135 DCHECK(!attribute.setter); | 120 DCHECK(!attribute.setter); |
| 136 DCHECK(!attribute.getterForMainWorld); | 121 DCHECK(!attribute.getterForMainWorld); |
| 137 DCHECK(!attribute.setterForMainWorld); | 122 DCHECK(!attribute.setterForMainWorld); |
| 138 v8::Local<v8::Value> data = | 123 v8::Local<v8::Value> data = |
| 139 v8::External::New(isolate, const_cast<WrapperTypeInfo*>(attribute.data)); | 124 v8::External::New(isolate, const_cast<WrapperTypeInfo*>(attribute.data)); |
| 140 DCHECK(static_cast<v8::AccessControl>(attribute.settings) == v8::DEFAULT); | 125 DCHECK(static_cast<v8::AccessControl>(attribute.settings) == v8::DEFAULT); |
| 141 | 126 |
| 142 DCHECK(attribute.propertyLocationConfiguration); | 127 DCHECK(attribute.propertyLocationConfiguration); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 | 204 |
| 220 template <class ObjectOrTemplate, class FunctionOrTemplate> | 205 template <class ObjectOrTemplate, class FunctionOrTemplate> |
| 221 void installAccessorInternal( | 206 void installAccessorInternal( |
| 222 v8::Isolate* isolate, | 207 v8::Isolate* isolate, |
| 223 v8::Local<ObjectOrTemplate> instanceOrTemplate, | 208 v8::Local<ObjectOrTemplate> instanceOrTemplate, |
| 224 v8::Local<ObjectOrTemplate> prototypeOrTemplate, | 209 v8::Local<ObjectOrTemplate> prototypeOrTemplate, |
| 225 v8::Local<FunctionOrTemplate> interfaceOrTemplate, | 210 v8::Local<FunctionOrTemplate> interfaceOrTemplate, |
| 226 v8::Local<v8::Signature> signature, | 211 v8::Local<v8::Signature> signature, |
| 227 const V8DOMConfiguration::AccessorConfiguration& accessor, | 212 const V8DOMConfiguration::AccessorConfiguration& accessor, |
| 228 const DOMWrapperWorld& world) { | 213 const DOMWrapperWorld& world) { |
| 229 if (accessor.exposeConfiguration == | |
| 230 V8DOMConfiguration::OnlyExposedToPrivateScript && | |
| 231 !world.isPrivateScriptIsolatedWorld()) | |
| 232 return; | |
| 233 | |
| 234 v8::Local<v8::Name> name = v8AtomicString(isolate, accessor.name); | 214 v8::Local<v8::Name> name = v8AtomicString(isolate, accessor.name); |
| 235 v8::FunctionCallback getterCallback = accessor.getter; | 215 v8::FunctionCallback getterCallback = accessor.getter; |
| 236 v8::FunctionCallback setterCallback = accessor.setter; | 216 v8::FunctionCallback setterCallback = accessor.setter; |
| 237 V8DOMConfiguration::CachedAccessorCallback cachedAccessorCallback = nullptr; | 217 V8DOMConfiguration::CachedAccessorCallback cachedAccessorCallback = nullptr; |
| 238 if (world.isMainWorld()) { | 218 if (world.isMainWorld()) { |
| 239 if (accessor.getterForMainWorld) | 219 if (accessor.getterForMainWorld) |
| 240 getterCallback = accessor.getterForMainWorld; | 220 getterCallback = accessor.getterForMainWorld; |
| 241 if (accessor.setterForMainWorld) | 221 if (accessor.setterForMainWorld) |
| 242 setterCallback = accessor.setterForMainWorld; | 222 setterCallback = accessor.setterForMainWorld; |
| 243 cachedAccessorCallback = accessor.cachedAccessorCallback; | 223 cachedAccessorCallback = accessor.cachedAccessorCallback; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 } | 324 } |
| 345 | 325 |
| 346 template <class Configuration> | 326 template <class Configuration> |
| 347 void installMethodInternal(v8::Isolate* isolate, | 327 void installMethodInternal(v8::Isolate* isolate, |
| 348 v8::Local<v8::ObjectTemplate> instanceTemplate, | 328 v8::Local<v8::ObjectTemplate> instanceTemplate, |
| 349 v8::Local<v8::ObjectTemplate> prototypeTemplate, | 329 v8::Local<v8::ObjectTemplate> prototypeTemplate, |
| 350 v8::Local<v8::FunctionTemplate> interfaceTemplate, | 330 v8::Local<v8::FunctionTemplate> interfaceTemplate, |
| 351 v8::Local<v8::Signature> signature, | 331 v8::Local<v8::Signature> signature, |
| 352 const Configuration& method, | 332 const Configuration& method, |
| 353 const DOMWrapperWorld& world) { | 333 const DOMWrapperWorld& world) { |
| 354 if (method.exposeConfiguration == | |
| 355 V8DOMConfiguration::OnlyExposedToPrivateScript && | |
| 356 !world.isPrivateScriptIsolatedWorld()) | |
| 357 return; | |
| 358 | |
| 359 v8::Local<v8::Name> name = method.methodName(isolate); | 334 v8::Local<v8::Name> name = method.methodName(isolate); |
| 360 v8::FunctionCallback callback = method.callbackForWorld(world); | 335 v8::FunctionCallback callback = method.callbackForWorld(world); |
| 361 // Promise-returning functions need to return a reject promise when | 336 // Promise-returning functions need to return a reject promise when |
| 362 // an exception occurs. This includes a case that the receiver object is not | 337 // an exception occurs. This includes a case that the receiver object is not |
| 363 // of the type. So, we disable the type check of the receiver object on V8 | 338 // of the type. So, we disable the type check of the receiver object on V8 |
| 364 // side so that V8 won't throw. Instead, we do the check on Blink side and | 339 // side so that V8 won't throw. Instead, we do the check on Blink side and |
| 365 // convert an exception to a reject promise. | 340 // convert an exception to a reject promise. |
| 366 if (method.holderCheckConfiguration == V8DOMConfiguration::DoNotCheckHolder) | 341 if (method.holderCheckConfiguration == V8DOMConfiguration::DoNotCheckHolder) |
| 367 signature = v8::Local<v8::Signature>(); | 342 signature = v8::Local<v8::Signature>(); |
| 368 | 343 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 397 } | 372 } |
| 398 | 373 |
| 399 void installMethodInternal( | 374 void installMethodInternal( |
| 400 v8::Isolate* isolate, | 375 v8::Isolate* isolate, |
| 401 v8::Local<v8::Object> instance, | 376 v8::Local<v8::Object> instance, |
| 402 v8::Local<v8::Object> prototype, | 377 v8::Local<v8::Object> prototype, |
| 403 v8::Local<v8::Function> interface, | 378 v8::Local<v8::Function> interface, |
| 404 v8::Local<v8::Signature> signature, | 379 v8::Local<v8::Signature> signature, |
| 405 const V8DOMConfiguration::MethodConfiguration& method, | 380 const V8DOMConfiguration::MethodConfiguration& method, |
| 406 const DOMWrapperWorld& world) { | 381 const DOMWrapperWorld& world) { |
| 407 if (method.exposeConfiguration == | |
| 408 V8DOMConfiguration::OnlyExposedToPrivateScript && | |
| 409 !world.isPrivateScriptIsolatedWorld()) | |
| 410 return; | |
| 411 | |
| 412 v8::Local<v8::Name> name = method.methodName(isolate); | 382 v8::Local<v8::Name> name = method.methodName(isolate); |
| 413 v8::FunctionCallback callback = method.callbackForWorld(world); | 383 v8::FunctionCallback callback = method.callbackForWorld(world); |
| 414 // Promise-returning functions need to return a reject promise when | 384 // Promise-returning functions need to return a reject promise when |
| 415 // an exception occurs. This includes a case that the receiver object is not | 385 // an exception occurs. This includes a case that the receiver object is not |
| 416 // of the type. So, we disable the type check of the receiver object on V8 | 386 // of the type. So, we disable the type check of the receiver object on V8 |
| 417 // side so that V8 won't throw. Instead, we do the check on Blink side and | 387 // side so that V8 won't throw. Instead, we do the check on Blink side and |
| 418 // convert an exception to a reject promise. | 388 // convert an exception to a reject promise. |
| 419 if (method.holderCheckConfiguration == V8DOMConfiguration::DoNotCheckHolder) | 389 if (method.holderCheckConfiguration == V8DOMConfiguration::DoNotCheckHolder) |
| 420 signature = v8::Local<v8::Signature>(); | 390 signature = v8::Local<v8::Signature>(); |
| 421 | 391 |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 void V8DOMConfiguration::setClassString( | 652 void V8DOMConfiguration::setClassString( |
| 683 v8::Isolate* isolate, | 653 v8::Isolate* isolate, |
| 684 v8::Local<v8::ObjectTemplate> objectTemplate, | 654 v8::Local<v8::ObjectTemplate> objectTemplate, |
| 685 const char* classString) { | 655 const char* classString) { |
| 686 objectTemplate->Set( | 656 objectTemplate->Set( |
| 687 v8::Symbol::GetToStringTag(isolate), v8AtomicString(isolate, classString), | 657 v8::Symbol::GetToStringTag(isolate), v8AtomicString(isolate, classString), |
| 688 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); | 658 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum)); |
| 689 } | 659 } |
| 690 | 660 |
| 691 } // namespace blink | 661 } // namespace blink |
| OLD | NEW |