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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 #include <v8.h> | 45 #include <v8.h> |
46 | 46 |
47 namespace blink { | 47 namespace blink { |
48 | 48 |
49 class CompiledScript; | 49 class CompiledScript; |
50 class DOMWrapperWorld; | 50 class DOMWrapperWorld; |
51 class Element; | 51 class Element; |
52 class KURL; | 52 class KURL; |
53 class ScriptSourceCode; | 53 class ScriptSourceCode; |
54 class SecurityOrigin; | 54 class SecurityOrigin; |
55 class WindowProxy; | |
56 class Widget; | 55 class Widget; |
57 | 56 |
58 typedef WTF::Vector<v8::Extension*> V8Extensions; | 57 typedef WTF::Vector<v8::Extension*> V8Extensions; |
59 | 58 |
60 enum ReasonForCallingCanExecuteScripts { | 59 enum ReasonForCallingCanExecuteScripts { |
61 AboutToExecuteScript, | 60 AboutToExecuteScript, |
62 NotAboutToExecuteScript | 61 NotAboutToExecuteScript |
63 }; | 62 }; |
64 | 63 |
65 class CORE_EXPORT ScriptController final | 64 class CORE_EXPORT ScriptController final |
66 : public GarbageCollected<ScriptController> { | 65 : public GarbageCollected<ScriptController> { |
67 WTF_MAKE_NONCOPYABLE(ScriptController); | 66 WTF_MAKE_NONCOPYABLE(ScriptController); |
68 | 67 |
69 public: | 68 public: |
70 enum ExecuteScriptPolicy { | 69 enum ExecuteScriptPolicy { |
71 ExecuteScriptWhenScriptsDisabled, | 70 ExecuteScriptWhenScriptsDisabled, |
72 DoNotExecuteScriptWhenScriptsDisabled | 71 DoNotExecuteScriptWhenScriptsDisabled |
73 }; | 72 }; |
74 | 73 |
75 static ScriptController* create(LocalFrame* frame) { | 74 static ScriptController* create(LocalFrame* frame) { |
76 return new ScriptController(frame); | 75 return new ScriptController(frame); |
77 } | 76 } |
78 | 77 |
79 DECLARE_TRACE(); | 78 DECLARE_TRACE(); |
80 | 79 |
81 // This returns an initialized window proxy. (If the window proxy is not | 80 // This returns an initialized window proxy. (If the window proxy is not |
82 // yet initialized, it's implicitly initialized at the first access.) | 81 // yet initialized, it's implicitly initialized at the first access.) |
83 WindowProxy* windowProxy(DOMWrapperWorld&); | 82 LocalWindowProxy* windowProxy(DOMWrapperWorld&); |
Yuki
2017/01/11 10:09:24
nit: I don't fully understand why you made RefPtr<
dcheng
2017/01/11 10:35:28
WindowProxy takes a reference when we construct it
| |
84 | 83 |
85 // Evaluate JavaScript in the main world. | 84 // Evaluate JavaScript in the main world. |
86 void executeScriptInMainWorld( | 85 void executeScriptInMainWorld( |
87 const String&, | 86 const String&, |
88 ExecuteScriptPolicy = DoNotExecuteScriptWhenScriptsDisabled); | 87 ExecuteScriptPolicy = DoNotExecuteScriptWhenScriptsDisabled); |
89 void executeScriptInMainWorld(const ScriptSourceCode&, | 88 void executeScriptInMainWorld(const ScriptSourceCode&, |
90 AccessControlStatus = NotSharableCrossOrigin); | 89 AccessControlStatus = NotSharableCrossOrigin); |
91 v8::Local<v8::Value> executeScriptInMainWorldAndReturnValue( | 90 v8::Local<v8::Value> executeScriptInMainWorldAndReturnValue( |
92 const ScriptSourceCode&, | 91 const ScriptSourceCode&, |
93 ExecuteScriptPolicy = DoNotExecuteScriptWhenScriptsDisabled); | 92 ExecuteScriptPolicy = DoNotExecuteScriptWhenScriptsDisabled); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 void clearForClose(); | 140 void clearForClose(); |
142 | 141 |
143 // Registers a v8 extension to be available on webpages. Will only | 142 // Registers a v8 extension to be available on webpages. Will only |
144 // affect v8 contexts initialized after this call. Takes ownership of | 143 // affect v8 contexts initialized after this call. Takes ownership of |
145 // the v8::Extension object passed. | 144 // the v8::Extension object passed. |
146 static void registerExtensionIfNeeded(v8::Extension*); | 145 static void registerExtensionIfNeeded(v8::Extension*); |
147 static V8Extensions& registeredExtensions(); | 146 static V8Extensions& registeredExtensions(); |
148 | 147 |
149 v8::Isolate* isolate() const { return m_windowProxyManager->isolate(); } | 148 v8::Isolate* isolate() const { return m_windowProxyManager->isolate(); } |
150 | 149 |
151 WindowProxyManager* getWindowProxyManager() const { | 150 LocalWindowProxyManager* getWindowProxyManager() const { |
152 return m_windowProxyManager.get(); | 151 return m_windowProxyManager.get(); |
153 } | 152 } |
154 | 153 |
155 private: | 154 private: |
156 explicit ScriptController(LocalFrame*); | 155 explicit ScriptController(LocalFrame*); |
157 | 156 |
158 LocalFrame* frame() const { | 157 LocalFrame* frame() const { return m_windowProxyManager->frame(); } |
159 return toLocalFrame(m_windowProxyManager->frame()); | |
160 } | |
161 | 158 |
162 v8::Local<v8::Value> evaluateScriptInMainWorld(const ScriptSourceCode&, | 159 v8::Local<v8::Value> evaluateScriptInMainWorld(const ScriptSourceCode&, |
163 AccessControlStatus, | 160 AccessControlStatus, |
164 ExecuteScriptPolicy); | 161 ExecuteScriptPolicy); |
165 | 162 |
166 Member<WindowProxyManager> m_windowProxyManager; | 163 Member<LocalWindowProxyManager> m_windowProxyManager; |
167 }; | 164 }; |
168 | 165 |
169 } // namespace blink | 166 } // namespace blink |
170 | 167 |
171 #endif // ScriptController_h | 168 #endif // ScriptController_h |
OLD | NEW |