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; Tizen 2.1; sdk) AppleWebKit/537.3 (KHTML, like Gecko) Version/2.1 Mobile Safari/537.3";
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);
68 __userAgent = pUserAgent;
73 __userAgent = DEFAULT_USER_AGENT;
78 _WebSettingImpl::~_WebSettingImpl(void)
84 _WebSettingImpl::SetCacheControl(CacheMode mode)
91 _WebSettingImpl::GetCacheControl(void) const
98 _WebSettingImpl::SetFontSize(int fontSize)
100 __fontSize = fontSize;
105 _WebSettingImpl::GetFontSize(void) const
112 _WebSettingImpl::SetDefaultTextEncoding(const Tizen::Base::String& encoding)
114 __encoding = encoding;
119 _WebSettingImpl::GetDefaultTextEncoding(void) const
126 _WebSettingImpl::SetJavascriptEnabled(bool enable)
128 __javascriptEnabled = enable;
133 _WebSettingImpl::SetAutoImageLoadEnabled(bool enable)
135 __autoImageEnabled = enable;
140 _WebSettingImpl::IsJavascriptEnabled(void) const
142 return __javascriptEnabled;
147 _WebSettingImpl::IsAutoImageLoadEnabled(void) const
149 return __autoImageEnabled;
154 _WebSettingImpl::SetInputStyle(Tizen::Ui::Controls::InputStyle inputStyle)
156 __inputStyle = inputStyle;
160 Tizen::Ui::Controls::InputStyle
161 _WebSettingImpl::GetInputStyle(void) const
168 _WebSettingImpl::SetCertificateErrorHandlingMode(CertificateErrorHandlingMode mode)
170 __certificateErrorHandlingMode = mode;
174 CertificateErrorHandlingMode
175 _WebSettingImpl::GetCertificateErrorHandlingMode(void) const
177 return __certificateErrorHandlingMode;
182 _WebSettingImpl::SetUserAgent(const Tizen::Base::String& agent)
189 _WebSettingImpl::GetUserAgent(void) const
196 _WebSettingImpl::SetScrollEnabled(bool enable)
198 __isScrollEnabled = enable;
203 _WebSettingImpl::IsScrollEnabled(void) const
205 return __isScrollEnabled;
210 _WebSettingImpl::SetPrivateBrowsingEnabled(bool enable)
212 __isPrivateBrowsingEnabled = enable;
217 _WebSettingImpl::IsPrivateBrowsingEnabled(void) const
219 return __isPrivateBrowsingEnabled;
224 _WebSettingImpl::SetCookiEnabled(bool enable)
226 __isCookieEnabled = enable;
231 _WebSettingImpl::IsCookieEnabled(void) const
233 return __isCookieEnabled;
238 _WebSettingImpl::SetZoomLevel(float level)
245 _WebSettingImpl::GetZoomLevel(void) const
252 _WebSettingImpl::SetAutoFittingEnabled(bool enable)
254 __autoFittingEnabled = enable;
259 _WebSettingImpl::IsAutoFittingEnabled(void) const
261 return __autoFittingEnabled;
266 _WebSettingImpl::SetJavaScriptPopupEnabled(bool enable)
268 __javaScriptPopupEnabled = enable;
273 _WebSettingImpl::IsJavaScriptPopupEnabled(void) const
275 return __javaScriptPopupEnabled;
280 _WebSettingImpl::SetGeolocationEnabled(bool enable)
282 __geolocationEnabled = enable;
287 _WebSettingImpl::IsGeolocationEnabled(void) const
289 return __geolocationEnabled;
294 _WebSettingImpl::SetAutoFormDataShowEnabled(bool enable)
296 __autoFormDataEnabled = enable;
301 _WebSettingImpl::IsAutoFormDataShowEnabled(void) const
303 return __autoFormDataEnabled;
308 _WebSettingImpl::SetAutoLoginFormFillEnabled(bool enable)
310 __autoLoginFormEnabled = enable;
315 _WebSettingImpl::IsAutoLoginFormFillEnabled(void) const
317 return __autoLoginFormEnabled;
322 _WebSettingImpl::Equals(const Object& obj) const
324 const _WebSettingImpl* pRhs = dynamic_cast< const _WebSettingImpl* >(&obj);
330 return __cacheMode == pRhs->__cacheMode && __encoding == pRhs->__encoding && __fontSize == pRhs->__fontSize
331 && __javascriptEnabled == pRhs->__javascriptEnabled && __autoImageEnabled == pRhs->__autoImageEnabled
332 && __isScrollEnabled == pRhs->__isScrollEnabled && __inputStyle == pRhs->__inputStyle
333 && __certificateErrorHandlingMode == pRhs->__certificateErrorHandlingMode && __userAgent == pRhs->__userAgent
334 && __autoFittingEnabled == pRhs->__autoFittingEnabled && __javaScriptPopupEnabled == pRhs->__javaScriptPopupEnabled
335 && __geolocationEnabled == pRhs->__geolocationEnabled && __autoFormDataEnabled == pRhs->__autoFormDataEnabled
336 && __autoLoginFormEnabled == pRhs->__autoLoginFormEnabled;
341 _WebSettingImpl::GetHashCode(void) const
343 return Integer(__cacheMode).GetHashCode() + __encoding.GetHashCode() + Integer(__fontSize).GetHashCode()
344 + Boolean(__javascriptEnabled).GetHashCode() + Boolean(__autoImageEnabled).GetHashCode()
345 + Boolean(__isScrollEnabled).GetHashCode() + Integer(__inputStyle).GetHashCode()
346 + Integer(__certificateErrorHandlingMode).GetHashCode() + __userAgent.GetHashCode()
347 + Boolean(__autoFittingEnabled).GetHashCode() + Boolean(__javaScriptPopupEnabled).GetHashCode()
348 + Boolean(__geolocationEnabled).GetHashCode() + Boolean(__autoFormDataEnabled).GetHashCode()
349 + Boolean(__autoLoginFormEnabled).GetHashCode();
354 _WebSettingImpl::GetInstance(WebSetting* pWebSetting)
356 return pWebSetting->__pWebSettingImpl;
360 const _WebSettingImpl*
361 _WebSettingImpl::GetInstance(const WebSetting* pWebSetting)
363 return pWebSetting->__pWebSettingImpl;
367 }}} // Tizen::Web::Controls