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 "config.h" | 5 #include "config.h" |
6 #include "bindings/core/v8/ScriptState.h" | 6 #include "bindings/core/v8/ScriptState.h" |
7 | 7 |
8 #include "bindings/core/v8/V8Binding.h" | 8 #include "bindings/core/v8/V8Binding.h" |
9 #include "core/dom/ExecutionContext.h" | 9 #include "core/dom/ExecutionContext.h" |
10 #include "core/frame/LocalDOMWindow.h" | 10 #include "core/frame/LocalDOMWindow.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 void ScriptState::setEvalEnabled(bool enabled) | 82 void ScriptState::setEvalEnabled(bool enabled) |
83 { | 83 { |
84 v8::HandleScope handleScope(m_isolate); | 84 v8::HandleScope handleScope(m_isolate); |
85 return context()->AllowCodeGenerationFromStrings(enabled); | 85 return context()->AllowCodeGenerationFromStrings(enabled); |
86 } | 86 } |
87 | 87 |
88 ScriptValue ScriptState::getFromGlobalObject(const char* name) | 88 ScriptValue ScriptState::getFromGlobalObject(const char* name) |
89 { | 89 { |
90 v8::HandleScope handleScope(m_isolate); | 90 v8::HandleScope handleScope(m_isolate); |
91 v8::Local<v8::Value> v8Value = context()->Global()->Get(v8AtomicString(isola
te(), name)); | 91 v8::Local<v8::Value> v8Value; |
| 92 if (!context()->Global()->Get(context(), v8AtomicString(isolate(), name)).To
Local(&v8Value)) |
| 93 return ScriptValue(); |
92 return ScriptValue(this, v8Value); | 94 return ScriptValue(this, v8Value); |
93 } | 95 } |
94 | 96 |
95 ExecutionContext* ScriptState::executionContext() const | 97 ExecutionContext* ScriptState::executionContext() const |
96 { | 98 { |
97 v8::HandleScope scope(m_isolate); | 99 v8::HandleScope scope(m_isolate); |
98 return toExecutionContext(context()); | 100 return toExecutionContext(context()); |
99 } | 101 } |
100 | 102 |
101 void ScriptState::setExecutionContext(ExecutionContext*) | 103 void ScriptState::setExecutionContext(ExecutionContext*) |
102 { | 104 { |
103 ASSERT_NOT_REACHED(); | 105 ASSERT_NOT_REACHED(); |
104 } | 106 } |
105 | 107 |
106 LocalDOMWindow* ScriptState::domWindow() const | 108 LocalDOMWindow* ScriptState::domWindow() const |
107 { | 109 { |
108 v8::HandleScope scope(m_isolate); | 110 v8::HandleScope scope(m_isolate); |
109 return toLocalDOMWindow(toDOMWindow(context())); | 111 return toLocalDOMWindow(toDOMWindow(context())); |
110 } | 112 } |
111 | 113 |
112 ScriptState* ScriptState::forMainWorld(LocalFrame* frame) | 114 ScriptState* ScriptState::forMainWorld(LocalFrame* frame) |
113 { | 115 { |
114 v8::Isolate* isolate = toIsolate(frame); | 116 v8::Isolate* isolate = toIsolate(frame); |
115 v8::HandleScope handleScope(isolate); | 117 v8::HandleScope handleScope(isolate); |
116 return ScriptState::from(toV8Context(frame, DOMWrapperWorld::mainWorld())); | 118 return ScriptState::from(toV8Context(frame, DOMWrapperWorld::mainWorld())); |
117 } | 119 } |
118 | 120 |
119 } | 121 } |
OLD | NEW |