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)
63 char* pUserAgent = vconf_get_str(VCONFKEY_BROWSER_USER_AGENT);
67 __userAgent = pUserAgent;
72 __userAgent = DEFAULT_USER_AGENT;
77 _WebSettingImpl::~_WebSettingImpl(void)
83 _WebSettingImpl::SetCacheControl(CacheMode mode)
90 _WebSettingImpl::GetCacheControl(void) const
97 _WebSettingImpl::SetFontSize(int fontSize)
99 __fontSize = fontSize;
104 _WebSettingImpl::GetFontSize(void) const
111 _WebSettingImpl::SetDefaultTextEncoding(const Tizen::Base::String& encoding)
113 __encoding = encoding;
118 _WebSettingImpl::GetDefaultTextEncoding(void) const
125 _WebSettingImpl::SetJavascriptEnabled(bool enable)
127 __javascriptEnabled = enable;
132 _WebSettingImpl::SetAutoImageLoadEnabled(bool enable)
134 __autoImageEnabled = enable;
139 _WebSettingImpl::IsJavascriptEnabled(void) const
141 return __javascriptEnabled;
146 _WebSettingImpl::IsAutoImageLoadEnabled(void) const
148 return __autoImageEnabled;
153 _WebSettingImpl::SetInputStyle(Tizen::Ui::Controls::InputStyle inputStyle)
155 __inputStyle = inputStyle;
159 Tizen::Ui::Controls::InputStyle
160 _WebSettingImpl::GetInputStyle(void) const
167 _WebSettingImpl::SetCertificateErrorHandlingMode(CertificateErrorHandlingMode mode)
169 __certificateErrorHandlingMode = mode;
173 CertificateErrorHandlingMode
174 _WebSettingImpl::GetCertificateErrorHandlingMode(void) const
176 return __certificateErrorHandlingMode;
181 _WebSettingImpl::SetUserAgent(const Tizen::Base::String& agent)
188 _WebSettingImpl::GetUserAgent(void) const
195 _WebSettingImpl::SetScrollEnabled(bool enable)
197 __isScrollEnabled = enable;
202 _WebSettingImpl::IsScrollEnabled(void) const
204 return __isScrollEnabled;
209 _WebSettingImpl::SetPrivateBrowsingEnabled(bool enable)
211 __isPrivateBrowsingEnabled = enable;
216 _WebSettingImpl::IsPrivateBrowsingEnabled(void) const
218 return __isPrivateBrowsingEnabled;
223 _WebSettingImpl::SetCookiEnabled(bool enable)
225 __isCookieEnabled = enable;
230 _WebSettingImpl::IsCookieEnabled(void) const
232 return __isCookieEnabled;
237 _WebSettingImpl::SetZoomLevel(float level)
244 _WebSettingImpl::GetZoomLevel(void) const
251 _WebSettingImpl::SetAutoFittingEnabled(bool enable)
253 __autoFittingEnabled = enable;
258 _WebSettingImpl::IsAutoFittingEnabled(void) const
260 return __autoFittingEnabled;
265 _WebSettingImpl::SetJavaScriptPopupEnabled(bool enable)
267 __javaScriptPopupEnabled = enable;
272 _WebSettingImpl::IsJavaScriptPopupEnabled(void) const
274 return __javaScriptPopupEnabled;
279 _WebSettingImpl::SetGeolocationEnabled(bool enable)
281 __geolocationEnabled = enable;
286 _WebSettingImpl::IsGeolocationEnabled(void) const
288 return __geolocationEnabled;
293 _WebSettingImpl::Equals(const Object& obj) const
295 const _WebSettingImpl* pRhs = dynamic_cast< const _WebSettingImpl* >(&obj);
301 return __cacheMode == pRhs->__cacheMode && __encoding == pRhs->__encoding && __fontSize == pRhs->__fontSize
302 && __javascriptEnabled == pRhs->__javascriptEnabled && __autoImageEnabled == pRhs->__autoImageEnabled
303 && __isScrollEnabled == pRhs->__isScrollEnabled && __inputStyle == pRhs->__inputStyle
304 && __certificateErrorHandlingMode == pRhs->__certificateErrorHandlingMode && __userAgent == pRhs->__userAgent
305 && __autoFittingEnabled == pRhs->__autoFittingEnabled && __javaScriptPopupEnabled == pRhs->__javaScriptPopupEnabled
306 && __geolocationEnabled == pRhs->__geolocationEnabled;
311 _WebSettingImpl::GetHashCode(void) const
313 return Integer(__cacheMode).GetHashCode() + __encoding.GetHashCode() + Integer(__fontSize).GetHashCode()
314 + Boolean(__javascriptEnabled).GetHashCode() + Boolean(__autoImageEnabled).GetHashCode()
315 + Boolean(__isScrollEnabled).GetHashCode() + Integer(__inputStyle).GetHashCode()
316 + Integer(__certificateErrorHandlingMode).GetHashCode() + __userAgent.GetHashCode()
317 + Boolean(__autoFittingEnabled).GetHashCode() + Boolean(__javaScriptPopupEnabled).GetHashCode()
318 + Boolean(__geolocationEnabled).GetHashCode();
323 _WebSettingImpl::GetInstance(WebSetting* pWebSetting)
325 return pWebSetting->__pWebSettingImpl;
329 const _WebSettingImpl*
330 _WebSettingImpl::GetInstance(const WebSetting* pWebSetting)
332 return pWebSetting->__pWebSettingImpl;
336 }}} // Tizen::Web::Controls