c00723e4f4e5e4388fe93a7f500d1f8e4178b4bf
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / web-engine.cpp
1 /*
2  * Copyright (c) 2022 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 <dali/devel-api/adaptor-framework/web-engine.h>
20
21 // INTERNAL INCLUDES
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>
28
29 // EXTERNAL INCLUDES
30 #include <dali/public-api/images/pixel-data.h>
31
32 namespace Dali
33 {
34 WebEngine::WebEngine()
35 {
36 }
37
38 WebEngine::WebEngine(Internal::Adaptor::WebEngine* internal)
39 : BaseHandle(internal)
40 {
41 }
42
43 WebEngine::~WebEngine()
44 {
45 }
46
47 WebEngine WebEngine::New()
48 {
49   Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New();
50
51   return WebEngine(engine.Get());
52 }
53
54 WebEngine::WebEngine(const WebEngine& webEngine)
55 : BaseHandle(webEngine)
56 {
57 }
58
59 WebEngine& WebEngine::operator=(const WebEngine& webEngine)
60 {
61   if(*this != webEngine)
62   {
63     BaseHandle::operator=(webEngine);
64   }
65   return *this;
66 }
67
68 WebEngine WebEngine::DownCast(BaseHandle handle)
69 {
70   return WebEngine(dynamic_cast<Internal::Adaptor::WebEngine*>(handle.GetObjectPtr()));
71 }
72
73 void WebEngine::Create(int width, int height, const std::string& locale, const std::string& timezoneId)
74 {
75   GetImplementation(*this).Create(width, height, locale, timezoneId);
76 }
77
78 void WebEngine::Create(int width, int height, int argc, char** argv)
79 {
80   GetImplementation(*this).Create(width, height, argc, argv);
81 }
82
83 void WebEngine::Destroy()
84 {
85   GetImplementation(*this).Destroy();
86 }
87
88 NativeImageInterfacePtr WebEngine::GetNativeImageSource()
89 {
90   return GetImplementation(*this).GetNativeImageSource();
91 }
92
93 Dali::WebEngineSettings& WebEngine::GetSettings() const
94 {
95   return GetImplementation(*this).GetSettings();
96 }
97
98 Dali::WebEngineContext& WebEngine::GetContext() const
99 {
100   return GetImplementation(*this).GetContext();
101 }
102
103 Dali::WebEngineCookieManager& WebEngine::GetCookieManager() const
104 {
105   return GetImplementation(*this).GetCookieManager();
106 }
107
108 Dali::WebEngineBackForwardList& WebEngine::GetBackForwardList() const
109 {
110   return GetImplementation(*this).GetBackForwardList();
111 }
112
113 void WebEngine::LoadUrl(const std::string& url)
114 {
115   return GetImplementation(*this).LoadUrl(url);
116 }
117
118 std::string WebEngine::GetTitle() const
119 {
120   return GetImplementation(*this).GetTitle();
121 }
122
123 Dali::PixelData WebEngine::GetFavicon() const
124 {
125   return GetImplementation(*this).GetFavicon();
126 }
127
128 const std::string& WebEngine::GetUrl()
129 {
130   return GetImplementation(*this).GetUrl();
131 }
132
133 void WebEngine::LoadHtmlString(const std::string& htmlString)
134 {
135   GetImplementation(*this).LoadHtmlString(htmlString);
136 }
137
138 void WebEngine::Reload()
139 {
140   GetImplementation(*this).Reload();
141 }
142
143 void WebEngine::StopLoading()
144 {
145   GetImplementation(*this).StopLoading();
146 }
147
148 void WebEngine::Suspend()
149 {
150   GetImplementation(*this).Suspend();
151 }
152
153 void WebEngine::Resume()
154 {
155   GetImplementation(*this).Resume();
156 }
157
158 void WebEngine::ScrollBy(int deltaX, int deltaY)
159 {
160   GetImplementation(*this).ScrollBy(deltaX, deltaY);
161 }
162
163 void WebEngine::SetScrollPosition(int x, int y)
164 {
165   GetImplementation(*this).SetScrollPosition(x, y);
166 }
167
168 void WebEngine::GetScrollPosition(int& x, int& y) const
169 {
170   GetImplementation(*this).GetScrollPosition(x, y);
171 }
172
173 void WebEngine::GetScrollSize(int& width, int& height) const
174 {
175   GetImplementation(*this).GetScrollSize(width, height);
176 }
177
178 void WebEngine::GetContentSize(int& width, int& height) const
179 {
180   GetImplementation(*this).GetContentSize(width, height);
181 }
182
183 bool WebEngine::CanGoForward()
184 {
185   return GetImplementation(*this).CanGoForward();
186 }
187
188 void WebEngine::GoForward()
189 {
190   GetImplementation(*this).GoForward();
191 }
192
193 bool WebEngine::CanGoBack()
194 {
195   return GetImplementation(*this).CanGoBack();
196 }
197
198 void WebEngine::GoBack()
199 {
200   GetImplementation(*this).GoBack();
201 }
202
203 void WebEngine::EvaluateJavaScript(const std::string& script, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback resultHandler)
204 {
205   GetImplementation(*this).EvaluateJavaScript(script, resultHandler);
206 }
207
208 void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, Dali::WebEnginePlugin::JavaScriptMessageHandlerCallback handler)
209 {
210   GetImplementation(*this).AddJavaScriptMessageHandler(exposedObjectName, handler);
211 }
212
213 void WebEngine::ClearAllTilesResources()
214 {
215   GetImplementation(*this).ClearAllTilesResources();
216 }
217
218 void WebEngine::ClearHistory()
219 {
220   return GetImplementation(*this).ClearHistory();
221 }
222
223 const std::string& WebEngine::GetUserAgent() const
224 {
225   return GetImplementation(*this).GetUserAgent();
226 }
227
228 void WebEngine::SetUserAgent(const std::string& userAgent)
229 {
230   GetImplementation(*this).SetUserAgent(userAgent);
231 }
232
233 void WebEngine::SetSize(int width, int height)
234 {
235   return GetImplementation(*this).SetSize(width, height);
236 }
237
238 bool WebEngine::SendTouchEvent(const TouchEvent& touch)
239 {
240   return GetImplementation(*this).SendTouchEvent(touch);
241 }
242
243 bool WebEngine::SendKeyEvent(const KeyEvent& event)
244 {
245   return GetImplementation(*this).SendKeyEvent(event);
246 }
247
248 void WebEngine::SetFocus(bool focused)
249 {
250   GetImplementation(*this).SetFocus(focused);
251 }
252
253 void WebEngine::UpdateDisplayArea(Dali::Rect<int> displayArea)
254 {
255   GetImplementation(*this).UpdateDisplayArea(displayArea);
256 }
257
258 void WebEngine::EnableVideoHole(bool enabled)
259 {
260   GetImplementation(*this).EnableVideoHole(enabled);
261 }
262
263 void WebEngine::RegisterPageLoadStartedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
264 {
265   GetImplementation(*this).RegisterPageLoadStartedCallback(callback);
266 }
267
268 void WebEngine::RegisterPageLoadFinishedCallback(Dali::WebEnginePlugin::WebEnginePageLoadCallback callback)
269 {
270   GetImplementation(*this).RegisterPageLoadFinishedCallback(callback);
271 }
272
273 void WebEngine::RegisterPageLoadErrorCallback(Dali::WebEnginePlugin::WebEnginePageLoadErrorCallback callback)
274 {
275   GetImplementation(*this).RegisterPageLoadErrorCallback(callback);
276 }
277
278 void WebEngine::RegisterScrollEdgeReachedCallback(Dali::WebEnginePlugin::WebEngineScrollEdgeReachedCallback callback)
279 {
280   GetImplementation(*this).RegisterScrollEdgeReachedCallback(callback);
281 }
282
283 void WebEngine::RegisterUrlChangedCallback(Dali::WebEnginePlugin::WebEngineUrlChangedCallback callback)
284 {
285   GetImplementation(*this).RegisterUrlChangedCallback(callback);
286 }
287
288 void WebEngine::RegisterNavigationPolicyDecidedCallback(Dali::WebEnginePlugin::WebEngineNavigationPolicyDecidedCallback callback)
289 {
290   GetImplementation(*this).RegisterNavigationPolicyDecidedCallback(callback);
291 }
292
293 void WebEngine::GetPlainTextAsynchronously(Dali::WebEnginePlugin::PlainTextReceivedCallback callback)
294 {
295   GetImplementation(*this).GetPlainTextAsynchronously(callback);
296 }
297
298 } // namespace Dali