35eac17e512e8281f74510d52f308b1ae3476a4d
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / web-engine.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/devel-api/adaptor-framework/web-engine.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/devel-api/adaptor-framework/web-engine-back-forward-list.h>
23 #include <dali/devel-api/adaptor-framework/web-engine-context.h>
24 #include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
25 #include <dali/devel-api/adaptor-framework/web-engine-settings.h>
26 #include <dali/internal/web-engine/common/web-engine-impl.h>
27
28 // EXTERNAL INCLUDES
29 #include <dali/public-api/images/pixel-data.h>
30
31 namespace Dali
32 {
33 WebEngine::WebEngine()
34 {
35 }
36
37 WebEngine::WebEngine(Internal::Adaptor::WebEngine* internal)
38 : BaseHandle(internal)
39 {
40 }
41
42 WebEngine::~WebEngine()
43 {
44 }
45
46 WebEngine WebEngine::New()
47 {
48   Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New();
49
50   return WebEngine(engine.Get());
51 }
52
53 WebEngine::WebEngine(const WebEngine& webEngine)
54 : BaseHandle(webEngine)
55 {
56 }
57
58 WebEngine& WebEngine::operator=(const WebEngine& webEngine)
59 {
60   if(*this != webEngine)
61   {
62     BaseHandle::operator=(webEngine);
63   }
64   return *this;
65 }
66
67 WebEngine WebEngine::DownCast(BaseHandle handle)
68 {
69   return WebEngine(dynamic_cast<Internal::Adaptor::WebEngine*>(handle.GetObjectPtr()));
70 }
71
72 void WebEngine::Create(int width, int height, const std::string& locale, const std::string& timezoneId)
73 {
74   GetImplementation(*this).Create(width, height, locale, timezoneId);
75 }
76
77 void WebEngine::Create(int width, int height, int argc, char** argv)
78 {
79   GetImplementation(*this).Create(width, height, argc, argv);
80 }
81
82 void WebEngine::Destroy()
83 {
84   GetImplementation(*this).Destroy();
85 }
86
87 NativeImageInterfacePtr WebEngine::GetNativeImageSource()
88 {
89   return GetImplementation(*this).GetNativeImageSource();
90 }
91
92 Dali::WebEngineSettings& WebEngine::GetSettings() const
93 {
94   return GetImplementation(*this).GetSettings();
95 }
96
97 Dali::WebEngineContext& WebEngine::GetContext() const
98 {
99   return GetImplementation(*this).GetContext();
100 }
101
102 Dali::WebEngineCookieManager& WebEngine::GetCookieManager() const
103 {
104   return GetImplementation(*this).GetCookieManager();
105 }
106
107 Dali::WebEngineBackForwardList& WebEngine::GetBackForwardList() const
108 {
109   return GetImplementation(*this).GetBackForwardList();
110 }
111
112 void WebEngine::LoadUrl(const std::string& url)
113 {
114   return GetImplementation(*this).LoadUrl(url);
115 }
116
117 std::string WebEngine::GetTitle() const
118 {
119   return GetImplementation(*this).GetTitle();
120 }
121
122 Dali::PixelData WebEngine::GetFavicon() const
123 {
124   return GetImplementation(*this).GetFavicon();
125 }
126
127 const std::string& WebEngine::GetUrl()
128 {
129   return GetImplementation(*this).GetUrl();
130 }
131
132 void WebEngine::LoadHtmlString(const std::string& htmlString)
133 {
134   GetImplementation(*this).LoadHtmlString(htmlString);
135 }
136
137 void WebEngine::Reload()
138 {
139   GetImplementation(*this).Reload();
140 }
141
142 void WebEngine::StopLoading()
143 {
144   GetImplementation(*this).StopLoading();
145 }
146
147 void WebEngine::Suspend()
148 {
149   GetImplementation(*this).Suspend();
150 }
151
152 void WebEngine::Resume()
153 {
154   GetImplementation(*this).Resume();
155 }
156
157 void WebEngine::ScrollBy(int deltaX, int deltaY)
158 {
159   GetImplementation(*this).ScrollBy(deltaX, deltaY);
160 }
161
162 void WebEngine::SetScrollPosition(int x, int y)
163 {
164   GetImplementation(*this).SetScrollPosition(x, y);
165 }
166
167 Dali::Vector2 WebEngine::GetScrollPosition() const
168 {
169   return GetImplementation(*this).GetScrollPosition();
170 }
171
172 Dali::Vector2 WebEngine::GetScrollSize() const
173 {
174   return GetImplementation(*this).GetScrollSize();
175 }
176
177 Dali::Vector2 WebEngine::GetContentSize() const
178 {
179   return GetImplementation(*this).GetContentSize();
180 }
181
182 bool WebEngine::CanGoForward()
183 {
184   return GetImplementation(*this).CanGoForward();
185 }
186
187 void WebEngine::GoForward()
188 {
189   GetImplementation(*this).GoForward();
190 }
191
192 bool WebEngine::CanGoBack()
193 {
194   return GetImplementation(*this).CanGoBack();
195 }
196
197 void WebEngine::GoBack()
198 {
199   GetImplementation(*this).GoBack();
200 }
201
202 void WebEngine::EvaluateJavaScript(const std::string& script, std::function<void(const std::string&)> resultHandler)
203 {
204   GetImplementation(*this).EvaluateJavaScript(script, resultHandler);
205 }
206
207 void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler)
208 {
209   GetImplementation(*this).AddJavaScriptMessageHandler(exposedObjectName, handler);
210 }
211
212 void WebEngine::RegisterJavaScriptAlertCallback(Dali::WebEnginePlugin::JavaScriptAlertCallback callback)
213 {
214   GetImplementation(*this).RegisterJavaScriptAlertCallback(callback);
215 }
216
217 void WebEngine::JavaScriptAlertReply()
218 {
219   GetImplementation(*this).JavaScriptAlertReply();
220 }
221
222 void WebEngine::RegisterJavaScriptConfirmCallback(Dali::WebEnginePlugin::JavaScriptConfirmCallback callback)
223 {
224   GetImplementation(*this).RegisterJavaScriptConfirmCallback(callback);
225 }
226
227 void WebEngine::JavaScriptConfirmReply(bool confirmed)
228 {
229   GetImplementation(*this).JavaScriptConfirmReply(confirmed);
230 }
231
232 void WebEngine::RegisterJavaScriptPromptCallback(Dali::WebEnginePlugin::JavaScriptPromptCallback callback)
233 {
234   GetImplementation(*this).RegisterJavaScriptPromptCallback(callback);
235 }
236
237 void WebEngine::JavaScriptPromptReply(const std::string& result)
238 {
239   GetImplementation(*this).JavaScriptPromptReply(result);
240 }
241
242 void WebEngine::ClearHistory()
243 {
244   return GetImplementation(*this).ClearHistory();
245 }
246
247 void WebEngine::ClearAllTilesResources()
248 {
249   GetImplementation(*this).ClearAllTilesResources();
250 }
251
252 const std::string& WebEngine::GetUserAgent() const
253 {
254   return GetImplementation(*this).GetUserAgent();
255 }
256
257 void WebEngine::SetUserAgent(const std::string& userAgent)
258 {
259   GetImplementation(*this).SetUserAgent(userAgent);
260 }
261
262 void WebEngine::SetSize(int width, int height)
263 {
264   GetImplementation(*this).SetSize(width, height);
265 }
266
267 void WebEngine::SetDocumentBackgroundColor(Dali::Vector4 color)
268 {
269   GetImplementation(*this).SetDocumentBackgroundColor(color);
270 }
271
272 void WebEngine::ClearTilesWhenHidden(bool cleared)
273 {
274   GetImplementation(*this).ClearTilesWhenHidden(cleared);
275 }
276
277 void WebEngine::SetTileCoverAreaMultiplier(float multiplier)
278 {
279   GetImplementation(*this).SetTileCoverAreaMultiplier(multiplier);
280 }
281
282 void WebEngine::EnableCursorByClient(bool enabled)
283 {
284   GetImplementation(*this).EnableCursorByClient(enabled);
285 }
286
287 std::string WebEngine::GetSelectedText() const
288 {
289   return GetImplementation(*this).GetSelectedText();
290 }
291
292 bool WebEngine::SendTouchEvent(const TouchEvent& touch)
293 {
294   return GetImplementation(*this).SendTouchEvent(touch);
295 }
296
297 bool WebEngine::SendKeyEvent(const KeyEvent& event)
298 {
299   return GetImplementation(*this).SendKeyEvent(event);
300 }
301
302 bool WebEngine::SendHoverEvent( const HoverEvent& event )
303 {
304   return GetImplementation( *this ).SendHoverEvent( event );
305 }
306
307 bool WebEngine::SendWheelEvent( const WheelEvent& event )
308 {
309   return GetImplementation( *this ).SendWheelEvent( event );
310 }
311
312 void WebEngine::SetFocus(bool focused)
313 {
314   GetImplementation(*this).SetFocus(focused);
315 }
316
317 void WebEngine::UpdateDisplayArea(Dali::Rect<int> displayArea)
318 {
319   GetImplementation(*this).UpdateDisplayArea(displayArea);
320 }
321
322 void WebEngine::EnableMouseEvents(bool enabled)
323 {
324   GetImplementation(*this).EnableMouseEvents(enabled);
325 }
326
327 void WebEngine::EnableKeyEvents(bool enabled)
328 {
329   GetImplementation(*this).EnableKeyEvents(enabled);
330 }
331
332 void WebEngine::EnableVideoHole(bool enabled)
333 {
334   GetImplementation(*this).EnableVideoHole(enabled);
335 }
336
337 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
338 {
339   return GetImplementation(*this).PageLoadStartedSignal();
340 }
341
342 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadInProgressSignal()
343 {
344   return GetImplementation(*this).PageLoadInProgressSignal();
345 }
346
347 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal()
348 {
349   return GetImplementation(*this).PageLoadFinishedSignal();
350 }
351
352 Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal()
353 {
354   return GetImplementation(*this).PageLoadErrorSignal();
355 }
356
357 Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
358 {
359   return GetImplementation(*this).ScrollEdgeReachedSignal();
360 }
361
362 Dali::WebEnginePlugin::WebEngineUrlChangedSignalType& WebEngine::UrlChangedSignal()
363 {
364   return GetImplementation(*this).UrlChangedSignal();
365 }
366
367 } // namespace Dali