215ea0d17c0c4d6a92c916f936102c80b23165d6
[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) 2018 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 TouchData;
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   typedef Signal< void( const std::string& ) > WebEngineSignalType;
41
42   /**
43    * @brief Constructor.
44    */
45   WebEnginePlugin()
46   {
47   }
48
49   /**
50    * @brief Destructor.
51    */
52   virtual ~WebEnginePlugin()
53   {
54   }
55
56   /**
57    * @brief Creates WebEngine instance.
58    *
59    * @param [in] width The width of Web
60    * @param [in] height The height of Web
61    * @param [in] locale The locale of Web
62    * @param [in] timezoneId The timezoneID of Web
63    */
64   virtual void Create( int width, int height, const std::string& locale, const std::string& timezoneId ) = 0;
65
66   /**
67    * @brief Destroys WebEngine instance.
68    */
69   virtual void Destroy() = 0;
70
71   /**
72    * @brief Loads a web page based on a given URL.
73    *
74    * @param [in] url The URL of the resource to load
75    */
76   virtual void LoadUrl( const std::string& url ) = 0;
77
78   /**
79    * @brief Gets image to render.
80    */
81   virtual NativeImageInterfacePtr GetNativeImageSource() = 0;
82
83   /**
84    * @brief Returns the URL of the Web.
85    *
86    * @return Url of string type
87    */
88   virtual const std::string& GetUrl() = 0;
89
90   /**
91    * @brief Loads a given string as web contents.
92    *
93    * @param [in] htmlString The string to use as the contents of the web page
94    */
95   virtual void LoadHTMLString( const std::string& htmlString ) = 0;
96
97   /**
98    * @brief Reloads the Web.
99    */
100   virtual void Reload() = 0;
101
102   /**
103    * @brief Stops loading web contents on the current page.
104    */
105   virtual void StopLoading() = 0;
106
107   /**
108    * @brief Returns whether forward is possible.
109    *
110    * @return True if forward is possible, false otherwise
111    */
112   virtual bool CanGoForward() = 0;
113
114   /**
115    * @brief Goes to forward.
116    */
117   virtual void GoForward() = 0;
118
119   /**
120    * @brief Returns whether backward is possible.
121    *
122    * @return True if backward is possible, false otherwise
123    */
124   virtual bool CanGoBack() = 0;
125
126   /**
127    * @brief Goes to back.
128    */
129   virtual void GoBack() = 0;
130
131   /**
132     * @brief Evaluates JavaScript code represented as a string.
133     *
134     * @param[in] script The JavaScript code
135     */
136   virtual void EvaluateJavaScript( const std::string& script ) = 0;
137
138   /**
139     * @brief Adds a JavaScript interface.
140     *
141     * @param[in] exposedObjectName The name of exposed object
142     * @param[in] jsFunctionName The name of JavaScript function
143     * @param[in] cb The callback function
144     */
145   virtual void AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > cb ) = 0;
146
147   /**
148     * @brief Removes a JavaScript interface.
149     *
150     * @param[in] exposedObjectName The name of exposed object
151     * @param[in] jsFunctionName The name of JavaScript function
152     */
153   virtual void RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName ) = 0;
154
155   /**
156    * @brief Clears the history of Web.
157    */
158   virtual void ClearHistory() = 0;
159
160   /**
161    * @brief Clears the cache of Web.
162    */
163   virtual void ClearCache() = 0;
164
165   /**
166    * @brief Sets size of Web Page.
167    */
168   virtual void SetSize( int width, int height ) = 0;
169
170   /**
171    * @brief Sends Touch Events.
172    */
173   virtual bool SendTouchEvent( const TouchData& touch ) = 0;
174
175   /**
176    * @brief Sends Key Events.
177    */
178   virtual bool SendKeyEvent( const KeyEvent& event ) = 0;
179
180   /**
181    * @brief Connects to this signal to be notified when page loading is started.
182    *
183    * @return A signal object to connect with.
184    */
185   virtual WebEngineSignalType& PageLoadStartedSignal() = 0;
186
187   /**
188    * @brief Connects to this signal to be notified when page loading is finished.
189    *
190    * @return A signal object to connect with.
191    */
192   virtual WebEngineSignalType& PageLoadFinishedSignal() = 0;
193
194 };
195
196 } // namespace Dali;
197
198 #endif