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