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

« back to all changes in this revision

Viewing changes to Source/WebKit2/UIProcess/efl/PageUIClientEfl.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) 2012 Samsung Electronics. All rights reserved.
 
3
 * Copyright (C) 2012 Intel Corporation. All rights reserved.
 
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 INC. AND ITS CONTRIBUTORS ``AS IS''
 
15
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 
16
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
17
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 
18
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
19
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
20
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
21
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
22
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
23
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 
24
 * THE POSSIBILITY OF SUCH DAMAGE.
 
25
 */
 
26
 
 
27
#include "config.h"
 
28
#include "PageUIClientEfl.h"
 
29
 
 
30
#include "EwkViewImpl.h"
 
31
#include "WKAPICast.h"
 
32
#include "WKEvent.h"
 
33
#include "WKString.h"
 
34
#include "ewk_file_chooser_request_private.h"
 
35
#include "ewk_window_features_private.h"
 
36
#include <Ecore_Evas.h>
 
37
#include <WebCore/Color.h>
 
38
 
 
39
using namespace EwkViewCallbacks;
 
40
 
 
41
namespace WebKit {
 
42
 
 
43
static inline PageUIClientEfl* toPageUIClientEfl(const void* clientInfo)
 
44
{
 
45
    return static_cast<PageUIClientEfl*>(const_cast<void*>(clientInfo));
 
46
}
 
47
 
 
48
void PageUIClientEfl::closePage(WKPageRef, const void* clientInfo)
 
49
{
 
50
    toPageUIClientEfl(clientInfo)->m_viewImpl->closePage();
 
51
}
 
52
 
 
53
WKPageRef PageUIClientEfl::createNewPage(WKPageRef, WKURLRequestRef, WKDictionaryRef wkWindowFeatures, WKEventModifiers, WKEventMouseButton, const void* clientInfo)
 
54
{
 
55
    return toPageUIClientEfl(clientInfo)->m_viewImpl->createNewPage(toImpl(wkWindowFeatures));
 
56
}
 
57
 
 
58
void PageUIClientEfl::runJavaScriptAlert(WKPageRef, WKStringRef alertText, WKFrameRef, const void* clientInfo)
 
59
{
 
60
    toPageUIClientEfl(clientInfo)->m_viewImpl->requestJSAlertPopup(WKEinaSharedString(alertText));
 
61
}
 
62
 
 
63
bool PageUIClientEfl::runJavaScriptConfirm(WKPageRef, WKStringRef message, WKFrameRef, const void* clientInfo)
 
64
{
 
65
    return toPageUIClientEfl(clientInfo)->m_viewImpl->requestJSConfirmPopup(WKEinaSharedString(message));
 
66
}
 
67
 
 
68
WKStringRef PageUIClientEfl::runJavaScriptPrompt(WKPageRef, WKStringRef message, WKStringRef defaultValue, WKFrameRef, const void* clientInfo)
 
69
{
 
70
    WKEinaSharedString value = toPageUIClientEfl(clientInfo)->m_viewImpl->requestJSPromptPopup(WKEinaSharedString(message), WKEinaSharedString(defaultValue));
 
71
    return value ? WKStringCreateWithUTF8CString(value) : 0;
 
72
}
 
73
 
 
74
bool PageUIClientEfl::toolbarsAreVisible(WKPageRef, const void* clientInfo)
 
75
{
 
76
    EwkWindowFeatures* features = toPageUIClientEfl(clientInfo)->m_viewImpl->windowFeatures();
 
77
    ASSERT(features);
 
78
    return features->toolbarVisible();
 
79
}
 
80
 
 
81
void PageUIClientEfl::setToolbarsAreVisible(WKPageRef, bool toolbarVisible, const void* clientInfo)
 
82
{
 
83
    EwkWindowFeatures* features = toPageUIClientEfl(clientInfo)->m_viewImpl->windowFeatures();
 
84
    ASSERT(features);
 
85
    features->setToolbarVisible(toolbarVisible);
 
86
}
 
87
 
 
88
bool PageUIClientEfl::menuBarIsVisible(WKPageRef, const void* clientInfo)
 
89
{
 
90
    EwkWindowFeatures* features = toPageUIClientEfl(clientInfo)->m_viewImpl->windowFeatures();
 
91
    ASSERT(features);
 
92
    return features->menuBarVisible();
 
93
}
 
94
 
 
95
void PageUIClientEfl::setMenuBarIsVisible(WKPageRef, bool menuBarVisible, const void* clientInfo)
 
96
{
 
97
    EwkWindowFeatures* features = toPageUIClientEfl(clientInfo)->m_viewImpl->windowFeatures();
 
98
    ASSERT(features);
 
99
    features->setMenuBarVisible(menuBarVisible);
 
100
}
 
101
 
 
102
bool PageUIClientEfl::statusBarIsVisible(WKPageRef, const void* clientInfo)
 
103
{
 
104
    EwkWindowFeatures* features = toPageUIClientEfl(clientInfo)->m_viewImpl->windowFeatures();
 
105
    ASSERT(features);
 
106
    return features->statusBarVisible();
 
107
}
 
108
 
 
109
void PageUIClientEfl::setStatusBarIsVisible(WKPageRef, bool statusBarVisible, const void* clientInfo)
 
110
{
 
111
    EwkWindowFeatures* features = toPageUIClientEfl(clientInfo)->m_viewImpl->windowFeatures();
 
112
    ASSERT(features);
 
113
    features->setStatusBarVisible(statusBarVisible);
 
114
}
 
115
 
 
116
bool PageUIClientEfl::isResizable(WKPageRef, const void* clientInfo)
 
117
{
 
118
    EwkWindowFeatures* features = toPageUIClientEfl(clientInfo)->m_viewImpl->windowFeatures();
 
119
    ASSERT(features);
 
120
    return features->resizable();
 
121
}
 
122
 
 
123
void PageUIClientEfl::setIsResizable(WKPageRef, bool resizable, const void* clientInfo)
 
124
{
 
125
    EwkWindowFeatures* features = toPageUIClientEfl(clientInfo)->m_viewImpl->windowFeatures();
 
126
    ASSERT(features);
 
127
    features->setResizable(resizable);
 
128
}
 
129
 
 
130
#if ENABLE(INPUT_TYPE_COLOR)
 
131
void PageUIClientEfl::showColorPicker(WKPageRef, WKStringRef initialColor, WKColorPickerResultListenerRef listener, const void* clientInfo)
 
132
{
 
133
    PageUIClientEfl* pageUIClient = toPageUIClientEfl(clientInfo);
 
134
    WebCore::Color color = WebCore::Color(WebKit::toWTFString(initialColor));
 
135
    pageUIClient->m_viewImpl->requestColorPicker(listener, color);
 
136
}
 
137
 
 
138
void PageUIClientEfl::hideColorPicker(WKPageRef, const void* clientInfo)
 
139
{
 
140
    PageUIClientEfl* pageUIClient = toPageUIClientEfl(clientInfo);
 
141
    pageUIClient->m_viewImpl->dismissColorPicker();
 
142
}
 
143
#endif
 
144
 
 
145
#if ENABLE(SQL_DATABASE)
 
146
unsigned long long PageUIClientEfl::exceededDatabaseQuota(WKPageRef, WKFrameRef, WKSecurityOriginRef, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage, const void* clientInfo)
 
147
{
 
148
    EwkViewImpl* viewImpl = toPageUIClientEfl(clientInfo)->m_viewImpl;
 
149
    return viewImpl->informDatabaseQuotaReached(toImpl(databaseName)->string(), toImpl(displayName)->string(), currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage);
 
150
}
 
151
#endif
 
152
 
 
153
void PageUIClientEfl::focus(WKPageRef, const void* clientInfo)
 
154
{
 
155
    evas_object_focus_set(toPageUIClientEfl(clientInfo)->m_viewImpl->view(), true);
 
156
}
 
157
 
 
158
void PageUIClientEfl::unfocus(WKPageRef, const void* clientInfo)
 
159
{
 
160
    evas_object_focus_set(toPageUIClientEfl(clientInfo)->m_viewImpl->view(), false);
 
161
}
 
162
 
 
163
void PageUIClientEfl::takeFocus(WKPageRef, WKFocusDirection, const void* clientInfo)
 
164
{
 
165
    // FIXME: this is only a partial implementation.
 
166
    evas_object_focus_set(toPageUIClientEfl(clientInfo)->m_viewImpl->view(), false);
 
167
}
 
168
 
 
169
WKRect PageUIClientEfl::getWindowFrame(WKPageRef, const void* clientInfo)
 
170
{
 
171
    return toPageUIClientEfl(clientInfo)->m_viewImpl->windowGeometry();
 
172
}
 
173
 
 
174
void PageUIClientEfl::setWindowFrame(WKPageRef, WKRect frame, const void* clientInfo)
 
175
{
 
176
    toPageUIClientEfl(clientInfo)->m_viewImpl->setWindowGeometry(frame);
 
177
}
 
178
 
 
179
void PageUIClientEfl::runOpenPanel(WKPageRef, WKFrameRef, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void* clientInfo)
 
180
{
 
181
    EwkViewImpl* viewImpl = toPageUIClientEfl(clientInfo)->m_viewImpl;
 
182
    RefPtr<EwkFileChooserRequest> fileChooserRequest = EwkFileChooserRequest::create(toImpl(parameters), toImpl(listener));
 
183
    viewImpl->smartCallback<FileChooserRequest>().call(fileChooserRequest.get());
 
184
}
 
185
 
 
186
PageUIClientEfl::PageUIClientEfl(EwkViewImpl* viewImpl)
 
187
    : m_viewImpl(viewImpl)
 
188
{
 
189
    WKPageRef pageRef = m_viewImpl->wkPage();
 
190
    ASSERT(pageRef);
 
191
 
 
192
    WKPageUIClient uiClient;
 
193
    memset(&uiClient, 0, sizeof(WKPageUIClient));
 
194
    uiClient.version = kWKPageUIClientCurrentVersion;
 
195
    uiClient.clientInfo = this;
 
196
    uiClient.close = closePage;
 
197
    uiClient.createNewPage = createNewPage;
 
198
    uiClient.runJavaScriptAlert = runJavaScriptAlert;
 
199
    uiClient.runJavaScriptConfirm = runJavaScriptConfirm;
 
200
    uiClient.runJavaScriptPrompt = runJavaScriptPrompt;
 
201
    uiClient.toolbarsAreVisible = toolbarsAreVisible;
 
202
    uiClient.setToolbarsAreVisible = setToolbarsAreVisible;
 
203
    uiClient.menuBarIsVisible = menuBarIsVisible;
 
204
    uiClient.setMenuBarIsVisible = setMenuBarIsVisible;
 
205
    uiClient.statusBarIsVisible = statusBarIsVisible;
 
206
    uiClient.setStatusBarIsVisible = setStatusBarIsVisible;
 
207
    uiClient.isResizable = isResizable;
 
208
    uiClient.setIsResizable = setIsResizable;
 
209
    uiClient.takeFocus = takeFocus;
 
210
    uiClient.focus = focus;
 
211
    uiClient.unfocus = unfocus;
 
212
    uiClient.getWindowFrame = getWindowFrame;
 
213
    uiClient.setWindowFrame = setWindowFrame;
 
214
    uiClient.runOpenPanel = runOpenPanel;
 
215
#if ENABLE(SQL_DATABASE)
 
216
    uiClient.exceededDatabaseQuota = exceededDatabaseQuota;
 
217
#endif
 
218
 
 
219
#if ENABLE(INPUT_TYPE_COLOR)
 
220
    uiClient.showColorPicker = showColorPicker;
 
221
    uiClient.hideColorPicker = hideColorPicker;
 
222
#endif
 
223
 
 
224
    WKPageSetPageUIClient(pageRef, &uiClient);
 
225
}
 
226
 
 
227
} // namespace WebKit