2 * Copyright (c) 2020 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.
19 #include <dali/devel-api/adaptor-framework/web-engine.h>
22 #include <dali/devel-api/adaptor-framework/web-engine-back-forward-list.h>
23 #include <dali/devel-api/adaptor-framework/web-engine-context.h>
24 #include <dali/devel-api/adaptor-framework/web-engine-cookie-manager.h>
25 #include <dali/devel-api/adaptor-framework/web-engine-settings.h>
26 #include <dali/internal/web-engine/common/web-engine-impl.h>
30 WebEngine::WebEngine()
34 WebEngine::WebEngine(Internal::Adaptor::WebEngine* internal)
35 : BaseHandle(internal)
39 WebEngine::~WebEngine()
43 WebEngine WebEngine::New()
45 Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New();
47 return WebEngine(engine.Get());
50 WebEngine::WebEngine(const WebEngine& webEngine)
51 : BaseHandle(webEngine)
55 WebEngine& WebEngine::operator=(const WebEngine& webEngine)
57 if(*this != webEngine)
59 BaseHandle::operator=(webEngine);
64 WebEngine WebEngine::DownCast(BaseHandle handle)
66 return WebEngine(dynamic_cast<Internal::Adaptor::WebEngine*>(handle.GetObjectPtr()));
69 void WebEngine::Create(int width, int height, const std::string& locale, const std::string& timezoneId)
71 GetImplementation(*this).Create(width, height, locale, timezoneId);
74 void WebEngine::Destroy()
76 GetImplementation(*this).Destroy();
79 NativeImageInterfacePtr WebEngine::GetNativeImageSource()
81 return GetImplementation(*this).GetNativeImageSource();
84 Dali::WebEngineSettings& WebEngine::GetSettings() const
86 return GetImplementation( *this ).GetSettings();
89 Dali::WebEngineContext& WebEngine::GetContext() const
91 return GetImplementation( *this ).GetContext();
94 Dali::WebEngineCookieManager& WebEngine::GetCookieManager() const
96 return GetImplementation( *this ).GetCookieManager();
99 Dali::WebEngineBackForwardList& WebEngine::GetBackForwardList() const
101 return GetImplementation( *this ).GetBackForwardList();
104 void WebEngine::LoadUrl(const std::string& url)
106 return GetImplementation(*this).LoadUrl(url);
109 const std::string& WebEngine::GetUrl()
111 return GetImplementation(*this).GetUrl();
114 void WebEngine::LoadHtmlString(const std::string& htmlString)
116 GetImplementation(*this).LoadHtmlString(htmlString);
119 void WebEngine::Reload()
121 GetImplementation(*this).Reload();
124 void WebEngine::StopLoading()
126 GetImplementation(*this).StopLoading();
129 void WebEngine::Suspend()
131 GetImplementation(*this).Suspend();
134 void WebEngine::Resume()
136 GetImplementation(*this).Resume();
139 void WebEngine::ScrollBy( int deltaX, int deltaY )
141 GetImplementation( *this ).ScrollBy( deltaX, deltaY );
144 void WebEngine::SetScrollPosition( int x, int y )
146 GetImplementation( *this ).SetScrollPosition( x, y );
149 void WebEngine::GetScrollPosition( int& x, int& y ) const
151 GetImplementation( *this ).GetScrollPosition( x, y );
154 void WebEngine::GetScrollSize( int& width, int& height ) const
156 GetImplementation( *this ).GetScrollSize( width, height );
159 void WebEngine::GetContentSize( int& width, int& height ) const
161 GetImplementation( *this ).GetContentSize( width, height );
164 bool WebEngine::CanGoForward()
166 return GetImplementation(*this).CanGoForward();
169 void WebEngine::GoForward()
171 GetImplementation(*this).GoForward();
174 bool WebEngine::CanGoBack()
176 return GetImplementation(*this).CanGoBack();
179 void WebEngine::GoBack()
181 GetImplementation(*this).GoBack();
184 void WebEngine::EvaluateJavaScript(const std::string& script, std::function<void(const std::string&)> resultHandler)
186 GetImplementation(*this).EvaluateJavaScript(script, resultHandler);
189 void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler)
191 GetImplementation(*this).AddJavaScriptMessageHandler(exposedObjectName, handler);
194 void WebEngine::ClearHistory()
196 return GetImplementation(*this).ClearHistory();
199 const std::string& WebEngine::GetUserAgent() const
201 return GetImplementation(*this).GetUserAgent();
204 void WebEngine::SetUserAgent(const std::string& userAgent)
206 GetImplementation(*this).SetUserAgent(userAgent);
209 void WebEngine::SetSize(int width, int height)
211 return GetImplementation(*this).SetSize(width, height);
214 bool WebEngine::SendTouchEvent(const TouchEvent& touch)
216 return GetImplementation(*this).SendTouchEvent(touch);
219 bool WebEngine::SendKeyEvent(const KeyEvent& event)
221 return GetImplementation(*this).SendKeyEvent(event);
224 void WebEngine::SetFocus( bool focused )
226 GetImplementation( *this ).SetFocus( focused );
229 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
231 return GetImplementation(*this).PageLoadStartedSignal();
234 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal()
236 return GetImplementation(*this).PageLoadFinishedSignal();
239 Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal()
241 return GetImplementation(*this).PageLoadErrorSignal();
244 Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
246 return GetImplementation( *this ).ScrollEdgeReachedSignal();