Chromium Code Reviews| 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 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 */ | 30 */ |
| 31 | 31 |
| 32 #include "config.h" | 32 #include "config.h" |
| 33 #include "ScriptController.h" | 33 #include "ScriptController.h" |
| 34 | 34 |
| 35 #include "PlatformSupport.h" | 35 #include "PlatformSupport.h" |
| 36 #include "DartController.h" | |
|
vsm
2011/12/05 17:20:28
We should refactor ScriptController to bindings/pu
| |
| 36 #include "Document.h" | 37 #include "Document.h" |
| 37 #include "ScriptCallStack.h" | 38 #include "ScriptCallStack.h" |
| 38 #include "ScriptCallStackFactory.h" | 39 #include "ScriptCallStackFactory.h" |
| 39 #include "ScriptableDocumentParser.h" | 40 #include "ScriptableDocumentParser.h" |
| 40 #include "DOMWindow.h" | 41 #include "DOMWindow.h" |
| 41 #include "Event.h" | 42 #include "Event.h" |
| 42 #include "EventListener.h" | 43 #include "EventListener.h" |
| 43 #include "EventNames.h" | 44 #include "EventNames.h" |
| 44 #include "Frame.h" | 45 #include "Frame.h" |
| 45 #include "FrameLoaderClient.h" | 46 #include "FrameLoaderClient.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 ScriptController::ScriptController(Frame* frame) | 111 ScriptController::ScriptController(Frame* frame) |
| 111 : m_frame(frame) | 112 : m_frame(frame) |
| 112 , m_sourceURL(0) | 113 , m_sourceURL(0) |
| 113 , m_inExecuteScript(false) | 114 , m_inExecuteScript(false) |
| 114 , m_paused(false) | 115 , m_paused(false) |
| 115 , m_proxy(adoptPtr(new V8Proxy(frame))) | 116 , m_proxy(adoptPtr(new V8Proxy(frame))) |
| 116 #if ENABLE(NETSCAPE_PLUGIN_API) | 117 #if ENABLE(NETSCAPE_PLUGIN_API) |
| 117 , m_wrappedWindowScriptNPObject(0) | 118 , m_wrappedWindowScriptNPObject(0) |
| 118 #endif | 119 #endif |
| 119 { | 120 { |
| 121 // FIXME: should be set from outside. | |
| 122 m_controllers.set("dart", DartController::create(frame)); | |
| 120 } | 123 } |
| 121 | 124 |
| 122 ScriptController::~ScriptController() | 125 ScriptController::~ScriptController() |
| 123 { | 126 { |
| 124 } | 127 } |
| 125 | 128 |
| 126 void ScriptController::clearScriptObjects() | 129 void ScriptController::clearScriptObjects() |
| 127 { | 130 { |
| 128 PluginObjectMap::iterator it = m_pluginObjects.begin(); | 131 PluginObjectMap::iterator it = m_pluginObjects.begin(); |
| 129 for (; it != m_pluginObjects.end(); ++it) { | 132 for (; it != m_pluginObjects.end(); ++it) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 } | 181 } |
| 179 | 182 |
| 180 void ScriptController::setIsolatedWorldSecurityOrigin(int worldID, PassRefPtr<Se curityOrigin> securityOrigin) | 183 void ScriptController::setIsolatedWorldSecurityOrigin(int worldID, PassRefPtr<Se curityOrigin> securityOrigin) |
| 181 { | 184 { |
| 182 m_proxy->setIsolatedWorldSecurityOrigin(worldID, securityOrigin); | 185 m_proxy->setIsolatedWorldSecurityOrigin(worldID, securityOrigin); |
| 183 } | 186 } |
| 184 | 187 |
| 185 // Evaluate a script file in the environment of this proxy. | 188 // Evaluate a script file in the environment of this proxy. |
| 186 ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode) | 189 ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode) |
| 187 { | 190 { |
| 191 if (!sourceCode.mimeType().isEmpty()) { | |
| 192 for (ControllerMap::iterator it = m_controllers.begin(); it != m_control lers.end(); ++it) { | |
| 193 if (it->second->isScriptTypeSupported(sourceCode.mimeType())) { | |
| 194 it->second->evaluate(sourceCode); | |
| 195 return ScriptValue(); | |
| 196 } | |
| 197 } | |
| 198 } | |
| 199 | |
| 188 String sourceURL = sourceCode.url(); | 200 String sourceURL = sourceCode.url(); |
| 189 const String* savedSourceURL = m_sourceURL; | 201 const String* savedSourceURL = m_sourceURL; |
| 190 m_sourceURL = &sourceURL; | 202 m_sourceURL = &sourceURL; |
| 191 | 203 |
| 192 v8::HandleScope handleScope; | 204 v8::HandleScope handleScope; |
| 193 v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(m_proxy->frame ()); | 205 v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(m_proxy->frame ()); |
| 194 if (v8Context.IsEmpty()) | 206 if (v8Context.IsEmpty()) |
| 195 return ScriptValue(); | 207 return ScriptValue(); |
| 196 | 208 |
| 197 v8::Context::Scope scope(v8Context); | 209 v8::Context::Scope scope(v8Context); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 217 } | 229 } |
| 218 | 230 |
| 219 void ScriptController::finishedWithEvent(Event* event) | 231 void ScriptController::finishedWithEvent(Event* event) |
| 220 { | 232 { |
| 221 m_proxy->finishedWithEvent(event); | 233 m_proxy->finishedWithEvent(event); |
| 222 } | 234 } |
| 223 | 235 |
| 224 // Create a V8 object with an interceptor of NPObjectPropertyGetter. | 236 // Create a V8 object with an interceptor of NPObjectPropertyGetter. |
| 225 void ScriptController::bindToWindowObject(Frame* frame, const String& key, NPObj ect* object) | 237 void ScriptController::bindToWindowObject(Frame* frame, const String& key, NPObj ect* object) |
| 226 { | 238 { |
| 239 for (ControllerMap::iterator it = m_controllers.begin(); it != m_controllers .end(); ++it) | |
| 240 it->second->bindToWindowObject(frame, key, object); | |
| 241 | |
| 227 v8::HandleScope handleScope; | 242 v8::HandleScope handleScope; |
| 228 | 243 |
| 229 v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(frame); | 244 v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(frame); |
| 230 if (v8Context.IsEmpty()) | 245 if (v8Context.IsEmpty()) |
| 231 return; | 246 return; |
| 232 | 247 |
| 233 v8::Context::Scope scope(v8Context); | 248 v8::Context::Scope scope(v8Context); |
| 234 | 249 |
| 235 v8::Handle<v8::Object> value = createV8ObjectForNPObject(object, 0); | 250 v8::Handle<v8::Object> value = createV8ObjectForNPObject(object, 0); |
| 236 | 251 |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 439 void ScriptController::namedItemAdded(HTMLDocument* doc, const AtomicString& nam e) | 454 void ScriptController::namedItemAdded(HTMLDocument* doc, const AtomicString& nam e) |
| 440 { | 455 { |
| 441 m_proxy->windowShell()->namedItemAdded(doc, name); | 456 m_proxy->windowShell()->namedItemAdded(doc, name); |
| 442 } | 457 } |
| 443 | 458 |
| 444 void ScriptController::namedItemRemoved(HTMLDocument* doc, const AtomicString& n ame) | 459 void ScriptController::namedItemRemoved(HTMLDocument* doc, const AtomicString& n ame) |
| 445 { | 460 { |
| 446 m_proxy->windowShell()->namedItemRemoved(doc, name); | 461 m_proxy->windowShell()->namedItemRemoved(doc, name); |
| 447 } | 462 } |
| 448 | 463 |
| 464 bool ScriptController::isScriptTypeSupported(const String& mimeType) | |
| 465 { | |
| 466 if (mimeType.isEmpty()) | |
| 467 return false; | |
| 468 for (ControllerMap::iterator it = m_controllers.begin(); it != m_controllers .end(); ++it) { | |
| 469 if (it->second->isScriptTypeSupported(mimeType)) | |
| 470 return true; | |
| 471 } | |
| 472 return false; | |
| 473 } | |
| 474 | |
| 475 AbstractController* ScriptController::controller(const String& name) | |
| 476 { | |
| 477 return m_controllers.get(name).get(); | |
| 478 } | |
| 479 | |
| 449 } // namespace WebCore | 480 } // namespace WebCore |
| OLD | NEW |