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.
24 #include <unique_ptr.h>
26 #include <FBaseBoolean.h>
27 #include <FBaseInteger.h>
28 #include <FWebCtrlWebSetting.h>
29 #include <FBaseSysLog.h>
30 #include "FWebCtrl_WebSettingImpl.h"
33 using namespace Tizen::Base;
34 using namespace Tizen::Ui::Controls;
37 namespace Tizen { namespace Web { namespace Controls
41 static const wchar_t* DEFAULT_ENCODING_MODE = L"UTF-8";
42 static const int DEFAULT_FONT_SIZE = 17;
43 static const float DEFAULT_ZOOM_LEVEL = 2.0f;
44 static const wchar_t* DEFAULT_USER_AGENT = L"Mozilla/5.0 (Linux; U; Tizen 2.0; en-us) AppleWebKit/537.1 (KHTML, like Gecko) Version/2.0 Mobile";
47 _WebSettingImpl::_WebSettingImpl(void)
48 : __cacheMode(WEB_CACHE_VALIDATED)
49 , __encoding(DEFAULT_ENCODING_MODE)
50 , __fontSize(DEFAULT_FONT_SIZE)
51 , __javascriptEnabled(true)
52 , __autoImageEnabled(true)
53 , __isScrollEnabled(true)
54 , __isPrivateBrowsingEnabled(false)
55 , __isCookieEnabled(true)
56 , __zoomLevel(DEFAULT_ZOOM_LEVEL)
57 , __inputStyle(INPUT_STYLE_FULLSCREEN)
58 , __certificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM)
59 , __autoFittingEnabled(true)
60 , __javaScriptPopupEnabled(true)
61 , __geolocationEnabled(true)
62 , __autoFormDataEnabled(true)
63 , __autoLoginFormEnabled(true)
65 char* pUserAgent = vconf_get_str(VCONFKEY_BROWSER_USER_AGENT);
69 __userAgent = pUserAgent;
74 __userAgent = DEFAULT_USER_AGENT;
79 _WebSettingImpl::~_WebSettingImpl(void)
85 _WebSettingImpl::SetCacheControl(CacheMode mode)
92 _WebSettingImpl::GetCacheControl(void) const
99 _WebSettingImpl::SetFontSize(int fontSize)
101 __fontSize = fontSize;
106 _WebSettingImpl::GetFontSize(void) const
113 _WebSettingImpl::SetDefaultTextEncoding(const Tizen::Base::String& encoding)
115 __encoding = encoding;
120 _WebSettingImpl::GetDefaultTextEncoding(void) const
127 _WebSettingImpl::SetJavascriptEnabled(bool enable)
129 __javascriptEnabled = enable;
134 _WebSettingImpl::SetAutoImageLoadEnabled(bool enable)
136 __autoImageEnabled = enable;
141 _WebSettingImpl::IsJavascriptEnabled(void) const
143 return __javascriptEnabled;
148 _WebSettingImpl::IsAutoImageLoadEnabled(void) const
150 return __autoImageEnabled;
155 _WebSettingImpl::SetInputStyle(Tizen::Ui::Controls::InputStyle inputStyle)
157 __inputStyle = inputStyle;
161 Tizen::Ui::Controls::InputStyle
162 _WebSettingImpl::GetInputStyle(void) const
169 _WebSettingImpl::SetCertificateErrorHandlingMode(CertificateErrorHandlingMode mode)
171 __certificateErrorHandlingMode = mode;
175 CertificateErrorHandlingMode
176 _WebSettingImpl::GetCertificateErrorHandlingMode(void) const
178 return __certificateErrorHandlingMode;
183 _WebSettingImpl::SetUserAgent(const Tizen::Base::String& agent)
190 _WebSettingImpl::GetUserAgent(void) const
197 _WebSettingImpl::SetScrollEnabled(bool enable)
199 __isScrollEnabled = enable;
204 _WebSettingImpl::IsScrollEnabled(void) const
206 return __isScrollEnabled;
211 _WebSettingImpl::SetPrivateBrowsingEnabled(bool enable)
213 __isPrivateBrowsingEnabled = enable;
218 _WebSettingImpl::IsPrivateBrowsingEnabled(void) const
220 return __isPrivateBrowsingEnabled;
225 _WebSettingImpl::SetCookiEnabled(bool enable)
227 __isCookieEnabled = enable;
232 _WebSettingImpl::IsCookieEnabled(void) const
234 return __isCookieEnabled;
239 _WebSettingImpl::SetZoomLevel(float level)
246 _WebSettingImpl::GetZoomLevel(void) const
253 _WebSettingImpl::SetAutoFittingEnabled(bool enable)
255 __autoFittingEnabled = enable;
260 _WebSettingImpl::IsAutoFittingEnabled(void) const
262 return __autoFittingEnabled;
267 _WebSettingImpl::SetJavaScriptPopupEnabled(bool enable)
269 __javaScriptPopupEnabled = enable;
274 _WebSettingImpl::IsJavaScriptPopupEnabled(void) const
276 return __javaScriptPopupEnabled;
281 _WebSettingImpl::SetGeolocationEnabled(bool enable)
283 __geolocationEnabled = enable;
288 _WebSettingImpl::IsGeolocationEnabled(void) const
290 return __geolocationEnabled;
295 _WebSettingImpl::SetAutoFormDataShowEnabled(bool enable)
297 __autoFormDataEnabled = enable;
302 _WebSettingImpl::IsAutoFormDataShowEnabled(void) const
304 return __autoFormDataEnabled;
309 _WebSettingImpl::SetAutoLoginFormFillEnabled(bool enable)
311 __autoLoginFormEnabled = enable;
316 _WebSettingImpl::IsAutoLoginFormFillEnabled(void) const
318 return __autoLoginFormEnabled;
323 _WebSettingImpl::Equals(const Object& obj) const
325 const _WebSettingImpl* pRhs = dynamic_cast< const _WebSettingImpl* >(&obj);
331 return __cacheMode == pRhs->__cacheMode && __encoding == pRhs->__encoding && __fontSize == pRhs->__fontSize
332 && __javascriptEnabled == pRhs->__javascriptEnabled && __autoImageEnabled == pRhs->__autoImageEnabled
333 && __isScrollEnabled == pRhs->__isScrollEnabled && __inputStyle == pRhs->__inputStyle
334 && __certificateErrorHandlingMode == pRhs->__certificateErrorHandlingMode && __userAgent == pRhs->__userAgent
335 && __autoFittingEnabled == pRhs->__autoFittingEnabled && __javaScriptPopupEnabled == pRhs->__javaScriptPopupEnabled
336 && __geolocationEnabled == pRhs->__geolocationEnabled && __autoFormDataEnabled == pRhs->__autoFormDataEnabled
337 && __autoLoginFormEnabled == pRhs->__autoLoginFormEnabled;
342 _WebSettingImpl::GetHashCode(void) const
344 return Integer(__cacheMode).GetHashCode() + __encoding.GetHashCode() + Integer(__fontSize).GetHashCode()
345 + Boolean(__javascriptEnabled).GetHashCode() + Boolean(__autoImageEnabled).GetHashCode()
346 + Boolean(__isScrollEnabled).GetHashCode() + Integer(__inputStyle).GetHashCode()
347 + Integer(__certificateErrorHandlingMode).GetHashCode() + __userAgent.GetHashCode()
348 + Boolean(__autoFittingEnabled).GetHashCode() + Boolean(__javaScriptPopupEnabled).GetHashCode()
349 + Boolean(__geolocationEnabled).GetHashCode() + Boolean(__autoFormDataEnabled).GetHashCode()
350 + Boolean(__autoLoginFormEnabled).GetHashCode();
355 _WebSettingImpl::GetInstance(WebSetting* pWebSetting)
357 return pWebSetting->__pWebSettingImpl;
361 const _WebSettingImpl*
362 _WebSettingImpl::GetInstance(const WebSetting* pWebSetting)
364 return pWebSetting->__pWebSettingImpl;
368 }}} // Tizen::Web::Controls