~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebKit/efl/WebCoreSupport/InspectorClientEfl.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (C) 2008 INdT - Instituto Nokia de Tecnologia
 
3
 *  Copyright (C) 2009-2010 ProFUSION embedded systems
 
4
 *  Copyright (C) 2009-2010 Samsung Electronics
 
5
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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
 
19
 */
 
20
 
 
21
#include "config.h"
 
22
#include "InspectorClientEfl.h"
 
23
 
 
24
#if ENABLE(INSPECTOR)
 
25
#include "InspectorController.h"
 
26
#include "NotImplemented.h"
 
27
#include "ewk_view_private.h"
 
28
#include <unistd.h>
 
29
#include <wtf/text/WTFString.h>
 
30
 
 
31
namespace WebCore {
 
32
 
 
33
static void notifyInspectorDestroy(void* userData, Evas_Object* /*webview*/, void* /*eventInfo*/)
 
34
{
 
35
    InspectorFrontendClientEfl* inspectorFrontendClient = static_cast<InspectorFrontendClientEfl*>(userData);
 
36
    if (inspectorFrontendClient)
 
37
        inspectorFrontendClient->destroyInspectorWindow(true);
 
38
}
 
39
 
 
40
static void invalidateView(Evas_Object* webView)
 
41
{
 
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);
 
46
        if (page)
 
47
            page->mainFrame()->view()->invalidateRect(WebCore::IntRect(0, 0, width, height));
 
48
    }
 
49
}
 
50
 
 
51
class InspectorFrontendSettingsEfl : public InspectorFrontendClientLocal::Settings {
 
52
public:
 
53
    virtual String getProperty(const String& /*name*/)
 
54
    {
 
55
        notImplemented();
 
56
        return String();
 
57
    }
 
58
 
 
59
    virtual void setProperty(const String& /*name*/, const String& /*value*/)
 
60
    {
 
61
        notImplemented();
 
62
    }
 
63
};
 
64
 
 
65
InspectorClientEfl::InspectorClientEfl(Evas_Object* webView)
 
66
    : m_inspectedView(webView)
 
67
    , m_inspectorView(0)
 
68
    , m_frontendClient(0)
 
69
{
 
70
}
 
71
 
 
72
InspectorClientEfl::~InspectorClientEfl()
 
73
{
 
74
    if (m_frontendClient) {
 
75
        m_frontendClient->disconnectInspectorClient();
 
76
        m_frontendClient = 0;
 
77
    }
 
78
}
 
79
 
 
80
void InspectorClientEfl::inspectorDestroyed()
 
81
{
 
82
    closeInspectorFrontend();
 
83
    delete this;
 
84
}
 
85
 
 
86
InspectorFrontendChannel* InspectorClientEfl::openInspectorFrontend(InspectorController*)
 
87
{
 
88
    evas_object_smart_callback_call(m_inspectedView, "inspector,view,create", 0);
 
89
 
 
90
    Evas_Object* inspectorView = ewk_view_inspector_view_get(m_inspectedView);
 
91
    if (!inspectorView)
 
92
        return 0;
 
93
 
 
94
    m_inspectorView = inspectorView;
 
95
 
 
96
    String inspectorUri = inspectorFilesPath() + "/inspector.html";
 
97
    ewk_view_uri_set(m_inspectorView, inspectorUri.utf8().data());
 
98
 
 
99
    OwnPtr<InspectorFrontendClientEfl> frontendClient = adoptPtr(new InspectorFrontendClientEfl(m_inspectedView, m_inspectorView, this));
 
100
    m_frontendClient = frontendClient.get();
 
101
 
 
102
    InspectorController* controller = EWKPrivate::corePage(m_inspectorView)->inspectorController();
 
103
    controller->setInspectorFrontendClient(frontendClient.release());
 
104
    
 
105
    return this;
 
106
}
 
107
 
 
108
void InspectorClientEfl::closeInspectorFrontend()
 
109
{
 
110
    if (m_frontendClient)
 
111
        m_frontendClient->destroyInspectorWindow(false);
 
112
}
 
113
 
 
114
void InspectorClientEfl::bringFrontendToFront()
 
115
{
 
116
    m_frontendClient->bringToFront();
 
117
}
 
118
 
 
119
void InspectorClientEfl::highlight()
 
120
{
 
121
    invalidateView(m_inspectedView);
 
122
}
 
123
 
 
124
void InspectorClientEfl::hideHighlight()
 
125
{
 
126
    invalidateView(m_inspectedView);
 
127
}
 
128
 
 
129
bool InspectorClientEfl::sendMessageToFrontend(const String& message)
 
130
{
 
131
    Page* frontendPage = EWKPrivate::corePage(m_inspectorView);
 
132
    return doDispatchMessageOnFrontendPage(frontendPage, message);
 
133
}
 
134
 
 
135
void InspectorClientEfl::releaseFrontendPage()
 
136
{
 
137
    m_inspectorView = 0;
 
138
    m_frontendClient = 0;
 
139
}
 
140
 
 
141
String InspectorClientEfl::inspectorFilesPath()
 
142
{
 
143
    String inspectorFilesPath = WEB_INSPECTOR_INSTALL_DIR;
 
144
    if (access(inspectorFilesPath.utf8().data(), R_OK))
 
145
        inspectorFilesPath = WEB_INSPECTOR_DIR;
 
146
 
 
147
    return "file://" + inspectorFilesPath;
 
148
}
 
149
 
 
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)
 
155
{
 
156
    evas_object_smart_callback_add(m_inspectorView, "inspector,view,destroy", notifyInspectorDestroy, this);
 
157
}
 
158
 
 
159
InspectorFrontendClientEfl::~InspectorFrontendClientEfl()
 
160
{
 
161
    evas_object_smart_callback_del(m_inspectorView, "inspector,view,destroy", notifyInspectorDestroy);
 
162
 
 
163
    if (m_inspectorClient) {
 
164
        m_inspectorClient->releaseFrontendPage();
 
165
        m_inspectorClient = 0;
 
166
    }
 
167
}
 
168
 
 
169
String InspectorFrontendClientEfl::localizedStringsURL()
 
170
{
 
171
    return m_inspectorClient->inspectorFilesPath() + "/localizedStrings.js";
 
172
}
 
173
 
 
174
String InspectorFrontendClientEfl::hiddenPanels()
 
175
{
 
176
    notImplemented();
 
177
    return String();
 
178
}
 
179
 
 
180
void InspectorFrontendClientEfl::bringToFront()
 
181
{
 
182
    notImplemented();
 
183
}
 
184
 
 
185
void InspectorFrontendClientEfl::closeWindow()
 
186
{
 
187
    destroyInspectorWindow(true);
 
188
}
 
189
 
 
190
void InspectorFrontendClientEfl::inspectedURLChanged(const String&)
 
191
{
 
192
    notImplemented();
 
193
}
 
194
 
 
195
void InspectorFrontendClientEfl::attachWindow()
 
196
{
 
197
    notImplemented();
 
198
}
 
199
 
 
200
void InspectorFrontendClientEfl::detachWindow()
 
201
{
 
202
    notImplemented();
 
203
}
 
204
 
 
205
void InspectorFrontendClientEfl::setAttachedWindowHeight(unsigned)
 
206
{
 
207
    notImplemented();
 
208
}
 
209
 
 
210
void InspectorFrontendClientEfl::destroyInspectorWindow(bool notifyInspectorController)
 
211
{
 
212
    if (notifyInspectorController)
 
213
        EWKPrivate::corePage(m_inspectedView)->inspectorController()->disconnectFrontend();
 
214
 
 
215
    if (m_inspectorClient)
 
216
        m_inspectorClient->releaseFrontendPage();
 
217
 
 
218
    evas_object_smart_callback_call(m_inspectedView, "inspector,view,close", m_inspectorView);
 
219
}
 
220
 
 
221
}
 
222
#endif