InspectorClientManx.cpp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * Copyright (C) 2008 Apple Computer, Inc. All rights reserved.
  3. * Copyright (C) 2012 Sony Computer Entertainment Inc.
  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. * 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. *
  14. * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
  15. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  17. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
  18. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  19. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  20. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  21. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  22. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  24. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #include "config.h"
  27. #include "InspectorClientManx.h"
  28. #include "Frame.h"
  29. #include "FrameView.h"
  30. #include "InspectorController.h"
  31. #include "InspectorServerManx.h"
  32. #include "NotImplemented.h"
  33. #include "Page.h"
  34. #include "WebViewPrivate.h"
  35. #include <wtf/text/WTFString.h>
  36. using namespace WebKit;
  37. namespace WebCore {
  38. InspectorClientManx::InspectorClientManx(WebViewPrivate* webview)
  39. : m_webview(webview)
  40. , m_remoteFrontendClientId(0)
  41. , m_remoteFrontendConnected(false)
  42. {
  43. }
  44. InspectorClientManx::~InspectorClientManx()
  45. {
  46. }
  47. WebViewPrivate* InspectorClientManx::webview() const
  48. {
  49. return m_webview;
  50. }
  51. Page* InspectorClientManx::page() const
  52. {
  53. return m_webview->m_page.get();
  54. }
  55. void InspectorClientManx::setRemoteInspectionEnabled(bool enabled)
  56. {
  57. if (enabled && !m_remoteFrontendClientId)
  58. m_remoteFrontendClientId = InspectorServerManx::shared().registerClient(this);
  59. else if (!enabled && m_remoteFrontendClientId)
  60. InspectorServerManx::shared().unregisterClient(m_remoteFrontendClientId);
  61. }
  62. bool InspectorClientManx::remoteInspectionEnabled() const
  63. {
  64. return m_remoteFrontendClientId;
  65. }
  66. void InspectorClientManx::inspectorDestroyed()
  67. {
  68. if (m_remoteFrontendClientId)
  69. InspectorServerManx::shared().unregisterClient(m_remoteFrontendClientId);
  70. delete this;
  71. }
  72. WebCore::InspectorFrontendChannel* InspectorClientManx::openInspectorFrontend(InspectorController* controller)
  73. {
  74. notImplemented();
  75. return 0;
  76. }
  77. void InspectorClientManx::closeInspectorFrontend()
  78. {
  79. m_webview = 0;
  80. notImplemented();
  81. }
  82. void InspectorClientManx::bringFrontendToFront()
  83. {
  84. notImplemented();
  85. }
  86. void InspectorClientManx::highlight()
  87. {
  88. if (!m_webview)
  89. return;
  90. Frame* mainFrame = m_webview->m_page->mainFrame();
  91. if (!mainFrame)
  92. return;
  93. m_webview->invalidate(IntRect(IntPoint(), mainFrame->view()->contentsSize()), false);
  94. }
  95. void InspectorClientManx::hideHighlight()
  96. {
  97. highlight();
  98. }
  99. void InspectorClientManx::populateSetting(const WTF::String& key, WTF::String* value)
  100. {
  101. notImplemented();
  102. }
  103. void InspectorClientManx::storeSetting(const WTF::String& key, const WTF::String& value)
  104. {
  105. notImplemented();
  106. }
  107. bool InspectorClientManx::sendMessageToFrontend(const WTF::String& message)
  108. {
  109. if (m_remoteFrontendClientId && m_remoteFrontendConnected) {
  110. InspectorServerManx::shared().sendMessageOverConnection(m_remoteFrontendClientId, message);
  111. return true;
  112. }
  113. notImplemented();
  114. return false;
  115. }
  116. void InspectorClientManx::resourceTrackingWasEnabled()
  117. {
  118. notImplemented();
  119. }
  120. void InspectorClientManx::resourceTrackingWasDisabled()
  121. {
  122. notImplemented();
  123. }
  124. void InspectorClientManx::timelineProfilerWasStarted()
  125. {
  126. notImplemented();
  127. }
  128. void InspectorClientManx::timelineProfilerWasStopped()
  129. {
  130. notImplemented();
  131. }
  132. void InspectorClientManx::dispatchMessageFromRemoteFrontend(const String& message)
  133. {
  134. ASSERT(m_remoteFrontendConnected);
  135. if (m_webview->m_page)
  136. m_webview->m_page->inspectorController()->dispatchMessageFromFrontend(message);
  137. }
  138. void InspectorClientManx::remoteFrontendConnected()
  139. {
  140. ASSERT(!m_remoteFrontendConnected);
  141. if (m_webview->m_page) {
  142. m_webview->m_page->inspectorController()->connectFrontend(this);
  143. m_remoteFrontendConnected = true;
  144. }
  145. }
  146. void InspectorClientManx::remoteFrontendDisconnected()
  147. {
  148. ASSERT(m_remoteFrontendConnected);
  149. if (m_webview->m_page) {
  150. m_remoteFrontendConnected = false;
  151. m_webview->m_page->inspectorController()->disconnectFrontend();
  152. }
  153. }
  154. } // namespace WebKit