WebInspectorClient.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Copyright (C) 2006, 2007 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. *
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
  14. * its contributors may be used to endorse or promote products derived
  15. * from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
  18. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
  21. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  23. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. */
  28. #ifndef WebInspectorClient_h
  29. #define WebInspectorClient_h
  30. #include <WebCore/COMPtr.h>
  31. #include <WebCore/InspectorClient.h>
  32. #include <WebCore/InspectorFrontendChannel.h>
  33. #include <WebCore/InspectorFrontendClientLocal.h>
  34. #include <WebCore/WindowMessageListener.h>
  35. #include <windows.h>
  36. #include <wtf/Forward.h>
  37. #include <wtf/HashMap.h>
  38. #include <wtf/OwnPtr.h>
  39. #include <wtf/text/StringHash.h>
  40. #include <wtf/text/WTFString.h>
  41. namespace WebCore {
  42. class Page;
  43. }
  44. class WebInspectorFrontendClient;
  45. class WebNodeHighlight;
  46. class WebView;
  47. class WebInspectorClient : public WebCore::InspectorClient, public WebCore::InspectorFrontendChannel {
  48. public:
  49. explicit WebInspectorClient(WebView*);
  50. // InspectorClient
  51. virtual void inspectorDestroyed();
  52. virtual WebCore::InspectorFrontendChannel* openInspectorFrontend(WebCore::InspectorController*);
  53. virtual void closeInspectorFrontend();
  54. virtual void bringFrontendToFront();
  55. virtual void highlight();
  56. virtual void hideHighlight();
  57. virtual bool sendMessageToFrontend(const WTF::String&);
  58. bool inspectorStartsAttached();
  59. void setInspectorStartsAttached(bool);
  60. bool inspectorAttachDisabled();
  61. void setInspectorAttachDisabled(bool);
  62. void releaseFrontend();
  63. WebInspectorFrontendClient* frontendClient() { return m_frontendClient; }
  64. void updateHighlight();
  65. private:
  66. virtual ~WebInspectorClient();
  67. WTF::PassOwnPtr<WebCore::InspectorFrontendClientLocal::Settings> createFrontendSettings();
  68. WebView* m_inspectedWebView;
  69. WebCore::Page* m_frontendPage;
  70. WebInspectorFrontendClient* m_frontendClient;
  71. HWND m_inspectedWebViewHwnd;
  72. HWND m_frontendHwnd;
  73. OwnPtr<WebNodeHighlight> m_highlight;
  74. };
  75. class WebInspectorFrontendClient : public WebCore::InspectorFrontendClientLocal, WebCore::WindowMessageListener {
  76. public:
  77. WebInspectorFrontendClient(WebView* inspectedWebView, HWND inspectedWebViewHwnd, HWND frontendHwnd, const COMPtr<WebView>& frotnendWebView, HWND frontendWebViewHwnd, WebInspectorClient*, WTF::PassOwnPtr<Settings>);
  78. virtual ~WebInspectorFrontendClient();
  79. virtual void frontendLoaded();
  80. virtual WTF::String localizedStringsURL();
  81. virtual void bringToFront();
  82. virtual void closeWindow();
  83. virtual void attachWindow(DockSide);
  84. virtual void detachWindow();
  85. virtual void setAttachedWindowHeight(unsigned height);
  86. virtual void setAttachedWindowWidth(unsigned);
  87. virtual void setToolbarHeight(unsigned) OVERRIDE;
  88. virtual void inspectedURLChanged(const WTF::String& newURL);
  89. void destroyInspectorView(bool notifyInspectorController);
  90. private:
  91. void closeWindowWithoutNotifications();
  92. void showWindowWithoutNotifications();
  93. void updateWindowTitle();
  94. LRESULT onGetMinMaxInfo(WPARAM, LPARAM);
  95. LRESULT onSize(WPARAM, LPARAM);
  96. LRESULT onClose(WPARAM, LPARAM);
  97. LRESULT onSetFocus();
  98. virtual void windowReceivedMessage(HWND, UINT message, WPARAM, LPARAM);
  99. void onWebViewWindowPosChanging(WPARAM, LPARAM);
  100. WebView* m_inspectedWebView;
  101. HWND m_inspectedWebViewHwnd;
  102. HWND m_frontendHwnd;
  103. WebInspectorClient* m_inspectorClient;
  104. COMPtr<WebView> m_frontendWebView;
  105. HWND m_frontendWebViewHwnd;
  106. bool m_attached;
  107. WTF::String m_inspectedURL;
  108. bool m_destroyingInspectorView;
  109. static friend LRESULT CALLBACK WebInspectorWndProc(HWND, UINT, WPARAM, LPARAM);
  110. };
  111. #endif // !defined(WebInspectorClient_h)