Changes after TouchData renamed to TouchEvent
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / web-engine-plugin.h
1 #ifndef DALI_WEB_ENGINE_PLUGIN_H
2 #define DALI_WEB_ENGINE_PLUGIN_H
3
4 /*
5  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/images/native-image-interface.h>
23 #include <dali/public-api/signals/dali-signal.h>
24 #include <functional>
25
26 namespace Dali
27 {
28
29 class KeyEvent;
30 class TouchEvent;
31
32 /**
33  * @brief WebEnginePlugin is an abstract interface, used by dali-adaptor to access WebEngine plugin.
34  * A concrete implementation must be created for each platform and provided as dynamic library.
35  */
36 class WebEnginePlugin
37 {
38 public:
39
40   /**
41    * @brief WebEngine signal type related with page loading.
42    */
43   typedef Signal< void( const std::string& ) > WebEnginePageLoadSignalType;
44
45   /**
46    * @brief WebView signal type related with page loading error.
47    */
48   typedef Signal< void( const std::string&, int ) > WebEnginePageLoadErrorSignalType;
49
50   /**
51    * @brief Enumeration for cache model options.
52    */
53   enum class CacheModel
54   {
55     /**
56      * @brief Use the smallest cache capacity.
57      */
58     DOCUMENT_VIEWER,
59
60     /**
61      * @brief Use the bigger cache capacity than DocumentBrowser.
62      */
63     DOCUMENT_BROWSER,
64
65     /**
66      * @brief Use the biggest cache capacity.
67      */
68     PRIMARY_WEB_BROWSER
69   };
70
71   /**
72    * @brief Enumeration for the cookies accept policies.
73    */
74   enum class CookieAcceptPolicy
75   {
76     /**
77      * @brief Accepts every cookie sent from any page.
78      */
79     ALWAYS,
80
81     /**
82      * @brief Rejects all the cookies.
83      */
84     NEVER,
85
86     /**
87      * @brief Accepts only cookies set by the main document that is loaded.
88      */
89     NO_THIRD_PARTY
90   };
91
92   /**
93    * @brief Constructor.
94    */
95   WebEnginePlugin()
96   {
97   }
98
99   /**
100    * @brief Destructor.
101    */
102   virtual ~WebEnginePlugin()
103   {
104   }
105
106   /**
107    * @brief Creates WebEngine instance.
108    *
109    * @param [in] width The width of Web
110    * @param [in] height The height of Web
111    * @param [in] locale The locale of Web
112    * @param [in] timezoneId The timezoneID of Web
113    */
114   virtual void Create( int width, int height, const std::string& locale, const std::string& timezoneId ) = 0;
115
116   /**
117    * @brief Destroys WebEngine instance.
118    */
119   virtual void Destroy() = 0;
120
121   /**
122    * @brief Loads a web page based on a given URL.
123    *
124    * @param [in] url The URL of the resource to load
125    */
126   virtual void LoadUrl( const std::string& url ) = 0;
127
128   /**
129    * @brief Gets image to render.
130    */
131   virtual NativeImageInterfacePtr GetNativeImageSource() = 0;
132
133   /**
134    * @brief Returns the URL of the Web.
135    *
136    * @return Url of string type
137    */
138   virtual const std::string& GetUrl() = 0;
139
140   /**
141    * @brief Loads a given string as web contents.
142    *
143    * @param [in] htmlString The string to use as the contents of the web page
144    */
145   virtual void LoadHTMLString( const std::string& htmlString ) = 0;
146
147   /**
148    * @brief Reloads the Web.
149    */
150   virtual void Reload() = 0;
151
152   /**
153    * @brief Stops loading web contents on the current page.
154    */
155   virtual void StopLoading() = 0;
156
157   /**
158    * @brief Suspends the operation associated with the view.
159    */
160   virtual void Suspend() = 0;
161
162   /**
163    * @brief Resumes the operation associated with the view object after calling Suspend().
164    */
165   virtual void Resume() = 0;
166
167   /**
168    * @brief Returns whether forward is possible.
169    *
170    * @return True if forward is possible, false otherwise
171    */
172   virtual bool CanGoForward() = 0;
173
174   /**
175    * @brief Goes to forward.
176    */
177   virtual void GoForward() = 0;
178
179   /**
180    * @brief Returns whether backward is possible.
181    *
182    * @return True if backward is possible, false otherwise
183    */
184   virtual bool CanGoBack() = 0;
185
186   /**
187    * @brief Goes to back.
188    */
189   virtual void GoBack() = 0;
190
191   /**
192    * @brief Evaluates JavaScript code represented as a string.
193    *
194    * @param[in] script The JavaScript code
195    * @param[in] resultHandler The callback function to be called by the JavaScript runtime. This carries evaluation result.
196    */
197   virtual void EvaluateJavaScript( const std::string& script, std::function< void( const std::string& ) > resultHandler ) = 0;
198
199   /**
200    * @brief Add a message handler into JavaScript.
201    *
202    * @param[in] exposedObjectName The name of exposed object
203    * @param[in] handler The callback function
204    */
205   virtual void AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void( const std::string& ) > handler ) = 0;
206
207   /**
208    * @brief Clears the history of Web.
209    */
210   virtual void ClearHistory() = 0;
211
212   /**
213    * @brief Clears the cache of Web.
214    */
215   virtual void ClearCache() = 0;
216
217   /**
218    * @brief Clears all the cookies of Web.
219    */
220   virtual void ClearCookies() = 0;
221
222   /**
223    * @brief Get cache model option. The default is DOCUMENT_VIEWER.
224    *
225    * @return The cache model option
226    */
227   virtual CacheModel GetCacheModel() const = 0;
228
229   /**
230    * @brief Set cache model option. The default is DOCUMENT_VIEWER.
231    *
232    * @param[in] cacheModel The cache model option
233    */
234   virtual void SetCacheModel( CacheModel cacheModel ) = 0;
235
236   /**
237    * @brief Gets the cookie acceptance policy. The default is NO_THIRD_PARTY.
238    *
239    * @return The cookie acceptance policy
240    */
241   virtual CookieAcceptPolicy GetCookieAcceptPolicy() const = 0;
242
243   /**
244    * @brief Sets the cookie acceptance policy. The default is NO_THIRD_PARTY.
245    *
246    * @param[in] policy The cookie acceptance policy
247    */
248   virtual void SetCookieAcceptPolicy( CookieAcceptPolicy policy ) = 0;
249
250   /**
251    * @brief Get user agent string.
252    *
253    * @return The string value of user agent
254    */
255   virtual const std::string& GetUserAgent() const = 0;
256
257   /**
258    * @brief Set user agent string.
259    *
260    * @param[in] userAgent The string value of user agent
261    */
262   virtual void SetUserAgent( const std::string& userAgent ) = 0;
263
264   /**
265    * @brief Returns whether JavaScript can be executable. The default is true.
266    *
267    * @return true if JavaScript executing is enabled, false otherwise
268    */
269   virtual bool IsJavaScriptEnabled() const = 0;
270
271   /**
272    * @brief Enables/disables JavaScript executing. The default is enabled.
273    *
274    * @param[in] enabled True if JavaScript executing is enabled, false otherwise
275    */
276   virtual void EnableJavaScript( bool enabled ) = 0;
277
278   /**
279    * @brief Returns whether images can be loaded automatically. The default is true.
280    *
281    * @return true if images are loaded automatically, false otherwise
282    */
283   virtual bool AreImagesAutomaticallyLoaded() const = 0;
284
285   /**
286    * @brief Enables/disables auto loading of images. The default is enabled.
287    *
288    * @param[in] automatic True if images are loaded automatically, false otherwise
289    */
290   virtual void LoadImagesAutomatically( bool automatic ) = 0;
291
292   /**
293    * @brief Gets the default text encoding name (e.g. UTF-8).
294    *
295    * @return The default text encoding name
296    */
297   virtual const std::string& GetDefaultTextEncodingName() const = 0;
298
299   /**
300    * @brief Sets the default text encoding name (e.g. UTF-8).
301    *
302    * @param[in] defaultTextEncodingName The default text encoding name
303    */
304   virtual void SetDefaultTextEncodingName( const std::string& defaultTextEncodingName ) = 0;
305
306   /**
307    * @brief Returns the default font size in pixel. The default value is 16.
308    *
309    * @return The default font size
310    */
311   virtual int GetDefaultFontSize() const = 0;
312
313   /**
314    * @brief Sets the default font size in pixel. The default value is 16.
315    *
316    * @param[in] defaultFontSize A new default font size to set
317    */
318   virtual void SetDefaultFontSize( int defaultFontSize ) = 0;
319
320   /**
321    * @brief Sets size of Web Page.
322    */
323   virtual void SetSize( int width, int height ) = 0;
324
325   /**
326    * @brief Sends Touch Events.
327    */
328   virtual bool SendTouchEvent( const TouchEvent& touch ) = 0;
329
330   /**
331    * @brief Sends Key Events.
332    */
333   virtual bool SendKeyEvent( const KeyEvent& event ) = 0;
334
335   /**
336    * @brief Connects to this signal to be notified when page loading is started.
337    *
338    * @return A signal object to connect with.
339    */
340   virtual WebEnginePageLoadSignalType& PageLoadStartedSignal() = 0;
341
342   /**
343    * @brief Connects to this signal to be notified when page loading is finished.
344    *
345    * @return A signal object to connect with.
346    */
347   virtual WebEnginePageLoadSignalType& PageLoadFinishedSignal() = 0;
348
349   /**
350    * @brief Connects to this signal to be notified when an error occurs in page loading.
351    *
352    * @return A signal object to connect with.
353    */
354   virtual WebEnginePageLoadErrorSignalType& PageLoadErrorSignal() = 0;
355
356 };
357
358 } // namespace Dali;
359
360 #endif