OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | |
3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> | |
4 * Copyright (C) 2010 Google Inc. All rights reserved. | |
5 * | |
6 * Redistribution and use in source and binary forms, with or without | |
7 * modification, are permitted provided that the following conditions | |
8 * are met: | |
9 * | |
10 * 1. Redistributions of source code must retain the above copyright | |
11 * notice, this list of conditions and the following disclaimer. | |
12 * 2. Redistributions in binary form must reproduce the above copyright | |
13 * notice, this list of conditions and the following disclaimer in the | |
14 * documentation and/or other materials provided with the distribution. | |
15 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of | |
16 * its contributors may be used to endorse or promote products derived | |
17 * from this software without specific prior written permission. | |
18 * | |
19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | |
20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
22 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | |
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 */ | |
30 | |
31 #include "sky/engine/config.h" | |
32 #include "sky/engine/core/inspector/InjectedScriptHost.h" | |
33 | |
34 #include "sky/engine/platform/JSONValues.h" | |
35 #include "sky/engine/v8_inspector/InspectorDebuggerAgent.h" | |
36 #include "sky/engine/v8_inspector/InstrumentingAgents.h" | |
37 | |
38 #include "sky/engine/wtf/RefPtr.h" | |
39 #include "sky/engine/wtf/text/StringBuilder.h" | |
40 | |
41 namespace blink { | |
42 | |
43 PassRefPtr<InjectedScriptHost> InjectedScriptHost::create() | |
44 { | |
45 return adoptRef(new InjectedScriptHost()); | |
46 } | |
47 | |
48 InjectedScriptHost::InjectedScriptHost() | |
49 : m_instrumentingAgents(nullptr) | |
50 , m_scriptDebugServer(0) | |
51 { | |
52 m_defaultInspectableObject = adoptPtr(new InspectableObject()); | |
53 } | |
54 | |
55 InjectedScriptHost::~InjectedScriptHost() | |
56 { | |
57 } | |
58 | |
59 void InjectedScriptHost::disconnect() | |
60 { | |
61 m_instrumentingAgents = nullptr; | |
62 m_scriptDebugServer = 0; | |
63 } | |
64 | |
65 void InjectedScriptHost::inspectImpl(PassRefPtr<JSONValue> object, PassRefPtr<JS
ONValue> hints) | |
66 { | |
67 // FIXME(sky) | |
68 } | |
69 | |
70 void InjectedScriptHost::getEventListenersImpl(EventTarget* target, Vector<Event
ListenerInfo>& listenersArray) | |
71 { | |
72 // FIXME(sky) | |
73 } | |
74 | |
75 void InjectedScriptHost::clearConsoleMessages() | |
76 { | |
77 // FIXME(sky) | |
78 } | |
79 | |
80 ScriptValue InjectedScriptHost::InspectableObject::get(ScriptState*) | |
81 { | |
82 return ScriptValue(); | |
83 }; | |
84 | |
85 void InjectedScriptHost::addInspectedObject(PassOwnPtr<InjectedScriptHost::Inspe
ctableObject> object) | |
86 { | |
87 m_inspectedObjects.prepend(object); | |
88 while (m_inspectedObjects.size() > 5) | |
89 m_inspectedObjects.removeLast(); | |
90 } | |
91 | |
92 void InjectedScriptHost::clearInspectedObjects() | |
93 { | |
94 m_inspectedObjects.clear(); | |
95 } | |
96 | |
97 InjectedScriptHost::InspectableObject* InjectedScriptHost::inspectedObject(unsig
ned num) | |
98 { | |
99 if (num >= m_inspectedObjects.size()) | |
100 return m_defaultInspectableObject.get(); | |
101 return m_inspectedObjects[num].get(); | |
102 } | |
103 | |
104 void InjectedScriptHost::debugFunction(const String& scriptId, int lineNumber, i
nt columnNumber) | |
105 { | |
106 if (InspectorDebuggerAgent* debuggerAgent = m_instrumentingAgents ? m_instru
mentingAgents->inspectorDebuggerAgent() : 0) | |
107 debuggerAgent->setBreakpoint(scriptId, lineNumber, columnNumber, Inspect
orDebuggerAgent::DebugCommandBreakpointSource); | |
108 } | |
109 | |
110 void InjectedScriptHost::undebugFunction(const String& scriptId, int lineNumber,
int columnNumber) | |
111 { | |
112 if (InspectorDebuggerAgent* debuggerAgent = m_instrumentingAgents ? m_instru
mentingAgents->inspectorDebuggerAgent() : 0) | |
113 debuggerAgent->removeBreakpoint(scriptId, lineNumber, columnNumber, Insp
ectorDebuggerAgent::DebugCommandBreakpointSource); | |
114 } | |
115 | |
116 void InjectedScriptHost::monitorFunction(const String& scriptId, int lineNumber,
int columnNumber, const String& functionName) | |
117 { | |
118 StringBuilder builder; | |
119 builder.appendLiteral("console.log(\"function "); | |
120 if (functionName.isEmpty()) | |
121 builder.appendLiteral("(anonymous function)"); | |
122 else | |
123 builder.append(functionName); | |
124 builder.appendLiteral(" called\" + (arguments.length > 0 ? \" with arguments
: \" + Array.prototype.join.call(arguments, \", \") : \"\")) && false"); | |
125 if (InspectorDebuggerAgent* debuggerAgent = m_instrumentingAgents ? m_instru
mentingAgents->inspectorDebuggerAgent() : 0) | |
126 debuggerAgent->setBreakpoint(scriptId, lineNumber, columnNumber, Inspect
orDebuggerAgent::MonitorCommandBreakpointSource, builder.toString()); | |
127 } | |
128 | |
129 void InjectedScriptHost::unmonitorFunction(const String& scriptId, int lineNumbe
r, int columnNumber) | |
130 { | |
131 if (InspectorDebuggerAgent* debuggerAgent = m_instrumentingAgents ? m_instru
mentingAgents->inspectorDebuggerAgent() : 0) | |
132 debuggerAgent->removeBreakpoint(scriptId, lineNumber, columnNumber, Insp
ectorDebuggerAgent::MonitorCommandBreakpointSource); | |
133 } | |
134 | |
135 } // namespace blink | |
136 | |
OLD | NEW |