Implement some new ewk apis in web engine.
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / web-engine.cpp
1 /*
2  * Copyright (c) 2020 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 namespace Dali
29 {
30 WebEngine::WebEngine()
31 {
32 }
33
34 WebEngine::WebEngine(Internal::Adaptor::WebEngine* internal)
35 : BaseHandle(internal)
36 {
37 }
38
39 WebEngine::~WebEngine()
40 {
41 }
42
43 WebEngine WebEngine::New()
44 {
45   Internal::Adaptor::WebEnginePtr engine = Internal::Adaptor::WebEngine::New();
46
47   return WebEngine(engine.Get());
48 }
49
50 WebEngine::WebEngine(const WebEngine& webEngine)
51 : BaseHandle(webEngine)
52 {
53 }
54
55 WebEngine& WebEngine::operator=(const WebEngine& webEngine)
56 {
57   if(*this != webEngine)
58   {
59     BaseHandle::operator=(webEngine);
60   }
61   return *this;
62 }
63
64 WebEngine WebEngine::DownCast(BaseHandle handle)
65 {
66   return WebEngine(dynamic_cast<Internal::Adaptor::WebEngine*>(handle.GetObjectPtr()));
67 }
68
69 void WebEngine::Create(int width, int height, const std::string& locale, const std::string& timezoneId)
70 {
71   GetImplementation(*this).Create(width, height, locale, timezoneId);
72 }
73
74 void WebEngine::Destroy()
75 {
76   GetImplementation(*this).Destroy();
77 }
78
79 NativeImageInterfacePtr WebEngine::GetNativeImageSource()
80 {
81   return GetImplementation(*this).GetNativeImageSource();
82 }
83
84 Dali::WebEngineSettings& WebEngine::GetSettings() const
85 {
86   return GetImplementation( *this ).GetSettings();
87 }
88
89 Dali::WebEngineContext& WebEngine::GetContext() const
90 {
91   return GetImplementation( *this ).GetContext();
92 }
93
94 Dali::WebEngineCookieManager& WebEngine::GetCookieManager() const
95 {
96   return GetImplementation( *this ).GetCookieManager();
97 }
98
99 Dali::WebEngineBackForwardList& WebEngine::GetBackForwardList() const
100 {
101   return GetImplementation( *this ).GetBackForwardList();
102 }
103
104 void WebEngine::LoadUrl(const std::string& url)
105 {
106   return GetImplementation(*this).LoadUrl(url);
107 }
108
109 const std::string& WebEngine::GetUrl()
110 {
111   return GetImplementation(*this).GetUrl();
112 }
113
114 void WebEngine::LoadHtmlString(const std::string& htmlString)
115 {
116   GetImplementation(*this).LoadHtmlString(htmlString);
117 }
118
119 void WebEngine::Reload()
120 {
121   GetImplementation(*this).Reload();
122 }
123
124 void WebEngine::StopLoading()
125 {
126   GetImplementation(*this).StopLoading();
127 }
128
129 void WebEngine::Suspend()
130 {
131   GetImplementation(*this).Suspend();
132 }
133
134 void WebEngine::Resume()
135 {
136   GetImplementation(*this).Resume();
137 }
138
139 void WebEngine::ScrollBy( int deltaX, int deltaY )
140 {
141   GetImplementation( *this ).ScrollBy( deltaX, deltaY );
142 }
143
144 void WebEngine::SetScrollPosition( int x, int y )
145 {
146   GetImplementation( *this ).SetScrollPosition( x, y );
147 }
148
149 void WebEngine::GetScrollPosition( int& x, int& y ) const
150 {
151   GetImplementation( *this ).GetScrollPosition( x, y );
152 }
153
154 void WebEngine::GetScrollSize( int& width, int& height ) const
155 {
156   GetImplementation( *this ).GetScrollSize( width, height );
157 }
158
159 void WebEngine::GetContentSize( int& width, int& height ) const
160 {
161   GetImplementation( *this ).GetContentSize( width, height );
162 }
163
164 bool WebEngine::CanGoForward()
165 {
166   return GetImplementation(*this).CanGoForward();
167 }
168
169 void WebEngine::GoForward()
170 {
171   GetImplementation(*this).GoForward();
172 }
173
174 bool WebEngine::CanGoBack()
175 {
176   return GetImplementation(*this).CanGoBack();
177 }
178
179 void WebEngine::GoBack()
180 {
181   GetImplementation(*this).GoBack();
182 }
183
184 void WebEngine::EvaluateJavaScript(const std::string& script, std::function<void(const std::string&)> resultHandler)
185 {
186   GetImplementation(*this).EvaluateJavaScript(script, resultHandler);
187 }
188
189 void WebEngine::AddJavaScriptMessageHandler(const std::string& exposedObjectName, std::function<void(const std::string&)> handler)
190 {
191   GetImplementation(*this).AddJavaScriptMessageHandler(exposedObjectName, handler);
192 }
193
194 void WebEngine::ClearHistory()
195 {
196   return GetImplementation(*this).ClearHistory();
197 }
198
199 const std::string& WebEngine::GetUserAgent() const
200 {
201   return GetImplementation(*this).GetUserAgent();
202 }
203
204 void WebEngine::SetUserAgent(const std::string& userAgent)
205 {
206   GetImplementation(*this).SetUserAgent(userAgent);
207 }
208
209 void WebEngine::SetSize(int width, int height)
210 {
211   return GetImplementation(*this).SetSize(width, height);
212 }
213
214 bool WebEngine::SendTouchEvent(const TouchEvent& touch)
215 {
216   return GetImplementation(*this).SendTouchEvent(touch);
217 }
218
219 bool WebEngine::SendKeyEvent(const KeyEvent& event)
220 {
221   return GetImplementation(*this).SendKeyEvent(event);
222 }
223
224 void WebEngine::SetFocus( bool focused )
225 {
226   GetImplementation( *this ).SetFocus( focused );
227 }
228
229 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadStartedSignal()
230 {
231   return GetImplementation(*this).PageLoadStartedSignal();
232 }
233
234 Dali::WebEnginePlugin::WebEnginePageLoadSignalType& WebEngine::PageLoadFinishedSignal()
235 {
236   return GetImplementation(*this).PageLoadFinishedSignal();
237 }
238
239 Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErrorSignal()
240 {
241   return GetImplementation(*this).PageLoadErrorSignal();
242 }
243
244 Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
245 {
246   return GetImplementation( *this ).ScrollEdgeReachedSignal();
247 }
248
249 } // namespace Dali