Init Tizen 2.2.1
[framework/osp/web.git] / inc / FWebCtrlWebStorageManager.h
1 //\r
2 // Open Service Platform\r
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
4 //\r
5 // Licensed under the Apache License, Version 2.0 (the License);\r
6 // you may not use this file except in compliance with the License.\r
7 // You may obtain a copy of the License at\r
8 //\r
9 //     http://www.apache.org/licenses/LICENSE-2.0\r
10 //\r
11 // Unless required by applicable law or agreed to in writing, software\r
12 // distributed under the License is distributed on an "AS IS" BASIS,\r
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14 // See the License for the specific language governing permissions and\r
15 // limitations under the License.\r
16 //\r
17 \r
18 /**\r
19 * @file            FWebCtrlWebStorageManager.h\r
20 * @brief           This is the header file for the %WebStorageManager class.\r
21 *\r
22 * This header file contains the declarations of the %WebStorageManager class for a %Web control.\r
23 */\r
24 #ifndef _FWEB_CTRL_WEB_STORAGE_MANAGER_H_\r
25 #define _FWEB_CTRL_WEB_STORAGE_MANAGER_H_\r
26 \r
27 #include <unique_ptr.h>\r
28 #include <FBaseString.h>\r
29 \r
30 namespace Tizen { namespace Base { namespace Collection\r
31 {\r
32 class IList;\r
33 }}} // Tizen::Base::Collection\r
34 \r
35 namespace Tizen { namespace Web { namespace Controls\r
36 {\r
37 class _WebStorageManagerImpl;\r
38 }}} // Tizen::Web::Control\r
39 \r
40 namespace Tizen { namespace Web { namespace Controls\r
41 {\r
42 \r
43 /**\r
44 * @enum WebStorageType\r
45 *\r
46 * Defines the web storage type.\r
47 *\r
48 * @since                2.1\r
49 */\r
50 enum WebStorageType\r
51 {\r
52         WEB_STORAGE_TYPE_APPLICATION_CACHE,     /**< The web storage type: application cache */\r
53         WEB_STORAGE_TYPE_INDEXED_DATABASE,      /**< The web storage type: indexed database */\r
54         WEB_STORAGE_TYPE_WEB_SQL_DATABASE,      /**< The web storage type: web database */\r
55         WEB_STORAGE_TYPE_WEB_STORAGE,           /**< The web storage type: web storage */\r
56         WEB_STORAGE_TYPE_FILE_SYSTEM            /**< The web storage type: file system */\r
57 };\r
58 \r
59 /**\r
60 * @class                WebStorageManager\r
61 * @brief                This class holds the setting values for a %Web control.\r
62 *\r
63 * @since                2.1\r
64 *\r
65 * @final                This class is not intended for extension.\r
66 *\r
67 * The %WebStorageManager class holds the setting values for a %Web control.\r
68 */\r
69 class _OSP_EXPORT_ WebStorageManager\r
70         : public Tizen::Base::Object\r
71 {\r
72 public:\r
73 \r
74         /**\r
75          * Gets the list of origins for a given storage type. @n\r
76          * The @c WEB_STORAGE_TYPE_INDEXED_DATABASE is not supported.\r
77          *\r
78          * @since               2.1\r
79          * @privlevel   public\r
80          * @privilege   %http://tizen.org/privilege/web.privacy\r
81          *\r
82          * @return              A pointer to Tizen::Base::Collection::IList that contains the origin(Tizen::Base::String) list, @n\r
83          *                              else @c null if no web storage data exists\r
84          * @param[in]   storageType                     The web storage type\r
85          * @exception   E_SUCCESS                       The method is successful.\r
86          * @exception   E_UNSUPPORTED_TYPE      The specified @c storageType is not supported.\r
87          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.\r
88          * @remarks             The specific error code can be accessed using the GetLastResult() method.\r
89          */\r
90         Tizen::Base::Collection::IList* GetOriginListN(WebStorageType storageType) const;\r
91 \r
92         /**\r
93          * Sets the default quota for a given origin of a given storage type. @n\r
94          * Only @c WEB_STORAGE_TYPE_WEB_SQL_DATABASE and @c WEB_STORAGE_TYPE_APPLICATION_CACHE are supported.\r
95          *\r
96          * @since               2.1\r
97          * @privlevel   public\r
98          * @privilege   %http://tizen.org/privilege/web.privacy\r
99          *\r
100          * @return              An error code\r
101          * @param[in]   storageType                     The web storage type\r
102          * @param[in]   origin                          The origin\r
103          * @param[in]   quota                           The quota of the web storage to set in bytes\r
104          * @exception   E_SUCCESS                       The method is successful.\r
105          * @exception   E_INVALID_ARG           The specified @c origin is invalid.\r
106          * @exception   E_UNSUPPORTED_TYPE      The specified @c storageType is not supported.\r
107          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.\r
108          */\r
109         result SetQuotaForOrigin(WebStorageType storageType, const Tizen::Base::String& origin, long quota);\r
110 \r
111 \r
112         /**\r
113          * Gets the quota for a given origin of a given storage type. @n\r
114          * Only @c WEB_STORAGE_TYPE_WEB_SQL_DATABASE is supported.\r
115          *\r
116          * @since               2.1\r
117          * @privlevel   public\r
118          * @privilege   %http://tizen.org/privilege/web.privacy\r
119          *\r
120          * @return              The usage of the web storage in bytes\r
121          * @param[in]   storageType                     The web storage type\r
122          * @param[in]   origin                          The origin\r
123          * @exception   E_SUCCESS                       The method is successful.\r
124          * @exception   E_INVALID_ARG           The specified @c origin is invalid.\r
125          * @exception   E_UNSUPPORTED_TYPE      The specified @c storageType is not supported.\r
126          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.\r
127          */\r
128         long GetQuotaForOrigin(WebStorageType storageType, const Tizen::Base::String& origin);\r
129 \r
130         /**\r
131          * Gets the usage for a given origin of a given storage type. @n\r
132          * @c WEB_STORAGE_TYPE_INDEXED_DATABASE and @c WEB_STORAGE_TYPE_FILE_SYSTEM are not supported.\r
133          *\r
134          * @since               2.1\r
135          * @privlevel   public\r
136          * @privilege   %http://tizen.org/privilege/web.privacy\r
137          *\r
138          * @return              The usage of the web storage in bytes\r
139          * @param[in]   storageType                     The web storage type\r
140          * @param[in]   origin                          The origin\r
141          * @exception   E_SUCCESS                       The method is successful.\r
142          * @exception   E_INVALID_ARG           The specified @c origin is invalid.\r
143          * @exception   E_UNSUPPORTED_TYPE      The specified @c storageType is not supported.\r
144          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.\r
145          * @remarks             The specific error code can be accessed using the GetLastResult() method.\r
146          */\r
147         long GetUsageForOrigin(WebStorageType storageType, const Tizen::Base::String& origin) const;\r
148 \r
149         /**\r
150          * Removes the data for a given origin of a given storage type. @n\r
151          * @c WEB_STORAGE_TYPE_INDEXED_DATABASE is not supported.\r
152          *\r
153          * @since               2.1\r
154          * @privlevel   public\r
155          * @privilege   %http://tizen.org/privilege/web.privacy\r
156          *\r
157          * @return              An error code\r
158          * @param[in]   storageType                     The web storage type\r
159          * @param[in]   origin                          The origin\r
160          * @exception   E_SUCCESS                       The method is successful.\r
161          * @exception   E_INVALID_ARG           The specified @c origin is invalid.\r
162          * @exception   E_UNSUPPORTED_TYPE      The specified @c storageType is not supported.\r
163          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.\r
164          * @see RemoveAll()\r
165          */\r
166         result Remove(WebStorageType storageType, const Tizen::Base::String& origin);\r
167 \r
168         /**\r
169          * Removes all the data of a given storage type.\r
170          *\r
171          * @since               2.1\r
172          * @privlevel   public\r
173          * @privilege   %http://tizen.org/privilege/web.privacy\r
174          *\r
175          * @return              An error code\r
176          * @param[in]   storageType                     The web storage type\r
177          * @exception   E_SUCCESS                       The method is successful.\r
178          * @exception   E_UNSUPPORTED_TYPE      The specified @c storageType is not supported.\r
179          * @exception   E_PRIVILEGE_DENIED      The application does not have the privilege to call this method.\r
180          * @see Remove()\r
181          */\r
182         result RemoveAll(WebStorageType storageType);\r
183 \r
184         /**\r
185          * Gets a web storage manager instance.\r
186          *\r
187          * @since               2.1\r
188          *\r
189          * @return              A pointer to the %WebStorageManager instance, @n\r
190          *                              else @c null if it fails\r
191          * @exception   E_SUCCESS                       The method is successful.\r
192          * @exception   E_OUT_OF_MEMORY         The memory is insufficient.\r
193          * @remarks             The specific error code can be accessed using the GetLastResult() method.\r
194          */\r
195         static WebStorageManager* GetInstance(void);\r
196 \r
197 private:\r
198         //\r
199         // This default constructor is intentionally declared as private to implement the Singleton semantic.\r
200         //\r
201         // @remarks             This constructor is hidden.\r
202         //\r
203         WebStorageManager(void);\r
204 \r
205         //\r
206         // This destructor is intentionally declared as private to implement the Singleton semantic.\r
207         //\r
208         // @remarks             This destructor is hidden.\r
209         //\r
210         virtual ~WebStorageManager(void);\r
211 \r
212         // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.\r
213         //\r
214         // @param[in] rhs                       The instance of the % WebStorageManager class to copy from\r
215         // @remarks             This constructor is hidden.\r
216         //\r
217         WebStorageManager(const WebStorageManager& rhs);\r
218 \r
219         //\r
220         // Initializes the web storage manager instance.\r
221         //\r
222         // @since               2.1\r
223         //\r
224         static void InitWebStorageManager(void);\r
225 \r
226         //\r
227         // Destroys the web storage manager instance.\r
228         //\r
229         // @since               2.1\r
230         //\r
231         static void DestroyWebStorageManager(void);\r
232 \r
233         //\r
234         // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.\r
235         //\r
236         // @param[in] rhs                       An instance of % WebStorageManager to assign from\r
237         // @remarks             This operator is hidden.\r
238         //\r
239         WebStorageManager& operator=(const WebStorageManager& rhs);\r
240 \r
241 private:\r
242         _WebStorageManagerImpl* __pWebStorageManagerImpl;\r
243 \r
244         static WebStorageManager* __pInstance;\r
245 \r
246         friend class _WebStorageManagerImpl;\r
247 \r
248         friend struct std::default_delete<WebStorageManager>;\r
249 }; // WebStorageManager\r
250 \r
251 }}} // Tizen::Web::Controls\r
252 #endif // _FWEB_CTRL_WEB_STORAGE_MANAGER_H_\r