869046367d03ea95a3f520e2e6bd482514822441
[platform/framework/native/web.git] / inc / FWebCtrlILoadingListener.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FWebCtrlILoadingListener.h
20  * @brief               This is the header file for the %ILoadingListener interface.
21  *
22  * This header file contains the declarations of the %ILoadingListener interface.
23  */
24 #ifndef _FWEB_CTRL_ILOADING_LISTENER_H_
25 #define _FWEB_CTRL_ILOADING_LISTENER_H_
26
27 #include <FBaseRtIEventListener.h>
28 #include <FBaseString.h>
29
30 namespace Tizen { namespace Net { namespace Http
31 {
32 class HttpHeader;
33 }}} // Tizen::Neb::Http
34
35 namespace Tizen { namespace Web { namespace Controls
36 {
37 class AuthenticationChallenge;
38 }}} // Tizen::Web::Controls
39
40 namespace Tizen { namespace Web { namespace Controls
41 {
42
43 /**
44  * @enum WebNavigationType
45  *
46  * Defines the type of %Web navigation.
47  *
48  * @since               2.0
49  */
50 enum WebNavigationType
51 {
52         WEB_NAVIGATION_LINK_CLICKED,            /**< The clicking of a link on the page */
53         WEB_NAVIGATION_FORM_SUBMITTED,          /**< The submission of a form */
54         WEB_NAVIGATION_BACKFORWARD,             /**< The back and forward navigation*/
55         WEB_NAVIGATION_RELOAD,                  /**< The reloading of the page */
56         WEB_NAVIGATION_FORM_RESUBMITTED,        /**< The resubmission of the form  */
57         WEB_NAVIGATION_OTHER                    /**< A navigation other than any of the above */
58 };
59
60 /**
61  * @enum LoadingErrorType
62  *
63  * Defines the types of loading errors.
64  *
65  * @since               2.0
66  */
67 enum LoadingErrorType
68 {
69         WEB_ERROR_UNKNOWN,                          /**< An unknown error*/
70         WEB_REQUEST_TIMEOUT,                    /**< The request timeout */
71         WEB_NO_CONNECTION,                          /**< The network is not in service */
72         WEB_MIME_NOT_SUPPORTED,                     /**< The content type is not supported */
73         WEB_BAD_URL,                                /**< The URL is invalid */
74         WEB_HTTP_RESPONSE,                      /**< The hypertext transfer protocol (HTTP) response */
75         WEB_OUT_OF_MEMORY,                      /**< The memory is not enough to load the page */
76         WEB_FILE_ACCESS_FAILED,                 /**< The file access failed */
77         WEB_REQUEST_MAX_EXCEEDED,               /**< The request has failed because the total number of requests have exceeded the maximum limit */
78         WEB_INVALID_CERTIFICATE                 /**< The hypertext transfer protocol secure (HTTPS) request has failed due to an invalid certificate or CA */
79 };
80
81 /**
82  * @enum DecisionPolicy
83  *
84  * Defines the decision policy.
85  *
86  * @since               2.0
87  */
88 enum DecisionPolicy
89 {
90         WEB_DECISION_DOWNLOAD,                          /**< The download policy*/
91         WEB_DECISION_CONTINUE,                          /**< The usage policy*/
92         WEB_DECISION_IGNORE,                                /**< The ignore policy*/
93 };
94
95 /**
96  * @interface   ILoadingListener
97  * @brief               This interface is for receiving the events that occur during the loading of data.
98  *
99  * @since               2.0
100  *
101  * The %ILoadingListener interface receives the events that occur during the loading of data.
102  * To listen to the events occurred during a data loading operation, implement this listener. If there is no
103  * registered load event listener, the browser engine handles these events according to its own settings.
104  * @n
105  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/web/controls_namespace.htm">Web Controls Guide</a>.
106  */
107 class _OSP_EXPORT_ ILoadingListener
108         : public virtual Tizen::Base::Runtime::IEventListener
109 {
110 public:
111         /**
112          * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
113          *
114          * @since               2.0
115          */
116         virtual ~ILoadingListener(void) {}
117
118         /**
119          * Called when an authentication is requested.
120          *
121          * @since               2.0
122          *
123          * @return              @c true if the ownership is taken by the application, @n
124          *                                      else @c false, and a default dialog for the ID and password is displayed @n
125          *                              If this method returns @c true, the application must delete the AuthenticationChallenge instance.
126          * @param[in]   host                    The host requiring the authentication
127          * @param[in]   realm                   The description to help save the user credentials for future visits
128          * @param[in]   authentication  The handler to send a user response to the server that requested the authentication
129          */
130         virtual bool OnHttpAuthenticationRequestedN(const Tizen::Base::String& host, const Tizen::Base::String& realm, const Tizen::Web::Controls::AuthenticationChallenge& authentication) = 0;
131
132         /**
133          * Called when the authentication request is cancelled.
134          *
135          * @since               2.0
136          */
137         virtual void OnHttpAuthenticationCanceled(void) = 0;
138
139         /**
140          * Called when the loading operation starts.
141          *
142          * @since               2.0
143          */
144         virtual void OnLoadingStarted(void) = 0;
145
146         /**
147          * Called when the loading operation is cancelled.
148          *
149          * @since               2.0
150          */
151         virtual void OnLoadingCanceled(void) = 0;
152
153         /**
154         * Called when the loading operation fails.
155         *
156         * @since                2.0
157         *
158         * @param[in]    error                   The error that occurred during loading
159         * @param[in]    reason                  The reason for the loading failure, @n
160         *                                                                       - @c WEB_HTTP_RESPONSE: The HTTP state code such as "404" @n
161         *                                                                       - @c WEB_MIME_NOT_SUPPORTED: The Multipurpose Internet Mail Extensions (MIME) type such as "application/rdf+xml" is not supported @n
162         *                                                                       - @c WEB_BAD_URL: The URL is incorrect
163         */
164         virtual void OnLoadingErrorOccurred(LoadingErrorType error, const Tizen::Base::String& reason) = 0;
165
166         /**
167          * Called when the loading operation is completed.
168          *
169          * @since               2.0
170          */
171         virtual void OnLoadingCompleted(void) = 0;
172
173         /**
174          * Called when the loading progress for the current page is requested. @n
175          * The progress rate is displayed as a percentage.
176          *
177          * @since               2.0
178          *
179          * @param[in]   progress                The progress rate ranging from [@c 0 ~ @c 100]
180          */
181         virtual void OnEstimatedProgress(int progress) = 0;
182
183         /**
184          * Called when the title of the new page has been received.
185          *
186          * @since               2.0
187          */
188         virtual void OnPageTitleReceived(const Tizen::Base::String& title) = 0;
189
190         /**
191          * Called to notify an application of the URL to be requested. @n
192          * If an application wants to handle the URL, it must return @c true. If an application returns @c false, the request of the URL continues with the
193          * browser engine.
194          *
195          * @since               2.0
196          *
197          * @return              @c true if the application handles the URL after the request is canceled in the browser engine, @n
198          *                  else @c false if the browser engine proceeds with the requested URL
199          * @param[in]   url                             The URL that is requested
200          * @param[in]   type                    The type indicating how the URL is triggered
201          */
202         virtual bool OnLoadingRequested(const Tizen::Base::String& url, WebNavigationType type) = 0;
203
204         /**
205          * Called to notify an application of the content type of the data to be downloaded. @n
206          * - To handle data by itself, the application must return @c WEB_DECISION_DOWNLOAD. The data is routed to IWebDownloadListener to be downloaded incrementally. @n
207          * - If an application returns @c WEB_DECISION_CONTINUE, the browser engine continues the downloading and tries to parse the data. @n
208          * - If an application returns @c WEB_DECISION_IGNORE, the browser engine cancels the downloading of the data.
209          *
210          * @since               2.0
211          *
212          * @return              DecisionPolicy  A value of the enumerator DecisionPolicy
213          * @param[in]   mime                    The content type of the data that is downloaded
214          * @param[in]   httpHeader              The HTTP header string
215          */
216         virtual DecisionPolicy OnWebDataReceived(const Tizen::Base::String& mime, const Tizen::Net::Http::HttpHeader& httpHeader) = 0;
217
218 protected:
219         //
220         // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
221         //
222         // Gets the Impl instance.
223         //
224         // @since               2.0
225         //
226         virtual void ILoadingListener_Reserved1(void) {}
227
228         //
229         // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
230         //
231         // Gets the Impl instance.
232         //
233         // @since               2.0
234         //
235         virtual void ILoadingListener_Reserved2(void) {}
236
237         //
238         // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
239         //
240         // Gets the Impl instance.
241         //
242         // @since               2.0
243         //
244         virtual void ILoadingListener_Reserved3(void) {}
245
246         //
247         // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
248         //
249         // Gets the Impl instance.
250         //
251         // @since               2.0
252         //
253         virtual void ILoadingListener_Reserved4(void) {}
254
255         //
256         // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
257         //
258         // Gets the Impl instance.
259         //
260         // @since               2.0
261         //
262         virtual void ILoadingListener_Reserved5(void) {}
263
264 }; // ILoadingListener
265
266 }}} // Tizen::Web::Controls
267 #endif // _FWEB_CTRL_ILOADING_LISTENER_H_