| 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 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 class CORE_EXPORT ScriptController final | 60 class CORE_EXPORT ScriptController final |
| 61 : public GarbageCollected<ScriptController> { | 61 : public GarbageCollected<ScriptController> { |
| 62 WTF_MAKE_NONCOPYABLE(ScriptController); | 62 WTF_MAKE_NONCOPYABLE(ScriptController); |
| 63 | 63 |
| 64 public: | 64 public: |
| 65 enum ExecuteScriptPolicy { | 65 enum ExecuteScriptPolicy { |
| 66 ExecuteScriptWhenScriptsDisabled, | 66 ExecuteScriptWhenScriptsDisabled, |
| 67 DoNotExecuteScriptWhenScriptsDisabled | 67 DoNotExecuteScriptWhenScriptsDisabled |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 static ScriptController* create(LocalFrame* frame) { | 70 static ScriptController* create(LocalWindowProxyManager* windowProxyManager) { |
| 71 return new ScriptController(frame); | 71 return new ScriptController(windowProxyManager); |
| 72 } | 72 } |
| 73 | 73 |
| 74 DECLARE_TRACE(); | 74 DECLARE_TRACE(); |
| 75 | 75 |
| 76 // This returns an initialized window proxy. (If the window proxy is not | 76 // This returns an initialized window proxy. (If the window proxy is not |
| 77 // yet initialized, it's implicitly initialized at the first access.) | 77 // yet initialized, it's implicitly initialized at the first access.) |
| 78 LocalWindowProxy* windowProxy(DOMWrapperWorld&); | 78 LocalWindowProxy* windowProxy(DOMWrapperWorld& world) { |
| 79 return m_windowProxyManager->windowProxy(world); |
| 80 } |
| 79 | 81 |
| 80 // Evaluate JavaScript in the main world. | 82 // Evaluate JavaScript in the main world. |
| 81 void executeScriptInMainWorld( | 83 void executeScriptInMainWorld( |
| 82 const String&, | 84 const String&, |
| 83 ExecuteScriptPolicy = DoNotExecuteScriptWhenScriptsDisabled); | 85 ExecuteScriptPolicy = DoNotExecuteScriptWhenScriptsDisabled); |
| 84 void executeScriptInMainWorld(const ScriptSourceCode&, | 86 void executeScriptInMainWorld(const ScriptSourceCode&, |
| 85 AccessControlStatus = NotSharableCrossOrigin); | 87 AccessControlStatus = NotSharableCrossOrigin); |
| 86 v8::Local<v8::Value> executeScriptInMainWorldAndReturnValue( | 88 v8::Local<v8::Value> executeScriptInMainWorldAndReturnValue( |
| 87 const ScriptSourceCode&, | 89 const ScriptSourceCode&, |
| 88 ExecuteScriptPolicy = DoNotExecuteScriptWhenScriptsDisabled); | 90 ExecuteScriptPolicy = DoNotExecuteScriptWhenScriptsDisabled); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 void updateSecurityOrigin(SecurityOrigin*); | 126 void updateSecurityOrigin(SecurityOrigin*); |
| 125 | 127 |
| 126 void clearForClose(); | 128 void clearForClose(); |
| 127 | 129 |
| 128 // Registers a v8 extension to be available on webpages. Will only | 130 // Registers a v8 extension to be available on webpages. Will only |
| 129 // affect v8 contexts initialized after this call. Takes ownership of | 131 // affect v8 contexts initialized after this call. Takes ownership of |
| 130 // the v8::Extension object passed. | 132 // the v8::Extension object passed. |
| 131 static void registerExtensionIfNeeded(v8::Extension*); | 133 static void registerExtensionIfNeeded(v8::Extension*); |
| 132 static V8Extensions& registeredExtensions(); | 134 static V8Extensions& registeredExtensions(); |
| 133 | 135 |
| 134 v8::Isolate* isolate() const { return m_windowProxyManager->isolate(); } | |
| 135 | |
| 136 LocalWindowProxyManager* getWindowProxyManager() const { | |
| 137 return m_windowProxyManager.get(); | |
| 138 } | |
| 139 | |
| 140 private: | 136 private: |
| 141 explicit ScriptController(LocalFrame*); | 137 explicit ScriptController(LocalWindowProxyManager* windowProxyManager) |
| 138 : m_windowProxyManager(windowProxyManager) {} |
| 142 | 139 |
| 143 LocalFrame* frame() const { return m_windowProxyManager->frame(); } | 140 LocalFrame* frame() const { return m_windowProxyManager->frame(); } |
| 141 v8::Isolate* isolate() const { return m_windowProxyManager->isolate(); } |
| 144 | 142 |
| 145 v8::Local<v8::Value> evaluateScriptInMainWorld(const ScriptSourceCode&, | 143 v8::Local<v8::Value> evaluateScriptInMainWorld(const ScriptSourceCode&, |
| 146 AccessControlStatus, | 144 AccessControlStatus, |
| 147 ExecuteScriptPolicy); | 145 ExecuteScriptPolicy); |
| 148 | 146 |
| 149 Member<LocalWindowProxyManager> m_windowProxyManager; | 147 const Member<LocalWindowProxyManager> m_windowProxyManager; |
| 150 }; | 148 }; |
| 151 | 149 |
| 152 } // namespace blink | 150 } // namespace blink |
| 153 | 151 |
| 154 #endif // ScriptController_h | 152 #endif // ScriptController_h |
| OLD | NEW |