| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "bindings/core/v8/ScriptState.h" | 5 #include "bindings/core/v8/ScriptState.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/V8Binding.h" | 7 #include "bindings/core/v8/V8Binding.h" |
| 8 #include "core/dom/ExecutionContext.h" | 8 #include "core/dom/ExecutionContext.h" |
| 9 #include "core/frame/LocalDOMWindow.h" | 9 #include "core/frame/LocalDOMWindow.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 #if ENABLE(ASSERT) | 59 #if ENABLE(ASSERT) |
| 60 m_globalObjectDetached = true; | 60 m_globalObjectDetached = true; |
| 61 #endif | 61 #endif |
| 62 } | 62 } |
| 63 | 63 |
| 64 void ScriptState::disposePerContextData() | 64 void ScriptState::disposePerContextData() |
| 65 { | 65 { |
| 66 m_perContextData = nullptr; | 66 m_perContextData = nullptr; |
| 67 } | 67 } |
| 68 | 68 |
| 69 bool ScriptState::evalEnabled() const | |
| 70 { | |
| 71 v8::HandleScope handleScope(m_isolate); | |
| 72 return context()->IsCodeGenerationFromStringsAllowed(); | |
| 73 } | |
| 74 | |
| 75 void ScriptState::setEvalEnabled(bool enabled) | |
| 76 { | |
| 77 v8::HandleScope handleScope(m_isolate); | |
| 78 return context()->AllowCodeGenerationFromStrings(enabled); | |
| 79 } | |
| 80 | |
| 81 ScriptValue ScriptState::getFromGlobalObject(const char* name) | |
| 82 { | |
| 83 v8::HandleScope handleScope(m_isolate); | |
| 84 v8::Local<v8::Value> v8Value; | |
| 85 if (!context()->Global()->Get(context(), v8AtomicString(isolate(), name)).To
Local(&v8Value)) | |
| 86 return ScriptValue(); | |
| 87 return ScriptValue(this, v8Value); | |
| 88 } | |
| 89 | |
| 90 ScriptValue ScriptState::getFromExtrasExports(const char* name) | 69 ScriptValue ScriptState::getFromExtrasExports(const char* name) |
| 91 { | 70 { |
| 92 v8::HandleScope handleScope(m_isolate); | 71 v8::HandleScope handleScope(m_isolate); |
| 93 v8::Local<v8::Value> v8Value; | 72 v8::Local<v8::Value> v8Value; |
| 94 if (!context()->GetExtrasBindingObject()->Get(context(), v8AtomicString(isol
ate(), name)).ToLocal(&v8Value)) | 73 if (!context()->GetExtrasBindingObject()->Get(context(), v8AtomicString(isol
ate(), name)).ToLocal(&v8Value)) |
| 95 return ScriptValue(); | 74 return ScriptValue(); |
| 96 return ScriptValue(this, v8Value); | 75 return ScriptValue(this, v8Value); |
| 97 } | 76 } |
| 98 | 77 |
| 99 ExecutionContext* ScriptState::getExecutionContext() const | 78 ExecutionContext* ScriptState::getExecutionContext() const |
| (...skipping 30 matching lines...) Expand all Loading... |
| 130 v8::HandleScope handleScope(toIsolate(frame)); | 109 v8::HandleScope handleScope(toIsolate(frame)); |
| 131 v8::Local<v8::Context> context = toV8Context(frame, world); | 110 v8::Local<v8::Context> context = toV8Context(frame, world); |
| 132 if (context.IsEmpty()) | 111 if (context.IsEmpty()) |
| 133 return nullptr; | 112 return nullptr; |
| 134 ScriptState* scriptState = ScriptState::from(context); | 113 ScriptState* scriptState = ScriptState::from(context); |
| 135 ASSERT(scriptState->contextIsValid()); | 114 ASSERT(scriptState->contextIsValid()); |
| 136 return scriptState; | 115 return scriptState; |
| 137 } | 116 } |
| 138 | 117 |
| 139 } // namespace blink | 118 } // namespace blink |
| OLD | NEW |