fix bug for geolocation and contents download
[framework/osp/web.git] / src / controls / FWebCtrlWebSetting.cpp
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                FWebCtrlWebSetting.cpp
20  * @brief               The file contains the definition of WebSetting class.
21  *
22  * The file contains the definition of WebSetting class.
23  */
24 #include <new>
25 #include <FBaseResult.h>
26 #include <FBaseSysLog.h>
27 #include <FWebCtrlWebSetting.h>
28 #include "FWebCtrl_WebSettingImpl.h"
29
30
31 using namespace Tizen::Base;
32 using namespace Tizen::Ui::Controls;
33
34
35 namespace Tizen { namespace Web { namespace Controls
36 {
37
38
39 WebSetting::WebSetting(void)
40         : __pWebSettingImpl(new (std::nothrow) _WebSettingImpl())
41 {
42         SysTryReturnVoidResult(NID_WEB_CTRL, __pWebSettingImpl, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
43 }
44
45
46 WebSetting::WebSetting(const WebSetting& setting)
47         : __pWebSettingImpl(new (std::nothrow) _WebSettingImpl(*_WebSettingImpl::GetInstance(&setting)))
48 {
49         SysTryReturnVoidResult(NID_WEB_CTRL, __pWebSettingImpl, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
50 }
51
52
53 WebSetting&
54 WebSetting::operator =(const WebSetting& setting)
55 {
56         if (&setting == this)
57         {
58                 return *this;
59         }
60
61         Object::operator =(setting);
62         _WebSettingImpl* pImpl = _WebSettingImpl::GetInstance(this);
63         if (pImpl)
64         {
65                 *pImpl = *_WebSettingImpl::GetInstance(&setting);
66         }
67
68         return *this;
69 }
70
71
72 WebSetting::~WebSetting(void)
73 {
74         delete __pWebSettingImpl;
75         __pWebSettingImpl = null;
76 }
77
78
79 void
80 WebSetting::SetCacheControl(CacheMode mode)
81 {
82         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
83
84         __pWebSettingImpl->SetCacheControl(mode);
85
86         SysLog(NID_WEB_CTRL, "The current value of mode is %d", mode);
87 }
88
89
90 CacheMode
91 WebSetting::GetCacheControl(void) const
92 {
93         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
94
95         return __pWebSettingImpl->GetCacheControl();
96 }
97
98
99 void
100 WebSetting::SetFontSize(int fontSize)
101 {
102         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
103
104         __pWebSettingImpl->SetFontSize(fontSize);
105
106         SysLog(NID_WEB_CTRL, "The current value of fontSize is %d", fontSize);
107 }
108
109
110 int
111 WebSetting::GetFontSize(void) const
112 {
113         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
114
115         return __pWebSettingImpl->GetFontSize();
116 }
117
118
119 void
120 WebSetting::SetDefaultTextEncoding(const String& encoding)
121 {
122         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
123
124         __pWebSettingImpl->SetDefaultTextEncoding(encoding);
125
126         SysLog(NID_WEB_CTRL, "The current value of encoding is %ls", encoding.GetPointer());
127 }
128
129
130 String
131 WebSetting::GetDefaultTextEncoding(void) const
132 {
133         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
134
135         return __pWebSettingImpl->GetDefaultTextEncoding();
136 }
137
138
139 void
140 WebSetting::SetJavascriptEnabled(bool enable)
141 {
142         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
143
144         __pWebSettingImpl->SetJavascriptEnabled(enable);
145
146         SysLog(NID_WEB_CTRL, "The current value of enable is %d", enable);
147 }
148
149
150 void
151 WebSetting::SetAutoImageLoadEnabled(bool enable)
152 {
153         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
154
155         __pWebSettingImpl->SetAutoImageLoadEnabled(enable);
156
157         SysLog(NID_WEB_CTRL, "The current value of enable is %d", enable);
158 }
159
160
161 bool
162 WebSetting::IsJavascriptEnabled(void) const
163 {
164         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
165
166         return __pWebSettingImpl->IsJavascriptEnabled();
167 }
168
169
170 bool
171 WebSetting::IsAutoImageLoadEnabled(void) const
172 {
173         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
174
175         return __pWebSettingImpl->IsAutoImageLoadEnabled();
176 }
177
178
179 void
180 WebSetting::SetInputStyle(InputStyle inputStyle)
181 {
182         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
183
184         __pWebSettingImpl->SetInputStyle(inputStyle);
185
186         SysLog(NID_WEB_CTRL, "The current value of inputStyle is %d", inputStyle);
187 }
188
189
190 InputStyle
191 WebSetting::GetInputStyle(void) const
192 {
193         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
194
195         return __pWebSettingImpl->GetInputStyle();
196 }
197
198
199 void
200 WebSetting::SetCertificateErrorHandlingMode(CertificateErrorHandlingMode mode)
201 {
202         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
203
204         __pWebSettingImpl->SetCertificateErrorHandlingMode(mode);
205
206         SysLog(NID_WEB_CTRL, "The current value of mode is %d", mode);
207 }
208
209
210 CertificateErrorHandlingMode
211 WebSetting::GetCertificateErrorHandlingMode(void) const
212 {
213         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
214
215         return __pWebSettingImpl->GetCertificateErrorHandlingMode();
216 }
217
218
219 void
220 WebSetting::SetUserAgent(const String& agent)
221 {
222         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
223
224         __pWebSettingImpl->SetUserAgent(agent);
225
226         SysLog(NID_WEB_CTRL, "The current value of agent is %ls", agent.GetPointer());
227 }
228
229
230 String
231 WebSetting::GetUserAgent(void) const
232 {
233         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
234
235         return __pWebSettingImpl->GetUserAgent();
236 }
237
238
239 void
240 WebSetting::SetAutoFittingEnabled(bool enable)
241 {
242         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
243
244         __pWebSettingImpl->SetAutoFittingEnabled(enable);
245
246         SysLog(NID_WEB_CTRL, "The current value of enable is %d", enable);
247 }
248
249
250 bool
251 WebSetting::IsAutoFittingEnabled(void) const
252 {
253         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
254
255         return __pWebSettingImpl->IsAutoFittingEnabled();
256 }
257
258
259 void 
260 WebSetting::SetJavaScriptPopupEnabled(bool enable)
261 {
262         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
263
264         __pWebSettingImpl->SetJavaScriptPopupEnabled(enable);
265
266         SysLog(NID_WEB_CTRL, "The current value of enable is %d", enable);
267 }
268
269
270 bool
271 WebSetting::IsJavaScriptPopupEnabled(void) const
272 {
273         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
274
275         return __pWebSettingImpl->IsJavaScriptPopupEnabled();
276 }
277
278
279 void
280 WebSetting::SetGeolocationEnabled(bool enable)
281 {
282         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
283
284         __pWebSettingImpl->SetGeolocationEnabled(enable);
285
286         SysLog(NID_WEB_CTRL, "The current value of enable is %d", enable);
287 }
288
289
290 bool
291 WebSetting::IsGeolocationEnabled(void) const
292 {
293         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
294
295         return __pWebSettingImpl->IsGeolocationEnabled();
296 }
297
298
299 void
300 WebSetting::SetAutoFormDataShowEnabled(bool enable)
301 {
302         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
303
304         __pWebSettingImpl->SetAutoFormDataShowEnabled(enable);
305
306         SysLog(NID_WEB_CTRL, "The current value of enable is %d", enable);
307 }
308
309
310 bool
311 WebSetting::IsAutoFormDataShowEnabled(void) const
312 {
313         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
314
315         return __pWebSettingImpl->IsAutoFormDataShowEnabled();
316 }
317
318
319 void
320 WebSetting::SetAutoLoginFormFillEnabled(bool enable)
321 {
322         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
323
324         __pWebSettingImpl->SetAutoLoginFormFillEnabled(enable);
325
326         SysLog(NID_WEB_CTRL, "The current value of enable is %d", enable);
327 }
328
329
330 bool
331 WebSetting::IsAutoLoginFormFillEnabled(void) const
332 {
333         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
334
335         return __pWebSettingImpl->IsAutoLoginFormFillEnabled();
336 }
337
338
339 bool
340 WebSetting::Equals(const Object& obj) const
341 {
342         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
343
344         const WebSetting* pRhs = dynamic_cast< const WebSetting* >(&obj);
345         if (pRhs == null)
346         {
347                 return false;
348         }
349
350         return __pWebSettingImpl->Equals(*pRhs->__pWebSettingImpl);
351 }
352
353
354 int
355 WebSetting::GetHashCode(void) const
356 {
357         SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
358
359         return __pWebSettingImpl->GetHashCode();
360 }
361
362
363 }}} // Tizen::Web::Controls