[dali_2.0.24] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / web-view / web-view-impl.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 "web-view-impl.h"
20
21 // EXTERNAL INCLUDES
22 #include <dali/devel-api/adaptor-framework/web-engine-back-forward-list.h>
23 #include <dali/devel-api/adaptor-framework/web-engine-certificate.h>
24 #include <dali/devel-api/adaptor-framework/web-engine-console-message.h>
25 #include <dali/devel-api/adaptor-framework/web-engine-context-menu-item.h>
26 #include <dali/devel-api/adaptor-framework/web-engine-context-menu.h>
27 #include <dali/devel-api/adaptor-framework/web-engine-context.h>
28 #include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
29 #include <dali/devel-api/adaptor-framework/web-engine-form-repost-decision.h>
30 #include <dali/devel-api/adaptor-framework/web-engine-hit-test.h>
31 #include <dali/devel-api/adaptor-framework/web-engine-http-auth-handler.h>
32 #include <dali/devel-api/adaptor-framework/web-engine-load-error.h>
33 #include <dali/devel-api/adaptor-framework/web-engine-policy-decision.h>
34 #include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
35 #include <dali/devel-api/adaptor-framework/web-engine-settings.h>
36 #include <dali/devel-api/common/stage.h>
37 #include <dali/devel-api/scripting/enum-helper.h>
38 #include <dali/devel-api/scripting/scripting.h>
39 #include <dali/public-api/adaptor-framework/native-image-source.h>
40 #include <dali/public-api/object/type-registry-helper.h>
41 #include <dali/public-api/object/type-registry.h>
42 #include <cstring>
43 #include <memory>
44
45 // INTERNAL INCLUDES
46 #include <dali-toolkit/devel-api/controls/control-devel.h>
47 #include <dali-toolkit/devel-api/controls/web-view/web-back-forward-list.h>
48 #include <dali-toolkit/devel-api/controls/web-view/web-context.h>
49 #include <dali-toolkit/devel-api/controls/web-view/web-cookie-manager.h>
50 #include <dali-toolkit/devel-api/controls/web-view/web-settings.h>
51 #include <dali-toolkit/devel-api/image-loader/texture-manager.h>
52 #include <dali-toolkit/internal/visuals/visual-factory-impl.h>
53 #include <dali-toolkit/public-api/image-loader/image.h>
54 #include <dali-toolkit/public-api/visuals/image-visual-properties.h>
55
56 namespace Dali
57 {
58 namespace Toolkit
59 {
60 namespace Internal
61 {
62 namespace
63 {
64 BaseHandle Create()
65 {
66   return Toolkit::WebView::New();
67 }
68
69 // clang-format off
70 DALI_TYPE_REGISTRATION_BEGIN(Toolkit::WebView, Toolkit::Control, Create)
71
72 DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "url",                     STRING,  URL                       )
73 DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "userAgent",               STRING,  USER_AGENT                )
74 DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "scrollPosition",          VECTOR2, SCROLL_POSITION           )
75 DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "scrollSize",              VECTOR2, SCROLL_SIZE               )
76 DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "contentSize",             VECTOR2, CONTENT_SIZE              )
77 DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "title",                   STRING,  TITLE                     )
78 DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "videoHoleEnabled",        BOOLEAN, VIDEO_HOLE_ENABLED        )
79 DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "mouseEventsEnabled",      BOOLEAN, MOUSE_EVENTS_ENABLED      )
80 DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "keyEventsEnabled",        BOOLEAN, KEY_EVENTS_ENABLED        )
81 DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "documentBackgroundColor", VECTOR4, DOCUMENT_BACKGROUND_COLOR )
82 DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "tilesClearedWhenHidden",  BOOLEAN, TILES_CLEARED_WHEN_HIDDEN )
83 DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "tileCoverAreaMultiplier", FLOAT,   TILE_COVER_AREA_MULTIPLIER)
84 DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "cursorEnabledByClient",   BOOLEAN, CURSOR_ENABLED_BY_CLIENT  )
85 DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "selectedText",            STRING,  SELECTED_TEXT             )
86 DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "pageZoomFactor",          FLOAT,   PAGE_ZOOM_FACTOR          )
87 DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "textZoomFactor",          FLOAT,   TEXT_ZOOM_FACTOR          )
88 DALI_PROPERTY_REGISTRATION(Toolkit, WebView, "loadProgressPercentage",  FLOAT,   LOAD_PROGRESS_PERCENTAGE  )
89
90 DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "pageLoadStarted",         PAGE_LOAD_STARTED_SIGNAL         )
91 DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "pageLoadInProgress",      PAGE_LOAD_IN_PROGRESS_SIGNAL     )
92 DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "pageLoadFinished",        PAGE_LOAD_FINISHED_SIGNAL        )
93 DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "pageLoadError",           PAGE_LOAD_ERROR_SIGNAL           )
94 DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "scrollEdgeReached",       SCROLL_EDGE_REACHED_SIGNAL       )
95 DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "urlChanged",              URL_CHANGED_SIGNAL               )
96 DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "formRepostDecision",      FORM_REPOST_DECISION_SIGNAL      )
97 DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "frameRendered",           FRAME_RENDERED_SIGNAL            )
98 DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "requestInterceptor",      REQUEST_INTERCEPTOR_SIGNAL       )
99 DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "consoleMessage",          CONSOLE_MESSAGE_SIGNAL           )
100 DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "policyDecision",          POLICY_DECISION                  )
101 DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "certificateConfirm",      CERTIFICATE_CONFIRM_SIGNAL       )
102 DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "sslCertificateChanged",   SSL_CERTIFICATE_CHANGED_SIGNAL   )
103 DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "httpAuthRequest",         HTTP_AUTH_REQUEST_SIGNAL         )
104 DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "contextMenuCustomized",   CONTEXT_MENU_CUSTOMIZED_SIGNAL   )
105 DALI_SIGNAL_REGISTRATION(Toolkit, WebView, "contextMenuItemSelected", CONTEXT_MENU_ITEM_SELECTED_SIGNAL)
106
107 DALI_TYPE_REGISTRATION_END()
108 // clang-format on
109
110 const std::string kEmptyString;
111
112 } // namespace
113
114 #define GET_ENUM_STRING(structName, inputExp) \
115   Scripting::GetLinearEnumerationName<Toolkit::WebView::structName::Type>(static_cast<Toolkit::WebView::structName::Type>(inputExp), structName##_TABLE, structName##_TABLE_COUNT)
116
117 #define GET_ENUM_VALUE(structName, inputExp, outputExp) \
118   Scripting::GetEnumerationProperty<Toolkit::WebView::structName::Type>(inputExp, structName##_TABLE, structName##_TABLE_COUNT, outputExp)
119
120 WebView::WebView(const std::string& locale, const std::string& timezoneId)
121 : Control(ControlBehaviour(ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS)),
122   mUrl(),
123   mVisual(),
124   mWebViewSize(Stage::GetCurrent().GetSize()),
125   mWebEngine(),
126   mPageLoadStartedSignal(),
127   mPageLoadFinishedSignal(),
128   mPageLoadErrorSignal(),
129   mUrlChangedSignal(),
130   mWebViewArea(0, 0, mWebViewSize.width, mWebViewSize.height),
131   mVideoHoleEnabled(true),
132   mMouseEventsEnabled(true),
133   mKeyEventsEnabled(true)
134 {
135   mWebEngine = Dali::WebEngine::New();
136
137   // WebEngine is empty when it is not properly initialized.
138   if(mWebEngine)
139   {
140     mWebEngine.Create(mWebViewSize.width, mWebViewSize.height, locale, timezoneId);
141   }
142 }
143
144 WebView::WebView(uint32_t argc, char** argv)
145 : Control(ControlBehaviour(ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS)),
146   mUrl(),
147   mVisual(),
148   mWebViewSize(Stage::GetCurrent().GetSize()),
149   mWebEngine(),
150   mPageLoadStartedSignal(),
151   mPageLoadFinishedSignal(),
152   mPageLoadErrorSignal(),
153   mUrlChangedSignal(),
154   mWebViewArea(0, 0, mWebViewSize.width, mWebViewSize.height),
155   mVideoHoleEnabled(true),
156   mMouseEventsEnabled(true),
157   mKeyEventsEnabled(true)
158 {
159   mWebEngine = Dali::WebEngine::New();
160
161   // WebEngine is empty when it is not properly initialized.
162   if(mWebEngine)
163   {
164     mWebEngine.Create(mWebViewSize.width, mWebViewSize.height, argc, argv);
165   }
166 }
167
168 WebView::WebView()
169 : WebView("", "")
170 {
171 }
172
173 WebView::~WebView()
174 {
175   if(mWebEngine)
176   {
177     mWebEngine.Destroy();
178   }
179 }
180
181 Toolkit::WebView WebView::New()
182 {
183   WebView*         impl   = new WebView();
184   Toolkit::WebView handle = Toolkit::WebView(*impl);
185
186   impl->Initialize();
187   return handle;
188 }
189
190 Toolkit::WebView WebView::New(const std::string& locale, const std::string& timezoneId)
191 {
192   WebView*         impl   = new WebView(locale, timezoneId);
193   Toolkit::WebView handle = Toolkit::WebView(*impl);
194
195   impl->Initialize();
196   return handle;
197 }
198
199 Toolkit::WebView WebView::New(uint32_t argc, char** argv)
200 {
201   WebView*         impl   = new WebView(argc, argv);
202   Toolkit::WebView handle = Toolkit::WebView(*impl);
203
204   impl->Initialize();
205   return handle;
206 }
207
208 void WebView::OnInitialize()
209 {
210   Actor self = Self();
211
212   self.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
213   self.TouchedSignal().Connect(this, &WebView::OnTouchEvent);
214   self.HoveredSignal().Connect(this, &WebView::OnHoverEvent);
215   self.WheelEventSignal().Connect(this, &WebView::OnWheelEvent);
216   Dali::DevelActor::VisibilityChangedSignal(self).Connect(this, &WebView::OnVisibilityChanged);
217
218   mPositionUpdateNotification = self.AddPropertyNotification(Actor::Property::WORLD_POSITION, StepCondition(1.0f, 1.0f));
219   mSizeUpdateNotification     = self.AddPropertyNotification(Actor::Property::SIZE, StepCondition(1.0f, 1.0f));
220   mScaleUpdateNotification    = self.AddPropertyNotification(Actor::Property::WORLD_SCALE, StepCondition(0.1f, 1.0f));
221   mPositionUpdateNotification.NotifySignal().Connect(this, &WebView::UpdateDisplayArea);
222   mSizeUpdateNotification.NotifySignal().Connect(this, &WebView::UpdateDisplayArea);
223   mScaleUpdateNotification.NotifySignal().Connect(this, &WebView::UpdateDisplayArea);
224
225   if(mWebEngine)
226   {
227     mWebEngine.PageLoadStartedSignal().Connect(this, &WebView::OnPageLoadStarted);
228     mWebEngine.PageLoadInProgressSignal().Connect(this, &WebView::OnPageLoadInProgress);
229     mWebEngine.PageLoadFinishedSignal().Connect(this, &WebView::OnPageLoadFinished);
230     mWebEngine.PageLoadErrorSignal().Connect(this, &WebView::OnPageLoadError);
231     mWebEngine.ScrollEdgeReachedSignal().Connect(this, &WebView::OnScrollEdgeReached);
232     mWebEngine.UrlChangedSignal().Connect(this, &WebView::OnUrlChanged);
233     mWebEngine.FormRepostDecisionSignal().Connect(this, &WebView::OnFormRepostDecision);
234     mWebEngine.FrameRenderedSignal().Connect(this, &WebView::OnFrameRendered);
235     mWebEngine.RequestInterceptorSignal().Connect(this, &WebView::OnInterceptRequest);
236     mWebEngine.ConsoleMessageSignal().Connect(this, &WebView::OnConsoleMessage);
237     mWebEngine.PolicyDecisionSignal().Connect(this, &WebView::OnPolicyDecisionRequest);
238     mWebEngine.CertificateConfirmSignal().Connect(this, &WebView::OnCertificateConfirm);
239     mWebEngine.SslCertificateChangedSignal().Connect(this, &WebView::OnSslCertificateChanged);
240     mWebEngine.HttpAuthHandlerSignal().Connect(this, &WebView::OnHttpAuthenticationRequest);
241     mWebEngine.ContextMenuCustomizedSignal().Connect(this, &WebView::OnContextMenuCustomized);
242     mWebEngine.ContextMenuItemSelectedSignal().Connect(this, &WebView::OnContextMenuItemSelected);
243
244     mWebContext         = std::unique_ptr<Dali::Toolkit::WebContext>(new WebContext(mWebEngine.GetContext()));
245     mWebCookieManager   = std::unique_ptr<Dali::Toolkit::WebCookieManager>(new WebCookieManager(mWebEngine.GetCookieManager()));
246     mWebSettings        = std::unique_ptr<Dali::Toolkit::WebSettings>(new WebSettings(mWebEngine.GetSettings()));
247     mWebBackForwardList = std::unique_ptr<Dali::Toolkit::WebBackForwardList>(new WebBackForwardList(mWebEngine.GetBackForwardList()));
248   }
249 }
250
251 Dali::Toolkit::WebSettings* WebView::GetSettings() const
252 {
253   return mWebSettings.get();
254 }
255
256 Dali::Toolkit::WebContext* WebView::GetContext() const
257 {
258   return mWebContext.get();
259 }
260
261 Dali::Toolkit::WebCookieManager* WebView::GetCookieManager() const
262 {
263   return mWebCookieManager.get();
264 }
265
266 Dali::Toolkit::WebBackForwardList* WebView::GetBackForwardList() const
267 {
268   return mWebBackForwardList.get();
269 }
270
271 Dali::Toolkit::ImageView& WebView::GetFavicon()
272 {
273   if(mWebEngine)
274   {
275     Dali::PixelData pixelData = mWebEngine.GetFavicon();
276     mFaviconView              = CreateImageView(pixelData);
277   }
278   return mFaviconView;
279 }
280
281 void WebView::LoadUrl(const std::string& url)
282 {
283   mUrl = url;
284   if(mWebEngine)
285   {
286     Texture           texture        = Dali::Texture::New(*mWebEngine.GetNativeImageSource());
287     const std::string nativeImageUrl = Dali::Toolkit::TextureManager::AddTexture(texture);
288     mVisual                          = Toolkit::VisualFactory::Get().CreateVisual(
289       {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
290        {Toolkit::ImageVisual::Property::URL, nativeImageUrl}});
291
292     if(mVisual)
293     {
294       // Clean up previously registered visual and add new one.
295       DevelControl::RegisterVisual(*this, Toolkit::WebView::Property::URL, mVisual);
296       mWebEngine.LoadUrl(url);
297     }
298
299     if(mVideoHoleEnabled)
300     {
301       EnableBlendMode(false);
302     }
303   }
304 }
305
306 void WebView::LoadHtmlString(const std::string& htmlString)
307 {
308   if(mWebEngine)
309   {
310     Texture           texture        = Dali::Texture::New(*mWebEngine.GetNativeImageSource());
311     const std::string nativeImageUrl = Dali::Toolkit::TextureManager::AddTexture(texture);
312     mVisual                          = Toolkit::VisualFactory::Get().CreateVisual(
313       {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
314        {Toolkit::ImageVisual::Property::URL, nativeImageUrl}});
315
316     if(mVisual)
317     {
318       DevelControl::RegisterVisual(*this, Toolkit::WebView::Property::URL, mVisual);
319       mWebEngine.LoadHtmlString(htmlString);
320     }
321
322     if(mVideoHoleEnabled)
323     {
324       EnableBlendMode(false);
325     }
326   }
327 }
328
329 bool WebView::LoadHtmlStringOverrideCurrentEntry(const std::string& html, const std::string& basicUri, const std::string& unreachableUrl)
330 {
331   if(!mWebEngine)
332     return false;
333
334   Texture           texture        = Dali::Texture::New(*mWebEngine.GetNativeImageSource());
335   const std::string nativeImageUrl = Dali::Toolkit::TextureManager::AddTexture(texture);
336   mVisual                          = Toolkit::VisualFactory::Get().CreateVisual(
337     {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
338      {Toolkit::ImageVisual::Property::URL, nativeImageUrl}});
339
340   bool result = false;
341   if(mVisual)
342   {
343     DevelControl::RegisterVisual(*this, Toolkit::WebView::Property::URL, mVisual);
344     result = mWebEngine.LoadHtmlStringOverrideCurrentEntry(html, basicUri, unreachableUrl);
345   }
346
347   if(mVideoHoleEnabled)
348   {
349     EnableBlendMode(false);
350   }
351   return result;
352 }
353
354 bool WebView::LoadContents(const std::string& contents, uint32_t contentSize, const std::string& mimeType, const std::string& encoding, const std::string& baseUri)
355 {
356   if(!mWebEngine)
357     return false;
358
359   Texture           texture        = Dali::Texture::New(*mWebEngine.GetNativeImageSource());
360   const std::string nativeImageUrl = Dali::Toolkit::TextureManager::AddTexture(texture);
361   mVisual                          = Toolkit::VisualFactory::Get().CreateVisual(
362     {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
363      {Toolkit::ImageVisual::Property::URL, nativeImageUrl}});
364
365   bool result = false;
366   if(mVisual)
367   {
368     DevelControl::RegisterVisual(*this, Toolkit::WebView::Property::URL, mVisual);
369     result = mWebEngine.LoadContents(contents, contentSize, mimeType, encoding, baseUri);
370   }
371
372   if(mVideoHoleEnabled)
373   {
374     EnableBlendMode(false);
375   }
376   return result;
377 }
378
379 void WebView::Reload()
380 {
381   if(mWebEngine)
382   {
383     mWebEngine.Reload();
384   }
385 }
386
387 bool WebView::ReloadWithoutCache()
388 {
389   return mWebEngine ? mWebEngine.ReloadWithoutCache() : false;
390 }
391
392 void WebView::StopLoading()
393 {
394   if(mWebEngine)
395   {
396     mWebEngine.StopLoading();
397   }
398 }
399
400 void WebView::Suspend()
401 {
402   if(mWebEngine)
403   {
404     mWebEngine.Suspend();
405   }
406 }
407
408 void WebView::Resume()
409 {
410   if(mWebEngine)
411   {
412     mWebEngine.Resume();
413   }
414 }
415
416 void WebView::SuspendNetworkLoading()
417 {
418   if(mWebEngine)
419   {
420     mWebEngine.SuspendNetworkLoading();
421   }
422 }
423
424 void WebView::ResumeNetworkLoading()
425 {
426   if(mWebEngine)
427   {
428     mWebEngine.ResumeNetworkLoading();
429   }
430 }
431
432 bool WebView::AddCustomHeader(const std::string& name, const std::string& value)
433 {
434   return mWebEngine ? mWebEngine.AddCustomHeader(name, value) : false;
435 }
436
437 bool WebView::RemoveCustomHeader(const std::string& name)
438 {
439   return mWebEngine ? mWebEngine.RemoveCustomHeader(name) : false;
440 }
441
442 uint32_t WebView::StartInspectorServer(uint32_t port)
443 {
444   return mWebEngine ? mWebEngine.StartInspectorServer(port) : false;
445 }
446
447 bool WebView::StopInspectorServer()
448 {
449   return mWebEngine ? mWebEngine.StopInspectorServer() : false;
450 }
451
452 void WebView::ScrollBy(int32_t deltaX, int32_t deltaY)
453 {
454   if(mWebEngine)
455   {
456     mWebEngine.ScrollBy(deltaX, deltaY);
457   }
458 }
459
460 bool WebView::ScrollEdgeBy(int32_t deltaX, int32_t deltaY)
461 {
462   return mWebEngine ? mWebEngine.ScrollEdgeBy(deltaX, deltaY) : false;
463 }
464
465 bool WebView::CanGoForward()
466 {
467   return mWebEngine ? mWebEngine.CanGoForward() : false;
468 }
469
470 void WebView::GoForward()
471 {
472   if(mWebEngine)
473   {
474     mWebEngine.GoForward();
475   }
476 }
477
478 bool WebView::CanGoBack()
479 {
480   return mWebEngine ? mWebEngine.CanGoBack() : false;
481 }
482
483 void WebView::GoBack()
484 {
485   if(mWebEngine)
486   {
487     mWebEngine.GoBack();
488   }
489 }
490
491 void WebView::EvaluateJavaScript(const std::string& script, std::function<void(const std::string&)> resultHandler)
492 {
493   if(mWebEngine)
494   {
495     mWebEngine.EvaluateJavaScript(script, resultHandler);
496   }
497 }
498
499 void WebView::AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler)
500 {
501   if(mWebEngine)
502   {
503     mWebEngine.AddJavaScriptMessageHandler(exposedObjectName, handler);
504   }
505 }
506
507 void WebView::RegisterJavaScriptAlertCallback(Dali::WebEnginePlugin::JavaScriptAlertCallback callback)
508 {
509   if(mWebEngine)
510   {
511     mWebEngine.RegisterJavaScriptAlertCallback(callback);
512   }
513 }
514
515 void WebView::JavaScriptAlertReply()
516 {
517   if(mWebEngine)
518   {
519     mWebEngine.JavaScriptAlertReply();
520   }
521 }
522
523 void WebView::RegisterJavaScriptConfirmCallback(Dali::WebEnginePlugin::JavaScriptConfirmCallback callback)
524 {
525   if(mWebEngine)
526   {
527     mWebEngine.RegisterJavaScriptConfirmCallback(callback);
528   }
529 }
530
531 void WebView::JavaScriptConfirmReply(bool confirmed)
532 {
533   if(mWebEngine)
534   {
535     mWebEngine.JavaScriptConfirmReply(confirmed);
536   }
537 }
538
539 void WebView::RegisterJavaScriptPromptCallback(Dali::WebEnginePlugin::JavaScriptPromptCallback callback)
540 {
541   if(mWebEngine)
542   {
543     mWebEngine.RegisterJavaScriptPromptCallback(callback);
544   }
545 }
546
547 void WebView::JavaScriptPromptReply(const std::string& result)
548 {
549   if(mWebEngine)
550   {
551     mWebEngine.JavaScriptPromptReply(result);
552   }
553 }
554
555 std::unique_ptr<Dali::WebEngineHitTest> WebView::CreateHitTest(int32_t x, int32_t y, Dali::WebEngineHitTest::HitTestMode mode)
556 {
557   std::unique_ptr<Dali::WebEngineHitTest> webHitTest;
558   if(!mWebEngine)
559   {
560     return webHitTest;
561   }
562
563   return mWebEngine.CreateHitTest(x, y, mode);
564 }
565
566 bool WebView::CreateHitTestAsynchronously(int32_t x, int32_t y, Dali::WebEngineHitTest::HitTestMode mode, Dali::WebEnginePlugin::WebEngineHitTestCreatedCallback callback)
567 {
568   bool result = false;
569   if(mWebEngine)
570   {
571     result = mWebEngine.CreateHitTestAsynchronously(x, y, mode, callback);
572   }
573   return result;
574 }
575
576 void WebView::ClearHistory()
577 {
578   if(mWebEngine)
579   {
580     mWebEngine.ClearHistory();
581   }
582 }
583
584 void WebView::ClearAllTilesResources()
585 {
586   if(mWebEngine)
587   {
588     mWebEngine.ClearAllTilesResources();
589   }
590 }
591
592 void WebView::SetScaleFactor(float scaleFactor, Dali::Vector2 point)
593 {
594   if(mWebEngine)
595   {
596     mWebEngine.SetScaleFactor(scaleFactor, point);
597   }
598 }
599
600 float WebView::GetScaleFactor() const
601 {
602   return mWebEngine ? mWebEngine.GetScaleFactor() : 0.0f;
603 }
604
605 void WebView::ActivateAccessibility(bool activated)
606 {
607   if(mWebEngine)
608   {
609     mWebEngine.ActivateAccessibility(activated);
610   }
611 }
612
613 bool WebView::HighlightText(const std::string& text, Dali::WebEnginePlugin::FindOption options, uint32_t maxMatchCount)
614 {
615   return mWebEngine ? mWebEngine.HighlightText(text, options, maxMatchCount) : false;
616 }
617
618 void WebView::AddDynamicCertificatePath(const std::string& host, const std::string& certPath)
619 {
620   if(mWebEngine)
621   {
622     mWebEngine.AddDynamicCertificatePath(host, certPath);
623   }
624 }
625
626 Dali::Toolkit::ImageView WebView::GetScreenshot(Dali::Rect<int32_t> viewArea, float scaleFactor)
627 {
628   Dali::Toolkit::ImageView imageView;
629   if(mWebEngine)
630   {
631     Dali::PixelData pixelData = mWebEngine.GetScreenshot(viewArea, scaleFactor);
632     imageView                 = CreateImageView(pixelData);
633   }
634   return imageView;
635 }
636
637 bool WebView::GetScreenshotAsynchronously(Dali::Rect<int32_t> viewArea, float scaleFactor, Dali::Toolkit::WebView::WebViewScreenshotCapturedCallback callback)
638 {
639   mScreenshotCapturedCallback = callback;
640   return mWebEngine ? mWebEngine.GetScreenshotAsynchronously(viewArea, scaleFactor, std::bind(&WebView::OnScreenshotCaptured, this, std::placeholders::_1)) : false;
641 }
642
643 bool WebView::CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback)
644 {
645   return mWebEngine ? mWebEngine.CheckVideoPlayingAsynchronously(callback) : false;
646 }
647
648 void WebView::RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback)
649 {
650   if(mWebEngine)
651   {
652     mWebEngine.RegisterGeolocationPermissionCallback(callback);
653   }
654 }
655
656 void WebView::UpdateDisplayArea(Dali::PropertyNotification& /*source*/)
657 {
658   if(!mWebEngine)
659     return;
660
661   Actor self(Self());
662
663   bool    positionUsesAnchorPoint = self.GetProperty<bool>(Actor::Property::POSITION_USES_ANCHOR_POINT);
664   Vector3 actorSize               = self.GetCurrentProperty<Vector3>(Actor::Property::SIZE) * self.GetCurrentProperty<Vector3>(Actor::Property::SCALE);
665   Vector3 anchorPointOffSet       = actorSize * (positionUsesAnchorPoint ? self.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT) : AnchorPoint::TOP_LEFT);
666   Vector2 screenPosition          = self.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
667
668   Dali::Rect<int32_t> displayArea;
669   displayArea.x      = screenPosition.x - anchorPointOffSet.x;
670   displayArea.y      = screenPosition.y - anchorPointOffSet.y;
671   displayArea.width  = actorSize.x;
672   displayArea.height = actorSize.y;
673
674   Size displaySize = Size(displayArea.width, displayArea.height);
675   if(mWebViewSize != displaySize)
676   {
677     mWebViewSize = displaySize;
678   }
679
680   if(mWebViewArea != displayArea)
681   {
682     mWebViewArea = displayArea;
683     mWebEngine.UpdateDisplayArea(mWebViewArea);
684   }
685 }
686
687 void WebView::EnableVideoHole(bool enabled)
688 {
689   mVideoHoleEnabled = enabled;
690
691   EnableBlendMode(!mVideoHoleEnabled);
692
693   if(mWebEngine)
694   {
695     mWebEngine.EnableVideoHole(mVideoHoleEnabled);
696   }
697 }
698
699 void WebView::EnableBlendMode(bool blendEnabled)
700 {
701   Actor self = Self();
702   for(uint32_t i = 0; i < self.GetRendererCount(); i++)
703   {
704     Dali::Renderer render = self.GetRendererAt(i);
705     render.SetProperty(Renderer::Property::BLEND_MODE, blendEnabled ? BlendMode::ON : BlendMode::OFF);
706   }
707 }
708
709 Dali::Toolkit::ImageView WebView::CreateImageView(Dali::PixelData pixel)
710 {
711   std::string              url       = Dali::Toolkit::Image::GenerateUrl(pixel);
712   Dali::Toolkit::ImageView imageView = Dali::Toolkit::ImageView::New(url);
713   imageView.SetProperty(Dali::Actor::Property::SIZE, Vector2(pixel.GetWidth(), pixel.GetHeight()));
714   return imageView;
715 }
716
717 Dali::Toolkit::WebView::WebViewPageLoadSignalType& WebView::PageLoadStartedSignal()
718 {
719   return mPageLoadStartedSignal;
720 }
721
722 Dali::Toolkit::WebView::WebViewPageLoadSignalType& WebView::PageLoadInProgressSignal()
723 {
724   return mPageLoadInProgressSignal;
725 }
726
727 Dali::Toolkit::WebView::WebViewPageLoadSignalType& WebView::PageLoadFinishedSignal()
728 {
729   return mPageLoadFinishedSignal;
730 }
731
732 Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType& WebView::PageLoadErrorSignal()
733 {
734   return mPageLoadErrorSignal;
735 }
736
737 Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType& WebView::ScrollEdgeReachedSignal()
738 {
739   return mScrollEdgeReachedSignal;
740 }
741
742 Dali::Toolkit::WebView::WebViewUrlChangedSignalType& WebView::UrlChangedSignal()
743 {
744   return mUrlChangedSignal;
745 }
746
747 Dali::Toolkit::WebView::WebViewFormRepostDecisionSignalType& WebView::FormRepostDecisionSignal()
748 {
749   return mFormRepostDecisionSignal;
750 }
751
752 Dali::Toolkit::WebView::WebViewFrameRenderedSignalType& WebView::FrameRenderedSignal()
753 {
754   return mFrameRenderedSignal;
755 }
756
757 Dali::Toolkit::WebView::WebViewRequestInterceptorSignalType& WebView::RequestInterceptorSignal()
758 {
759   return mRequestInterceptorSignal;
760 }
761
762 Dali::Toolkit::WebView::WebViewConsoleMessageSignalType& WebView::ConsoleMessageSignal()
763 {
764   return mConsoleMessageSignal;
765 }
766
767 Dali::Toolkit::WebView::WebViewPolicyDecisionSignalType& WebView::PolicyDecisionSignal()
768 {
769   return mPolicyDecisionSignal;
770 }
771
772 Dali::Toolkit::WebView::WebViewCertificateSignalType& WebView::CertificateConfirmSignal()
773 {
774   return mCertificateConfirmSignal;
775 }
776
777 Dali::Toolkit::WebView::WebViewCertificateSignalType& WebView::SslCertificateChangedSignal()
778 {
779   return mSslCertificateChangedSignal;
780 }
781
782 Dali::Toolkit::WebView::WebViewHttpAuthHandlerSignalType& WebView::HttpAuthHandlerSignal()
783 {
784   return mHttpAuthHandlerSignal;
785 }
786
787 Dali::Toolkit::WebView::WebViewContextMenuCustomizedSignalType& WebView::ContextMenuCustomizedSignal()
788 {
789   return mContextMenuCustomizedSignal;
790 }
791
792 Dali::Toolkit::WebView::WebViewContextMenuItemSelectedSignalType& WebView::ContextMenuItemSelectedSignal()
793 {
794   return mContextMenuItemSelectedSignal;
795 }
796
797 void WebView::OnPageLoadStarted(const std::string& url)
798 {
799   if(!mPageLoadStartedSignal.Empty())
800   {
801     Dali::Toolkit::WebView handle(GetOwner());
802     mPageLoadStartedSignal.Emit(handle, url);
803   }
804 }
805
806 void WebView::OnPageLoadInProgress(const std::string& url)
807 {
808   if(!mPageLoadInProgressSignal.Empty())
809   {
810     Dali::Toolkit::WebView handle(GetOwner());
811     mPageLoadInProgressSignal.Emit(handle, url);
812   }
813 }
814
815 void WebView::OnPageLoadFinished(const std::string& url)
816 {
817   if(!mPageLoadFinishedSignal.Empty())
818   {
819     Dali::Toolkit::WebView handle(GetOwner());
820     mPageLoadFinishedSignal.Emit(handle, url);
821   }
822 }
823
824 void WebView::OnPageLoadError(std::shared_ptr<Dali::WebEngineLoadError> error)
825 {
826   if(!mPageLoadErrorSignal.Empty())
827   {
828     Dali::Toolkit::WebView handle(GetOwner());
829     mPageLoadErrorSignal.Emit(handle, std::move(error));
830   }
831 }
832
833 void WebView::OnScrollEdgeReached(Dali::WebEnginePlugin::ScrollEdge edge)
834 {
835   if(!mScrollEdgeReachedSignal.Empty())
836   {
837     Dali::Toolkit::WebView handle(GetOwner());
838     mScrollEdgeReachedSignal.Emit(handle, edge);
839   }
840 }
841
842 void WebView::OnUrlChanged(const std::string& url)
843 {
844   if(!mUrlChangedSignal.Empty())
845   {
846     Dali::Toolkit::WebView handle(GetOwner());
847     mUrlChangedSignal.Emit(handle, url);
848   }
849 }
850
851 void WebView::OnFormRepostDecision(std::shared_ptr<Dali::WebEngineFormRepostDecision> decision)
852 {
853   if(!mFormRepostDecisionSignal.Empty())
854   {
855     Dali::Toolkit::WebView handle(GetOwner());
856     mFormRepostDecisionSignal.Emit(handle, std::move(decision));
857   }
858 }
859
860 void WebView::OnFrameRendered()
861 {
862   if(!mFrameRenderedSignal.Empty())
863   {
864     Dali::Toolkit::WebView handle(GetOwner());
865     mFrameRenderedSignal.Emit(handle);
866   }
867 }
868
869 void WebView::OnVisibilityChanged(Actor actor, bool isVisible, Dali::DevelActor::VisibilityChange::Type type)
870 {
871   if(type == Dali::DevelActor::VisibilityChange::Type::SELF)
872   {
873     SetVisibility(isVisible);
874   }
875 }
876
877 void WebView::OnScreenshotCaptured(Dali::PixelData pixel)
878 {
879   if(mScreenshotCapturedCallback)
880   {
881     Dali::Toolkit::ImageView imageView = CreateImageView(pixel);
882     mScreenshotCapturedCallback(imageView);
883   }
884 }
885
886 void WebView::OnInterceptRequest(std::shared_ptr<Dali::WebEngineRequestInterceptor> interceptor)
887 {
888   if(!mRequestInterceptorSignal.Empty())
889   {
890     Dali::Toolkit::WebView handle(GetOwner());
891     mRequestInterceptorSignal.Emit(handle, std::move(interceptor));
892   }
893 }
894
895 void WebView::OnConsoleMessage(std::shared_ptr<Dali::WebEngineConsoleMessage> message)
896 {
897   if(!mConsoleMessageSignal.Empty())
898   {
899     Dali::Toolkit::WebView handle(GetOwner());
900     mConsoleMessageSignal.Emit(handle, std::move(message));
901   }
902 }
903
904 void WebView::OnPolicyDecisionRequest(std::shared_ptr<Dali::WebEnginePolicyDecision> decision)
905 {
906   if(!mPolicyDecisionSignal.Empty())
907   {
908     Dali::Toolkit::WebView handle(GetOwner());
909     mPolicyDecisionSignal.Emit(handle, std::move(decision));
910   }
911 }
912
913 void WebView::OnCertificateConfirm(std::shared_ptr<Dali::WebEngineCertificate> certificate)
914 {
915   if(!mCertificateConfirmSignal.Empty())
916   {
917     Dali::Toolkit::WebView handle(GetOwner());
918     mCertificateConfirmSignal.Emit(handle, std::move(certificate));
919   }
920 }
921
922 void WebView::OnSslCertificateChanged(std::shared_ptr<Dali::WebEngineCertificate> certificate)
923 {
924   if(!mSslCertificateChangedSignal.Empty())
925   {
926     Dali::Toolkit::WebView handle(GetOwner());
927     mSslCertificateChangedSignal.Emit(handle, std::move(certificate));
928   }
929 }
930
931 void WebView::OnHttpAuthenticationRequest(std::shared_ptr<Dali::WebEngineHttpAuthHandler> handler)
932 {
933   if(!mHttpAuthHandlerSignal.Empty())
934   {
935     Dali::Toolkit::WebView handle(GetOwner());
936     mHttpAuthHandlerSignal.Emit(handle, std::move(handler));
937   }
938 }
939
940 void WebView::OnContextMenuCustomized(std::shared_ptr<Dali::WebEngineContextMenu> menu)
941 {
942   if(!mContextMenuCustomizedSignal.Empty())
943   {
944     Dali::Toolkit::WebView handle(GetOwner());
945     mContextMenuCustomizedSignal.Emit(handle, std::move(menu));
946   }
947 }
948
949 void WebView::OnContextMenuItemSelected(std::shared_ptr<Dali::WebEngineContextMenuItem> item)
950 {
951   if(!mContextMenuItemSelectedSignal.Empty())
952   {
953     Dali::Toolkit::WebView handle(GetOwner());
954     mContextMenuItemSelectedSignal.Emit(handle, std::move(item));
955   }
956 }
957
958 bool WebView::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
959 {
960   Dali::BaseHandle handle(object);
961
962   bool             connected = false;
963   Toolkit::WebView webView   = Toolkit::WebView::DownCast(handle);
964
965   if(0 == strcmp(signalName.c_str(), PAGE_LOAD_STARTED_SIGNAL))
966   {
967     webView.PageLoadStartedSignal().Connect(tracker, functor);
968     connected = true;
969   }
970   else if(0 == strcmp(signalName.c_str(), PAGE_LOAD_IN_PROGRESS_SIGNAL))
971   {
972     webView.PageLoadInProgressSignal().Connect(tracker, functor);
973     connected = true;
974   }
975   else if(0 == strcmp(signalName.c_str(), PAGE_LOAD_FINISHED_SIGNAL))
976   {
977     webView.PageLoadFinishedSignal().Connect(tracker, functor);
978     connected = true;
979   }
980   else if(0 == strcmp(signalName.c_str(), PAGE_LOAD_ERROR_SIGNAL))
981   {
982     webView.PageLoadErrorSignal().Connect(tracker, functor);
983     connected = true;
984   }
985   else if(0 == strcmp(signalName.c_str(), SCROLL_EDGE_REACHED_SIGNAL))
986   {
987     webView.ScrollEdgeReachedSignal().Connect(tracker, functor);
988     connected = true;
989   }
990   else if(0 == strcmp(signalName.c_str(), URL_CHANGED_SIGNAL))
991   {
992     webView.UrlChangedSignal().Connect(tracker, functor);
993     connected = true;
994   }
995   else if(0 == strcmp(signalName.c_str(), FORM_REPOST_DECISION_SIGNAL))
996   {
997     webView.FormRepostDecisionSignal().Connect(tracker, functor);
998     connected = true;
999   }
1000   else if(0 == strcmp(signalName.c_str(), FRAME_RENDERED_SIGNAL))
1001   {
1002     webView.FrameRenderedSignal().Connect(tracker, functor);
1003     connected = true;
1004   }
1005   else if(0 == strcmp(signalName.c_str(), REQUEST_INTERCEPTOR_SIGNAL))
1006   {
1007     webView.RequestInterceptorSignal().Connect(tracker, functor);
1008     connected = true;
1009   }
1010   else if(0 == strcmp(signalName.c_str(), CONSOLE_MESSAGE_SIGNAL))
1011   {
1012     webView.ConsoleMessageSignal().Connect(tracker, functor);
1013     connected = true;
1014   }
1015   else if(0 == strcmp(signalName.c_str(), POLICY_DECISION))
1016   {
1017     webView.PolicyDecisionSignal().Connect(tracker, functor);
1018     connected = true;
1019   }
1020   else if(0 == strcmp(signalName.c_str(), CERTIFICATE_CONFIRM_SIGNAL))
1021   {
1022     webView.CertificateConfirmSignal().Connect(tracker, functor);
1023     connected = true;
1024   }
1025   else if(0 == strcmp(signalName.c_str(), SSL_CERTIFICATE_CHANGED_SIGNAL))
1026   {
1027     webView.SslCertificateChangedSignal().Connect(tracker, functor);
1028     connected = true;
1029   }
1030   else if(0 == strcmp(signalName.c_str(), HTTP_AUTH_REQUEST_SIGNAL))
1031   {
1032     webView.HttpAuthHandlerSignal().Connect(tracker, functor);
1033     connected = true;
1034   }
1035   else if(0 == strcmp(signalName.c_str(), CONTEXT_MENU_CUSTOMIZED_SIGNAL))
1036   {
1037     webView.ContextMenuCustomizedSignal().Connect(tracker, functor);
1038     connected = true;
1039   }
1040   else if(0 == strcmp(signalName.c_str(), CONTEXT_MENU_ITEM_SELECTED_SIGNAL))
1041   {
1042     webView.ContextMenuItemSelectedSignal().Connect(tracker, functor);
1043     connected = true;
1044   }
1045
1046   return connected;
1047 }
1048
1049 Vector3 WebView::GetNaturalSize()
1050 {
1051   if(mVisual)
1052   {
1053     Vector2 rendererNaturalSize;
1054     mVisual.GetNaturalSize(rendererNaturalSize);
1055     return Vector3(rendererNaturalSize);
1056   }
1057
1058   return Vector3(mWebViewSize);
1059 }
1060
1061 void WebView::OnSceneConnection(int depth)
1062 {
1063   Control::OnSceneConnection(depth);
1064
1065   EnableBlendMode(!mVideoHoleEnabled);
1066 }
1067
1068 void WebView::SetProperty(BaseObject* object, Property::Index index, const Property::Value& value)
1069 {
1070   Toolkit::WebView webView = Toolkit::WebView::DownCast(Dali::BaseHandle(object));
1071
1072   if(webView)
1073   {
1074     WebView& impl = GetImpl(webView);
1075     switch(index)
1076     {
1077       case Toolkit::WebView::Property::URL:
1078       {
1079         std::string url;
1080         if(value.Get(url))
1081         {
1082           impl.LoadUrl(url);
1083         }
1084         break;
1085       }
1086       case Toolkit::WebView::Property::USER_AGENT:
1087       {
1088         std::string input;
1089         if(value.Get(input))
1090         {
1091           impl.SetUserAgent(input);
1092         }
1093         break;
1094       }
1095       case Toolkit::WebView::Property::SCROLL_POSITION:
1096       {
1097         Vector2 input;
1098         if(value.Get(input))
1099         {
1100           impl.SetScrollPosition(input.x, input.y);
1101         }
1102         break;
1103       }
1104       case Toolkit::WebView::Property::VIDEO_HOLE_ENABLED:
1105       {
1106         bool input;
1107         if(value.Get(input))
1108         {
1109           impl.EnableVideoHole(input);
1110         }
1111         break;
1112       }
1113       case Toolkit::WebView::Property::MOUSE_EVENTS_ENABLED:
1114       {
1115         bool input;
1116         if(value.Get(input))
1117         {
1118           impl.EnableMouseEvents(input);
1119         }
1120         break;
1121       }
1122       case Toolkit::WebView::Property::KEY_EVENTS_ENABLED:
1123       {
1124         bool input;
1125         if(value.Get(input))
1126         {
1127           impl.EnableKeyEvents(input);
1128         }
1129         break;
1130       }
1131       case Toolkit::WebView::Property::DOCUMENT_BACKGROUND_COLOR:
1132       {
1133         Vector4 input;
1134         if(value.Get(input))
1135         {
1136           impl.SetDocumentBackgroundColor(input);
1137         }
1138         break;
1139       }
1140       case Toolkit::WebView::Property::TILES_CLEARED_WHEN_HIDDEN:
1141       {
1142         bool input;
1143         if(value.Get(input))
1144         {
1145           impl.ClearTilesWhenHidden(input);
1146         }
1147         break;
1148       }
1149       case Toolkit::WebView::Property::TILE_COVER_AREA_MULTIPLIER:
1150       {
1151         float input;
1152         if(value.Get(input))
1153         {
1154           impl.SetTileCoverAreaMultiplier(input);
1155         }
1156         break;
1157       }
1158       case Toolkit::WebView::Property::CURSOR_ENABLED_BY_CLIENT:
1159       {
1160         bool input;
1161         if(value.Get(input))
1162         {
1163           impl.EnableCursorByClient(input);
1164         }
1165         break;
1166       }
1167       case Toolkit::WebView::Property::PAGE_ZOOM_FACTOR:
1168       {
1169         float input;
1170         if(value.Get(input))
1171         {
1172           impl.SetPageZoomFactor(input);
1173         }
1174         break;
1175       }
1176       case Toolkit::WebView::Property::TEXT_ZOOM_FACTOR:
1177       {
1178         float input;
1179         if(value.Get(input))
1180         {
1181           impl.SetTextZoomFactor(input);
1182         }
1183         break;
1184       }
1185       default:
1186         break;
1187     }
1188   }
1189 }
1190
1191 Property::Value WebView::GetProperty(BaseObject* object, Property::Index propertyIndex)
1192 {
1193   Property::Value value;
1194
1195   Toolkit::WebView webView = Toolkit::WebView::DownCast(Dali::BaseHandle(object));
1196
1197   if(webView)
1198   {
1199     WebView& impl = GetImpl(webView);
1200     switch(propertyIndex)
1201     {
1202       case Toolkit::WebView::Property::URL:
1203       {
1204         value = impl.mUrl;
1205         break;
1206       }
1207       case Toolkit::WebView::Property::USER_AGENT:
1208       {
1209         value = impl.GetUserAgent();
1210         break;
1211       }
1212       case Toolkit::WebView::Property::SCROLL_POSITION:
1213       {
1214         value = impl.GetScrollPosition();
1215         break;
1216       }
1217       case Toolkit::WebView::Property::SCROLL_SIZE:
1218       {
1219         value = impl.GetScrollSize();
1220         break;
1221       }
1222       case Toolkit::WebView::Property::CONTENT_SIZE:
1223       {
1224         value = impl.GetContentSize();
1225         break;
1226       }
1227       case Toolkit::WebView::Property::TITLE:
1228       {
1229         value = impl.GetTitle();
1230         break;
1231       }
1232       case Toolkit::WebView::Property::VIDEO_HOLE_ENABLED:
1233       {
1234         value = impl.mVideoHoleEnabled;
1235         break;
1236       }
1237       case Toolkit::WebView::Property::MOUSE_EVENTS_ENABLED:
1238       {
1239         value = impl.mMouseEventsEnabled;
1240         break;
1241       }
1242       case Toolkit::WebView::Property::KEY_EVENTS_ENABLED:
1243       {
1244         value = impl.mKeyEventsEnabled;
1245         break;
1246       }
1247       case Toolkit::WebView::Property::SELECTED_TEXT:
1248       {
1249         value = impl.GetSelectedText();
1250         break;
1251       }
1252       case Toolkit::WebView::Property::PAGE_ZOOM_FACTOR:
1253       {
1254         value = impl.GetPageZoomFactor();
1255         break;
1256       }
1257       case Toolkit::WebView::Property::TEXT_ZOOM_FACTOR:
1258       {
1259         value = impl.GetTextZoomFactor();
1260         break;
1261       }
1262       case Toolkit::WebView::Property::LOAD_PROGRESS_PERCENTAGE:
1263       {
1264         value = impl.GetLoadProgressPercentage();
1265         break;
1266       }
1267       default:
1268         break;
1269     }
1270   }
1271
1272   return value;
1273 }
1274
1275 bool WebView::OnTouchEvent(Actor actor, const Dali::TouchEvent& touch)
1276 {
1277   bool result = false;
1278
1279   if(mWebEngine)
1280   {
1281     result = mWebEngine.SendTouchEvent(touch);
1282   }
1283   return result;
1284 }
1285
1286 bool WebView::OnKeyEvent(const Dali::KeyEvent& event)
1287 {
1288   bool result = false;
1289
1290   if(mWebEngine)
1291   {
1292     result = mWebEngine.SendKeyEvent(event);
1293   }
1294   return result;
1295 }
1296
1297 bool WebView::OnHoverEvent(Actor actor, const Dali::HoverEvent& hover)
1298 {
1299   bool result = false;
1300   if(mWebEngine && mMouseEventsEnabled)
1301   {
1302     result = mWebEngine.SendHoverEvent(hover);
1303   }
1304   return result;
1305 }
1306
1307 bool WebView::OnWheelEvent(Actor actor, const Dali::WheelEvent& wheel)
1308 {
1309   bool result = false;
1310   if(mWebEngine && mMouseEventsEnabled)
1311   {
1312     result = mWebEngine.SendWheelEvent(wheel);
1313   }
1314   return result;
1315 }
1316
1317 void WebView::OnKeyInputFocusGained()
1318 {
1319   if(mWebEngine)
1320   {
1321     mWebEngine.SetFocus(true);
1322   }
1323
1324   EmitKeyInputFocusSignal(true); // Calls back into the Control hence done last.
1325 }
1326
1327 void WebView::OnKeyInputFocusLost()
1328 {
1329   if(mWebEngine)
1330   {
1331     mWebEngine.SetFocus(false);
1332   }
1333
1334   EmitKeyInputFocusSignal(false); // Calls back into the Control hence done last.
1335 }
1336
1337 void WebView::SetScrollPosition(int32_t x, int32_t y)
1338 {
1339   if(mWebEngine)
1340   {
1341     mWebEngine.SetScrollPosition(x, y);
1342   }
1343 }
1344
1345 Dali::Vector2 WebView::GetScrollPosition() const
1346 {
1347   return mWebEngine ? mWebEngine.GetScrollPosition() : Dali::Vector2::ZERO;
1348 }
1349
1350 Dali::Vector2 WebView::GetScrollSize() const
1351 {
1352   return mWebEngine ? mWebEngine.GetScrollSize() : Dali::Vector2::ZERO;
1353 }
1354
1355 Dali::Vector2 WebView::GetContentSize() const
1356 {
1357   return mWebEngine ? mWebEngine.GetContentSize() : Dali::Vector2::ZERO;
1358 }
1359
1360 std::string WebView::GetTitle() const
1361 {
1362   return mWebEngine ? mWebEngine.GetTitle() : kEmptyString;
1363 }
1364
1365 void WebView::SetDocumentBackgroundColor(Dali::Vector4 color)
1366 {
1367   if(mWebEngine)
1368   {
1369     mWebEngine.SetDocumentBackgroundColor(color);
1370   }
1371 }
1372
1373 void WebView::ClearTilesWhenHidden(bool cleared)
1374 {
1375   if(mWebEngine)
1376   {
1377     mWebEngine.ClearTilesWhenHidden(cleared);
1378   }
1379 }
1380
1381 void WebView::SetTileCoverAreaMultiplier(float multiplier)
1382 {
1383   if(mWebEngine)
1384   {
1385     mWebEngine.SetTileCoverAreaMultiplier(multiplier);
1386   }
1387 }
1388
1389 void WebView::EnableCursorByClient(bool enabled)
1390 {
1391   if(mWebEngine)
1392   {
1393     mWebEngine.EnableCursorByClient(enabled);
1394   }
1395 }
1396
1397 std::string WebView::GetSelectedText() const
1398 {
1399   return mWebEngine ? mWebEngine.GetSelectedText() : kEmptyString;
1400 }
1401
1402 const std::string& WebView::GetUserAgent() const
1403 {
1404   return mWebEngine ? mWebEngine.GetUserAgent() : kEmptyString;
1405 }
1406
1407 void WebView::SetUserAgent(const std::string& userAgent)
1408 {
1409   if(mWebEngine)
1410   {
1411     mWebEngine.SetUserAgent(userAgent);
1412   }
1413 }
1414
1415 void WebView::EnableMouseEvents(bool enabled)
1416 {
1417   if(mWebEngine)
1418   {
1419     mMouseEventsEnabled = enabled;
1420     mWebEngine.EnableMouseEvents(enabled);
1421   }
1422 }
1423
1424 void WebView::EnableKeyEvents(bool enabled)
1425 {
1426   if(mWebEngine)
1427   {
1428     mKeyEventsEnabled = enabled;
1429     mWebEngine.EnableKeyEvents(enabled);
1430   }
1431 }
1432
1433 void WebView::SetPageZoomFactor(float zoomFactor)
1434 {
1435   if(mWebEngine)
1436   {
1437     mWebEngine.SetPageZoomFactor(zoomFactor);
1438   }
1439 }
1440
1441 float WebView::GetPageZoomFactor() const
1442 {
1443   return mWebEngine ? mWebEngine.GetPageZoomFactor() : 0.0f;
1444 }
1445
1446 void WebView::SetTextZoomFactor(float zoomFactor)
1447 {
1448   if(mWebEngine)
1449   {
1450     mWebEngine.SetTextZoomFactor(zoomFactor);
1451   }
1452 }
1453
1454 float WebView::GetTextZoomFactor() const
1455 {
1456   return mWebEngine ? mWebEngine.GetTextZoomFactor() : 0.0f;
1457 }
1458
1459 float WebView::GetLoadProgressPercentage() const
1460 {
1461   return mWebEngine ? mWebEngine.GetLoadProgressPercentage() : 0.0f;
1462 }
1463
1464 bool WebView::SetVisibility(bool visible)
1465 {
1466   return mWebEngine ? mWebEngine.SetVisibility(visible) : false;
1467 }
1468
1469 #undef GET_ENUM_STRING
1470 #undef GET_ENUM_VALUE
1471
1472 } // namespace Internal
1473
1474 } // namespace Toolkit
1475
1476 } // namespace Dali