| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Google Inc. All rights reserved. | 3 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 #ifndef InjectedScriptHost_h | 30 #ifndef InjectedScriptHost_h |
| 31 #define InjectedScriptHost_h | 31 #define InjectedScriptHost_h |
| 32 | 32 |
| 33 #include "bindings/core/v8/ScriptState.h" | 33 #include "bindings/core/v8/ScriptState.h" |
| 34 #include "bindings/core/v8/ScriptWrappable.h" | |
| 35 #include "core/InspectorTypeBuilder.h" | 34 #include "core/InspectorTypeBuilder.h" |
| 36 #include "core/inspector/InjectedScriptHostClient.h" | 35 #include "core/inspector/InjectedScriptHostClient.h" |
| 37 #include "wtf/Functional.h" | 36 #include "wtf/Functional.h" |
| 38 #include "wtf/PassOwnPtr.h" | 37 #include "wtf/PassOwnPtr.h" |
| 39 #include "wtf/RefCounted.h" | 38 #include "wtf/RefCounted.h" |
| 40 #include "wtf/Vector.h" | 39 #include "wtf/Vector.h" |
| 41 #include "wtf/text/WTFString.h" | 40 #include "wtf/text/WTFString.h" |
| 41 #include <v8.h> |
| 42 | 42 |
| 43 namespace blink { | 43 namespace blink { |
| 44 | 44 |
| 45 class EventTarget; | 45 class EventTarget; |
| 46 class InjectedScriptHostClient; | 46 class InjectedScriptHostClient; |
| 47 class InspectorConsoleAgent; | 47 class InspectorConsoleAgent; |
| 48 class InspectorDebuggerAgent; | 48 class InspectorDebuggerAgent; |
| 49 class JSONValue; | 49 class JSONValue; |
| 50 class Node; | 50 class Node; |
| 51 class ScriptValue; | 51 class ScriptValue; |
| 52 class V8Debugger; | 52 class V8Debugger; |
| 53 | 53 |
| 54 struct EventListenerInfo; | 54 struct EventListenerInfo; |
| 55 | 55 |
| 56 // SECURITY NOTE: Although the InjectedScriptHost is intended for use solely by
the inspector, | 56 // SECURITY NOTE: Although the InjectedScriptHost is intended for use solely by
the inspector, |
| 57 // a reference to the InjectedScriptHost may be leaked to the page being inspect
ed. Thus, the | 57 // a reference to the InjectedScriptHost may be leaked to the page being inspect
ed. Thus, the |
| 58 // InjectedScriptHost must never implemment methods that have more power over th
e page than the | 58 // InjectedScriptHost must never implemment methods that have more power over th
e page than the |
| 59 // page already has itself (e.g. origin restriction bypasses). | 59 // page already has itself (e.g. origin restriction bypasses). |
| 60 | 60 |
| 61 class InjectedScriptHost : public RefCountedWillBeGarbageCollectedFinalized<Inje
ctedScriptHost>, public ScriptWrappable { | 61 class InjectedScriptHost : public RefCountedWillBeGarbageCollectedFinalized<Inje
ctedScriptHost> { |
| 62 DEFINE_WRAPPERTYPEINFO(); | |
| 63 public: | 62 public: |
| 64 static PassRefPtrWillBeRawPtr<InjectedScriptHost> create(); | 63 static PassRefPtrWillBeRawPtr<InjectedScriptHost> create(); |
| 65 ~InjectedScriptHost(); | 64 ~InjectedScriptHost(); |
| 66 DECLARE_TRACE(); | 65 DECLARE_TRACE(); |
| 67 | 66 |
| 68 using InspectCallback = Function<void(PassRefPtr<TypeBuilder::Runtime::Remot
eObject>, PassRefPtr<JSONObject>)>; | 67 using InspectCallback = Function<void(PassRefPtr<TypeBuilder::Runtime::Remot
eObject>, PassRefPtr<JSONObject>)>; |
| 69 | 68 |
| 70 void init(InspectorConsoleAgent* consoleAgent, InspectorDebuggerAgent* debug
gerAgent, PassOwnPtr<InspectCallback> inspectCallback, V8Debugger* debugger, Pas
sOwnPtr<InjectedScriptHostClient> injectedScriptHostClient) | 69 void init(InspectorConsoleAgent* consoleAgent, InspectorDebuggerAgent* debug
gerAgent, PassOwnPtr<InspectCallback> inspectCallback, V8Debugger* debugger, Pas
sOwnPtr<InjectedScriptHostClient> injectedScriptHostClient) |
| 71 { | 70 { |
| 72 m_consoleAgent = consoleAgent; | 71 m_consoleAgent = consoleAgent; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 97 | 96 |
| 98 void clearConsoleMessages(); | 97 void clearConsoleMessages(); |
| 99 void debugFunction(const String& scriptId, int lineNumber, int columnNumber)
; | 98 void debugFunction(const String& scriptId, int lineNumber, int columnNumber)
; |
| 100 void undebugFunction(const String& scriptId, int lineNumber, int columnNumbe
r); | 99 void undebugFunction(const String& scriptId, int lineNumber, int columnNumbe
r); |
| 101 void monitorFunction(const String& scriptId, int lineNumber, int columnNumbe
r, const String& functionName); | 100 void monitorFunction(const String& scriptId, int lineNumber, int columnNumbe
r, const String& functionName); |
| 102 void unmonitorFunction(const String& scriptId, int lineNumber, int columnNum
ber); | 101 void unmonitorFunction(const String& scriptId, int lineNumber, int columnNum
ber); |
| 103 | 102 |
| 104 V8Debugger& debugger() { return *m_debugger; } | 103 V8Debugger& debugger() { return *m_debugger; } |
| 105 InjectedScriptHostClient* client() { return m_client.get(); } | 104 InjectedScriptHostClient* client() { return m_client.get(); } |
| 106 | 105 |
| 106 // FIXME: store this template in per isolate data |
| 107 void setWrapperTemplate(v8::Local<v8::FunctionTemplate> wrapperTemplate, v8:
:Isolate* isolate) { m_wrapperTemplate.Reset(isolate, wrapperTemplate); } |
| 108 v8::Local<v8::FunctionTemplate> wrapperTemplate(v8::Isolate* isolate) { retu
rn v8::Local<v8::FunctionTemplate>::New(isolate, m_wrapperTemplate); } |
| 109 |
| 107 private: | 110 private: |
| 108 InjectedScriptHost(); | 111 InjectedScriptHost(); |
| 109 | 112 |
| 110 RawPtrWillBeMember<InspectorConsoleAgent> m_consoleAgent; | 113 RawPtrWillBeMember<InspectorConsoleAgent> m_consoleAgent; |
| 111 RawPtrWillBeMember<InspectorDebuggerAgent> m_debuggerAgent; | 114 RawPtrWillBeMember<InspectorDebuggerAgent> m_debuggerAgent; |
| 112 OwnPtr<InspectCallback> m_inspectCallback; | 115 OwnPtr<InspectCallback> m_inspectCallback; |
| 113 RawPtrWillBeMember<V8Debugger> m_debugger; | 116 RawPtrWillBeMember<V8Debugger> m_debugger; |
| 114 Vector<OwnPtr<InspectableObject> > m_inspectedObjects; | 117 Vector<OwnPtr<InspectableObject> > m_inspectedObjects; |
| 115 OwnPtr<InspectableObject> m_defaultInspectableObject; | 118 OwnPtr<InspectableObject> m_defaultInspectableObject; |
| 116 OwnPtr<InjectedScriptHostClient> m_client; | 119 OwnPtr<InjectedScriptHostClient> m_client; |
| 120 v8::Global<v8::FunctionTemplate> m_wrapperTemplate; |
| 117 }; | 121 }; |
| 118 | 122 |
| 119 } // namespace blink | 123 } // namespace blink |
| 120 | 124 |
| 121 #endif // InjectedScriptHost_h | 125 #endif // InjectedScriptHost_h |
| OLD | NEW |