2 * Copyright (c) 2022 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-policy-decision.h>
26 #include <dali/devel-api/adaptor-framework/web-engine-settings.h>
27 #include <dali/internal/web-engine/common/web-engine-impl.h>
30 #include <dali/public-api/images/pixel-data.h>
34 WebEngine::WebEngine()
38 WebEngine::WebEngine(Internal::Adaptor::WebEngine* internal)
39 : BaseHandle(internal)
43 WebEngine::~WebEngine()
47 WebEngine WebEngine::New()
49 Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New();
51 return WebEngine(engine.Get());
54 WebEngine::WebEngine(const WebEngine& webEngine)
55 : BaseHandle(webEngine)
59 WebEngine& WebEngine::operator=(const WebEngine& webEngine)
61 if(*this != webEngine)
63 BaseHandle::operator=(webEngine);
68 WebEngine WebEngine::DownCast(BaseHandle handle)
70 return WebEngine(dynamic_cast<Internal::Adaptor::WebEngine*>(handle.GetObjectPtr()));
73 void WebEngine::Create(int width, int height, const std::string& locale, const std::string& timezoneId)
75 GetImplementation(*this).Create(width, height, locale, timezoneId);
78 void WebEngine::Create(int width, int height, int argc, char** argv)
80 GetImplementation(*this).Create(width, height, argc, argv);
83 void WebEngine::Destroy()
85 GetImplementation(*this).Destroy();
88 NativeImageInterfacePtr WebEngine::GetNativeImageSource()
90 return GetImplementation(*this).GetNativeImageSource();
93 Dali::WebEngineSettings& WebEngine::GetSettings() const
95 return GetImplementation(*this).GetSettings();
98 Dali::WebEngineContext& WebEngine::GetContext() const
100 return GetImplementation(*this).GetContext();
103 Dali::WebEngineCookieManager& WebEngine::GetCookieManager() const
105 return GetImplementation(*this).GetCookieManager();
108 Dali::WebEngineBackForwardList& WebEngine::GetBackForwardList() const
110 return GetImplementation(*this).GetBackForwardList();
113 void WebEngine::LoadUrl(const std::string& url)
115 return GetImplementation(*this).LoadUrl(url);
118 std::string WebEngine::GetTitle() const
120 return GetImplementation(*this).GetTitle();
123 Dali::PixelData WebEngine::GetFavicon() const
125 return GetImplementation(*this).GetFavicon();
128 const std::string& WebEngine::GetUrl()
130 return GetImplementation(*this).GetUrl();
133 void WebEngine::LoadHtmlString(const std::string& htmlString)
135 GetImplementation(*this).LoadHtmlString(htmlString);
138 void WebEngine::Reload()
140 GetImplementation(*this).Reload();
143 void WebEngine::StopLoading()
145 GetImplementation(*this).StopLoading();
148 void WebEngine::Suspend()
150 GetImplementation(*this).Suspend();
153 void WebEngine::Resume()
155 GetImplementation(*this).Resume();
158 void WebEngine::ScrollBy(int deltaX, int deltaY)
160 GetImplementation(*this).ScrollBy(deltaX, deltaY);
163 void WebEngine::SetScrollPosition(int x, int y)
165 GetImplementation(*this).SetScrollPosition(x, y);
168 void WebEngine::GetScrollPosition(int& x, int& y) const
170 GetImplementation(*this).GetScrollPosition(x, y);
173 void WebEngine::GetScrollSize(int& width, int& height) const
175 GetImplementation(*this).GetScrollSize(width, height);
178 void WebEngine::GetContentSize(int& width, int& height) const
180 GetImplementation(*this).GetContentSize(width, height);
183 bool WebEngine::CanGoForward()
185 return GetImplementation(*this).CanGoForward();
188 void WebEngine::GoForward()
190 GetImplementation(*this).GoForward();
193 bool WebEngine::CanGoBack()
195 return GetImplementation(*this).CanGoBack();
198 void WebEngine::GoBack()
200 GetImplementation(*this).GoBack();
203 void WebEngine::EvaluateJavaScript(const std::string& script, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback resultHandler)
205 GetImplementation(*this).EvaluateJavaScript(script, resultHandler);
208 void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback handler)
210 GetImplementation(*this).AddJavaScriptMessageHandler(exposedObjectName, handler);
213 void WebEngine::ClearAllTilesResources()
215 GetImplementation(*this).ClearAllTilesResources();
218 void WebEngine::ClearHistory()
220 return GetImplementation(*this).ClearHistory();
223 const std::string& WebEngine::GetUserAgent() const
225 return GetImplementation(*this).GetUserAgent();
228 void WebEngine::SetUserAgent(const std::string& userAgent)
230 GetImplementation(*this).SetUserAgent(userAgent);
233 void WebEngine::SetSize(int width, int height)
235 return GetImplementation(*this).SetSize(width, height);
238 bool WebEngine::SendTouchEvent(const TouchEvent& touch)
240 return GetImplementation(*this).SendTouchEvent(touch);
243 bool WebEngine::SendKeyEvent(const KeyEvent& event)
245 return GetImplementation(*this).SendKeyEvent(event);
248 void WebEngine::SetFocus(bool focused)
250 GetImplementation(*this).SetFocus(focused);
253 void WebEngine::UpdateDisplayArea(Dali::Rect<int> displayArea)
255 GetImplementation(*this).UpdateDisplayArea(displayArea);
258 void WebEngine::EnableVideoHole(bool enabled)
260 GetImplementation(*this).EnableVideoHole(enabled);
263 void WebEngine::RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
265 GetImplementation(*this).RegisterPageLoadStartedCallback(callback);
268 void WebEngine::RegisterPageLoadFinishedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
270 GetImplementation(*this).RegisterPageLoadFinishedCallback(callback);
273 void WebEngine::RegisterPageLoadErrorCallback(Dali::WebEnginePlugin::WebEnginePageLoadErrorCallback callback)
275 GetImplementation(*this).RegisterPageLoadErrorCallback(callback);
278 void WebEngine::RegisterScrollEdgeReachedCallback(Dali::WebEnginePlugin::WebEngineScrollEdgeReachedCallback callback)
280 GetImplementation(*this).RegisterScrollEdgeReachedCallback(callback);
283 void WebEngine::RegisterUrlChangedCallback(Dali::WebEnginePlugin::WebEngineUrlChangedCallback callback)
285 GetImplementation(*this).RegisterUrlChangedCallback(callback);
288 void WebEngine::RegisterNavigationPolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineNavigationPolicyDecidedCallback callback)
290 GetImplementation(*this).RegisterNavigationPolicyDecidedCallback(callback);
293 void WebEngine::GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceivedCallback callback)
295 GetImplementation(*this).GetPlainTextAsynchronously(callback);