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 20 matching lines...) Expand all Loading... | |
31 #ifndef ScriptController_h | 31 #ifndef ScriptController_h |
32 #define ScriptController_h | 32 #define ScriptController_h |
33 | 33 |
34 #include "bindings/core/v8/ScriptValue.h" | 34 #include "bindings/core/v8/ScriptValue.h" |
35 #include "bindings/core/v8/SharedPersistent.h" | 35 #include "bindings/core/v8/SharedPersistent.h" |
36 | 36 |
37 #include "core/fetch/CrossOriginAccessControl.h" | 37 #include "core/fetch/CrossOriginAccessControl.h" |
38 #include "wtf/Forward.h" | 38 #include "wtf/Forward.h" |
39 #include "wtf/HashMap.h" | 39 #include "wtf/HashMap.h" |
40 #include "wtf/RefCounted.h" | 40 #include "wtf/RefCounted.h" |
41 #include "wtf/TemporaryChange.h" | |
41 #include "wtf/Vector.h" | 42 #include "wtf/Vector.h" |
42 #include "wtf/text/TextPosition.h" | 43 #include "wtf/text/TextPosition.h" |
43 #include <v8.h> | 44 #include <v8.h> |
44 | 45 |
45 struct NPObject; | 46 struct NPObject; |
46 | 47 |
47 namespace blink { | 48 namespace blink { |
48 | 49 |
49 class DOMWrapperWorld; | 50 class DOMWrapperWorld; |
50 class ExecutionContext; | 51 class ExecutionContext; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 | 99 |
99 // Returns true if argument is a JavaScript URL. | 100 // Returns true if argument is a JavaScript URL. |
100 bool executeScriptIfJavaScriptURL(const KURL&); | 101 bool executeScriptIfJavaScriptURL(const KURL&); |
101 | 102 |
102 v8::Local<v8::Value> callFunction(v8::Handle<v8::Function>, v8::Handle<v8::V alue>, int argc, v8::Handle<v8::Value> argv[]); | 103 v8::Local<v8::Value> callFunction(v8::Handle<v8::Function>, v8::Handle<v8::V alue>, int argc, v8::Handle<v8::Value> argv[]); |
103 static v8::Local<v8::Value> callFunction(ExecutionContext*, v8::Handle<v8::F unction>, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> info[] , v8::Isolate*); | 104 static v8::Local<v8::Value> callFunction(ExecutionContext*, v8::Handle<v8::F unction>, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> info[] , v8::Isolate*); |
104 | 105 |
105 // Returns true if the current world is isolated, and has its own Content | 106 // Returns true if the current world is isolated, and has its own Content |
106 // Security Policy. In this case, the policy of the main world should be | 107 // Security Policy. In this case, the policy of the main world should be |
107 // ignored when evaluating resources injected into the DOM. | 108 // ignored when evaluating resources injected into the DOM. |
109 // Alternatively, this can be explicitly forced to true within a scope | |
110 // using BypassMainWorldCSP. | |
108 bool shouldBypassMainWorldCSP(); | 111 bool shouldBypassMainWorldCSP(); |
109 | 112 |
110 // Creates a property of the global object of a frame. | 113 // Creates a property of the global object of a frame. |
111 void bindToWindowObject(LocalFrame*, const String& key, NPObject*); | 114 void bindToWindowObject(LocalFrame*, const String& key, NPObject*); |
112 | 115 |
113 PassRefPtr<SharedPersistent<v8::Object> > createPluginWrapper(Widget*); | 116 PassRefPtr<SharedPersistent<v8::Object> > createPluginWrapper(Widget*); |
114 | 117 |
115 void enableEval(); | 118 void enableEval(); |
116 void disableEval(const String& errorMessage); | 119 void disableEval(const String& errorMessage); |
117 | 120 |
(...skipping 24 matching lines...) Expand all Loading... | |
142 // Registers a v8 extension to be available on webpages. Will only | 145 // Registers a v8 extension to be available on webpages. Will only |
143 // affect v8 contexts initialized after this call. Takes ownership of | 146 // affect v8 contexts initialized after this call. Takes ownership of |
144 // the v8::Extension object passed. | 147 // the v8::Extension object passed. |
145 static void registerExtensionIfNeeded(v8::Extension*); | 148 static void registerExtensionIfNeeded(v8::Extension*); |
146 static V8Extensions& registeredExtensions(); | 149 static V8Extensions& registeredExtensions(); |
147 | 150 |
148 void setWorldDebugId(int worldId, int debuggerId); | 151 void setWorldDebugId(int worldId, int debuggerId); |
149 | 152 |
150 v8::Isolate* isolate() const { return m_isolate; } | 153 v8::Isolate* isolate() const { return m_isolate; } |
151 | 154 |
155 class BypassMainWorldCSP : public TemporaryChange<bool> { | |
haraken
2014/09/01 00:59:43
The idea of introducing BypassMainWorldCSP looks g
jbroman
2014/09/02 15:44:04
The friend class is there to keep m_bypassMainWorl
| |
156 public: | |
157 BypassMainWorldCSP(ScriptController& controller) | |
158 : TemporaryChange<bool>(controller.m_bypassMainWorldCSP, true) | |
159 { | |
160 } | |
161 }; | |
162 friend class BypassMainWorldCSP; | |
163 | |
152 private: | 164 private: |
153 typedef HashMap<int, OwnPtr<WindowProxy> > IsolatedWorldMap; | 165 typedef HashMap<int, OwnPtr<WindowProxy> > IsolatedWorldMap; |
154 typedef HashMap<Widget*, NPObject*> PluginObjectMap; | 166 typedef HashMap<Widget*, NPObject*> PluginObjectMap; |
155 | 167 |
156 v8::Local<v8::Value> evaluateScriptInMainWorld(const ScriptSourceCode&, Acce ssControlStatus, ExecuteScriptPolicy); | 168 v8::Local<v8::Value> evaluateScriptInMainWorld(const ScriptSourceCode&, Acce ssControlStatus, ExecuteScriptPolicy); |
157 | 169 |
158 LocalFrame* m_frame; | 170 LocalFrame* m_frame; |
159 const String* m_sourceURL; | 171 const String* m_sourceURL; |
160 v8::Isolate* m_isolate; | 172 v8::Isolate* m_isolate; |
161 | 173 |
162 OwnPtr<WindowProxy> m_windowProxy; | 174 OwnPtr<WindowProxy> m_windowProxy; |
163 IsolatedWorldMap m_isolatedWorlds; | 175 IsolatedWorldMap m_isolatedWorlds; |
164 | 176 |
165 // A mapping between Widgets and their corresponding script object. | 177 // A mapping between Widgets and their corresponding script object. |
166 // This list is used so that when the plugin dies, we can immediately | 178 // This list is used so that when the plugin dies, we can immediately |
167 // invalidate all sub-objects which are associated with that plugin. | 179 // invalidate all sub-objects which are associated with that plugin. |
168 // The frame keeps a NPObject reference for each item on the list. | 180 // The frame keeps a NPObject reference for each item on the list. |
169 PluginObjectMap m_pluginObjects; | 181 PluginObjectMap m_pluginObjects; |
170 | 182 |
171 NPObject* m_windowScriptNPObject; | 183 NPObject* m_windowScriptNPObject; |
184 | |
185 bool m_bypassMainWorldCSP; | |
172 }; | 186 }; |
173 | 187 |
174 } // namespace blink | 188 } // namespace blink |
175 | 189 |
176 #endif // ScriptController_h | 190 #endif // ScriptController_h |
OLD | NEW |