2 * Copyright (C) 2010 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
27 #include "WebInspectorClient.h"
31 #include "WebInspector.h"
33 #include <WebCore/InspectorController.h>
34 #include <WebCore/Page.h>
35 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
36 #include <WebCore/Settings.h>
39 using namespace WebCore;
43 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
44 void WebInspectorClient::attachRemoteFrontend()
46 if (!m_page || !m_page->corePage())
49 Settings* settings = m_page->corePage()->settings();
51 settings->setDeveloperExtrasEnabled(true);
53 m_remoteFrontend = true;
54 InspectorController *controller = m_page->corePage()->inspectorController();
56 controller->connectFrontend(this);
59 void WebInspectorClient::detachRemoteFrontend()
61 if (!m_page || !m_page->corePage())
64 Settings* settings = m_page->corePage()->settings();
66 settings->setDeveloperExtrasEnabled(false);
68 m_remoteFrontend = false;
69 InspectorController *controller = m_page->corePage()->inspectorController();
71 controller->disconnectFrontend();
75 void WebInspectorClient::inspectorDestroyed()
77 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
78 WebInspectorServerTizen::server()->unregisterClient(this);
80 closeInspectorFrontend();
84 WebCore::InspectorFrontendChannel* WebInspectorClient::openInspectorFrontend(InspectorController*)
86 WebPage* inspectorPage = m_page->inspector()->createInspectorPage();
87 ASSERT_UNUSED(inspectorPage, inspectorPage);
91 void WebInspectorClient::closeInspectorFrontend()
93 if (m_page->inspector()) {
94 m_page->inspector()->didClose();
98 void WebInspectorClient::bringFrontendToFront()
100 m_page->inspector()->bringToFront();
103 void WebInspectorClient::didResizeMainFrame(Frame*)
105 if (m_page->inspector())
106 m_page->inspector()->updateDockingAvailability();
109 void WebInspectorClient::highlight()
111 if (!m_highlightOverlay) {
112 RefPtr<PageOverlay> highlightOverlay = PageOverlay::create(this);
113 m_highlightOverlay = highlightOverlay.get();
114 m_page->installPageOverlay(highlightOverlay.release());
116 m_highlightOverlay->setNeedsDisplay();
119 void WebInspectorClient::hideHighlight()
121 if (m_highlightOverlay)
122 m_page->uninstallPageOverlay(m_highlightOverlay, false);
125 bool WebInspectorClient::sendMessageToFrontend(const String& message)
127 #if ENABLE(TIZEN_REMOTE_WEB_INSPECTOR)
128 if (m_remoteFrontend)
129 return WebInspectorServerTizen::server()->webSocketSend(message);
131 WebInspector* inspector = m_page->inspector();
135 #if ENABLE(INSPECTOR_SERVER)
136 if (inspector->hasRemoteFrontendConnected()) {
137 inspector->sendMessageToRemoteFrontend(message);
142 WebPage* inspectorPage = inspector->inspectorPage();
144 return doDispatchMessageOnFrontendPage(inspectorPage->corePage(), message);
149 void WebInspectorClient::pageOverlayDestroyed(PageOverlay*)
153 void WebInspectorClient::willMoveToWebPage(PageOverlay*, WebPage* webPage)
158 // The page overlay is moving away from the web page, reset it.
159 ASSERT(m_highlightOverlay);
160 m_highlightOverlay = 0;
163 void WebInspectorClient::didMoveToWebPage(PageOverlay*, WebPage*)
167 void WebInspectorClient::drawRect(PageOverlay* overlay, WebCore::GraphicsContext& context, const WebCore::IntRect& dirtyRect)
169 m_page->corePage()->inspectorController()->drawHighlight(context);
172 bool WebInspectorClient::mouseEvent(PageOverlay*, const WebMouseEvent&)
177 } // namespace WebKit
179 #endif // ENABLE(INSPECTOR)