| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 bool executeScriptIfJavaScriptURL(const KURL&); | 108 bool executeScriptIfJavaScriptURL(const KURL&); |
| 109 | 109 |
| 110 v8::MaybeLocal<v8::Value> callFunction(v8::Local<v8::Function>, v8::Local<v8
::Value>, int argc, v8::Local<v8::Value> argv[]); | 110 v8::MaybeLocal<v8::Value> callFunction(v8::Local<v8::Function>, v8::Local<v8
::Value>, int argc, v8::Local<v8::Value> argv[]); |
| 111 static v8::MaybeLocal<v8::Value> callFunction(ExecutionContext*, v8::Local<v
8::Function>, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info
[], v8::Isolate*); | 111 static v8::MaybeLocal<v8::Value> callFunction(ExecutionContext*, v8::Local<v
8::Function>, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info
[], v8::Isolate*); |
| 112 | 112 |
| 113 // Returns true if the current world is isolated, and has its own Content | 113 // Returns true if the current world is isolated, and has its own Content |
| 114 // Security Policy. In this case, the policy of the main world should be | 114 // Security Policy. In this case, the policy of the main world should be |
| 115 // ignored when evaluating resources injected into the DOM. | 115 // ignored when evaluating resources injected into the DOM. |
| 116 bool shouldBypassMainWorldCSP(); | 116 bool shouldBypassMainWorldCSP(); |
| 117 | 117 |
| 118 // Creates a property of the global object of a frame. | |
| 119 bool bindToWindowObject(LocalFrame*, const String& key, NPObject*); | |
| 120 | |
| 121 PassRefPtr<SharedPersistent<v8::Object>> createPluginWrapper(Widget*); | 118 PassRefPtr<SharedPersistent<v8::Object>> createPluginWrapper(Widget*); |
| 122 | 119 |
| 123 void enableEval(); | 120 void enableEval(); |
| 124 void disableEval(const String& errorMessage); | 121 void disableEval(const String& errorMessage); |
| 125 | 122 |
| 126 static bool canAccessFromCurrentOrigin(LocalFrame*); | 123 static bool canAccessFromCurrentOrigin(LocalFrame*); |
| 127 | 124 |
| 128 static void setCaptureCallStackForUncaughtExceptions(v8::Isolate*, bool); | 125 static void setCaptureCallStackForUncaughtExceptions(v8::Isolate*, bool); |
| 129 void collectIsolatedContexts(Vector<std::pair<ScriptState*, SecurityOrigin*>
>&); | 126 void collectIsolatedContexts(Vector<std::pair<ScriptState*, SecurityOrigin*>
>&); |
| 130 | 127 |
| 131 bool canExecuteScripts(ReasonForCallingCanExecuteScripts); | 128 bool canExecuteScripts(ReasonForCallingCanExecuteScripts); |
| 132 | 129 |
| 133 TextPosition eventHandlerPosition() const; | 130 TextPosition eventHandlerPosition() const; |
| 134 | 131 |
| 135 void clearWindowProxy(); | 132 void clearWindowProxy(); |
| 136 void updateDocument(); | 133 void updateDocument(); |
| 137 | 134 |
| 138 void namedItemAdded(HTMLDocument*, const AtomicString&); | 135 void namedItemAdded(HTMLDocument*, const AtomicString&); |
| 139 void namedItemRemoved(HTMLDocument*, const AtomicString&); | 136 void namedItemRemoved(HTMLDocument*, const AtomicString&); |
| 140 | 137 |
| 141 void updateSecurityOrigin(SecurityOrigin*); | 138 void updateSecurityOrigin(SecurityOrigin*); |
| 142 void clearScriptObjects(); | |
| 143 void cleanupScriptObjectsForPlugin(Widget*); | |
| 144 | 139 |
| 145 void clearForClose(); | 140 void clearForClose(); |
| 146 | 141 |
| 147 NPObject* createScriptObjectForPluginElement(HTMLPlugInElement*); | |
| 148 NPObject* windowScriptNPObject(); | |
| 149 | |
| 150 // Registers a v8 extension to be available on webpages. Will only | 142 // Registers a v8 extension to be available on webpages. Will only |
| 151 // affect v8 contexts initialized after this call. Takes ownership of | 143 // affect v8 contexts initialized after this call. Takes ownership of |
| 152 // the v8::Extension object passed. | 144 // the v8::Extension object passed. |
| 153 static void registerExtensionIfNeeded(v8::Extension*); | 145 static void registerExtensionIfNeeded(v8::Extension*); |
| 154 static V8Extensions& registeredExtensions(); | 146 static V8Extensions& registeredExtensions(); |
| 155 | 147 |
| 156 v8::Isolate* isolate() const { return m_windowProxyManager->isolate(); } | 148 v8::Isolate* isolate() const { return m_windowProxyManager->isolate(); } |
| 157 | 149 |
| 158 WindowProxyManager* windowProxyManager() const { return m_windowProxyManager
.get(); } | 150 WindowProxyManager* windowProxyManager() const { return m_windowProxyManager
.get(); } |
| 159 | 151 |
| 160 private: | 152 private: |
| 161 explicit ScriptController(LocalFrame*); | 153 explicit ScriptController(LocalFrame*); |
| 162 | 154 |
| 163 LocalFrame* frame() const { return toLocalFrame(m_windowProxyManager->frame(
)); } | 155 LocalFrame* frame() const { return toLocalFrame(m_windowProxyManager->frame(
)); } |
| 164 | 156 |
| 165 typedef WillBeHeapHashMap<RawPtrWillBeMember<Widget>, NPObject*> PluginObjec
tMap; | |
| 166 | |
| 167 v8::Local<v8::Value> evaluateScriptInMainWorld(const ScriptSourceCode&, Acce
ssControlStatus, ExecuteScriptPolicy, double* compilationFinishTime = 0); | 157 v8::Local<v8::Value> evaluateScriptInMainWorld(const ScriptSourceCode&, Acce
ssControlStatus, ExecuteScriptPolicy, double* compilationFinishTime = 0); |
| 168 | 158 |
| 169 OwnPtrWillBeMember<WindowProxyManager> m_windowProxyManager; | 159 OwnPtrWillBeMember<WindowProxyManager> m_windowProxyManager; |
| 170 const String* m_sourceURL; | 160 const String* m_sourceURL; |
| 171 | |
| 172 // A mapping between Widgets and their corresponding script object. | |
| 173 // This list is used so that when the plugin dies, we can immediately | |
| 174 // invalidate all sub-objects which are associated with that plugin. | |
| 175 // The frame keeps a NPObject reference for each item on the list. | |
| 176 PluginObjectMap m_pluginObjects; | |
| 177 | |
| 178 NPObject* m_windowScriptNPObject; | |
| 179 }; | 161 }; |
| 180 | 162 |
| 181 } // namespace blink | 163 } // namespace blink |
| 182 | 164 |
| 183 #endif // ScriptController_h | 165 #endif // ScriptController_h |
| OLD | NEW |