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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 class WindowProxy; | 57 class WindowProxy; |
58 class Widget; | 58 class Widget; |
59 | 59 |
60 typedef WTF::Vector<v8::Extension*> V8Extensions; | 60 typedef WTF::Vector<v8::Extension*> V8Extensions; |
61 | 61 |
62 enum ReasonForCallingCanExecuteScripts { | 62 enum ReasonForCallingCanExecuteScripts { |
63 AboutToExecuteScript, | 63 AboutToExecuteScript, |
64 NotAboutToExecuteScript | 64 NotAboutToExecuteScript |
65 }; | 65 }; |
66 | 66 |
67 class CORE_EXPORT ScriptController final : public NoBaseWillBeGarbageCollectedFi
nalized<ScriptController> { | 67 class CORE_EXPORT ScriptController final : public GarbageCollectedFinalized<Scri
ptController> { |
68 WTF_MAKE_NONCOPYABLE(ScriptController); | 68 WTF_MAKE_NONCOPYABLE(ScriptController); |
69 USING_FAST_MALLOC_WILL_BE_REMOVED(ScriptController); | |
70 public: | 69 public: |
71 enum ExecuteScriptPolicy { | 70 enum ExecuteScriptPolicy { |
72 ExecuteScriptWhenScriptsDisabled, | 71 ExecuteScriptWhenScriptsDisabled, |
73 DoNotExecuteScriptWhenScriptsDisabled | 72 DoNotExecuteScriptWhenScriptsDisabled |
74 }; | 73 }; |
75 | 74 |
76 static PassOwnPtrWillBeRawPtr<ScriptController> create(LocalFrame* frame) | 75 static RawPtr<ScriptController> create(LocalFrame* frame) |
77 { | 76 { |
78 return adoptPtrWillBeNoop(new ScriptController(frame)); | 77 return new ScriptController(frame); |
79 } | 78 } |
80 | 79 |
81 ~ScriptController(); | 80 ~ScriptController(); |
82 DECLARE_TRACE(); | 81 DECLARE_TRACE(); |
83 | 82 |
84 bool initializeMainWorld(); | 83 bool initializeMainWorld(); |
85 WindowProxy* windowProxy(DOMWrapperWorld&); | 84 WindowProxy* windowProxy(DOMWrapperWorld&); |
86 WindowProxy* existingWindowProxy(DOMWrapperWorld&); | 85 WindowProxy* existingWindowProxy(DOMWrapperWorld&); |
87 | 86 |
88 // Evaluate JavaScript in the main world. | 87 // Evaluate JavaScript in the main world. |
89 void executeScriptInMainWorld(const String&, ExecuteScriptPolicy = DoNotExec
uteScriptWhenScriptsDisabled); | 88 void executeScriptInMainWorld(const String&, ExecuteScriptPolicy = DoNotExec
uteScriptWhenScriptsDisabled); |
90 void executeScriptInMainWorld(const ScriptSourceCode&, AccessControlStatus =
NotSharableCrossOrigin, double* compilationFinishTime = 0); | 89 void executeScriptInMainWorld(const ScriptSourceCode&, AccessControlStatus =
NotSharableCrossOrigin, double* compilationFinishTime = 0); |
91 v8::Local<v8::Value> executeScriptInMainWorldAndReturnValue(const ScriptSour
ceCode&, ExecuteScriptPolicy = DoNotExecuteScriptWhenScriptsDisabled); | 90 v8::Local<v8::Value> executeScriptInMainWorldAndReturnValue(const ScriptSour
ceCode&, ExecuteScriptPolicy = DoNotExecuteScriptWhenScriptsDisabled); |
92 v8::Local<v8::Value> executeScriptAndReturnValue(v8::Local<v8::Context>, con
st ScriptSourceCode&, AccessControlStatus = NotSharableCrossOrigin, double* comp
ilationFinishTime = 0); | 91 v8::Local<v8::Value> executeScriptAndReturnValue(v8::Local<v8::Context>, con
st ScriptSourceCode&, AccessControlStatus = NotSharableCrossOrigin, double* comp
ilationFinishTime = 0); |
93 | 92 |
94 // Executes JavaScript in an isolated world. The script gets its own global
scope, | 93 // Executes JavaScript in an isolated world. The script gets its own global
scope, |
95 // its own prototypes for intrinsic JavaScript objects (String, Array, and s
o-on), | 94 // its own prototypes for intrinsic JavaScript objects (String, Array, and s
o-on), |
96 // and its own wrappers for all DOM nodes and DOM constructors. | 95 // and its own wrappers for all DOM nodes and DOM constructors. |
97 // | 96 // |
98 // If an isolated world with the specified ID already exists, it is reused. | 97 // If an isolated world with the specified ID already exists, it is reused. |
99 // Otherwise, a new world is created. | 98 // Otherwise, a new world is created. |
100 // | 99 // |
101 // FIXME: Get rid of extensionGroup here. | 100 // FIXME: Get rid of extensionGroup here. |
102 // FIXME: We don't want to support multiple scripts. | 101 // FIXME: We don't want to support multiple scripts. |
103 void executeScriptInIsolatedWorld(int worldID, const WillBeHeapVector<Script
SourceCode>& sources, int extensionGroup, Vector<v8::Local<v8::Value>>* results)
; | 102 void executeScriptInIsolatedWorld(int worldID, const HeapVector<ScriptSource
Code>& sources, int extensionGroup, Vector<v8::Local<v8::Value>>* results); |
104 | 103 |
105 // Returns true if argument is a JavaScript URL. | 104 // Returns true if argument is a JavaScript URL. |
106 bool executeScriptIfJavaScriptURL(const KURL&); | 105 bool executeScriptIfJavaScriptURL(const KURL&); |
107 | 106 |
108 v8::MaybeLocal<v8::Value> callFunction(v8::Local<v8::Function>, v8::Local<v8
::Value>, int argc, v8::Local<v8::Value> argv[]); | 107 v8::MaybeLocal<v8::Value> callFunction(v8::Local<v8::Function>, v8::Local<v8
::Value>, int argc, v8::Local<v8::Value> argv[]); |
109 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*); | 108 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*); |
110 | 109 |
111 // Returns true if the current world is isolated, and has its own Content | 110 // Returns true if the current world is isolated, and has its own Content |
112 // Security Policy. In this case, the policy of the main world should be | 111 // Security Policy. In this case, the policy of the main world should be |
113 // ignored when evaluating resources injected into the DOM. | 112 // ignored when evaluating resources injected into the DOM. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 146 |
148 WindowProxyManager* getWindowProxyManager() const { return m_windowProxyMana
ger.get(); } | 147 WindowProxyManager* getWindowProxyManager() const { return m_windowProxyMana
ger.get(); } |
149 | 148 |
150 private: | 149 private: |
151 explicit ScriptController(LocalFrame*); | 150 explicit ScriptController(LocalFrame*); |
152 | 151 |
153 LocalFrame* frame() const { return toLocalFrame(m_windowProxyManager->frame(
)); } | 152 LocalFrame* frame() const { return toLocalFrame(m_windowProxyManager->frame(
)); } |
154 | 153 |
155 v8::Local<v8::Value> evaluateScriptInMainWorld(const ScriptSourceCode&, Acce
ssControlStatus, ExecuteScriptPolicy, double* compilationFinishTime = 0); | 154 v8::Local<v8::Value> evaluateScriptInMainWorld(const ScriptSourceCode&, Acce
ssControlStatus, ExecuteScriptPolicy, double* compilationFinishTime = 0); |
156 | 155 |
157 OwnPtrWillBeMember<WindowProxyManager> m_windowProxyManager; | 156 Member<WindowProxyManager> m_windowProxyManager; |
158 const String* m_sourceURL; | 157 const String* m_sourceURL; |
159 }; | 158 }; |
160 | 159 |
161 } // namespace blink | 160 } // namespace blink |
162 | 161 |
163 #endif // ScriptController_h | 162 #endif // ScriptController_h |
OLD | NEW |