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 "InspectorController.h"
26
#include "NotImplemented.h"
27
#include "ewk_view_private.h"
29
#include <wtf/text/WTFString.h>
33
static void notifyInspectorDestroy(void* userData, Evas_Object* /*webview*/, void* /*eventInfo*/)
35
InspectorFrontendClientEfl* inspectorFrontendClient = static_cast<InspectorFrontendClientEfl*>(userData);
36
if (inspectorFrontendClient)
37
inspectorFrontendClient->destroyInspectorWindow(true);
40
static void invalidateView(Evas_Object* webView)
42
Evas_Coord width, height;
43
Evas_Object* mainFrame = ewk_view_frame_main_get(webView);
44
if (mainFrame && ewk_frame_contents_size_get(mainFrame, &width, &height)) {
45
WebCore::Page* page = EWKPrivate::corePage(webView);
47
page->mainFrame()->view()->invalidateRect(WebCore::IntRect(0, 0, width, height));
51
class InspectorFrontendSettingsEfl : public InspectorFrontendClientLocal::Settings {
53
virtual String getProperty(const String& /*name*/)
59
virtual void setProperty(const String& /*name*/, const String& /*value*/)
65
InspectorClientEfl::InspectorClientEfl(Evas_Object* webView)
66
: m_inspectedView(webView)
72
InspectorClientEfl::~InspectorClientEfl()
74
if (m_frontendClient) {
75
m_frontendClient->disconnectInspectorClient();
80
void InspectorClientEfl::inspectorDestroyed()
82
closeInspectorFrontend();
86
InspectorFrontendChannel* InspectorClientEfl::openInspectorFrontend(InspectorController*)
88
evas_object_smart_callback_call(m_inspectedView, "inspector,view,create", 0);
90
Evas_Object* inspectorView = ewk_view_inspector_view_get(m_inspectedView);
94
m_inspectorView = inspectorView;
96
String inspectorUri = inspectorFilesPath() + "/inspector.html";
97
ewk_view_uri_set(m_inspectorView, inspectorUri.utf8().data());
99
OwnPtr<InspectorFrontendClientEfl> frontendClient = adoptPtr(new InspectorFrontendClientEfl(m_inspectedView, m_inspectorView, this));
100
m_frontendClient = frontendClient.get();
102
InspectorController* controller = EWKPrivate::corePage(m_inspectorView)->inspectorController();
103
controller->setInspectorFrontendClient(frontendClient.release());
108
void InspectorClientEfl::closeInspectorFrontend()
110
if (m_frontendClient)
111
m_frontendClient->destroyInspectorWindow(false);
114
void InspectorClientEfl::bringFrontendToFront()
116
m_frontendClient->bringToFront();
119
void InspectorClientEfl::highlight()
121
invalidateView(m_inspectedView);
124
void InspectorClientEfl::hideHighlight()
126
invalidateView(m_inspectedView);
129
bool InspectorClientEfl::sendMessageToFrontend(const String& message)
131
Page* frontendPage = EWKPrivate::corePage(m_inspectorView);
132
return doDispatchMessageOnFrontendPage(frontendPage, message);
135
void InspectorClientEfl::releaseFrontendPage()
138
m_frontendClient = 0;
141
String InspectorClientEfl::inspectorFilesPath()
143
String inspectorFilesPath = WEB_INSPECTOR_INSTALL_DIR;
144
if (access(inspectorFilesPath.utf8().data(), R_OK))
145
inspectorFilesPath = WEB_INSPECTOR_DIR;
147
return "file://" + inspectorFilesPath;
150
InspectorFrontendClientEfl::InspectorFrontendClientEfl(Evas_Object* inspectedView, Evas_Object* inspectorView, InspectorClientEfl* inspectorClient)
151
: InspectorFrontendClientLocal(EWKPrivate::corePage(inspectedView)->inspectorController(), EWKPrivate::corePage(inspectorView), adoptPtr(new InspectorFrontendSettingsEfl()))
152
, m_inspectedView(inspectedView)
153
, m_inspectorView(inspectorView)
154
, m_inspectorClient(inspectorClient)
156
evas_object_smart_callback_add(m_inspectorView, "inspector,view,destroy", notifyInspectorDestroy, this);
159
InspectorFrontendClientEfl::~InspectorFrontendClientEfl()
161
evas_object_smart_callback_del(m_inspectorView, "inspector,view,destroy", notifyInspectorDestroy);
163
if (m_inspectorClient) {
164
m_inspectorClient->releaseFrontendPage();
165
m_inspectorClient = 0;
169
String InspectorFrontendClientEfl::localizedStringsURL()
171
return m_inspectorClient->inspectorFilesPath() + "/localizedStrings.js";
174
String InspectorFrontendClientEfl::hiddenPanels()
180
void InspectorFrontendClientEfl::bringToFront()
185
void InspectorFrontendClientEfl::closeWindow()
187
destroyInspectorWindow(true);
190
void InspectorFrontendClientEfl::inspectedURLChanged(const String&)
195
void InspectorFrontendClientEfl::attachWindow()
200
void InspectorFrontendClientEfl::detachWindow()
205
void InspectorFrontendClientEfl::setAttachedWindowHeight(unsigned)
210
void InspectorFrontendClientEfl::destroyInspectorWindow(bool notifyInspectorController)
212
if (notifyInspectorController)
213
EWKPrivate::corePage(m_inspectedView)->inspectorController()->disconnectFrontend();
215
if (m_inspectorClient)
216
m_inspectorClient->releaseFrontendPage();
218
evas_object_smart_callback_call(m_inspectedView, "inspector,view,close", m_inspectorView);