OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 * This means interceptors in the prototype chain are not called. | 1045 * This means interceptors in the prototype chain are not called. |
1046 */ | 1046 */ |
1047 Handle<Value> GetRealNamedPropertyInPrototypeChain(Handle<String> key); | 1047 Handle<Value> GetRealNamedPropertyInPrototypeChain(Handle<String> key); |
1048 | 1048 |
1049 /** Tests for a named lookup interceptor.*/ | 1049 /** Tests for a named lookup interceptor.*/ |
1050 bool HasNamedLookupInterceptor(); | 1050 bool HasNamedLookupInterceptor(); |
1051 | 1051 |
1052 /** Tests for an index lookup interceptor.*/ | 1052 /** Tests for an index lookup interceptor.*/ |
1053 bool HasIndexedLookupInterceptor(); | 1053 bool HasIndexedLookupInterceptor(); |
1054 | 1054 |
| 1055 /** |
| 1056 * Turns on access check on the object if the object is an instance of |
| 1057 * a template that has access check callbacks. If an object has no |
| 1058 * access check info, the object cannot be accessed by anyone. |
| 1059 */ |
| 1060 void TurnOnAccessCheck(); |
1055 | 1061 |
1056 static Local<Object> New(); | 1062 static Local<Object> New(); |
1057 static Object* Cast(Value* obj); | 1063 static Object* Cast(Value* obj); |
1058 private: | 1064 private: |
1059 Object(); | 1065 Object(); |
1060 }; | 1066 }; |
1061 | 1067 |
1062 | 1068 |
1063 /** | 1069 /** |
1064 * An instance of the built-in array constructor (ECMA-262, 15.4.2). | 1070 * An instance of the built-in array constructor (ECMA-262, 15.4.2). |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1602 * normal objects. | 1608 * normal objects. |
1603 */ | 1609 */ |
1604 void MarkAsUndetectable(); | 1610 void MarkAsUndetectable(); |
1605 | 1611 |
1606 /** | 1612 /** |
1607 * Sets access check callbacks on the object template. | 1613 * Sets access check callbacks on the object template. |
1608 * | 1614 * |
1609 * When accessing properties on instances of this object template, | 1615 * When accessing properties on instances of this object template, |
1610 * the access check callback will be called to determine whether or | 1616 * the access check callback will be called to determine whether or |
1611 * not to allow cross-context access to the properties. | 1617 * not to allow cross-context access to the properties. |
| 1618 * The last parameter specifies whether access checks are turned |
| 1619 * on by default on instances. If access checks are off by default, |
| 1620 * they can be turned on on individual instances by calling |
| 1621 * Object::TurnOnAccessCheck(). |
1612 */ | 1622 */ |
1613 void SetAccessCheckCallbacks(NamedSecurityCallback named_handler, | 1623 void SetAccessCheckCallbacks(NamedSecurityCallback named_handler, |
1614 IndexedSecurityCallback indexed_handler, | 1624 IndexedSecurityCallback indexed_handler, |
1615 Handle<Value> data = Handle<Value>()); | 1625 Handle<Value> data = Handle<Value>(), |
| 1626 bool turned_on_by_default = true); |
1616 | 1627 |
1617 /** | 1628 /** |
1618 * Gets the number of internal fields for objects generated from | 1629 * Gets the number of internal fields for objects generated from |
1619 * this template. | 1630 * this template. |
1620 */ | 1631 */ |
1621 int InternalFieldCount(); | 1632 int InternalFieldCount(); |
1622 | 1633 |
1623 /** | 1634 /** |
1624 * Sets the number of internal fields for objects generated from | 1635 * Sets the number of internal fields for objects generated from |
1625 * this template. | 1636 * this template. |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2037 const char** names_; | 2048 const char** names_; |
2038 }; | 2049 }; |
2039 | 2050 |
2040 | 2051 |
2041 /** | 2052 /** |
2042 * A sandboxed execution context with its own set of built-in objects | 2053 * A sandboxed execution context with its own set of built-in objects |
2043 * and functions. | 2054 * and functions. |
2044 */ | 2055 */ |
2045 class EXPORT Context { | 2056 class EXPORT Context { |
2046 public: | 2057 public: |
| 2058 /** Returns the global object of the context. */ |
2047 Local<Object> Global(); | 2059 Local<Object> Global(); |
2048 | 2060 |
| 2061 /** |
| 2062 * Detaches the global object from its context before |
| 2063 * the global object can be reused to create a new context. |
| 2064 */ |
| 2065 void DetachGlobal(); |
| 2066 |
2049 /** Creates a new context. */ | 2067 /** Creates a new context. */ |
2050 static Persistent<Context> New( | 2068 static Persistent<Context> New( |
2051 ExtensionConfiguration* extensions = 0, | 2069 ExtensionConfiguration* extensions = 0, |
2052 Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(), | 2070 Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(), |
2053 Handle<Value> global_object = Handle<Value>()); | 2071 Handle<Value> global_object = Handle<Value>()); |
2054 | 2072 |
2055 /** Returns the last entered context. */ | 2073 /** Returns the last entered context. */ |
2056 static Local<Context> GetEntered(); | 2074 static Local<Context> GetEntered(); |
2057 | 2075 |
2058 /** Returns the context that is on the top of the stack. */ | 2076 /** Returns the context that is on the top of the stack. */ |
2059 static Local<Context> GetCurrent(); | 2077 static Local<Context> GetCurrent(); |
2060 | 2078 |
2061 /** Returns the security context that is currently used. */ | |
2062 static Local<Context> GetCurrentSecurityContext(); | |
2063 | |
2064 /** | 2079 /** |
2065 * Sets the security token for the context. To access an object in | 2080 * Sets the security token for the context. To access an object in |
2066 * another context, the security tokens must match. | 2081 * another context, the security tokens must match. |
2067 */ | 2082 */ |
2068 void SetSecurityToken(Handle<Value> token); | 2083 void SetSecurityToken(Handle<Value> token); |
2069 | 2084 |
| 2085 /** Restores the security token to the default value. */ |
| 2086 void UseDefaultSecurityToken(); |
| 2087 |
2070 /** Returns the security token of this context.*/ | 2088 /** Returns the security token of this context.*/ |
2071 Handle<Value> GetSecurityToken(); | 2089 Handle<Value> GetSecurityToken(); |
2072 | 2090 |
2073 /** | 2091 /** |
2074 * Enter this context. After entering a context, all code compiled | 2092 * Enter this context. After entering a context, all code compiled |
2075 * and run is compiled and run in this context. If another context | 2093 * and run is compiled and run in this context. If another context |
2076 * is already entered, this old context is saved so it can be | 2094 * is already entered, this old context is saved so it can be |
2077 * restored when the new context is exited. | 2095 * restored when the new context is exited. |
2078 */ | 2096 */ |
2079 void Enter(); | 2097 void Enter(); |
2080 | 2098 |
2081 /** | 2099 /** |
2082 * Exit this context. Exiting the current context restores the | 2100 * Exit this context. Exiting the current context restores the |
2083 * context that was in place when entering the current context. | 2101 * context that was in place when entering the current context. |
2084 */ | 2102 */ |
2085 void Exit(); | 2103 void Exit(); |
2086 | 2104 |
2087 /** Returns true if the context has experienced an out of memory situation. */ | 2105 /** Returns true if the context has experienced an out of memory situation. */ |
2088 bool HasOutOfMemoryException(); | 2106 bool HasOutOfMemoryException(); |
2089 | 2107 |
2090 /** Returns true if V8 has a current context. */ | 2108 /** Returns true if V8 has a current context. */ |
2091 static bool InContext(); | 2109 static bool InContext(); |
2092 | 2110 |
2093 /** Returns true if V8 has a current security context. */ | |
2094 static bool InSecurityContext(); | |
2095 | |
2096 /** | 2111 /** |
2097 * Stack-allocated class which sets the execution context for all | 2112 * Stack-allocated class which sets the execution context for all |
2098 * operations executed within a local scope. | 2113 * operations executed within a local scope. |
2099 */ | 2114 */ |
2100 class EXPORT Scope { | 2115 class EXPORT Scope { |
2101 public: | 2116 public: |
2102 inline Scope(Handle<Context> context) : context_(context) { | 2117 inline Scope(Handle<Context> context) : context_(context) { |
2103 context_->Enter(); | 2118 context_->Enter(); |
2104 } | 2119 } |
2105 inline ~Scope() { context_->Exit(); } | 2120 inline ~Scope() { context_->Exit(); } |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2393 | 2408 |
2394 } // namespace v8 | 2409 } // namespace v8 |
2395 | 2410 |
2396 | 2411 |
2397 #undef EXPORT | 2412 #undef EXPORT |
2398 #undef EXPORT_INLINE | 2413 #undef EXPORT_INLINE |
2399 #undef TYPE_CHECK | 2414 #undef TYPE_CHECK |
2400 | 2415 |
2401 | 2416 |
2402 #endif // V8_H_ | 2417 #endif // V8_H_ |
OLD | NEW |