OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. |
3 * Copyright (C) 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2009 Apple Inc. All rights reserved. |
4 * Copyright (C) 2014 Opera Software ASA. All rights reserved. | 4 * Copyright (C) 2014 Opera Software ASA. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions are | 7 * modification, are permitted provided that the following conditions are |
8 * met: | 8 * met: |
9 * | 9 * |
10 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 : m_frame(frame) | 94 : m_frame(frame) |
95 , m_sourceURL(0) | 95 , m_sourceURL(0) |
96 , m_isolate(v8::Isolate::GetCurrent()) | 96 , m_isolate(v8::Isolate::GetCurrent()) |
97 , m_windowProxy(WindowProxy::create(frame, DOMWrapperWorld::mainWorld(), m_i solate)) | 97 , m_windowProxy(WindowProxy::create(frame, DOMWrapperWorld::mainWorld(), m_i solate)) |
98 , m_windowScriptNPObject(0) | 98 , m_windowScriptNPObject(0) |
99 { | 99 { |
100 } | 100 } |
101 | 101 |
102 ScriptController::~ScriptController() | 102 ScriptController::~ScriptController() |
103 { | 103 { |
104 // WindowProxy::clearForClose() must be invoked before destruction starts. | 104 } |
105 ASSERT(!m_windowProxy->isContextInitialized()); | 105 |
106 void ScriptController::trace(Visitor* visitor) | |
107 { | |
108 #if ENABLE(OILPAN) | |
109 visitor->trace(m_frame); | |
110 visitor->trace(m_windowProxy); | |
111 visitor->trace(m_isolatedWorlds); | |
112 #endif | |
106 } | 113 } |
107 | 114 |
108 void ScriptController::clearScriptObjects() | 115 void ScriptController::clearScriptObjects() |
109 { | 116 { |
110 PluginObjectMap::iterator it = m_pluginObjects.begin(); | 117 PluginObjectMap::iterator it = m_pluginObjects.begin(); |
111 for (; it != m_pluginObjects.end(); ++it) { | 118 for (; it != m_pluginObjects.end(); ++it) { |
112 _NPN_UnregisterObject(it->value); | 119 _NPN_UnregisterObject(it->value); |
113 _NPN_ReleaseObject(it->value); | 120 _NPN_ReleaseObject(it->value); |
114 } | 121 } |
115 m_pluginObjects.clear(); | 122 m_pluginObjects.clear(); |
(...skipping 19 matching lines...) Expand all Loading... | |
135 } | 142 } |
136 | 143 |
137 void ScriptController::updateSecurityOrigin(SecurityOrigin* origin) | 144 void ScriptController::updateSecurityOrigin(SecurityOrigin* origin) |
138 { | 145 { |
139 m_windowProxy->updateSecurityOrigin(origin); | 146 m_windowProxy->updateSecurityOrigin(origin); |
140 } | 147 } |
141 | 148 |
142 v8::Local<v8::Value> ScriptController::callFunction(v8::Handle<v8::Function> fun ction, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> info[]) | 149 v8::Local<v8::Value> ScriptController::callFunction(v8::Handle<v8::Function> fun ction, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> info[]) |
143 { | 150 { |
144 // Keep LocalFrame (and therefore ScriptController) alive. | 151 // Keep LocalFrame (and therefore ScriptController) alive. |
145 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame); | 152 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); |
146 return ScriptController::callFunction(m_frame->document(), function, receive r, argc, info, m_isolate); | 153 return ScriptController::callFunction(m_frame->document(), function, receive r, argc, info, m_isolate); |
147 } | 154 } |
148 | 155 |
149 v8::Local<v8::Value> ScriptController::callFunction(ExecutionContext* context, v 8::Handle<v8::Function> function, v8::Handle<v8::Value> receiver, int argc, v8:: Handle<v8::Value> info[], v8::Isolate* isolate) | 156 v8::Local<v8::Value> ScriptController::callFunction(ExecutionContext* context, v 8::Handle<v8::Function> function, v8::Handle<v8::Value> receiver, int argc, v8:: Handle<v8::Value> info[], v8::Isolate* isolate) |
150 { | 157 { |
151 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "FunctionCall", "data", devToolsTraceEventData(context, function, isolate)); | 158 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "FunctionCall", "data", devToolsTraceEventData(context, function, isolate)); |
152 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), " CallStack", "stack", InspectorCallStackEvent::currentCallStack()); | 159 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), " CallStack", "stack", InspectorCallStackEvent::currentCallStack()); |
153 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing. | 160 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing. |
154 InspectorInstrumentationCookie cookie; | 161 InspectorInstrumentationCookie cookie; |
155 if (InspectorInstrumentation::timelineAgentEnabled(context)) { | 162 if (InspectorInstrumentation::timelineAgentEnabled(context)) { |
(...skipping 29 matching lines...) Expand all Loading... | |
185 // from here. | 192 // from here. |
186 v8::TryCatch tryCatch; | 193 v8::TryCatch tryCatch; |
187 tryCatch.SetVerbose(true); | 194 tryCatch.SetVerbose(true); |
188 | 195 |
189 v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(source, m_ isolate, corsStatus, v8CacheOptions); | 196 v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(source, m_ isolate, corsStatus, v8CacheOptions); |
190 | 197 |
191 if (compilationFinishTime) { | 198 if (compilationFinishTime) { |
192 *compilationFinishTime = WTF::monotonicallyIncreasingTime(); | 199 *compilationFinishTime = WTF::monotonicallyIncreasingTime(); |
193 } | 200 } |
194 // Keep LocalFrame (and therefore ScriptController) alive. | 201 // Keep LocalFrame (and therefore ScriptController) alive. |
195 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame); | 202 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); |
196 result = V8ScriptRunner::runCompiledScript(script, m_frame->document(), m_isolate); | 203 result = V8ScriptRunner::runCompiledScript(script, m_frame->document(), m_isolate); |
197 ASSERT(!tryCatch.HasCaught() || result.IsEmpty()); | 204 ASSERT(!tryCatch.HasCaught() || result.IsEmpty()); |
198 } | 205 } |
199 | 206 |
200 InspectorInstrumentation::didEvaluateScript(cookie); | 207 InspectorInstrumentation::didEvaluateScript(cookie); |
201 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", "data", InspectorUpdateCountersEvent::data()); | 208 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", "data", InspectorUpdateCountersEvent::data()); |
202 | 209 |
203 return result; | 210 return result; |
204 } | 211 } |
205 | 212 |
(...skipping 10 matching lines...) Expand all Loading... | |
216 return m_windowProxy->isContextInitialized() ? m_windowProxy.get() : 0; | 223 return m_windowProxy->isContextInitialized() ? m_windowProxy.get() : 0; |
217 | 224 |
218 IsolatedWorldMap::iterator iter = m_isolatedWorlds.find(world.worldId()); | 225 IsolatedWorldMap::iterator iter = m_isolatedWorlds.find(world.worldId()); |
219 if (iter == m_isolatedWorlds.end()) | 226 if (iter == m_isolatedWorlds.end()) |
220 return 0; | 227 return 0; |
221 return iter->value->isContextInitialized() ? iter->value.get() : 0; | 228 return iter->value->isContextInitialized() ? iter->value.get() : 0; |
222 } | 229 } |
223 | 230 |
224 WindowProxy* ScriptController::windowProxy(DOMWrapperWorld& world) | 231 WindowProxy* ScriptController::windowProxy(DOMWrapperWorld& world) |
225 { | 232 { |
226 WindowProxy* windowProxy = 0; | 233 WindowProxy* windowProxy = nullptr; |
227 if (world.isMainWorld()) { | 234 if (world.isMainWorld()) { |
228 windowProxy = m_windowProxy.get(); | 235 windowProxy = m_windowProxy.get(); |
229 } else { | 236 } else { |
230 IsolatedWorldMap::iterator iter = m_isolatedWorlds.find(world.worldId()) ; | 237 IsolatedWorldMap::iterator iter = m_isolatedWorlds.find(world.worldId()) ; |
231 if (iter != m_isolatedWorlds.end()) { | 238 if (iter != m_isolatedWorlds.end()) { |
232 windowProxy = iter->value.get(); | 239 windowProxy = iter->value.get(); |
233 } else { | 240 } else { |
234 OwnPtr<WindowProxy> isolatedWorldWindowProxy = WindowProxy::create(m _frame, world, m_isolate); | 241 OwnPtrWillBeMember<WindowProxy> isolatedWorldWindowProxy = WindowPro xy::create(m_frame, world, m_isolate); |
haraken
2014/10/05 23:37:26
OwnPtrWillBeRawPtr ?
sof
2014/10/06 07:34:40
Thanks, fixed up.
| |
235 windowProxy = isolatedWorldWindowProxy.get(); | 242 windowProxy = isolatedWorldWindowProxy.get(); |
236 m_isolatedWorlds.set(world.worldId(), isolatedWorldWindowProxy.relea se()); | 243 m_isolatedWorlds.set(world.worldId(), isolatedWorldWindowProxy.relea se()); |
237 } | 244 } |
238 } | 245 } |
239 if (!windowProxy->isContextInitialized() && windowProxy->initializeIfNeeded( ) && world.isMainWorld()) | 246 if (!windowProxy->isContextInitialized() && windowProxy->initializeIfNeeded( ) && world.isMainWorld()) |
240 m_frame->loader().dispatchDidClearWindowObjectInMainWorld(); | 247 m_frame->loader().dispatchDidClearWindowObjectInMainWorld(); |
241 return windowProxy; | 248 return windowProxy; |
242 } | 249 } |
243 | 250 |
244 bool ScriptController::shouldBypassMainWorldCSP() | 251 bool ScriptController::shouldBypassMainWorldCSP() |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
530 { | 537 { |
531 if (!protocolIsJavaScript(url)) | 538 if (!protocolIsJavaScript(url)) |
532 return false; | 539 return false; |
533 | 540 |
534 if (!m_frame->page() | 541 if (!m_frame->page() |
535 || !m_frame->document()->contentSecurityPolicy()->allowJavaScriptURLs(m_ frame->document()->url(), eventHandlerPosition().m_line)) | 542 || !m_frame->document()->contentSecurityPolicy()->allowJavaScriptURLs(m_ frame->document()->url(), eventHandlerPosition().m_line)) |
536 return true; | 543 return true; |
537 | 544 |
538 // We need to hold onto the LocalFrame here because executing script can | 545 // We need to hold onto the LocalFrame here because executing script can |
539 // destroy the frame. | 546 // destroy the frame. |
540 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame); | 547 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); |
541 RefPtrWillBeRawPtr<Document> ownerDocument(m_frame->document()); | 548 RefPtrWillBeRawPtr<Document> ownerDocument(m_frame->document()); |
542 | 549 |
543 const int javascriptSchemeLength = sizeof("javascript:") - 1; | 550 const int javascriptSchemeLength = sizeof("javascript:") - 1; |
544 | 551 |
545 bool locationChangeBefore = m_frame->navigationScheduler().locationChangePen ding(); | 552 bool locationChangeBefore = m_frame->navigationScheduler().locationChangePen ding(); |
546 | 553 |
547 String decodedURL = decodeURLEscapeSequences(url.string()); | 554 String decodedURL = decodeURLEscapeSequences(url.string()); |
548 v8::HandleScope handleScope(m_isolate); | 555 v8::HandleScope handleScope(m_isolate); |
549 v8::Local<v8::Value> result = evaluateScriptInMainWorld(ScriptSourceCode(dec odedURL.substring(javascriptSchemeLength)), NotSharableCrossOrigin, DoNotExecute ScriptWhenScriptsDisabled); | 556 v8::Local<v8::Value> result = evaluateScriptInMainWorld(ScriptSourceCode(dec odedURL.substring(javascriptSchemeLength)), NotSharableCrossOrigin, DoNotExecute ScriptWhenScriptsDisabled); |
550 | 557 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
593 m_sourceURL = &sourceURL; | 600 m_sourceURL = &sourceURL; |
594 | 601 |
595 v8::EscapableHandleScope handleScope(m_isolate); | 602 v8::EscapableHandleScope handleScope(m_isolate); |
596 v8::Handle<v8::Context> context = toV8Context(m_frame, DOMWrapperWorld::main World()); | 603 v8::Handle<v8::Context> context = toV8Context(m_frame, DOMWrapperWorld::main World()); |
597 if (context.IsEmpty()) | 604 if (context.IsEmpty()) |
598 return v8::Local<v8::Value>(); | 605 return v8::Local<v8::Value>(); |
599 | 606 |
600 ScriptState* scriptState = ScriptState::from(context); | 607 ScriptState* scriptState = ScriptState::from(context); |
601 ScriptState::Scope scope(scriptState); | 608 ScriptState::Scope scope(scriptState); |
602 | 609 |
603 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame); | 610 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); |
604 if (m_frame->loader().stateMachine()->isDisplayingInitialEmptyDocument()) | 611 if (m_frame->loader().stateMachine()->isDisplayingInitialEmptyDocument()) |
605 m_frame->loader().didAccessInitialDocument(); | 612 m_frame->loader().didAccessInitialDocument(); |
606 | 613 |
607 OwnPtr<ScriptSourceCode> maybeProcessedSourceCode = InspectorInstrumentatio n::preprocess(m_frame, sourceCode); | 614 OwnPtr<ScriptSourceCode> maybeProcessedSourceCode = InspectorInstrumentatio n::preprocess(m_frame, sourceCode); |
608 const ScriptSourceCode& sourceCodeToCompile = maybeProcessedSourceCode ? *ma ybeProcessedSourceCode : sourceCode; | 615 const ScriptSourceCode& sourceCodeToCompile = maybeProcessedSourceCode ? *ma ybeProcessedSourceCode : sourceCode; |
609 | 616 |
610 v8::Local<v8::Value> object = executeScriptAndReturnValue(scriptState->conte xt(), sourceCodeToCompile, corsStatus, compilationFinishTime); | 617 v8::Local<v8::Value> object = executeScriptAndReturnValue(scriptState->conte xt(), sourceCodeToCompile, corsStatus, compilationFinishTime); |
611 m_sourceURL = savedSourceURL; | 618 m_sourceURL = savedSourceURL; |
612 | 619 |
613 if (object.IsEmpty()) | 620 if (object.IsEmpty()) |
(...skipping 23 matching lines...) Expand all Loading... | |
637 resultArray->Set(i, evaluationResult); | 644 resultArray->Set(i, evaluationResult); |
638 } | 645 } |
639 | 646 |
640 if (results) { | 647 if (results) { |
641 for (size_t i = 0; i < resultArray->Length(); ++i) | 648 for (size_t i = 0; i < resultArray->Length(); ++i) |
642 results->append(handleScope.Escape(resultArray->Get(i))); | 649 results->append(handleScope.Escape(resultArray->Get(i))); |
643 } | 650 } |
644 } | 651 } |
645 | 652 |
646 } // namespace blink | 653 } // namespace blink |
OLD | NEW |