Support policy decision in web engine.
[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 // CLASSHEADER
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-console-message.h>
24 #include <dali/devel-api/adaptor-framework/web-engine-context.h>
25 #include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
26 #include <dali/devel-api/adaptor-framework/web-engine-load-error.h>
27 #include <dali/devel-api/adaptor-framework/web-engine-policy-decision.h>
28 #include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
29 #include <dali/devel-api/adaptor-framework/web-engine-settings.h>
30 #include <dali/internal/web-engine/common/web-engine-impl.h>
31
32 // EXTERNAL INCLUDES
33 #include <dali/public-api/images/pixel-data.h>
34
35 namespace Dali
36 {
37 WebEngine::WebEngine()
38 {
39 }
40
41 WebEngine::WebEngine(Internal::Adaptor::WebEngine* internal)
42 : BaseHandle(internal)
43 {
44 }
45
46 WebEngine::~WebEngine()
47 {
48 }
49
50 WebEngine WebEngine::New()
51 {
52   Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New();
53
54   return WebEngine(engine.Get());
55 }
56
57 WebEngine::WebEngine(const WebEngine& webEngine)
58 : BaseHandle(webEngine)
59 {
60 }
61
62 WebEngine& WebEngine::operator=(const WebEngine& webEngine)
63 {
64   if(*this != webEngine)
65   {
66     BaseHandle::operator=(webEngine);
67   }
68   return *this;
69 }
70
71 WebEngine WebEngine::DownCast(BaseHandle handle)
72 {
73   return WebEngine(dynamic_cast<Internal::Adaptor::WebEngine*>(handle.GetObjectPtr()));
74 }
75
76 void WebEngine::Create(int width, int height, const std::string& locale, const std::string& timezoneId)
77 {
78   GetImplementation(*this).Create(width, height, locale, timezoneId);
79 }
80
81 void WebEngine::Create(int width, int height, int argc, char** argv)
82 {
83   GetImplementation(*this).Create(width, height, argc, argv);
84 }
85
86 void WebEngine::Destroy()
87 {
88   GetImplementation(*this).Destroy();
89 }
90
91 NativeImageInterfacePtr WebEngine::GetNativeImageSource()
92 {
93   return GetImplementation(*this).GetNativeImageSource();
94 }
95
96 Dali::WebEngineSettings& WebEngine::GetSettings() const
97 {
98   return GetImplementation(*this).GetSettings();
99 }
100
101 Dali::WebEngineContext& WebEngine::GetContext() const
102 {
103   return GetImplementation(*this).GetContext();
104 }
105
106 Dali::WebEngineCookieManager& WebEngine::GetCookieManager() const
107 {
108   return GetImplementation(*this).GetCookieManager();
109 }
110
111 Dali::WebEngineBackForwardList& WebEngine::GetBackForwardList() const
112 {
113   return GetImplementation(*this).GetBackForwardList();
114 }
115
116 void WebEngine::LoadUrl(const std::string& url)
117 {
118   return GetImplementation(*this).LoadUrl(url);
119 }
120
121 std::string WebEngine::GetTitle() const
122 {
123   return GetImplementation(*this).GetTitle();
124 }
125
126 Dali::PixelData WebEngine::GetFavicon() const
127 {
128   return GetImplementation(*this).GetFavicon();
129 }
130
131 const std::string& WebEngine::GetUrl()
132 {
133   return GetImplementation(*this).GetUrl();
134 }
135
136 void WebEngine::LoadHtmlString(const std::string& htmlString)
137 {
138   GetImplementation(*this).LoadHtmlString(htmlString);
139 }
140
141 bool WebEngine::LoadHtmlStringOverrideCurrentEntry(const std::string& html, const std::string& basicUri, const std::string& unreachableUrl)
142 {
143   return GetImplementation(*this).LoadHtmlStringOverrideCurrentEntry(html, basicUri, unreachableUrl);
144 }
145
146 bool WebEngine::LoadContents(const std::string& contents, uint32_t contentSize, const std::string& mimeType, const std::string& encoding, const std::string& baseUri)
147 {
148   return GetImplementation(*this).LoadContents(contents, contentSize, mimeType, encoding, baseUri);
149 }
150
151 void WebEngine::Reload()
152 {
153   GetImplementation(*this).Reload();
154 }
155
156 bool WebEngine::ReloadWithoutCache()
157 {
158   return GetImplementation(*this).ReloadWithoutCache();
159 }
160
161 void WebEngine::StopLoading()
162 {
163   GetImplementation(*this).StopLoading();
164 }
165
166 void WebEngine::Suspend()
167 {
168   GetImplementation(*this).Suspend();
169 }
170
171 void WebEngine::Resume()
172 {
173   GetImplementation(*this).Resume();
174 }
175
176 void WebEngine::SuspendNetworkLoading()
177 {
178   GetImplementation(*this).SuspendNetworkLoading();
179 }
180
181 void WebEngine::ResumeNetworkLoading()
182 {
183   GetImplementation(*this).ResumeNetworkLoading();
184 }
185
186 bool WebEngine::AddCustomHeader(const std::string& name, const std::string& value)
187 {
188   return GetImplementation(*this).AddCustomHeader(name, value);
189 }
190
191 bool WebEngine::RemoveCustomHeader(const std::string& name)
192 {
193   return GetImplementation(*this).RemoveCustomHeader(name);
194 }
195
196 uint32_t WebEngine::StartInspectorServer(uint32_t port)
197 {
198   return GetImplementation(*this).StartInspectorServer(port);
199 }
200
201 bool WebEngine::StopInspectorServer()
202 {
203   return GetImplementation(*this).StopInspectorServer();
204 }
205
206 void WebEngine::ScrollBy(int deltaX, int deltaY)
207 {
208   GetImplementation(*this).ScrollBy(deltaX, deltaY);
209 }
210
211 bool WebEngine::ScrollEdgeBy(int deltaX, int deltaY)
212 {
213   return GetImplementation(*this).ScrollEdgeBy(deltaX, deltaY);
214 }
215
216 void WebEngine::SetScrollPosition(int x, int y)
217 {
218   GetImplementation(*this).SetScrollPosition(x, y);
219 }
220
221 Dali::Vector2 WebEngine::GetScrollPosition() const
222 {
223   return GetImplementation(*this).GetScrollPosition();
224 }
225
226 Dali::Vector2 WebEngine::GetScrollSize() const
227 {
228   return GetImplementation(*this).GetScrollSize();
229 }
230
231 Dali::Vector2 WebEngine::GetContentSize() const
232 {
233   return GetImplementation(*this).GetContentSize();
234 }
235
236 bool WebEngine::CanGoForward()
237 {
238   return GetImplementation(*this).CanGoForward();
239 }
240
241 void WebEngine::GoForward()
242 {
243   GetImplementation(*this).GoForward();
244 }
245
246 bool WebEngine::CanGoBack()
247 {
248   return GetImplementation(*this).CanGoBack();
249 }
250
251 void WebEngine::GoBack()
252 {
253   GetImplementation(*this).GoBack();
254 }
255
256 void WebEngine::EvaluateJavaScript(const std::string& script, std::function<void(const std::string&)> resultHandler)
257 {
258   GetImplementation(*this).EvaluateJavaScript(script, resultHandler);
259 }
260
261 void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler)
262 {
263   GetImplementation(*this).AddJavaScriptMessageHandler(exposedObjectName, handler);
264 }
265
266 void WebEngine::RegisterJavaScriptAlertCallback(Dali::WebEnginePlugin::JavaScriptAlertCallback callback)
267 {
268   GetImplementation(*this).RegisterJavaScriptAlertCallback(callback);
269 }
270
271 void WebEngine::JavaScriptAlertReply()
272 {
273   GetImplementation(*this).JavaScriptAlertReply();
274 }
275
276 void WebEngine::RegisterJavaScriptConfirmCallback(Dali::WebEnginePlugin::JavaScriptConfirmCallback callback)
277 {
278   GetImplementation(*this).RegisterJavaScriptConfirmCallback(callback);
279 }
280
281 void WebEngine::JavaScriptConfirmReply(bool confirmed)
282 {
283   GetImplementation(*this).JavaScriptConfirmReply(confirmed);
284 }
285
286 void WebEngine::RegisterJavaScriptPromptCallback(Dali::WebEnginePlugin::JavaScriptPromptCallback callback)
287 {
288   GetImplementation(*this).RegisterJavaScriptPromptCallback(callback);
289 }
290
291 void WebEngine::JavaScriptPromptReply(const std::string& result)
292 {
293   GetImplementation(*this).JavaScriptPromptReply(result);
294 }
295
296 void WebEngine::ClearHistory()
297 {
298   GetImplementation(*this).ClearHistory();
299 }
300
301 void WebEngine::ClearAllTilesResources()
302 {
303   GetImplementation(*this).ClearAllTilesResources();
304 }
305
306 const std::string& WebEngine::GetUserAgent() const
307 {
308   return GetImplementation(*this).GetUserAgent();
309 }
310
311 void WebEngine::SetUserAgent(const std::string& userAgent)
312 {
313   GetImplementation(*this).SetUserAgent(userAgent);
314 }
315
316 void WebEngine::SetSize(int width, int height)
317 {
318   GetImplementation(*this).SetSize(width, height);
319 }
320
321 void WebEngine::SetDocumentBackgroundColor(Dali::Vector4 color)
322 {
323   GetImplementation(*this).SetDocumentBackgroundColor(color);
324 }
325
326 void WebEngine::ClearTilesWhenHidden(bool cleared)
327 {
328   GetImplementation(*this).ClearTilesWhenHidden(cleared);
329 }
330
331 void WebEngine::SetTileCoverAreaMultiplier(float multiplier)
332 {
333   GetImplementation(*this).SetTileCoverAreaMultiplier(multiplier);
334 }
335
336 void WebEngine::EnableCursorByClient(bool enabled)
337 {
338   GetImplementation(*this).EnableCursorByClient(enabled);
339 }
340
341 std::string WebEngine::GetSelectedText() const
342 {
343   return GetImplementation(*this).GetSelectedText();
344 }
345
346 bool WebEngine::SendTouchEvent(const TouchEvent& touch)
347 {
348   return GetImplementation(*this).SendTouchEvent(touch);
349 }
350
351 bool WebEngine::SendKeyEvent(const KeyEvent& event)
352 {
353   return GetImplementation(*this).SendKeyEvent(event);
354 }
355
356 bool WebEngine::SendHoverEvent( const HoverEvent& event )
357 {
358   return GetImplementation( *this ).SendHoverEvent( event );
359 }
360
361 bool WebEngine::SendWheelEvent( const WheelEvent& event )
362 {
363   return GetImplementation( *this ).SendWheelEvent( event );
364 }
365
366 void WebEngine::SetFocus(bool focused)
367 {
368   GetImplementation(*this).SetFocus(focused);
369 }
370
371 void WebEngine::SetPageZoomFactor(float zoomFactor)
372 {
373   GetImplementation(*this).SetPageZoomFactor(zoomFactor);
374 }
375
376 float WebEngine::GetPageZoomFactor() const
377 {
378   return GetImplementation(*this).GetPageZoomFactor();
379 }
380
381 void WebEngine::SetTextZoomFactor(float zoomFactor)
382 {
383   GetImplementation(*this).SetTextZoomFactor(zoomFactor);
384 }
385
386 float WebEngine::GetTextZoomFactor() const
387 {
388   return GetImplementation(*this).GetTextZoomFactor();
389 }
390
391 float WebEngine::GetLoadProgressPercentage() const
392 {
393   return GetImplementation(*this).GetLoadProgressPercentage();
394 }
395
396 void WebEngine::SetScaleFactor(float scaleFactor, Dali::Vector2 point)
397 {
398   GetImplementation(*this).SetScaleFactor(scaleFactor, point);
399 }
400
401 float WebEngine::GetScaleFactor() const
402 {
403   return GetImplementation(*this).GetScaleFactor();
404 }
405
406 void WebEngine::ActivateAccessibility(bool activated)
407 {
408   GetImplementation(*this).ActivateAccessibility(activated);
409 }
410
411 bool WebEngine::SetVisibility(bool visible)
412 {
413   return GetImplementation(*this).SetVisibility(visible);
414 }
415
416 bool WebEngine::HighlightText(const std::string& text, Dali::WebEnginePlugin::FindOption options, uint32_t maxMatchCount)
417 {
418   return GetImplementation(*this).HighlightText(text, options, maxMatchCount);
419 }
420
421 void WebEngine::AddDynamicCertificatePath(const std::string& host, const std::string& certPath)
422 {
423   GetImplementation(*this).AddDynamicCertificatePath(host, certPath);
424 }
425
426 Dali::PixelData WebEngine::GetScreenshot(Dali::Rect<int> viewArea, float scaleFactor)
427 {
428   return GetImplementation(*this).GetScreenshot(viewArea, scaleFactor);
429 }
430
431 bool WebEngine::GetScreenshotAsynchronously(Dali::Rect<int> viewArea, float scaleFactor, Dali::WebEnginePlugin::ScreenshotCapturedCallback callback)
432 {
433   return GetImplementation(*this).GetScreenshotAsynchronously(viewArea, scaleFactor, callback);
434 }
435
436 bool WebEngine::CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback)
437 {
438   return GetImplementation(*this).CheckVideoPlayingAsynchronously(callback);
439 }
440
441 void WebEngine::RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback)
442 {
443   GetImplementation(*this).RegisterGeolocationPermissionCallback(callback);
444 }
445
446 void WebEngine::UpdateDisplayArea(Dali::Rect<int> displayArea)
447 {
448   GetImplementation(*this).UpdateDisplayArea(displayArea);
449 }
450
451 void WebEngine::EnableMouseEvents(bool enabled)
452 {
453   GetImplementation(*this).EnableMouseEvents(enabled);
454 }
455
456 void WebEngine::EnableKeyEvents(bool enabled)
457 {
458   GetImplementation(*this).EnableKeyEvents(enabled);
459 }
460
461 void WebEngine::EnableVideoHole(bool enabled)
462 {
463   GetImplementation(*this).EnableVideoHole(enabled);
464 }
465
466 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
467 {
468   return GetImplementation(*this).PageLoadStartedSignal();
469 }
470
471 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadInProgressSignal()
472 {
473   return GetImplementation(*this).PageLoadInProgressSignal();
474 }
475
476 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal()
477 {
478   return GetImplementation(*this).PageLoadFinishedSignal();
479 }
480
481 Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal()
482 {
483   return GetImplementation(*this).PageLoadErrorSignal();
484 }
485
486 Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
487 {
488   return GetImplementation(*this).ScrollEdgeReachedSignal();
489 }
490
491 Dali::WebEnginePlugin::WebEngineUrlChangedSignalType& WebEngine::UrlChangedSignal()
492 {
493   return GetImplementation(*this).UrlChangedSignal();
494 }
495
496 Dali::WebEnginePlugin::WebEngineFormRepostDecisionSignalType& WebEngine::FormRepostDecisionSignal()
497 {
498   return GetImplementation(*this).FormRepostDecisionSignal();
499 }
500
501 Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& WebEngine::FrameRenderedSignal()
502 {
503   return GetImplementation(*this).FrameRenderedSignal();
504 }
505
506 Dali::WebEnginePlugin::WebEngineRequestInterceptorSignalType& WebEngine::RequestInterceptorSignal()
507 {
508   return GetImplementation(*this).RequestInterceptorSignal();
509 }
510
511 Dali::WebEnginePlugin::WebEngineConsoleMessageSignalType& WebEngine::ConsoleMessageSignal()
512 {
513   return GetImplementation(*this).ConsoleMessageSignal();
514 }
515
516 Dali::WebEnginePlugin::WebEnginePolicyDecisionSignalType& WebEngine::PolicyDecisionSignal()
517 {
518   return GetImplementation(*this).PolicyDecisionSignal();
519 }
520
521 } // namespace Dali