Home | History | Annotate | Download | only in inspector
      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 "bindings/v8/ScriptValue.h"
     35 #include "core/InspectorTypeBuilder.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 #include "wtf/Vector.h"
     41 
     42 namespace WebCore {
     43 
     44 class InjectedScriptModule;
     45 class Node;
     46 class SerializedScriptValue;
     47 
     48 class InjectedScript FINAL : public InjectedScriptBase {
     49 public:
     50     InjectedScript();
     51     virtual ~InjectedScript() { }
     52 
     53     void evaluate(
     54         ErrorString*,
     55         const String& expression,
     56         const String& objectGroup,
     57         bool includeCommandLineAPI,
     58         bool returnByValue,
     59         bool generatePreview,
     60         RefPtr<TypeBuilder::Runtime::RemoteObject>* result,
     61         TypeBuilder::OptOutput<bool>* wasThrown);
     62     void callFunctionOn(
     63         ErrorString*,
     64         const String& objectId,
     65         const String& expression,
     66         const String& arguments,
     67         bool returnByValue,
     68         bool generatePreview,
     69         RefPtr<TypeBuilder::Runtime::RemoteObject>* result,
     70         TypeBuilder::OptOutput<bool>* wasThrown);
     71     void evaluateOnCallFrame(
     72         ErrorString*,
     73         const ScriptValue& callFrames,
     74         const Vector<ScriptValue>& asyncCallStacks,
     75         const String& callFrameId,
     76         const String& expression,
     77         const String& objectGroup,
     78         bool includeCommandLineAPI,
     79         bool returnByValue,
     80         bool generatePreview,
     81         RefPtr<TypeBuilder::Runtime::RemoteObject>* result,
     82         TypeBuilder::OptOutput<bool>* wasThrown);
     83     void restartFrame(ErrorString*, const ScriptValue& callFrames, const String& callFrameId, RefPtr<JSONObject>* result);
     84     void getStepInPositions(ErrorString*, const ScriptValue& callFrames, const String& callFrameId, RefPtr<TypeBuilder::Array<TypeBuilder::Debugger::Location> >& positions);
     85     void setVariableValue(ErrorString*, const ScriptValue& callFrames, const String* callFrameIdOpt, const String* functionObjectIdOpt, int scopeNumber, const String& variableName, const String& newValueStr);
     86     void getFunctionDetails(ErrorString*, const String& functionId, RefPtr<TypeBuilder::Debugger::FunctionDetails>* result);
     87     void getProperties(ErrorString*, const String& objectId, bool ownProperties, bool accessorPropertiesOnly, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::PropertyDescriptor> >* result);
     88     void getInternalProperties(ErrorString*, const String& objectId, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::InternalPropertyDescriptor> >* result);
     89     Node* nodeForObjectId(const String& objectId);
     90     void releaseObject(const String& objectId);
     91 
     92     PassRefPtr<TypeBuilder::Array<TypeBuilder::Debugger::CallFrame> > wrapCallFrames(const ScriptValue&, int asyncOrdinal);
     93 
     94     PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapObject(const ScriptValue&, const String& groupName, bool generatePreview = false) const;
     95     PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapTable(const ScriptValue& table, const ScriptValue& columns) const;
     96     PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapNode(Node*, const String& groupName);
     97     ScriptValue findObjectById(const String& objectId) const;
     98 
     99     void inspectNode(Node*);
    100     void releaseObjectGroup(const String&);
    101 
    102 private:
    103     friend class InjectedScriptModule;
    104     friend InjectedScript InjectedScriptManager::injectedScriptFor(ScriptState*);
    105     InjectedScript(ScriptValue, InspectedStateAccessCheck);
    106 
    107     ScriptValue nodeAsScriptValue(Node*);
    108 };
    109 
    110 
    111 } // namespace WebCore
    112 
    113 #endif
    114