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