2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include "toolkit-timer.h"
20 #include <dali/devel-api/adaptor-framework/web-engine.h>
21 #include <dali/devel-api/adaptor-framework/web-engine-back-forward-list.h>
22 #include <dali/devel-api/adaptor-framework/web-engine-back-forward-list-item.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-form-repost-decision.h>
26 #include <dali/devel-api/adaptor-framework/web-engine-request-interceptor.h>
27 #include <dali/devel-api/adaptor-framework/web-engine-settings.h>
28 #include <dali/public-api/adaptor-framework/native-image-source.h>
29 #include <dali/public-api/images/pixel-data.h>
30 #include <dali/public-api/object/any.h>
31 #include <dali/public-api/object/base-object.h>
34 #include <toolkit-application.h>
50 // Generally only one WebEngine instance exists.
51 // If > 1, a new web engine has been created by CreateWindowSignal.
52 static WebEngine* gInstance = 0;
53 static int gInstanceCount = 0;
58 bool OnEvaluteJavaScript();
59 bool OnJavaScriptAlert();
60 bool OnJavaScriptConfirm();
61 bool OnJavaScriptPrompt();
63 bool OnScreenshotCaptured();
64 bool OnVideoPlaying();
65 bool OnGeolocationPermission();
66 bool OnClearHistory();
68 static void ConnectToGlobalSignal( bool ( *func )() )
70 Dali::Timer timer = Dali::Timer::New( 0 );
71 timer.TickSignal().Connect( func );
74 static void DisconnectFromGlobalSignal( bool ( *func )() )
76 Dali::Timer timer = Dali::Timer::New( 0 );
77 timer.TickSignal().Disconnect( func );
79 } // namespace anonymous
81 class MockWebEngineContext : public Dali::WebEngineContext
84 MockWebEngineContext()
85 : mockModel( Dali::WebEngineContext::CacheModel::DOCUMENT_VIEWER )
89 Dali::WebEngineContext::CacheModel GetCacheModel() const override
94 void SetCacheModel( Dali::WebEngineContext::CacheModel cacheModel ) override
96 mockModel = cacheModel;
99 void SetProxyUri( const std::string& uri ) override
103 void SetDefaultProxyAuth( const std::string& username, const std::string& password ) override
107 void SetCertificateFilePath( const std::string& certificatePath ) override
111 void DeleteWebDatabase() override
115 void DeleteWebStorage() override
119 void DeleteLocalFileSystem() override
123 void DisableCache( bool cacheDisabled ) override
127 void ClearCache() override
132 Dali::WebEngineContext::CacheModel mockModel;
135 class MockWebEngineCookieManager : public Dali::WebEngineCookieManager
138 MockWebEngineCookieManager()
139 : mockCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy::NO_THIRD_PARTY )
143 void SetCookieAcceptPolicy( Dali::WebEngineCookieManager::CookieAcceptPolicy policy ) override
145 mockCookieAcceptPolicy = policy;
148 Dali::WebEngineCookieManager::CookieAcceptPolicy GetCookieAcceptPolicy() const override
150 return mockCookieAcceptPolicy;
153 void ClearCookies() override
157 void SetPersistentStorage( const std::string& path, Dali::WebEngineCookieManager::CookiePersistentStorage storage ) override
162 Dali::WebEngineCookieManager::CookieAcceptPolicy mockCookieAcceptPolicy;
165 class MockWebEngineBackForwardListItem : public Dali::WebEngineBackForwardListItem
168 MockWebEngineBackForwardListItem()
169 : mockUrl( "http://url" ),
170 mockTitle( "title" ),
171 mockOriginalUrl( "http://originalurl" )
175 std::string GetUrl() const override
180 std::string GetTitle() const override
185 std::string GetOriginalUrl() const override
187 return mockOriginalUrl;
192 std::string mockTitle;
193 std::string mockOriginalUrl;
196 class MockWebEngineBackForwardList : public Dali::WebEngineBackForwardList
199 MockWebEngineBackForwardList()
201 pMockItem( &mockItem )
205 Dali::WebEngineBackForwardListItem& GetCurrentItem() const override
210 Dali::WebEngineBackForwardListItem& GetItemAtIndex( uint32_t index ) const override
215 uint32_t GetItemCount() const override
221 MockWebEngineBackForwardListItem mockItem;
222 WebEngineBackForwardListItem* pMockItem;
225 class MockWebEngineFormRepostDecision : public WebEngineFormRepostDecision
228 MockWebEngineFormRepostDecision()
232 void Reply(bool allowed) override {}
235 class MockWebEngineRequestInterceptor : public WebEngineRequestInterceptor
238 MockWebEngineRequestInterceptor()
242 std::string GetUrl() const override
244 return "http://test.html";
247 bool Ignore() override
252 bool SetResponseStatus(int statusCode, const std::string &customedStatusText) override
257 bool AddResponseHeader(const std::string &fieldName, const std::string &fieldValue) override
262 bool AddResponseBody(const std::string &body, uint32_t length) override
268 class MockWebEngineSettings : public WebEngineSettings
271 MockWebEngineSettings()
272 : mockDefaultFontSize( 16 ),
273 mockJavaScriptEnabled( true ),
274 mockAutoFittingEnabled ( true ),
275 mockPluginsEnabled ( true ),
276 mockPrivateBrowsingEnabled( true ),
277 mockLinkMagnifierEnabled( true ),
278 mockKeypadWithoutUserActionUsed( true ),
279 mockAutofillPasswordFormEnabled( true ),
280 mockFormCandidateDataEnabled( true ),
281 mockTextSelectionEnabled( true ),
282 mockTextAutosizingEnable( true ),
283 mockArrowScrollEnable( true ),
284 mockClipboardEnabled( true ),
285 mockImePanelEnabled( true ),
286 mockImageLoadedAutomatically( true ),
287 mockDefaultTextEncodingName()
291 uint32_t GetDefaultFontSize() const override
293 return mockDefaultFontSize;
296 void SetDefaultFontSize( uint32_t size ) override
298 mockDefaultFontSize = size;
301 bool IsJavaScriptEnabled() const override
303 return mockJavaScriptEnabled;
306 void EnableJavaScript( bool enabled ) override
308 mockJavaScriptEnabled = enabled;
311 bool IsAutoFittingEnabled() const override
313 return mockAutoFittingEnabled;
316 void EnableAutoFitting( bool enabled ) override
318 mockAutoFittingEnabled = enabled;
321 bool ArePluginsEnabled() const override
323 return mockPluginsEnabled;
326 void EnablePlugins( bool enabled ) override
328 mockPluginsEnabled = enabled;
331 bool IsPrivateBrowsingEnabled() const override
333 return mockPrivateBrowsingEnabled;
336 void EnablePrivateBrowsing( bool enabled ) override
338 mockPrivateBrowsingEnabled = enabled;
341 bool IsLinkMagnifierEnabled() const override
343 return mockLinkMagnifierEnabled;
346 void EnableLinkMagnifier( bool enabled ) override
348 mockLinkMagnifierEnabled = enabled;
351 bool IsKeypadWithoutUserActionUsed() const override
353 return mockKeypadWithoutUserActionUsed;
356 void UseKeypadWithoutUserAction( bool used ) override
358 mockKeypadWithoutUserActionUsed = used;
361 bool IsAutofillPasswordFormEnabled() const override
363 return mockAutofillPasswordFormEnabled;
366 void EnableAutofillPasswordForm( bool enabled ) override
368 mockAutofillPasswordFormEnabled = enabled;
371 bool IsFormCandidateDataEnabled() const override
373 return mockFormCandidateDataEnabled;
376 void EnableFormCandidateData( bool enabled ) override
378 mockFormCandidateDataEnabled = enabled;
381 bool IsTextSelectionEnabled() const override
383 return mockTextSelectionEnabled;
386 void EnableTextSelection( bool enabled ) override
388 mockTextSelectionEnabled = enabled;
391 bool IsTextAutosizingEnabled() const override
393 return mockTextAutosizingEnable;
396 void EnableTextAutosizing( bool enabled ) override
398 mockTextAutosizingEnable = enabled;
401 bool IsArrowScrollEnabled() const override
403 return mockArrowScrollEnable;
406 void EnableArrowScroll( bool enabled ) override
408 mockArrowScrollEnable = enabled;
411 bool IsClipboardEnabled() const override
413 return mockClipboardEnabled;
416 void EnableClipboard( bool enabled ) override
418 mockClipboardEnabled = enabled;
421 bool IsImePanelEnabled() const override
423 return mockImePanelEnabled;
426 void EnableImePanel( bool enabled ) override
428 mockImePanelEnabled = enabled;
431 bool AreImagesLoadedAutomatically() const override
433 return mockImageLoadedAutomatically;
436 void AllowImagesLoadAutomatically( bool automatic ) override
438 mockImageLoadedAutomatically = automatic;
441 std::string GetDefaultTextEncodingName() const override
443 return mockDefaultTextEncodingName;
446 void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ) override
448 mockDefaultTextEncodingName = defaultTextEncodingName;
451 void AllowMixedContents( bool allowed ) override
455 void EnableSpatialNavigation( bool enabled ) override
459 void EnableWebSecurity( bool enabled ) override
463 void EnableCacheBuilder( bool enabled ) override
467 void UseScrollbarThumbFocusNotifications( bool used ) override
471 void EnableDoNotTrack( bool enabled ) override
475 void AllowFileAccessFromExternalUrl( bool allowed ) override
479 void AllowScriptsOpenWindows( bool allowed ) override
484 int mockDefaultFontSize;
485 bool mockJavaScriptEnabled;
486 bool mockAutoFittingEnabled;
487 bool mockPluginsEnabled;
488 bool mockPrivateBrowsingEnabled;
489 bool mockLinkMagnifierEnabled;
490 bool mockKeypadWithoutUserActionUsed;
491 bool mockAutofillPasswordFormEnabled;
492 bool mockFormCandidateDataEnabled;
493 bool mockTextSelectionEnabled;
494 bool mockTextAutosizingEnable;
495 bool mockArrowScrollEnable;
496 bool mockClipboardEnabled;
497 bool mockImePanelEnabled;
498 bool mockImageLoadedAutomatically;
499 std::string mockDefaultTextEncodingName;
502 class WebEngine: public Dali::BaseObject
506 using JavaScriptEvaluatedResultCallback = std::function<void(const std::string&)>;
510 , mCurrentPlusOnePos( 0 )
512 , mEvaluating( false )
513 , mScrollPosition( 0, 0 )
514 , mScrollSize( 500, 500 )
515 , mContentSize( 500, 500 )
518 if ( gInstanceCount == 1 ) // only first web engine need be saved.
523 mockWebEngineSettings = new MockWebEngineSettings();
524 mockWebEngineContext = new MockWebEngineContext();
525 mockWebEngineCookieManager = new MockWebEngineCookieManager();
526 mockWebEngineBackForwardList = new MockWebEngineBackForwardList();
532 if( !gInstanceCount )
537 delete mockWebEngineSettings;
538 delete mockWebEngineContext;
539 delete mockWebEngineCookieManager;
540 delete mockWebEngineBackForwardList;
543 Dali::WebEngineSettings& GetSettings() const
545 return *mockWebEngineSettings;
548 Dali::WebEngineContext& GetContext() const
550 return *mockWebEngineContext;
553 Dali::WebEngineCookieManager& GetCookieManager() const
555 return *mockWebEngineCookieManager;
558 Dali::WebEngineBackForwardList& GetBackForwardList() const
560 return *mockWebEngineBackForwardList;
563 void LoadUrl( const std::string& url )
566 ConnectToGlobalSignal( &OnLoadUrl );
569 const std::string& GetUrl() const
574 std::string GetTitle() const
576 return std::string("title");
579 Dali::PixelData GetFavicon() const
581 uint8_t* faviconData = new uint8_t[ 16 ];
583 faviconData[ 0 ] = 0xff;
584 faviconData[ 1 ] = 0x00;
585 faviconData[ 2 ] = 0x00;
586 faviconData[ 3 ] = 0xff;
587 faviconData[ 4 ] = 0xff;
588 faviconData[ 5 ] = 0x00;
589 faviconData[ 6 ] = 0x00;
590 faviconData[ 7 ] = 0xff;
591 faviconData[ 8 ] = 0xff;
592 faviconData[ 9 ] = 0x00;
593 faviconData[ 10 ] = 0x00;
594 faviconData[ 11 ] = 0xff;
595 faviconData[ 12 ] = 0xff;
596 faviconData[ 13 ] = 0x00;
597 faviconData[ 14 ] = 0x00;
598 faviconData[ 15 ] = 0xff;
600 return Dali::PixelData::New( faviconData, 16, 2, 2,
601 Dali::Pixel::Format::RGBA8888,
602 Dali::PixelData::ReleaseFunction::DELETE_ARRAY );
605 bool CanGoForward() const
607 return mHistory.size() > mCurrentPlusOnePos;
612 ConnectToGlobalSignal( &OnGoForward );
615 bool CanGoBack() const
617 return mCurrentPlusOnePos > 1;
622 ConnectToGlobalSignal( &OnGoBack );
625 void EvaluateJavaScript( const std::string& script, std::function< void( const std::string& ) > resultHandler )
631 ConnectToGlobalSignal( &OnEvaluteJavaScript );
633 mResultCallbacks.push_back( resultHandler );
637 void RegisterJavaScriptAlertCallback( Dali::WebEnginePlugin::JavaScriptAlertCallback callback )
641 ConnectToGlobalSignal( &OnJavaScriptAlert );
642 mJavaScriptAlertCallback = callback;
646 void RegisterJavaScriptConfirmCallback( Dali::WebEnginePlugin::JavaScriptConfirmCallback callback )
650 ConnectToGlobalSignal( &OnJavaScriptConfirm );
651 mJavaScriptConfirmCallback = callback;
655 void RegisterJavaScriptPromptCallback( Dali::WebEnginePlugin::JavaScriptPromptCallback callback )
659 ConnectToGlobalSignal( &OnJavaScriptPrompt );
660 mJavaScriptPromptCallback = callback;
666 ConnectToGlobalSignal( &OnClearHistory );
669 const std::string& GetUserAgent() const
674 void SetUserAgent( const std::string& userAgent )
676 mUserAgent = userAgent;
679 void ScrollBy( int dx, int dy )
681 mScrollPosition += Dali::Vector2( dx, dy );
682 if ( mScrollPosition.y + mScrollSize.height > mContentSize.height )
684 ConnectToGlobalSignal( &OnScrollEdge );
688 bool ScrollEdgeBy( int dx, int dy )
690 mScrollPosition += Dali::Vector2( dx, dy );
691 if ( mScrollPosition.y + mScrollSize.height > mContentSize.height )
693 ConnectToGlobalSignal( &OnScrollEdge );
698 void SetScrollPosition( int x, int y )
700 mScrollPosition.x = x;
701 mScrollPosition.y = y;
704 Dali::Vector2 GetScrollPosition() const
706 return mScrollPosition;
709 Dali::Vector2 GetScrollSize() const
714 Dali::Vector2 GetContentSize() const
719 void SetPageZoomFactor(float zoomFactor)
721 mPageZoomFactor = zoomFactor;
724 float GetPageZoomFactor() const
726 return mPageZoomFactor;
729 void SetTextZoomFactor(float zoomFactor)
731 mTextZoomFactor = zoomFactor;
734 float GetTextZoomFactor() const
736 return mTextZoomFactor;
739 float GetLoadProgressPercentage() const
744 void SetScaleFactor(float scaleFactor, Dali::Vector2 point)
746 mScaleFactor = scaleFactor;
749 float GetScaleFactor() const
754 Dali::PixelData GetScreenshot(Dali::Rect<int> viewArea, float scaleFactor)
756 uint32_t bufferSize = viewArea.width * viewArea.height * 4 ;
757 uint8_t* pixel = new uint8_t[ bufferSize ];
758 memset(pixel, 0xff, bufferSize);
759 return Dali::PixelData::New( pixel, bufferSize, viewArea.width, viewArea.height,
760 Dali::Pixel::Format::RGBA8888,
761 Dali::PixelData::ReleaseFunction::DELETE_ARRAY );
764 bool GetScreenshotAsynchronously(Dali::Rect<int> viewArea, float scaleFactor, Dali::WebEnginePlugin::ScreenshotCapturedCallback callback)
768 ConnectToGlobalSignal( &OnScreenshotCaptured );
769 mScreenshotCapturedCallback = callback;
774 bool CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback)
778 ConnectToGlobalSignal( &OnVideoPlaying );
779 mVideoPlayingCallback = callback;
784 void RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback)
788 ConnectToGlobalSignal( &OnGeolocationPermission );
789 mGeolocationPermissionCallback = callback;
793 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal()
795 return mPageLoadStartedSignal;
798 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadInProgressSignal()
800 return mPageLoadInProgressSignal;
803 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadFinishedSignal()
805 return mPageLoadFinishedSignal;
808 Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& PageLoadErrorSignal()
810 return mPageLoadErrorSignal;
813 Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal()
815 return mScrollEdgeReachedSignal;
818 Dali::WebEnginePlugin::WebEngineUrlChangedSignalType& UrlChangedSignal()
820 return mUrlChangedSignal;
823 Dali::WebEnginePlugin::WebEngineFormRepostDecisionSignalType& FormRepostDecisionSignal()
825 return mFormRepostDecisionSignal;
828 Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& FrameRenderedSignal()
830 return mFrameRenderedSignal;
833 Dali::WebEnginePlugin::WebEngineRequestInterceptorSignalType& RequestInterceptorSignal()
835 return mRequestInterceptorSignal;
839 std::vector<std::string> mHistory;
840 size_t mCurrentPlusOnePos;
841 std::string mUserAgent;
843 Dali::WebEnginePlugin::WebEnginePageLoadSignalType mPageLoadStartedSignal;
844 Dali::WebEnginePlugin::WebEnginePageLoadSignalType mPageLoadInProgressSignal;
845 Dali::WebEnginePlugin::WebEnginePageLoadSignalType mPageLoadFinishedSignal;
846 Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType mPageLoadErrorSignal;
847 Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType mScrollEdgeReachedSignal;
848 Dali::WebEnginePlugin::WebEngineUrlChangedSignalType mUrlChangedSignal;
849 Dali::WebEnginePlugin::WebEngineFormRepostDecisionSignalType mFormRepostDecisionSignal;
850 Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType mFrameRenderedSignal;
851 Dali::WebEnginePlugin::WebEngineRequestInterceptorSignalType mRequestInterceptorSignal;
854 float mPageZoomFactor;
855 float mTextZoomFactor;
858 Dali::Vector2 mScrollPosition;
859 Dali::Vector2 mScrollSize;
860 Dali::Vector2 mContentSize;
861 WebEngineBackForwardList* mockWebEngineBackForwardList;
862 WebEngineContext* mockWebEngineContext;
863 WebEngineCookieManager* mockWebEngineCookieManager;
864 WebEngineSettings* mockWebEngineSettings;
866 std::vector<JavaScriptEvaluatedResultCallback> mResultCallbacks;
867 Dali::WebEnginePlugin::JavaScriptAlertCallback mJavaScriptAlertCallback;
868 Dali::WebEnginePlugin::JavaScriptConfirmCallback mJavaScriptConfirmCallback;
869 Dali::WebEnginePlugin::JavaScriptPromptCallback mJavaScriptPromptCallback;
870 Dali::WebEnginePlugin::ScreenshotCapturedCallback mScreenshotCapturedCallback;
871 Dali::WebEnginePlugin::VideoPlayingCallback mVideoPlayingCallback;
872 Dali::WebEnginePlugin::GeolocationPermissionCallback mGeolocationPermissionCallback;
881 DisconnectFromGlobalSignal( &OnGoBack );
883 if( gInstance && gInstance->CanGoBack() )
885 gInstance->mCurrentPlusOnePos--;
892 DisconnectFromGlobalSignal( &OnGoForward );
894 if( gInstance && gInstance->CanGoForward() )
896 gInstance->mCurrentPlusOnePos++;
903 DisconnectFromGlobalSignal( &OnLoadUrl );
907 if( gInstance->mHistory.size() > gInstance->mCurrentPlusOnePos )
909 gInstance->mHistory.erase( gInstance->mHistory.begin() + gInstance->mCurrentPlusOnePos, gInstance->mHistory.end() );
911 gInstance->mHistory.push_back( gInstance->mUrl );
912 gInstance->mCurrentPlusOnePos++;
913 gInstance->mPageLoadStartedSignal.Emit( gInstance->mUrl );
914 gInstance->mPageLoadInProgressSignal.Emit( gInstance->mUrl );
915 gInstance->mPageLoadFinishedSignal.Emit( gInstance->mUrl );
916 gInstance->mUrlChangedSignal.Emit( "http://new-test" );
918 std::shared_ptr<Dali::WebEngineFormRepostDecision> decision(new MockWebEngineFormRepostDecision());
919 gInstance->mFormRepostDecisionSignal.Emit(std::move(decision));
920 gInstance->mFrameRenderedSignal.Emit();
921 std::shared_ptr<Dali::WebEngineRequestInterceptor> interceptor(new MockWebEngineRequestInterceptor());
922 gInstance->mRequestInterceptorSignal.Emit(std::move(interceptor));
929 DisconnectFromGlobalSignal( &OnScrollEdge );
933 gInstance->mScrollEdgeReachedSignal.Emit( Dali::WebEnginePlugin::ScrollEdge::BOTTOM );
939 bool OnEvaluteJavaScript()
941 DisconnectFromGlobalSignal( &OnEvaluteJavaScript );
945 for( auto& func : gInstance->mResultCallbacks )
949 gInstance->mResultCallbacks.clear();
954 bool OnJavaScriptAlert()
956 DisconnectFromGlobalSignal( &OnJavaScriptAlert );
959 gInstance->mJavaScriptAlertCallback( "this is an alert popup." );
964 bool OnJavaScriptConfirm()
966 DisconnectFromGlobalSignal( &OnJavaScriptConfirm );
969 gInstance->mJavaScriptConfirmCallback( "this is a confirm popup." );
974 bool OnJavaScriptPrompt()
976 DisconnectFromGlobalSignal( &OnJavaScriptPrompt );
979 gInstance->mJavaScriptPromptCallback( "this is a prompt pompt.", "" );
984 bool OnScreenshotCaptured()
986 DisconnectFromGlobalSignal( &OnScreenshotCaptured );
989 uint8_t* pixel = new uint8_t[ 2 * 2 * 4 ];
990 memset(pixel, 0xff, 2 * 2 * 4);
991 Dali::PixelData data = Dali::PixelData::New( pixel, 2 * 2 * 4, 2, 2,
992 Dali::Pixel::Format::RGBA8888,
993 Dali::PixelData::ReleaseFunction::DELETE_ARRAY );
994 gInstance->mScreenshotCapturedCallback( data );
999 bool OnVideoPlaying()
1001 DisconnectFromGlobalSignal( &OnVideoPlaying );
1004 gInstance->mVideoPlayingCallback( true );
1009 bool OnGeolocationPermission()
1011 DisconnectFromGlobalSignal( &OnGeolocationPermission );
1014 gInstance->mGeolocationPermissionCallback( "", "" );
1019 bool OnClearHistory()
1021 DisconnectFromGlobalSignal( &OnClearHistory );
1023 if( gInstance && gInstance->mCurrentPlusOnePos )
1025 std::string url = gInstance->mHistory[ gInstance->mCurrentPlusOnePos - 1 ];
1026 std::vector< std::string >().swap( gInstance->mHistory );
1027 gInstance->mHistory.push_back( url );
1028 gInstance->mCurrentPlusOnePos = 1;
1035 inline WebEngine& GetImplementation( Dali::WebEngine& webEngine )
1037 DALI_ASSERT_ALWAYS( webEngine && "WebEngine handle is empty." );
1038 BaseObject& handle = webEngine.GetBaseObject();
1039 return static_cast< Internal::Adaptor::WebEngine& >( handle );
1042 inline const WebEngine& GetImplementation( const Dali::WebEngine& webEngine )
1044 DALI_ASSERT_ALWAYS( webEngine && "WebEngine handle is empty." );
1045 const BaseObject& handle = webEngine.GetBaseObject();
1046 return static_cast< const Internal::Adaptor::WebEngine& >( handle );
1049 } // namespace Adaptor
1051 } // namespace Internal
1053 // Dali::WebEngine Implementation
1054 WebEngine::WebEngine()
1058 WebEngine::WebEngine( Internal::Adaptor::WebEngine* internal )
1059 : BaseHandle( internal )
1063 WebEngine::~WebEngine()
1067 WebEngine WebEngine::New()
1069 Internal::Adaptor::WebEngine* baseObject = new Internal::Adaptor::WebEngine();
1071 return WebEngine( baseObject );
1074 WebEngine::WebEngine( const WebEngine& WebEngine )
1075 : BaseHandle( WebEngine )
1079 WebEngine& WebEngine::operator=( const WebEngine& webEngine )
1081 BaseHandle::operator=( webEngine );
1085 WebEngine WebEngine::DownCast( BaseHandle handle )
1087 return WebEngine( dynamic_cast< Internal::Adaptor::WebEngine* >( handle.GetObjectPtr() ) );
1090 void WebEngine::Create( int width, int height, const std::string& locale, const std::string& timezoneId )
1094 void WebEngine::Create( int width, int height, int argc, char** argv )
1098 void WebEngine::Destroy()
1102 WebEngineSettings& WebEngine::GetSettings() const
1104 return Internal::Adaptor::GetImplementation( *this ).GetSettings();
1107 WebEngineContext& WebEngine::GetContext() const
1109 return Internal::Adaptor::GetImplementation( *this ).GetContext();
1112 WebEngineCookieManager& WebEngine::GetCookieManager() const
1114 return Internal::Adaptor::GetImplementation( *this ).GetCookieManager();
1117 WebEngineBackForwardList& WebEngine::GetBackForwardList() const
1119 return Internal::Adaptor::GetImplementation( *this ).GetBackForwardList();
1122 void WebEngine::LoadUrl( const std::string& url )
1124 return Internal::Adaptor::GetImplementation( *this ).LoadUrl( url );
1127 std::string WebEngine::GetTitle() const
1129 return Internal::Adaptor::GetImplementation( *this ).GetTitle();
1132 Dali::PixelData WebEngine::GetFavicon() const
1134 return Internal::Adaptor::GetImplementation( *this ).GetFavicon();
1137 const std::string& WebEngine::GetUrl()
1139 return Internal::Adaptor::GetImplementation( *this ).GetUrl();
1142 NativeImageInterfacePtr WebEngine::GetNativeImageSource()
1145 Dali::NativeImageSourcePtr sourcePtr = Dali::NativeImageSource::New( source );
1149 void WebEngine::LoadHtmlString( const std::string& htmlString )
1153 bool WebEngine::LoadHtmlStringOverrideCurrentEntry(const std::string& html, const std::string& basicUri, const std::string& unreachableUrl)
1158 bool WebEngine::LoadContents(const std::string& contents, uint32_t contentSize, const std::string& mimeType, const std::string& encoding, const std::string& baseUri)
1163 void WebEngine::Reload()
1167 bool WebEngine::ReloadWithoutCache()
1172 void WebEngine::StopLoading()
1176 void WebEngine::Suspend()
1180 void WebEngine::Resume()
1184 void WebEngine::SuspendNetworkLoading()
1188 void WebEngine::ResumeNetworkLoading()
1192 bool WebEngine::AddCustomHeader(const std::string& name, const std::string& value)
1197 bool WebEngine::RemoveCustomHeader(const std::string& name)
1202 uint32_t WebEngine::StartInspectorServer(uint32_t port)
1207 bool WebEngine::StopInspectorServer()
1212 bool WebEngine::CanGoForward()
1214 return Internal::Adaptor::GetImplementation( *this ).CanGoForward();
1217 void WebEngine::GoForward()
1219 Internal::Adaptor::GetImplementation( *this ).GoForward();
1222 bool WebEngine::CanGoBack()
1224 return Internal::Adaptor::GetImplementation( *this ).CanGoBack();
1227 void WebEngine::GoBack()
1229 Internal::Adaptor::GetImplementation( *this ).GoBack();
1232 void WebEngine::EvaluateJavaScript( const std::string& script, std::function< void( const std::string& ) > resultHandler )
1234 Internal::Adaptor::GetImplementation( *this ).EvaluateJavaScript( script, resultHandler );
1237 void WebEngine::AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void(const std::string&) > handler )
1241 void WebEngine::RegisterJavaScriptAlertCallback( Dali::WebEnginePlugin::JavaScriptAlertCallback callback )
1243 Internal::Adaptor::GetImplementation( *this ).RegisterJavaScriptAlertCallback( callback );
1246 void WebEngine::JavaScriptAlertReply()
1250 void WebEngine::RegisterJavaScriptConfirmCallback( Dali::WebEnginePlugin::JavaScriptConfirmCallback callback )
1252 Internal::Adaptor::GetImplementation( *this ).RegisterJavaScriptConfirmCallback( callback );
1255 void WebEngine::JavaScriptConfirmReply( bool confirmed )
1259 void WebEngine::RegisterJavaScriptPromptCallback( Dali::WebEnginePlugin::JavaScriptPromptCallback callback )
1261 Internal::Adaptor::GetImplementation( *this ).RegisterJavaScriptPromptCallback( callback );
1264 void WebEngine::JavaScriptPromptReply( const std::string& result )
1268 void WebEngine::ClearAllTilesResources()
1272 void WebEngine::ClearHistory()
1274 Internal::Adaptor::GetImplementation( *this ).ClearHistory();
1277 void WebEngine::SetScaleFactor(float scaleFactor, Dali::Vector2 point)
1279 Internal::Adaptor::GetImplementation( *this ).SetScaleFactor(scaleFactor, point);
1282 float WebEngine::GetScaleFactor() const
1284 return Internal::Adaptor::GetImplementation( *this ).GetScaleFactor();
1287 void WebEngine::ActivateAccessibility(bool activated)
1291 bool WebEngine::HighlightText(const std::string& text, Dali::WebEnginePlugin::FindOption options, uint32_t maxMatchCount)
1296 void WebEngine::AddDynamicCertificatePath(const std::string& host, const std::string& certPath)
1300 Dali::PixelData WebEngine::GetScreenshot(Dali::Rect<int> viewArea, float scaleFactor)
1302 return Internal::Adaptor::GetImplementation( *this ).GetScreenshot(viewArea, scaleFactor);
1305 bool WebEngine::GetScreenshotAsynchronously(Dali::Rect<int> viewArea, float scaleFactor, Dali::WebEnginePlugin::ScreenshotCapturedCallback callback)
1307 return Internal::Adaptor::GetImplementation( *this ).GetScreenshotAsynchronously(viewArea, scaleFactor, callback);
1310 bool WebEngine::CheckVideoPlayingAsynchronously(Dali::WebEnginePlugin::VideoPlayingCallback callback)
1312 return Internal::Adaptor::GetImplementation( *this ).CheckVideoPlayingAsynchronously(callback);
1315 void WebEngine::RegisterGeolocationPermissionCallback(Dali::WebEnginePlugin::GeolocationPermissionCallback callback)
1317 Internal::Adaptor::GetImplementation( *this ).RegisterGeolocationPermissionCallback(callback);
1320 const std::string& WebEngine::GetUserAgent() const
1322 return Internal::Adaptor::GetImplementation( *this ).GetUserAgent();
1325 void WebEngine::SetUserAgent( const std::string& userAgent )
1327 Internal::Adaptor::GetImplementation( *this ).SetUserAgent( userAgent );
1330 void WebEngine::ScrollBy( int dx, int dy )
1332 Internal::Adaptor::GetImplementation( *this ).ScrollBy( dx, dy );
1335 bool WebEngine::ScrollEdgeBy( int dx, int dy )
1337 return Internal::Adaptor::GetImplementation( *this ).ScrollEdgeBy( dx, dy );
1340 void WebEngine::SetScrollPosition( int x, int y )
1342 Internal::Adaptor::GetImplementation( *this ).SetScrollPosition( x, y );
1345 Dali::Vector2 WebEngine::GetScrollPosition() const
1347 return Internal::Adaptor::GetImplementation( *this ).GetScrollPosition();
1350 Dali::Vector2 WebEngine::GetScrollSize() const
1352 return Internal::Adaptor::GetImplementation( *this ).GetScrollSize();
1355 Dali::Vector2 WebEngine::GetContentSize() const
1357 return Internal::Adaptor::GetImplementation( *this ).GetContentSize();
1360 void WebEngine::SetSize( int width, int height )
1364 void WebEngine::SetDocumentBackgroundColor(Dali::Vector4 color)
1368 void WebEngine::ClearTilesWhenHidden(bool cleared)
1372 void WebEngine::SetTileCoverAreaMultiplier(float multiplier)
1376 void WebEngine::EnableCursorByClient(bool enabled)
1380 std::string WebEngine::GetSelectedText() const
1385 bool WebEngine::SendTouchEvent( const TouchEvent& touch )
1390 bool WebEngine::SendKeyEvent( const KeyEvent& event )
1395 bool WebEngine::SendHoverEvent( const HoverEvent& event )
1400 bool WebEngine::SendWheelEvent( const WheelEvent& event )
1405 void WebEngine::SetFocus( bool focused )
1409 void WebEngine::SetPageZoomFactor(float zoomFactor)
1411 Internal::Adaptor::GetImplementation( *this ).SetPageZoomFactor(zoomFactor);
1414 float WebEngine::GetPageZoomFactor() const
1416 return Internal::Adaptor::GetImplementation( *this ).GetPageZoomFactor();
1419 void WebEngine::SetTextZoomFactor(float zoomFactor)
1421 Internal::Adaptor::GetImplementation( *this ).SetTextZoomFactor(zoomFactor);
1424 float WebEngine::GetTextZoomFactor() const
1426 return Internal::Adaptor::GetImplementation( *this ).GetTextZoomFactor();
1429 float WebEngine::GetLoadProgressPercentage() const
1431 return Internal::Adaptor::GetImplementation( *this ).GetLoadProgressPercentage();
1434 void WebEngine::UpdateDisplayArea( Dali::Rect< int > displayArea )
1438 void WebEngine::EnableVideoHole( bool enabled )
1442 void WebEngine::EnableMouseEvents( bool enabled )
1446 void WebEngine::EnableKeyEvents( bool enabled )
1450 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
1452 return Internal::Adaptor::GetImplementation( *this ).PageLoadStartedSignal();
1455 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadInProgressSignal()
1457 return Internal::Adaptor::GetImplementation( *this ).PageLoadInProgressSignal();
1460 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal()
1462 return Internal::Adaptor::GetImplementation( *this ).PageLoadFinishedSignal();
1465 Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal()
1467 return Internal::Adaptor::GetImplementation( *this ).PageLoadErrorSignal();
1470 Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
1472 return Internal::Adaptor::GetImplementation( *this ).ScrollEdgeReachedSignal();
1475 Dali::WebEnginePlugin::WebEngineUrlChangedSignalType& WebEngine::UrlChangedSignal()
1477 return Internal::Adaptor::GetImplementation( *this ).UrlChangedSignal();
1480 Dali::WebEnginePlugin::WebEngineFormRepostDecisionSignalType& WebEngine::FormRepostDecisionSignal()
1482 return Internal::Adaptor::GetImplementation( *this ).FormRepostDecisionSignal();
1485 Dali::WebEnginePlugin::WebEngineFrameRenderedSignalType& WebEngine::FrameRenderedSignal()
1487 return Internal::Adaptor::GetImplementation(*this).FrameRenderedSignal();
1490 Dali::WebEnginePlugin::WebEngineRequestInterceptorSignalType& WebEngine::RequestInterceptorSignal()
1492 return Internal::Adaptor::GetImplementation(*this).RequestInterceptorSignal();
1495 } // namespace Dali;