InspectorAgent.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
  3. * Copyright (C) 2011 Google Inc. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
  15. * its contributors may be used to endorse or promote products derived
  16. * from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
  19. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  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
  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.
  28. */
  29. #ifndef InspectorAgent_h
  30. #define InspectorAgent_h
  31. #include "InspectorBaseAgent.h"
  32. #include <wtf/Forward.h>
  33. #include <wtf/HashMap.h>
  34. #include <wtf/PassOwnPtr.h>
  35. #include <wtf/Vector.h>
  36. #include <wtf/text/WTFString.h>
  37. namespace WebCore {
  38. class DOMWrapperWorld;
  39. class DocumentLoader;
  40. class Frame;
  41. class InjectedScriptManager;
  42. class InspectorFrontend;
  43. class InspectorObject;
  44. class InstrumentingAgents;
  45. class KURL;
  46. class Page;
  47. typedef String ErrorString;
  48. class InspectorAgent : public InspectorBaseAgent<InspectorAgent>, public InspectorBackendDispatcher::InspectorCommandHandler {
  49. WTF_MAKE_NONCOPYABLE(InspectorAgent);
  50. public:
  51. static PassOwnPtr<InspectorAgent> create(Page* page, InjectedScriptManager* injectedScriptManager, InstrumentingAgents* instrumentingAgents, InspectorCompositeState* state)
  52. {
  53. return adoptPtr(new InspectorAgent(page, injectedScriptManager, instrumentingAgents, state));
  54. }
  55. virtual ~InspectorAgent();
  56. bool developerExtrasEnabled() const;
  57. // Inspector front-end API.
  58. void enable(ErrorString*);
  59. void disable(ErrorString*);
  60. KURL inspectedURL() const;
  61. KURL inspectedURLWithoutFragment() const;
  62. InspectorFrontend* frontend() const { return m_frontend; }
  63. virtual void setFrontend(InspectorFrontend*);
  64. virtual void clearFrontend();
  65. void didClearWindowObjectInWorld(Frame*, DOMWrapperWorld*);
  66. void didCommitLoad();
  67. void domContentLoadedEventFired();
  68. bool hasFrontend() const { return m_frontend; }
  69. // Generic code called from custom implementations.
  70. void evaluateForTestInFrontend(long testCallId, const String& script);
  71. void setInjectedScriptForOrigin(const String& origin, const String& source);
  72. void inspect(PassRefPtr<TypeBuilder::Runtime::RemoteObject> objectToInspect, PassRefPtr<InspectorObject> hints);
  73. private:
  74. InspectorAgent(Page*, InjectedScriptManager*, InstrumentingAgents*, InspectorCompositeState*);
  75. void unbindAllResources();
  76. #if ENABLE(JAVASCRIPT_DEBUGGER)
  77. void toggleRecordButton(bool);
  78. #endif
  79. bool isMainResourceLoader(DocumentLoader*, const KURL& requestUrl);
  80. Page* m_inspectedPage;
  81. InspectorFrontend* m_frontend;
  82. InjectedScriptManager* m_injectedScriptManager;
  83. Vector<pair<long, String> > m_pendingEvaluateTestCommands;
  84. pair<RefPtr<TypeBuilder::Runtime::RemoteObject>, RefPtr<InspectorObject> > m_pendingInspectData;
  85. typedef HashMap<String, String> InjectedScriptForOriginMap;
  86. InjectedScriptForOriginMap m_injectedScriptForOrigin;
  87. };
  88. } // namespace WebCore
  89. #endif // !defined(InspectorAgent_h)