Change WebEngine API
[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 Add a message handler into JavaScript.
140    *
141    * @param[in] exposedObjectName The name of exposed object
142    * @param[in] handler The callback function
143    */
144   virtual void AddJavaScriptMessageHandler( const std::string& exposedObjectName, std::function< void( const std::string& ) > handler ) = 0;
145
146   /**
147    * @brief Clears the history of Web.
148    */
149   virtual void ClearHistory() = 0;
150
151   /**
152    * @brief Clears the cache of Web.
153    */
154   virtual void ClearCache() = 0;
155
156   /**
157    * @brief Sets size of Web Page.
158    */
159   virtual void SetSize( int width, int height ) = 0;
160
161   /**
162    * @brief Sends Touch Events.
163    */
164   virtual bool SendTouchEvent( const TouchData& touch ) = 0;
165
166   /**
167    * @brief Sends Key Events.
168    */
169   virtual bool SendKeyEvent( const KeyEvent& event ) = 0;
170
171   /**
172    * @brief Connects to this signal to be notified when page loading is started.
173    *
174    * @return A signal object to connect with.
175    */
176   virtual WebEngineSignalType& PageLoadStartedSignal() = 0;
177
178   /**
179    * @brief Connects to this signal to be notified when page loading is finished.
180    *
181    * @return A signal object to connect with.
182    */
183   virtual WebEngineSignalType& PageLoadFinishedSignal() = 0;
184
185 };
186
187 } // namespace Dali;
188
189 #endif