• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef InjectedScript_h
32 #define InjectedScript_h
33 
34 #include "InspectorTypeBuilder.h"
35 #include "bindings/v8/ScriptObject.h"
36 #include "core/inspector/InjectedScriptBase.h"
37 #include "core/inspector/InjectedScriptManager.h"
38 #include "core/inspector/ScriptArguments.h"
39 #include "wtf/Forward.h"
40 
41 namespace WebCore {
42 
43 class InjectedScriptModule;
44 class Node;
45 class SerializedScriptValue;
46 
47 
48 class InjectedScript : public InjectedScriptBase {
49 public:
50     InjectedScript();
~InjectedScript()51     ~InjectedScript() { }
52 
53     void evaluate(ErrorString*,
54                   const String& expression,
55                   const String& objectGroup,
56                   bool includeCommandLineAPI,
57                   bool returnByValue,
58                   bool generatePreview,
59                   RefPtr<TypeBuilder::Runtime::RemoteObject>* result,
60                   TypeBuilder::OptOutput<bool>* wasThrown);
61     void callFunctionOn(ErrorString*,
62                         const String& objectId,
63                         const String& expression,
64                         const String& arguments,
65                         bool returnByValue,
66                         bool generatePreview,
67                         RefPtr<TypeBuilder::Runtime::RemoteObject>* result,
68                         TypeBuilder::OptOutput<bool>* wasThrown);
69     void evaluateOnCallFrame(ErrorString*,
70                              const ScriptValue& callFrames,
71                              const String& callFrameId,
72                              const String& expression,
73                              const String& objectGroup,
74                              bool includeCommandLineAPI,
75                              bool returnByValue,
76                              bool generatePreview,
77                              RefPtr<TypeBuilder::Runtime::RemoteObject>* result,
78                              TypeBuilder::OptOutput<bool>* wasThrown);
79     void restartFrame(ErrorString*, const ScriptValue& callFrames, const String& callFrameId, RefPtr<JSONObject>* result);
80     void getStepInPositions(ErrorString*, const ScriptValue& callFrames, const String& callFrameId, RefPtr<TypeBuilder::Array<TypeBuilder::Debugger::Location> >& positions);
81     void setVariableValue(ErrorString*, const ScriptValue& callFrames, const String* callFrameIdOpt, const String* functionObjectIdOpt, int scopeNumber, const String& variableName, const String& newValueStr);
82     void getFunctionDetails(ErrorString*, const String& functionId, RefPtr<TypeBuilder::Debugger::FunctionDetails>* result);
83     void getProperties(ErrorString*, const String& objectId, bool ownProperties, bool accessorPropertiesOnly, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::PropertyDescriptor> >* result);
84     void getInternalProperties(ErrorString*, const String& objectId, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::InternalPropertyDescriptor> >* result);
85     Node* nodeForObjectId(const String& objectId);
86     void releaseObject(const String& objectId);
87 
88     PassRefPtr<TypeBuilder::Array<TypeBuilder::Debugger::CallFrame> > wrapCallFrames(const ScriptValue&);
89 
90     PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapObject(const ScriptValue&, const String& groupName, bool generatePreview = false) const;
91     PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapTable(const ScriptValue& table, const ScriptValue& columns) const;
92     PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapNode(Node*, const String& groupName);
93     ScriptValue findObjectById(const String& objectId) const;
94     ScriptValue findCallFrameById(ErrorString*, const ScriptValue& topCallFrame, const String& callFrameId);
95 
96     void inspectNode(Node*);
97     void releaseObjectGroup(const String&);
98 
99 private:
100     friend class InjectedScriptModule;
101     friend InjectedScript InjectedScriptManager::injectedScriptFor(ScriptState*);
102     InjectedScript(ScriptObject, InspectedStateAccessCheck);
103 
104     ScriptValue nodeAsScriptValue(Node*);
105 };
106 
107 
108 } // namespace WebCore
109 
110 #endif
111