2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FWebCtrlWebSetting.cpp
20 * @brief The file contains the definition of WebSetting class.
22 * The file contains the definition of WebSetting class.
25 #include <FBaseResult.h>
26 #include <FBaseSysLog.h>
27 #include <FWebCtrlWebSetting.h>
28 #include <FSec_AccessController.h>
29 #include "FWebCtrl_WebSettingImpl.h"
32 using namespace Tizen::Base;
33 using namespace Tizen::Security;
34 using namespace Tizen::Ui::Controls;
37 namespace Tizen { namespace Web { namespace Controls
41 WebSetting::WebSetting(void)
42 : __pWebSettingImpl(new (std::nothrow) _WebSettingImpl())
44 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebSettingImpl, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
48 WebSetting::WebSetting(const WebSetting& setting)
49 : __pWebSettingImpl(new (std::nothrow) _WebSettingImpl(*_WebSettingImpl::GetInstance(&setting)))
51 SysTryReturnVoidResult(NID_WEB_CTRL, __pWebSettingImpl, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
56 WebSetting::operator =(const WebSetting& setting)
63 Object::operator =(setting);
64 _WebSettingImpl* pImpl = _WebSettingImpl::GetInstance(this);
67 *pImpl = *_WebSettingImpl::GetInstance(&setting);
74 WebSetting::~WebSetting(void)
76 delete __pWebSettingImpl;
77 __pWebSettingImpl = null;
82 WebSetting::SetCacheControl(CacheMode mode)
84 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
89 r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
90 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
91 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
93 __pWebSettingImpl->SetCacheControl(mode);
95 SysLog(NID_WEB_CTRL, "The current value of mode is %d", mode);
100 WebSetting::GetCacheControl(void) const
102 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
104 return __pWebSettingImpl->GetCacheControl();
109 WebSetting::SetFontSize(int fontSize)
111 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
113 __pWebSettingImpl->SetFontSize(fontSize);
115 SysLog(NID_WEB_CTRL, "The current value of fontSize is %d", fontSize);
120 WebSetting::GetFontSize(void) const
122 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
124 return __pWebSettingImpl->GetFontSize();
129 WebSetting::SetDefaultTextEncoding(const String& encoding)
131 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
133 __pWebSettingImpl->SetDefaultTextEncoding(encoding);
135 SysLog(NID_WEB_CTRL, "The current value of encoding is %ls", encoding.GetPointer());
140 WebSetting::GetDefaultTextEncoding(void) const
142 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
144 return __pWebSettingImpl->GetDefaultTextEncoding();
149 WebSetting::SetJavascriptEnabled(bool enable)
151 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
153 __pWebSettingImpl->SetJavascriptEnabled(enable);
155 SysLog(NID_WEB_CTRL, "The current value of enable is %d", enable);
160 WebSetting::SetAutoImageLoadEnabled(bool enable)
162 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
164 __pWebSettingImpl->SetAutoImageLoadEnabled(enable);
166 SysLog(NID_WEB_CTRL, "The current value of enable is %d", enable);
171 WebSetting::IsJavascriptEnabled(void) const
173 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
175 return __pWebSettingImpl->IsJavascriptEnabled();
180 WebSetting::IsAutoImageLoadEnabled(void) const
182 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
184 return __pWebSettingImpl->IsAutoImageLoadEnabled();
189 WebSetting::SetInputStyle(InputStyle inputStyle)
191 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
193 __pWebSettingImpl->SetInputStyle(inputStyle);
195 SysLog(NID_WEB_CTRL, "The current value of inputStyle is %d", inputStyle);
200 WebSetting::GetInputStyle(void) const
202 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
204 return __pWebSettingImpl->GetInputStyle();
209 WebSetting::SetCertificateErrorHandlingMode(CertificateErrorHandlingMode mode)
211 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
214 result r = E_SUCCESS;
216 r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
217 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
218 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
220 __pWebSettingImpl->SetCertificateErrorHandlingMode(mode);
222 SysLog(NID_WEB_CTRL, "The current value of mode is %d", mode);
226 CertificateErrorHandlingMode
227 WebSetting::GetCertificateErrorHandlingMode(void) const
229 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
231 return __pWebSettingImpl->GetCertificateErrorHandlingMode();
236 WebSetting::SetUserAgent(const String& agent)
238 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
240 __pWebSettingImpl->SetUserAgent(agent);
242 SysLog(NID_WEB_CTRL, "The current value of agent is %ls", agent.GetPointer());
247 WebSetting::GetUserAgent(void) const
249 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
251 return __pWebSettingImpl->GetUserAgent();
256 WebSetting::SetAutoFittingEnabled(bool enable)
258 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
260 __pWebSettingImpl->SetAutoFittingEnabled(enable);
262 SysLog(NID_WEB_CTRL, "The current value of enable is %d", enable);
267 WebSetting::IsAutoFittingEnabled(void) const
269 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
271 return __pWebSettingImpl->IsAutoFittingEnabled();
276 WebSetting::SetJavaScriptPopupEnabled(bool enable)
278 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
280 __pWebSettingImpl->SetJavaScriptPopupEnabled(enable);
282 SysLog(NID_WEB_CTRL, "The current value of enable is %d", enable);
287 WebSetting::IsJavaScriptPopupEnabled(void) const
289 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
291 return __pWebSettingImpl->IsJavaScriptPopupEnabled();
296 WebSetting::SetGeolocationEnabled(bool enable)
298 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
301 result r = E_SUCCESS;
303 r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
304 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
305 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
307 __pWebSettingImpl->SetGeolocationEnabled(enable);
309 SysLog(NID_WEB_CTRL, "The current value of enable is %d", enable);
314 WebSetting::IsGeolocationEnabled(void) const
316 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
318 return __pWebSettingImpl->IsGeolocationEnabled();
323 WebSetting::SetAutoFormDataShowEnabled(bool enable)
325 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
328 result r = E_SUCCESS;
330 r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
331 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
332 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
334 __pWebSettingImpl->SetAutoFormDataShowEnabled(enable);
336 SysLog(NID_WEB_CTRL, "The current value of enable is %d", enable);
341 WebSetting::IsAutoFormDataShowEnabled(void) const
343 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
345 return __pWebSettingImpl->IsAutoFormDataShowEnabled();
350 WebSetting::SetAutoLoginFormFillEnabled(bool enable)
352 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
355 result r = E_SUCCESS;
357 r = _AccessController::CheckUserPrivilege(_PRV_WEB_SERVICE);
358 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
359 SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
361 __pWebSettingImpl->SetAutoLoginFormFillEnabled(enable);
363 SysLog(NID_WEB_CTRL, "The current value of enable is %d", enable);
368 WebSetting::IsAutoLoginFormFillEnabled(void) const
370 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
372 return __pWebSettingImpl->IsAutoLoginFormFillEnabled();
377 WebSetting::Equals(const Object& obj) const
379 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
381 const WebSetting* pRhs = dynamic_cast< const WebSetting* >(&obj);
387 return __pWebSettingImpl->Equals(*pRhs->__pWebSettingImpl);
392 WebSetting::GetHashCode(void) const
394 SysAssertf(__pWebSettingImpl != null, "Not yet constructed. Construct() should be called before use.");
396 return __pWebSettingImpl->GetHashCode();
400 }}} // Tizen::Web::Controls