InjectedScript.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. #ifndef InjectedScript_h
  31. #define InjectedScript_h
  32. #include "InjectedScriptBase.h"
  33. #include "InjectedScriptManager.h"
  34. #include "InspectorTypeBuilder.h"
  35. #include "ScriptArguments.h"
  36. #include "ScriptObject.h"
  37. #include <wtf/Forward.h>
  38. #include <wtf/Noncopyable.h>
  39. #include <wtf/PassRefPtr.h>
  40. #include <wtf/RefPtr.h>
  41. namespace WebCore {
  42. class InjectedScriptModule;
  43. class Node;
  44. class SerializedScriptValue;
  45. #if ENABLE(INSPECTOR)
  46. class InjectedScript : public InjectedScriptBase {
  47. public:
  48. InjectedScript();
  49. ~InjectedScript() { }
  50. void evaluate(ErrorString*,
  51. const String& expression,
  52. const String& objectGroup,
  53. bool includeCommandLineAPI,
  54. bool returnByValue,
  55. bool generatePreview,
  56. RefPtr<TypeBuilder::Runtime::RemoteObject>* result,
  57. TypeBuilder::OptOutput<bool>* wasThrown);
  58. void callFunctionOn(ErrorString*,
  59. const String& objectId,
  60. const String& expression,
  61. const String& arguments,
  62. bool returnByValue,
  63. bool generatePreview,
  64. RefPtr<TypeBuilder::Runtime::RemoteObject>* result,
  65. TypeBuilder::OptOutput<bool>* wasThrown);
  66. void evaluateOnCallFrame(ErrorString*,
  67. const ScriptValue& callFrames,
  68. const String& callFrameId,
  69. const String& expression,
  70. const String& objectGroup,
  71. bool includeCommandLineAPI,
  72. bool returnByValue,
  73. bool generatePreview,
  74. RefPtr<TypeBuilder::Runtime::RemoteObject>* result,
  75. TypeBuilder::OptOutput<bool>* wasThrown);
  76. void restartFrame(ErrorString*, const ScriptValue& callFrames, const String& callFrameId, RefPtr<InspectorObject>* result);
  77. void setVariableValue(ErrorString*, const ScriptValue& callFrames, const String* callFrameIdOpt, const String* functionObjectIdOpt, int scopeNumber, const String& variableName, const String& newValueStr);
  78. void getFunctionDetails(ErrorString*, const String& functionId, RefPtr<TypeBuilder::Debugger::FunctionDetails>* result);
  79. void getProperties(ErrorString*, const String& objectId, bool ownProperties, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::PropertyDescriptor> >* result);
  80. void getInternalProperties(ErrorString*, const String& objectId, RefPtr<TypeBuilder::Array<TypeBuilder::Runtime::InternalPropertyDescriptor> >* result);
  81. Node* nodeForObjectId(const String& objectId);
  82. void releaseObject(const String& objectId);
  83. #if ENABLE(JAVASCRIPT_DEBUGGER)
  84. PassRefPtr<TypeBuilder::Array<TypeBuilder::Debugger::CallFrame> > wrapCallFrames(const ScriptValue&);
  85. #endif
  86. PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapObject(const ScriptValue&, const String& groupName, bool generatePreview = false) const;
  87. PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapTable(const ScriptValue& table, const ScriptValue& columns) const;
  88. PassRefPtr<TypeBuilder::Runtime::RemoteObject> wrapNode(Node*, const String& groupName);
  89. ScriptValue findObjectById(const String& objectId) const;
  90. void inspectNode(Node*);
  91. void releaseObjectGroup(const String&);
  92. private:
  93. friend class InjectedScriptModule;
  94. friend InjectedScript InjectedScriptManager::injectedScriptFor(ScriptState*);
  95. InjectedScript(ScriptObject, InspectedStateAccessCheck);
  96. ScriptValue nodeAsScriptValue(Node*);
  97. };
  98. #endif
  99. } // namespace WebCore
  100. #endif