2 * Copyright (C) 2008 INdT - Instituto Nokia de Tecnologia
3 * Copyright (C) 2009-2010 ProFUSION embedded systems
4 * Copyright (C) 2009-2010 Samsung Electronics
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "InspectorClientEfl.h"
25 #include "EflInspectorUtilities.h"
26 #include "InspectorController.h"
27 #include "NotImplemented.h"
28 #include "ewk_view_private.h"
29 #include <wtf/text/CString.h>
30 #include <wtf/text/WTFString.h>
34 static void notifyInspectorDestroy(void* userData, Evas_Object* /*webview*/, void* /*eventInfo*/)
36 InspectorFrontendClientEfl* inspectorFrontendClient = static_cast<InspectorFrontendClientEfl*>(userData);
37 if (inspectorFrontendClient)
38 inspectorFrontendClient->destroyInspectorWindow(true);
41 static void invalidateView(Evas_Object* webView)
43 Evas_Coord width, height;
44 Evas_Object* mainFrame = ewk_view_frame_main_get(webView);
45 if (mainFrame && ewk_frame_contents_size_get(mainFrame, &width, &height)) {
46 WebCore::Page* page = EWKPrivate::corePage(webView);
48 page->mainFrame().view()->invalidateRect(WebCore::IntRect(0, 0, width, height));
52 class InspectorFrontendSettingsEfl : public InspectorFrontendClientLocal::Settings {
54 virtual String getProperty(const String& /*name*/)
60 virtual void setProperty(const String& /*name*/, const String& /*value*/)
66 InspectorClientEfl::InspectorClientEfl(Evas_Object* webView)
67 : m_inspectedView(webView)
73 InspectorClientEfl::~InspectorClientEfl()
75 if (m_frontendClient) {
76 m_frontendClient->disconnectInspectorClient();
81 void InspectorClientEfl::inspectorDestroyed()
83 closeInspectorFrontend();
87 InspectorFrontendChannel* InspectorClientEfl::openInspectorFrontend(InspectorController*)
89 evas_object_smart_callback_call(m_inspectedView, "inspector,view,create", 0);
91 Evas_Object* inspectorView = ewk_view_inspector_view_get(m_inspectedView);
95 m_inspectorView = inspectorView;
97 String inspectorUri = inspectorFilesPath() + "/inspector.html";
98 ewk_view_uri_set(m_inspectorView, inspectorUri.utf8().data());
100 OwnPtr<InspectorFrontendClientEfl> frontendClient = adoptPtr(new InspectorFrontendClientEfl(m_inspectedView, m_inspectorView, this));
101 m_frontendClient = frontendClient.get();
103 InspectorController* controller = EWKPrivate::corePage(m_inspectorView)->inspectorController();
104 controller->setInspectorFrontendClient(frontendClient.release());
109 void InspectorClientEfl::closeInspectorFrontend()
111 if (m_frontendClient)
112 m_frontendClient->destroyInspectorWindow(false);
115 void InspectorClientEfl::bringFrontendToFront()
117 m_frontendClient->bringToFront();
120 void InspectorClientEfl::highlight()
122 invalidateView(m_inspectedView);
125 void InspectorClientEfl::hideHighlight()
127 invalidateView(m_inspectedView);
130 bool InspectorClientEfl::sendMessageToFrontend(const String& message)
132 Page* frontendPage = EWKPrivate::corePage(m_inspectorView);
133 return doDispatchMessageOnFrontendPage(frontendPage, message);
136 void InspectorClientEfl::releaseFrontendPage()
139 m_frontendClient = 0;
142 String InspectorClientEfl::inspectorFilesPath()
144 return "file://" + inspectorResourcePath();
147 InspectorFrontendClientEfl::InspectorFrontendClientEfl(Evas_Object* inspectedView, Evas_Object* inspectorView, InspectorClientEfl* inspectorClient)
148 : InspectorFrontendClientLocal(EWKPrivate::corePage(inspectedView)->inspectorController(), EWKPrivate::corePage(inspectorView), adoptPtr(new InspectorFrontendSettingsEfl()))
149 , m_inspectedView(inspectedView)
150 , m_inspectorView(inspectorView)
151 , m_inspectorClient(inspectorClient)
153 evas_object_smart_callback_add(m_inspectorView, "inspector,view,destroy", notifyInspectorDestroy, this);
156 InspectorFrontendClientEfl::~InspectorFrontendClientEfl()
158 evas_object_smart_callback_del(m_inspectorView, "inspector,view,destroy", notifyInspectorDestroy);
160 if (m_inspectorClient) {
161 m_inspectorClient->releaseFrontendPage();
162 m_inspectorClient = 0;
166 String InspectorFrontendClientEfl::localizedStringsURL()
168 return m_inspectorClient->inspectorFilesPath() + "/localizedStrings.js";
171 void InspectorFrontendClientEfl::bringToFront()
173 evas_object_focus_set(m_inspectorView, true);
176 void InspectorFrontendClientEfl::closeWindow()
178 destroyInspectorWindow(true);
181 void InspectorFrontendClientEfl::inspectedURLChanged(const String&)
186 void InspectorFrontendClientEfl::attachWindow(DockSide)
191 void InspectorFrontendClientEfl::detachWindow()
196 void InspectorFrontendClientEfl::setAttachedWindowHeight(unsigned)
201 void InspectorFrontendClientEfl::setAttachedWindowWidth(unsigned)
206 void InspectorFrontendClientEfl::setToolbarHeight(unsigned)
211 void InspectorFrontendClientEfl::destroyInspectorWindow(bool notifyInspectorController)
213 if (notifyInspectorController)
214 EWKPrivate::corePage(m_inspectedView)->inspectorController()->disconnectFrontend();
216 if (m_inspectorClient)
217 m_inspectorClient->releaseFrontendPage();
219 evas_object_smart_callback_call(m_inspectedView, "inspector,view,close", m_inspectorView);