WebInspector.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. * Copyright (C) 2010 Apple 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
  6. * are met:
  7. * 1. Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * 2. Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. *
  13. * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
  14. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  15. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
  17. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  18. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  19. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  20. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  21. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  22. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  23. * THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #ifndef WebInspector_h
  26. #define WebInspector_h
  27. #if ENABLE(INSPECTOR)
  28. #include "APIObject.h"
  29. #include "Connection.h"
  30. #include <wtf/Noncopyable.h>
  31. #include <wtf/text/WTFString.h>
  32. namespace WebCore {
  33. class InspectorFrontendChannel;
  34. }
  35. namespace WebKit {
  36. class WebInspectorFrontendClient;
  37. class WebPage;
  38. struct WebPageCreationParameters;
  39. class WebInspector : public TypedAPIObject<APIObject::TypeBundleInspector> {
  40. public:
  41. static PassRefPtr<WebInspector> create(WebPage*, WebCore::InspectorFrontendChannel*);
  42. WebPage* page() const { return m_page; }
  43. WebPage* inspectorPage() const { return m_inspectorPage; }
  44. // Implemented in generated WebInspectorMessageReceiver.cpp
  45. void didReceiveWebInspectorMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&);
  46. // Called by WebInspector messages
  47. void show();
  48. void close();
  49. void didSave(const String& url);
  50. void didAppend(const String& url);
  51. void attachedBottom();
  52. void attachedRight();
  53. void detached();
  54. void evaluateScriptForTest(long callID, const String& script);
  55. void setJavaScriptProfilingEnabled(bool);
  56. void startPageProfiling();
  57. void stopPageProfiling();
  58. #if ENABLE(INSPECTOR_SERVER)
  59. bool hasRemoteFrontendConnected() const { return m_remoteFrontendConnected; }
  60. void sendMessageToRemoteFrontend(const String& message);
  61. void dispatchMessageFromRemoteFrontend(const String& message);
  62. void remoteFrontendConnected();
  63. void remoteFrontendDisconnected();
  64. #endif
  65. #if PLATFORM(MAC)
  66. void setInspectorUsesWebKitUserInterface(bool);
  67. #endif
  68. private:
  69. friend class WebInspectorClient;
  70. friend class WebInspectorFrontendClient;
  71. explicit WebInspector(WebPage*, WebCore::InspectorFrontendChannel*);
  72. // Called from WebInspectorClient
  73. WebPage* createInspectorPage();
  74. void destroyInspectorPage();
  75. // Called from WebInspectorFrontendClient
  76. void didClose();
  77. void bringToFront();
  78. void inspectedURLChanged(const String&);
  79. bool canSave() const;
  80. void save(const String& filename, const String& content, bool forceSaveAs);
  81. void append(const String& filename, const String& content);
  82. void attachBottom();
  83. void attachRight();
  84. void detach();
  85. void setAttachedWindowHeight(unsigned);
  86. void setAttachedWindowWidth(unsigned);
  87. void setToolbarHeight(unsigned);
  88. // Implemented in platform WebInspector file
  89. String localizedStringsURL() const;
  90. void showConsole();
  91. void showResources();
  92. void showMainResourceForFrame(uint64_t frameID);
  93. void startJavaScriptDebugging();
  94. void stopJavaScriptDebugging();
  95. void startJavaScriptProfiling();
  96. void stopJavaScriptProfiling();
  97. void updateDockingAvailability();
  98. #if PLATFORM(MANX)
  99. void disconnectLocalFrontend();
  100. #endif
  101. WebPage* m_page;
  102. WebPage* m_inspectorPage;
  103. WebInspectorFrontendClient* m_frontendClient;
  104. WebCore::InspectorFrontendChannel* m_frontendChannel;
  105. #if PLATFORM(MAC)
  106. mutable String m_localizedStringsURL;
  107. mutable bool m_hasLocalizedStringsURL;
  108. bool m_usesWebKitUserInterface;
  109. #endif
  110. #if ENABLE(INSPECTOR_SERVER)
  111. bool m_remoteFrontendConnected;
  112. #endif
  113. };
  114. } // namespace WebKit
  115. #endif // ENABLE(INSPECTOR)
  116. #endif // WebInspector_h