summaryrefslogtreecommitdiff
path: root/src/controls/FWebCtrl_WebSettingImpl.cpp
blob: 13c3b2f3d55c83b54899447dd5869ac0ad4027bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
//
// Open Service Platform
// Copyright (c) 2012 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the License);
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

/**
 * @file		FWebCtrlWebSetting.cpp
 * @brief		The file contains the definition of WebSetting class.
 *
 * The file contains the definition of WebSetting class.
 */
#include <unique_ptr.h>
#include <vconf.h>
#include <FBaseBoolean.h>
#include <FBaseInteger.h>
#include <FWebCtrlWebSetting.h>
#include <FBaseSysLog.h>
#include "FWebCtrl_WebSettingImpl.h"


using namespace Tizen::Base;
using namespace Tizen::Ui::Controls;


namespace Tizen { namespace Web { namespace Controls
{


static const wchar_t* DEFAULT_ENCODING_MODE = L"UTF-8";
static const int DEFAULT_FONT_SIZE = 17;
static const float DEFAULT_ZOOM_LEVEL = 2.0f;
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";


_WebSettingImpl::_WebSettingImpl(void)
	: __cacheMode(WEB_CACHE_VALIDATED)
	, __encoding(DEFAULT_ENCODING_MODE)
	, __fontSize(DEFAULT_FONT_SIZE)
	, __javascriptEnabled(true)
	, __autoImageEnabled(true)
	, __isScrollEnabled(true)
	, __isPrivateBrowsingEnabled(false)
	, __isCookieEnabled(true)
	, __zoomLevel(DEFAULT_ZOOM_LEVEL)
	, __inputStyle(INPUT_STYLE_FULLSCREEN)
	, __certificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM)
	, __autoFittingEnabled(true)
	, __javaScriptPopupEnabled(true)
	, __geolocationEnabled(true)
{
	char* pUserAgent = vconf_get_str(VCONFKEY_BROWSER_USER_AGENT);

	if(pUserAgent)
	{
		__userAgent = pUserAgent;
		free(pUserAgent);
	}
	else
	{
		__userAgent = DEFAULT_USER_AGENT;
	}
}


_WebSettingImpl::~_WebSettingImpl(void)
{
}


void
_WebSettingImpl::SetCacheControl(CacheMode mode)
{
	__cacheMode = mode;
}


CacheMode
_WebSettingImpl::GetCacheControl(void) const
{
	return __cacheMode;
}


void
_WebSettingImpl::SetFontSize(int fontSize)
{
	__fontSize = fontSize;
}


int
_WebSettingImpl::GetFontSize(void) const
{
	return __fontSize;
}


void
_WebSettingImpl::SetDefaultTextEncoding(const Tizen::Base::String& encoding)
{
	__encoding = encoding;
}


Tizen::Base::String
_WebSettingImpl::GetDefaultTextEncoding(void) const
{
	return __encoding;
}


void
_WebSettingImpl::SetJavascriptEnabled(bool enable)
{
	__javascriptEnabled = enable;
}


void
_WebSettingImpl::SetAutoImageLoadEnabled(bool enable)
{
	__autoImageEnabled = enable;
}


bool
_WebSettingImpl::IsJavascriptEnabled(void) const
{
	return __javascriptEnabled;
}


bool
_WebSettingImpl::IsAutoImageLoadEnabled(void) const
{
	return __autoImageEnabled;
}


void
_WebSettingImpl::SetInputStyle(Tizen::Ui::Controls::InputStyle inputStyle)
{
	__inputStyle = inputStyle;
}


Tizen::Ui::Controls::InputStyle
_WebSettingImpl::GetInputStyle(void) const
{
	return __inputStyle;
}


void
_WebSettingImpl::SetCertificateErrorHandlingMode(CertificateErrorHandlingMode mode)
{
	__certificateErrorHandlingMode = mode;
}


CertificateErrorHandlingMode
_WebSettingImpl::GetCertificateErrorHandlingMode(void) const
{
	return __certificateErrorHandlingMode;
}


void
_WebSettingImpl::SetUserAgent(const Tizen::Base::String& agent)
{
	__userAgent = agent;
}


Tizen::Base::String
_WebSettingImpl::GetUserAgent(void) const
{
	return __userAgent;
}


void
_WebSettingImpl::SetScrollEnabled(bool enable)
{
	__isScrollEnabled = enable;
}


bool
_WebSettingImpl::IsScrollEnabled(void) const
{
	return __isScrollEnabled;
}


void
_WebSettingImpl::SetPrivateBrowsingEnabled(bool enable)
{
	__isPrivateBrowsingEnabled = enable;
}


bool
_WebSettingImpl::IsPrivateBrowsingEnabled(void) const
{
	return __isPrivateBrowsingEnabled;
}


void
_WebSettingImpl::SetCookiEnabled(bool enable)
{
	__isCookieEnabled = enable;
}


bool
_WebSettingImpl::IsCookieEnabled(void) const
{
	return __isCookieEnabled;
}


void
_WebSettingImpl::SetZoomLevel(float level)
{
	__zoomLevel = level;
}


float
_WebSettingImpl::GetZoomLevel(void) const
{
	return __zoomLevel;
}


void
_WebSettingImpl::SetAutoFittingEnabled(bool enable)
{
	__autoFittingEnabled = enable;
}


bool
_WebSettingImpl::IsAutoFittingEnabled(void) const
{
	return __autoFittingEnabled;
}


void 
_WebSettingImpl::SetJavaScriptPopupEnabled(bool enable)
{
	__javaScriptPopupEnabled = enable;
}


bool
_WebSettingImpl::IsJavaScriptPopupEnabled(void) const
{
	return __javaScriptPopupEnabled;
}


void
_WebSettingImpl::SetGeolocationEnabled(bool enable)
{
	__geolocationEnabled = enable;
}


bool
_WebSettingImpl::IsGeolocationEnabled(void) const
{
	return __geolocationEnabled;
}


bool
_WebSettingImpl::Equals(const Object& obj) const
{
	const _WebSettingImpl* pRhs = dynamic_cast< const _WebSettingImpl* >(&obj);
	if (pRhs == null)
	{
		return false;
	}

	return __cacheMode == pRhs->__cacheMode && __encoding == pRhs->__encoding && __fontSize == pRhs->__fontSize
		   && __javascriptEnabled == pRhs->__javascriptEnabled && __autoImageEnabled == pRhs->__autoImageEnabled
		   && __isScrollEnabled == pRhs->__isScrollEnabled && __inputStyle == pRhs->__inputStyle
		   && __certificateErrorHandlingMode == pRhs->__certificateErrorHandlingMode && __userAgent == pRhs->__userAgent
		   && __autoFittingEnabled == pRhs->__autoFittingEnabled && __javaScriptPopupEnabled == pRhs->__javaScriptPopupEnabled
		   && __geolocationEnabled == pRhs->__geolocationEnabled;
}


int
_WebSettingImpl::GetHashCode(void) const
{
	return Integer(__cacheMode).GetHashCode() + __encoding.GetHashCode() + Integer(__fontSize).GetHashCode()
		   + Boolean(__javascriptEnabled).GetHashCode() + Boolean(__autoImageEnabled).GetHashCode()
		   + Boolean(__isScrollEnabled).GetHashCode() + Integer(__inputStyle).GetHashCode()
		   + Integer(__certificateErrorHandlingMode).GetHashCode() + __userAgent.GetHashCode()
		   + Boolean(__autoFittingEnabled).GetHashCode() + Boolean(__javaScriptPopupEnabled).GetHashCode()
		   + Boolean(__geolocationEnabled).GetHashCode();
}


_WebSettingImpl*
_WebSettingImpl::GetInstance(WebSetting* pWebSetting)
{
	return pWebSetting->__pWebSettingImpl;
}


const _WebSettingImpl*
_WebSettingImpl::GetInstance(const WebSetting* pWebSetting)
{
	return pWebSetting->__pWebSettingImpl;
}


}}} // Tizen::Web::Controls