db14c27797aeaee328b274e5551bd03eb859570a
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / web-view / web-view-impl.cpp
1 /*
2  * Copyright (c) 2020 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 <cstring>
23 #include <dali/devel-api/scripting/enum-helper.h>
24 #include <dali/devel-api/scripting/scripting.h>
25 #include <dali/devel-api/common/stage.h>
26 #include <dali/public-api/adaptor-framework/native-image-source.h>
27 #include <dali/public-api/object/type-registry.h>
28 #include <dali/public-api/object/type-registry-helper.h>
29
30 // INTERNAL INCLUDES
31 #include <dali-toolkit/devel-api/controls/control-devel.h>
32 #include <dali-toolkit/devel-api/image-loader/texture-manager.h>
33 #include <dali-toolkit/internal/visuals/visual-factory-impl.h>
34 #include <dali-toolkit/public-api/visuals/image-visual-properties.h>
35
36 namespace Dali
37 {
38
39 namespace Toolkit
40 {
41
42 namespace Internal
43 {
44
45 namespace
46 {
47
48 BaseHandle Create()
49 {
50   return Toolkit::WebView::New();
51 }
52
53 DALI_ENUM_TO_STRING_TABLE_BEGIN( CacheModel )
54 DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CacheModel, DOCUMENT_VIEWER )
55 DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CacheModel, DOCUMENT_BROWSER )
56 DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CacheModel, PRIMARY_WEB_BROWSER )
57 DALI_ENUM_TO_STRING_TABLE_END( CacheModel )
58
59 DALI_ENUM_TO_STRING_TABLE_BEGIN( CookieAcceptPolicy )
60 DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CookieAcceptPolicy, ALWAYS )
61 DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CookieAcceptPolicy, NEVER )
62 DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::WebView::CookieAcceptPolicy, NO_THIRD_PARTY )
63 DALI_ENUM_TO_STRING_TABLE_END( CookieAcceptPolicy )
64
65 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::WebView, Toolkit::Control, Create )
66
67 DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "url",                     STRING,  URL                        )
68 DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "cacheModel",              STRING,  CACHE_MODEL                )
69 DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "cookieAcceptPolicy",      STRING,  COOKIE_ACCEPT_POLICY       )
70 DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "userAgent",               STRING,  USER_AGENT                 )
71 DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "enableJavaScript",        BOOLEAN, ENABLE_JAVASCRIPT          )
72 DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "loadImagesAutomatically", BOOLEAN, LOAD_IMAGES_AUTOMATICALLY  )
73 DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "defaultTextEncodingName", STRING,  DEFAULT_TEXT_ENCODING_NAME )
74 DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "defaultFontSize",         INTEGER, DEFAULT_FONT_SIZE          )
75 DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "scrollPosition",          VECTOR2, SCROLL_POSITION            )
76 DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "scrollSize",              VECTOR2, SCROLL_SIZE                )
77 DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "contentSize",             VECTOR2, CONTENT_SIZE               )
78
79 DALI_SIGNAL_REGISTRATION(   Toolkit, WebView, "pageLoadStarted",         PAGE_LOAD_STARTED_SIGNAL            )
80 DALI_SIGNAL_REGISTRATION(   Toolkit, WebView, "pageLoadFinished",        PAGE_LOAD_FINISHED_SIGNAL           )
81 DALI_SIGNAL_REGISTRATION(   Toolkit, WebView, "pageLoadError",           PAGE_LOAD_ERROR_SIGNAL              )
82 DALI_SIGNAL_REGISTRATION(   Toolkit, WebView, "scrollEdgeReached",       SCROLL_EDGE_REACHED_SIGNAL          )
83
84 DALI_TYPE_REGISTRATION_END()
85
86 const std::string kEmptyString;
87
88 } // anonymous namepsace
89
90 #define GET_ENUM_STRING( structName, inputExp ) \
91   Scripting::GetLinearEnumerationName< Toolkit::WebView::structName::Type >( static_cast< Toolkit::WebView::structName::Type >( inputExp ), structName##_TABLE, structName##_TABLE_COUNT )
92
93 #define GET_ENUM_VALUE( structName, inputExp, outputExp ) \
94   Scripting::GetEnumerationProperty< Toolkit::WebView::structName::Type >( inputExp, structName##_TABLE, structName##_TABLE_COUNT, outputExp )
95
96 WebView::WebView( const std::string& locale, const std::string& timezoneId )
97 : Control( ControlBehaviour( ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS ) ),
98   mUrl(),
99   mVisual(),
100   mWebViewSize( Stage::GetCurrent().GetSize() ),
101   mWebEngine(),
102   mPageLoadStartedSignal(),
103   mPageLoadFinishedSignal(),
104   mPageLoadErrorSignal()
105 {
106   mWebEngine = Dali::WebEngine::New();
107
108   // WebEngine is empty when it is not properly initialized.
109   if( mWebEngine )
110   {
111     mWebEngine.Create( mWebViewSize.width, mWebViewSize.height, locale, timezoneId );
112   }
113 }
114
115 WebView::WebView()
116 : WebView( "", "" )
117 {
118 }
119
120 WebView::~WebView()
121 {
122 }
123
124 Toolkit::WebView WebView::New()
125 {
126   WebView* impl = new WebView();
127   Toolkit::WebView handle = Toolkit::WebView( *impl );
128
129   impl->Initialize();
130   return handle;
131 }
132
133 Toolkit::WebView WebView::New( const std::string& locale, const std::string& timezoneId )
134 {
135   WebView* impl = new WebView( locale, timezoneId );
136   Toolkit::WebView handle = Toolkit::WebView( *impl );
137
138   impl->Initialize();
139   return handle;
140 }
141
142 void WebView::OnInitialize()
143 {
144   Self().SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true );
145   Self().TouchedSignal().Connect( this, &WebView::OnTouchEvent );
146
147   if( mWebEngine )
148   {
149     mWebEngine.PageLoadStartedSignal().Connect( this, &WebView::OnPageLoadStarted );
150     mWebEngine.PageLoadFinishedSignal().Connect( this, &WebView::OnPageLoadFinished );
151     mWebEngine.PageLoadErrorSignal().Connect( this, &WebView::OnPageLoadError );
152     mWebEngine.ScrollEdgeReachedSignal().Connect( this, &WebView::OnScrollEdgeReached );
153   }
154 }
155
156 void WebView::LoadUrl( const std::string& url )
157 {
158   mUrl = url;
159   if( mWebEngine )
160   {
161     Texture texture = Dali::Texture::New( *mWebEngine.GetNativeImageSource() );
162     const std::string nativeImageUrl = Dali::Toolkit::TextureManager::AddTexture( texture );
163     mVisual = Toolkit::VisualFactory::Get().CreateVisual(
164       { { Toolkit::Visual::Property::TYPE,  Toolkit::Visual::IMAGE } ,
165         { Toolkit::ImageVisual::Property::URL, nativeImageUrl } } );
166
167     if( mVisual )
168     {
169       // Clean up previously registered visual and add new one.
170       DevelControl::RegisterVisual( *this, Toolkit::WebView::Property::URL, mVisual );
171       mWebEngine.LoadUrl( url );
172     }
173   }
174 }
175
176 void WebView::LoadHTMLString( const std::string& htmlString )
177 {
178   if( mWebEngine )
179   {
180     Texture texture = Dali::Texture::New( *mWebEngine.GetNativeImageSource() );
181     const std::string nativeImageUrl = Dali::Toolkit::TextureManager::AddTexture( texture );
182     mVisual = Toolkit::VisualFactory::Get().CreateVisual(
183       { { Toolkit::Visual::Property::TYPE,  Toolkit::Visual::IMAGE } ,
184         { Toolkit::ImageVisual::Property::URL, nativeImageUrl } } );
185
186     if( mVisual )
187     {
188       DevelControl::RegisterVisual( *this, Toolkit::WebView::Property::URL, mVisual );
189       mWebEngine.LoadHTMLString( htmlString );
190     }
191   }
192 }
193
194 void WebView::Reload()
195 {
196   if( mWebEngine )
197   {
198     mWebEngine.Reload();
199   }
200 }
201
202 void WebView::StopLoading()
203 {
204   if( mWebEngine )
205   {
206     mWebEngine.StopLoading();
207   }
208 }
209
210 void WebView::Suspend()
211 {
212   if( mWebEngine )
213   {
214     mWebEngine.Suspend();
215   }
216 }
217
218 void WebView::Resume()
219 {
220   if( mWebEngine )
221   {
222     mWebEngine.Resume();
223   }
224 }
225
226 void WebView::ScrollBy( int deltaX, int deltaY )
227 {
228   if ( mWebEngine )
229   {
230     mWebEngine.ScrollBy( deltaX, deltaY );
231   }
232 }
233
234 bool WebView::CanGoForward()
235 {
236   return mWebEngine ? mWebEngine.CanGoForward() : false;
237 }
238
239 void WebView::GoForward()
240 {
241   if( mWebEngine )
242   {
243     mWebEngine.GoForward();
244   }
245 }
246
247 bool WebView::CanGoBack()
248 {
249   return mWebEngine ? mWebEngine.CanGoBack() : false;
250 }
251
252 void WebView::GoBack()
253 {
254   if( mWebEngine )
255   {
256     mWebEngine.GoBack();
257   }
258 }
259
260 void WebView::EvaluateJavaScript( const std::string& script, std::function< void( const std::string& ) > resultHandler )
261 {
262   if( mWebEngine )
263   {
264     mWebEngine.EvaluateJavaScript( script, resultHandler );
265   }
266 }
267
268 void WebView::AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void( const std::string& ) > handler )
269 {
270   if( mWebEngine )
271   {
272     mWebEngine.AddJavaScriptMessageHandler( exposedObjectName, handler );
273   }
274 }
275
276 void WebView::ClearHistory()
277 {
278   if( mWebEngine )
279   {
280     mWebEngine.ClearHistory();
281   }
282 }
283
284 void WebView::ClearCache()
285 {
286   if( mWebEngine )
287   {
288     mWebEngine.ClearCache();
289   }
290 }
291
292 void WebView::ClearCookies()
293 {
294   if( mWebEngine )
295   {
296     mWebEngine.ClearCookies();
297   }
298 }
299
300 Dali::Toolkit::WebView::WebViewPageLoadSignalType& WebView::PageLoadStartedSignal()
301 {
302   return mPageLoadStartedSignal;
303 }
304
305 Dali::Toolkit::WebView::WebViewPageLoadSignalType& WebView::PageLoadFinishedSignal()
306 {
307   return mPageLoadFinishedSignal;
308 }
309
310 Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType& WebView::PageLoadErrorSignal()
311 {
312   return mPageLoadErrorSignal;
313 }
314
315 Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType& WebView::ScrollEdgeReachedSignal()
316 {
317   return mScrollEdgeReachedSignal;
318 }
319
320 void WebView::OnPageLoadStarted( const std::string& url )
321 {
322   if( !mPageLoadStartedSignal.Empty() )
323   {
324     Dali::Toolkit::WebView handle( GetOwner() );
325     mPageLoadStartedSignal.Emit( handle, url );
326   }
327 }
328
329 void WebView::OnPageLoadFinished( const std::string& url )
330 {
331   if( !mPageLoadFinishedSignal.Empty() )
332   {
333     Dali::Toolkit::WebView handle( GetOwner() );
334     mPageLoadFinishedSignal.Emit( handle, url );
335   }
336 }
337
338 void WebView::OnPageLoadError( const std::string& url, int errorCode )
339 {
340   if( !mPageLoadErrorSignal.Empty() )
341   {
342     Dali::Toolkit::WebView handle( GetOwner() );
343     mPageLoadErrorSignal.Emit( handle, url, static_cast< Toolkit::WebView::LoadErrorCode >( errorCode ) );
344   }
345 }
346
347 void WebView::OnScrollEdgeReached( Dali::WebEnginePlugin::ScrollEdge edge )
348 {
349   if( !mScrollEdgeReachedSignal.Empty() )
350   {
351     Dali::Toolkit::WebView handle( GetOwner() );
352     mScrollEdgeReachedSignal.Emit( handle, edge );
353   }
354 }
355
356 bool WebView::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
357 {
358   Dali::BaseHandle handle( object );
359
360   bool connected = false;
361   Toolkit::WebView webView = Toolkit::WebView::DownCast( handle );
362
363   if( 0 == strcmp( signalName.c_str(), PAGE_LOAD_STARTED_SIGNAL ) )
364   {
365     webView.PageLoadStartedSignal().Connect( tracker, functor );
366     connected = true;
367   }
368   else if( 0 == strcmp( signalName.c_str(), PAGE_LOAD_FINISHED_SIGNAL ) )
369   {
370     webView.PageLoadFinishedSignal().Connect( tracker, functor );
371     connected = true;
372   }
373   else if( 0 == strcmp( signalName.c_str(), PAGE_LOAD_ERROR_SIGNAL ) )
374   {
375     webView.PageLoadErrorSignal().Connect( tracker, functor );
376     connected = true;
377   }
378   else if( 0 == strcmp( signalName.c_str(), SCROLL_EDGE_REACHED_SIGNAL ) )
379   {
380     webView.ScrollEdgeReachedSignal().Connect( tracker, functor );
381     connected = true;
382   }
383
384   return connected;
385 }
386
387 Vector3 WebView::GetNaturalSize()
388 {
389   if( mVisual )
390   {
391     Vector2 rendererNaturalSize;
392     mVisual.GetNaturalSize( rendererNaturalSize );
393     return Vector3( rendererNaturalSize );
394   }
395
396   return Vector3( mWebViewSize );
397 }
398
399 void WebView::OnRelayout( const Vector2& size, RelayoutContainer& container )
400 {
401   Control::OnRelayout( size, container );
402
403   if( size.width > 0 && size.height > 0 && mWebViewSize != size )
404   {
405     mWebViewSize = size;
406
407     if( mWebEngine )
408     {
409       mWebEngine.SetSize( size.width, size.height );
410     }
411   }
412 }
413
414 void WebView::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
415 {
416   Toolkit::WebView webView = Toolkit::WebView::DownCast( Dali::BaseHandle( object ) );
417
418   if( webView )
419   {
420     WebView& impl = GetImpl( webView );
421     switch( index )
422     {
423       case Toolkit::WebView::Property::URL:
424       {
425         std::string url;
426         if( value.Get( url ) )
427         {
428           impl.LoadUrl( url );
429         }
430         break;
431       }
432       case Toolkit::WebView::Property::CACHE_MODEL:
433       {
434         Toolkit::WebView::CacheModel::Type output = impl.GetCacheModel();
435         GET_ENUM_VALUE( CacheModel, value, output );
436         impl.SetCacheModel( output );
437         break;
438       }
439       case Toolkit::WebView::Property::COOKIE_ACCEPT_POLICY:
440       {
441         Toolkit::WebView::CookieAcceptPolicy::Type output = impl.GetCookieAcceptPolicy();
442         GET_ENUM_VALUE( CookieAcceptPolicy, value, output );
443         impl.SetCookieAcceptPolicy( output );
444         break;
445       }
446       case Toolkit::WebView::Property::USER_AGENT:
447       {
448         std::string input;
449         if( value.Get( input ) )
450         {
451           impl.SetUserAgent( input );
452         }
453         break;
454       }
455       case Toolkit::WebView::Property::ENABLE_JAVASCRIPT:
456       {
457         bool input;
458         if( value.Get( input ) )
459         {
460           impl.EnableJavaScript( input );
461         }
462         break;
463       }
464       case Toolkit::WebView::Property::LOAD_IMAGES_AUTOMATICALLY:
465       {
466         bool input;
467         if( value.Get( input ) )
468         {
469           impl.LoadImagesAutomatically( input );
470         }
471         break;
472       }
473       case Toolkit::WebView::Property::DEFAULT_TEXT_ENCODING_NAME:
474       {
475         std::string input;
476         if( value.Get( input ) )
477         {
478           impl.SetDefaultTextEncodingName( input );
479         }
480         break;
481       }
482       case Toolkit::WebView::Property::DEFAULT_FONT_SIZE:
483       {
484         int input;
485         if( value.Get( input ) )
486         {
487           impl.SetDefaultFontSize( input );
488         }
489         break;
490       }
491       case Toolkit::WebView::Property::SCROLL_POSITION:
492       {
493         Vector2 input;
494         if ( value.Get( input ) )
495         {
496           impl.SetScrollPosition( input.x, input.y );
497         }
498         break;
499       }
500     }
501   }
502 }
503
504 Property::Value WebView::GetProperty( BaseObject* object, Property::Index propertyIndex )
505 {
506   Property::Value value;
507
508   Toolkit::WebView webView = Toolkit::WebView::DownCast( Dali::BaseHandle( object ) );
509
510   if( webView )
511   {
512     WebView& impl = GetImpl( webView );
513     switch( propertyIndex )
514     {
515       case Toolkit::WebView::Property::URL:
516       {
517         value = impl.mUrl;
518         break;
519       }
520       case Toolkit::WebView::Property::CACHE_MODEL:
521       {
522         value = GET_ENUM_STRING( CacheModel, impl.GetCacheModel() );
523         break;
524       }
525       case Toolkit::WebView::Property::COOKIE_ACCEPT_POLICY:
526       {
527         value = GET_ENUM_STRING( CookieAcceptPolicy, impl.GetCookieAcceptPolicy() );
528         break;
529       }
530       case Toolkit::WebView::Property::USER_AGENT:
531       {
532         value = impl.GetUserAgent();
533         break;
534       }
535       case Toolkit::WebView::Property::ENABLE_JAVASCRIPT:
536       {
537         value = impl.IsJavaScriptEnabled();
538         break;
539       }
540       case Toolkit::WebView::Property::LOAD_IMAGES_AUTOMATICALLY:
541       {
542         value = impl.AreImagesAutomaticallyLoaded();
543         break;
544       }
545       case Toolkit::WebView::Property::DEFAULT_TEXT_ENCODING_NAME:
546       {
547         value = impl.GetDefaultTextEncodingName();
548         break;
549       }
550       case Toolkit::WebView::Property::DEFAULT_FONT_SIZE:
551       {
552         value = impl.GetDefaultFontSize();
553         break;
554       }
555       case Toolkit::WebView::Property::SCROLL_POSITION:
556       {
557         int x, y;
558         impl.GetScrollPosition( x, y );
559         value = Vector2( x, y );
560         break;
561       }
562       case Toolkit::WebView::Property::SCROLL_SIZE:
563       {
564         int width, height;
565         impl.GetScrollSize( width, height );
566         value = Vector2( width, height );
567         break;
568       }
569       case Toolkit::WebView::Property::CONTENT_SIZE:
570       {
571         int width, height;
572         impl.GetContentSize( width, height );
573         value = Vector2( width, height );
574         break;
575       }
576       default:
577          break;
578     }
579   }
580
581   return value;
582 }
583
584 bool WebView::OnTouchEvent( Actor actor, const Dali::TouchEvent& touch )
585 {
586   bool result = false;
587
588   if( mWebEngine )
589   {
590     result = mWebEngine.SendTouchEvent( touch );
591   }
592   return result;
593 }
594
595 bool WebView::OnKeyEvent( const Dali::KeyEvent& event )
596 {
597   bool result = false;
598
599   if( mWebEngine )
600   {
601     result = mWebEngine.SendKeyEvent( event );
602   }
603   return result;
604 }
605
606 void WebView::OnKeyInputFocusGained()
607 {
608   if( mWebEngine )
609   {
610     mWebEngine.SetFocus( true );
611   }
612
613   EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last.
614 }
615
616 void WebView::OnKeyInputFocusLost()
617 {
618   if( mWebEngine )
619   {
620     mWebEngine.SetFocus( false );
621   }
622
623   EmitKeyInputFocusSignal( false ); // Calls back into the Control hence done last.
624 }
625
626 void WebView::SetScrollPosition( int x, int y )
627 {
628   if( mWebEngine )
629   {
630     mWebEngine.SetScrollPosition( x, y );
631   }
632 }
633
634 void WebView::GetScrollPosition( int& x, int& y ) const
635 {
636   if( mWebEngine )
637   {
638     mWebEngine.GetScrollPosition( x, y );
639   }
640 }
641
642 void WebView::GetScrollSize( int& width, int& height ) const
643 {
644   if( mWebEngine )
645   {
646     mWebEngine.GetScrollSize( width, height );
647   }
648 }
649
650 void WebView::GetContentSize( int& width, int& height ) const
651 {
652   if( mWebEngine )
653   {
654     mWebEngine.GetContentSize( width, height );
655   }
656 }
657
658 Toolkit::WebView::CacheModel::Type WebView::GetCacheModel() const
659 {
660   return mWebEngine ? static_cast< Toolkit::WebView::CacheModel::Type >( mWebEngine.GetCacheModel() ) : Toolkit::WebView::CacheModel::DOCUMENT_VIEWER;
661 }
662
663 void WebView::SetCacheModel( Toolkit::WebView::CacheModel::Type cacheModel )
664 {
665   if( mWebEngine )
666   {
667     mWebEngine.SetCacheModel( static_cast< WebEnginePlugin::CacheModel >( cacheModel ) );
668   }
669 }
670
671 Toolkit::WebView::CookieAcceptPolicy::Type WebView::GetCookieAcceptPolicy() const
672 {
673   return mWebEngine ? static_cast< Toolkit::WebView::CookieAcceptPolicy::Type >( mWebEngine.GetCookieAcceptPolicy() ) : Toolkit::WebView::CookieAcceptPolicy::NO_THIRD_PARTY;
674 }
675
676 void WebView::SetCookieAcceptPolicy( Toolkit::WebView::CookieAcceptPolicy::Type policy )
677 {
678   if( mWebEngine )
679   {
680     mWebEngine.SetCookieAcceptPolicy( static_cast< WebEnginePlugin::CookieAcceptPolicy >( policy ) );
681   }
682 }
683
684 const std::string& WebView::GetUserAgent() const
685 {
686   return mWebEngine ? mWebEngine.GetUserAgent() : kEmptyString;
687 }
688
689 void WebView::SetUserAgent( const std::string& userAgent )
690 {
691   if( mWebEngine )
692   {
693     mWebEngine.SetUserAgent( userAgent );
694   }
695 }
696
697 bool WebView::IsJavaScriptEnabled() const
698 {
699   return mWebEngine ? mWebEngine.IsJavaScriptEnabled() : true;
700 }
701
702 void WebView::EnableJavaScript( bool enabled )
703 {
704   if( mWebEngine )
705   {
706     mWebEngine.EnableJavaScript( enabled );
707   }
708 }
709
710 bool WebView::AreImagesAutomaticallyLoaded() const
711 {
712   return mWebEngine ? mWebEngine.AreImagesAutomaticallyLoaded() : true;
713 }
714
715 void WebView::LoadImagesAutomatically( bool automatic )
716 {
717   if( mWebEngine )
718   {
719     mWebEngine.LoadImagesAutomatically( automatic );
720   }
721 }
722
723 const std::string& WebView::GetDefaultTextEncodingName() const
724 {
725   return mWebEngine ? mWebEngine.GetDefaultTextEncodingName() : kEmptyString;
726 }
727
728 void WebView::SetDefaultTextEncodingName( const std::string& defaultTextEncodingName )
729 {
730   if( mWebEngine )
731   {
732     mWebEngine.SetDefaultTextEncodingName( defaultTextEncodingName );
733   }
734 }
735
736 int WebView::GetDefaultFontSize() const
737 {
738   return mWebEngine ? mWebEngine.GetDefaultFontSize() : 0;
739 }
740
741 void WebView::SetDefaultFontSize( int defaultFontSize )
742 {
743   if( mWebEngine )
744   {
745     mWebEngine.SetDefaultFontSize( defaultFontSize );
746   }
747 }
748
749 #undef GET_ENUM_STRING
750 #undef GET_ENUM_VALUE
751
752 } // namespace Internal
753
754 } // namespace Toolkit
755
756 } // namespace Dali