Fixed Nabi Issues
[apps/osp/Internet.git] / src / IntSettingPresentationModel.cpp
1 //
2
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.1 (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
8 //
9 //     http://floralicense.org/license/
10 //
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.
16 //
17
18 //!Internet
19 /*@file:        IntSettingsPresentationModel.cpp
20  *@brief:       Used to define SettingsManager
21  */
22
23 #include <cstdlib>
24 #include "IntCommonLib.h"
25 #include "IntSettingPresentationModel.h"
26
27 using namespace Tizen::App;
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Collection;
30 using namespace Tizen::Io;
31 using namespace Tizen::Ui::Controls;
32 using namespace Tizen::Web::Controls;
33
34 SettingPresentationModel* SettingPresentationModel::__pSettingsPresentationModel = null;
35
36 SettingPresentationModel::SettingPresentationModel(void)
37 {
38         __listenerList.Construct();
39         SetDefaultValues();
40         __isPrivateOn = false;
41 }
42
43 SettingPresentationModel::SettingPresentationModel(const SettingPresentationModel& settingModelObj)
44 {
45
46 }
47
48 SettingPresentationModel& SettingPresentationModel::operator=(const SettingPresentationModel& settingModelObj)
49 {
50         return *this;
51 }
52
53 SettingPresentationModel::~SettingPresentationModel(void)
54 {
55
56 }
57
58 void
59 SettingPresentationModel::SetDefaultValues(void)
60 {
61         //__homePage = CommonUtil::GetString(L"IDS_EMPTY_PAGE");
62         __homePage = (L"IDS_BR_BODY_MOST_VISITED_SITES");
63         __defaultViewLevel = L"IDS_BR_BODY_FIT_TO_WIDTH"; // IDS_FIT_TO_WIDTH
64         __runJsEnabled = true;
65         __displayImages = true;
66         __html5Videos = true;
67         __wordWrap = true;
68         __blockPopUp = true;
69         __rememberFormData = true;
70         __rememberPassword = true;
71         __cookies = true;
72         __savePassword = CommonUtil::GetString(L"IDS_BR_BODY_ALWAYS_ASK");              // IDS_ALWAYS_ASK
73         __securityWarnings = true;
74         __searchEngine = L"Yahoo";              //CommonUtil::GetString(L"IDS_BR_BODY_YAHOO");
75         __caseSensitive = false;
76         __runReader = true;
77         __fontSize = 24;
78
79         __setting.SetInputStyle(INPUT_STYLE_OVERLAY);
80         __setting.SetAutoImageLoadEnabled(__displayImages);
81         __setting.SetJavascriptEnabled(__runJsEnabled);
82         __setting.SetJavaScriptPopupEnabled(__blockPopUp);
83         __setting.SetAutoFormDataShowEnabled(__rememberFormData);
84         __setting.SetAutoLoginFormFillEnabled(__rememberPassword);
85
86         if (__defaultViewLevel.CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
87         {
88                 __setting.SetAutoFittingEnabled(true);
89         }
90         else if (__defaultViewLevel.CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
91         {
92                 __setting.SetAutoFittingEnabled(false);
93         }
94         if (__securityWarnings == true)
95         {
96                 __setting.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
97         }
98         else
99         {
100                 __setting.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
101         }
102 }
103
104 void
105 SettingPresentationModel::CreateInstance(void)
106 {
107         if (__pSettingsPresentationModel == null)
108                 __pSettingsPresentationModel = new(std::nothrow) SettingPresentationModel();
109         result r = __pSettingsPresentationModel->Construct();
110         if (IsFailed(r))
111         {
112                 delete __pSettingsPresentationModel;
113                 __pSettingsPresentationModel = null;
114                 return;
115         }
116         std::atexit(DestroyInstance);
117 }
118
119 SettingPresentationModel*
120 SettingPresentationModel::GetInstance(void)
121 {
122         if (__pSettingsPresentationModel == null)
123         {
124                 CreateInstance();
125         }
126         return __pSettingsPresentationModel;
127 }
128
129 void
130 SettingPresentationModel::DestroyInstance(void)
131 {
132         if (__pSettingsPresentationModel)
133         {
134                 delete __pSettingsPresentationModel;
135                 __pSettingsPresentationModel = null;
136         }
137 }
138
139 result
140 SettingPresentationModel::LoadRegistry(void)
141 {
142         AppLog("SettingPresentationModel::LoadRegistry entered");
143         result r = E_FAILURE;
144
145         SetDefaultValues();
146         for (int settingValueName = REGISTRY_SETTING_HOMEPAGE; settingValueName < MAX_REGISTRY_SETTING; settingValueName++)
147         {
148                 r = AppRegistry::GetInstance()->Get(__entry[settingValueName], __values[settingValueName]);
149                 if (r != E_SUCCESS && r != E_KEY_NOT_FOUND)
150                 {
151                         AppLog("Registry Load failed with result %s settingValueName %d", GetErrorMessage(r),settingValueName);
152                         return r;
153                 }
154         }
155         if (__values[REGISTRY_SETTING_HOMEPAGE].CompareTo(L"") != 0)
156         {
157                 __homePage = __values[REGISTRY_SETTING_HOMEPAGE];
158                 AppLog("homepage Loading from registry %ls",__homePage.GetPointer());
159         }
160         if (__values[REGISTRY_SETTING_DEFAULT_VIEW].CompareTo(L"") != 0)
161         {
162                 __defaultViewLevel = __values[REGISTRY_SETTING_DEFAULT_VIEW];
163         }
164         if (__values[REGISTRY_SETTING_RUN_JAVASCRIPT].CompareTo(L"") != 0)
165         {
166                 __runJsEnabled = Boolean::Parse(__values[REGISTRY_SETTING_RUN_JAVASCRIPT], false);
167                 AppLogDebug("LoadRegistry __runJsEnabled %d",__runJsEnabled);
168         }
169         if (__values[REGISTRY_SETTING_DISPLAY_IMAGES].CompareTo(L"") != 0)
170         {
171                 __displayImages = Boolean::Parse(__values[REGISTRY_SETTING_DISPLAY_IMAGES], false);
172                 AppLogDebug("LoadRegistry __displayImages %d",__displayImages);
173         }
174         if (__values[REGISTRY_SETTING_HTML5_VIDEOS].CompareTo(L"") != 0)
175         {
176                 __html5Videos = Boolean::Parse(__values[REGISTRY_SETTING_HTML5_VIDEOS], false);
177                 AppLogDebug("LoadRegistry __html5Videos %d",__html5Videos);
178         }
179         if (__values[REGISTRY_SETTING_WORD_WRAPPING].CompareTo(L"") != 0)
180         {
181                 __wordWrap = Boolean::Parse(__values[REGISTRY_SETTING_WORD_WRAPPING], false);
182                 AppLogDebug("LoadRegistry __wordWrap %d",__wordWrap);
183         }
184         if (__values[REGISTRY_SETTING_BLOCK_POPUP].CompareTo(L"") != 0)
185         {
186                 __blockPopUp = Boolean::Parse(__values[REGISTRY_SETTING_BLOCK_POPUP], false);
187                 AppLogDebug("LoadRegistry __blockPopUp %d",__blockPopUp);
188         }
189         if (__values[REGISTRY_SETTING_ACCEPT_COOKIES].CompareTo(L"") != 0)
190         {
191                 __cookies = Boolean::Parse(__values[REGISTRY_SETTING_ACCEPT_COOKIES], false);
192                 AppLogDebug("LoadRegistry __cookies %d",__cookies);
193         }
194         if (__values[REGISTRY_SETTING_AUTOSAVE_ID_PASSWORD].CompareTo(L"") != 0)
195         {
196                 __savePassword = __values[REGISTRY_SETTING_AUTOSAVE_ID_PASSWORD];
197         }
198         if (__values[REGISTRY_SETTING_SHOW_SECURITY_WARNINGS].CompareTo(L"") != 0)
199         {
200                 __securityWarnings = Boolean::Parse(__values[REGISTRY_SETTING_SHOW_SECURITY_WARNINGS], false);
201                 AppLogDebug("LoadRegistry __securityWarnings %d",__securityWarnings);
202         }
203         if (__values[REGISTRY_SETTING_SEARCH_ENGINE].CompareTo(L"") != 0)
204         {
205                 __searchEngine = __values[REGISTRY_SETTING_SEARCH_ENGINE];
206         }
207         if (__values[REGISTRY_SETTING_CASE_SENSITIVE].CompareTo(L"") != 0)
208         {
209                 __caseSensitive = Boolean::Parse(__values[REGISTRY_SETTING_CASE_SENSITIVE], false);
210                 AppLogDebug("LoadRegistry __caseSensitive %d",__caseSensitive);
211         }
212         if (__values[REGISTRY_SETTING_RUN_READER].CompareTo(L"") != 0)
213         {
214                 __runReader = Boolean::Parse(__values[REGISTRY_SETTING_RUN_READER], false);
215                 AppLogDebug("LoadRegistry __runReader %d",__runReader);
216         }
217         if (__values[REGISTRY_SETTING_READER_FONT_SIZE].CompareTo(L"") != 0)
218         {
219                 Integer::Parse(__values[REGISTRY_SETTING_READER_FONT_SIZE], (int&)__fontSize);
220         }
221         if (__values[REGISTRY_SETTING_REMEMBER_FORM_DATA].CompareTo(L"") != 0)
222         {
223                 __rememberFormData = Boolean::Parse(__values[REGISTRY_SETTING_REMEMBER_FORM_DATA], false);
224                 AppLogDebug("LoadRegistry form data %d",__rememberFormData);
225         }
226         if (__values[REGISTRY_SETTING_REMEMBER_PASSWORD].CompareTo(L"") != 0)
227         {
228                 __rememberPassword = Boolean::Parse(__values[REGISTRY_SETTING_REMEMBER_PASSWORD], false);
229                 AppLogDebug("LoadRegistry form password %d",__rememberPassword);
230         }
231         //
232         for (int index = REGISTRY_SETTING_HOMEPAGE; index < MAX_REGISTRY_SETTING; index++)
233         {
234                 AppLogDebug("registry loaded value :%ls at index %d", __values[index].GetPointer(), index);
235         }
236         __setting.SetInputStyle(INPUT_STYLE_OVERLAY);
237         __setting.SetAutoImageLoadEnabled(__displayImages);
238         __setting.SetJavascriptEnabled(__runJsEnabled);
239         __setting.SetJavaScriptPopupEnabled(__blockPopUp);
240         __setting.SetAutoFormDataShowEnabled(__rememberFormData);
241         __setting.SetAutoLoginFormFillEnabled(__rememberPassword);
242
243         if (__securityWarnings == true)
244         {
245                 __setting.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
246         }
247         else
248         {
249                 __setting.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
250         }
251         __favouriteURL.Clear();
252         __favouriteURL = L"";
253         r = AppRegistry::GetInstance()->Get(__entry[REGISTRY_SETTING_FAVORITE_URL_VALUE], __favouriteURL);
254         AppLog("__favouriteURL taken from registry is %ls",__favouriteURL.GetPointer());
255
256         if (r != E_SUCCESS && r != E_KEY_NOT_FOUND)
257         {
258                 AppLogDebug("Registry Load failed with result %s", GetErrorMessage(r));
259                 return r;
260         }
261
262         return E_SUCCESS;
263 }
264
265 result
266 SettingPresentationModel::ResetRegistry(void)
267 {
268         result r = E_FAILURE;
269
270         AppLogDebug("SettingsManager::ResetRegistry");
271         for (int index = REGISTRY_SETTING_INVALID+1; index < MAX_REGISTRY_SETTING; index++)
272         {
273                 r = AppRegistry::GetInstance()->Remove(__entry[index]);
274                 AppLogDebug("Registry Remove result %s",GetErrorMessage(r));
275         }
276
277         AppRegistry::GetInstance()->Save();
278
279         for (int index = REGISTRY_SETTING_HOMEPAGE; index < MAX_REGISTRY_SETTING; index++)
280         {
281                 __values[index] = L"";
282         }
283
284         SetDefaultValues();
285         for (int index = 0; index < __listenerList.GetCount(); index++)
286         {
287                 ISettingChangeEventListener* pSettingsListener = static_cast< ISettingChangeEventListener* >(__listenerList.GetAt(index));
288                 if (pSettingsListener)
289                         pSettingsListener->OnSettingsReset();
290         }
291
292         return E_SUCCESS;
293 }
294
295 void
296 SettingPresentationModel::ClearCache(void)
297 {
298         for (int index = 0; index < __listenerList.GetCount(); index++)
299         {
300                 ISettingChangeEventListener* pSettingsListener = static_cast< ISettingChangeEventListener* >(__listenerList.GetAt(index));
301                 if (pSettingsListener)
302                         pSettingsListener->OnClearCache();
303         }
304 }
305
306 void
307 SettingPresentationModel::ClearCookie(void)
308 {
309         for (int index = 0; index < __listenerList.GetCount(); index++)
310         {
311                 ISettingChangeEventListener* pSettingsListener = static_cast< ISettingChangeEventListener* >(__listenerList.GetAt(index));
312                 if (pSettingsListener)
313                         pSettingsListener->OnClearCookie();
314         }
315 }
316
317 void
318 SettingPresentationModel::ClearFormData(void)
319 {
320         for (int index = 0; index < __listenerList.GetCount(); index++)
321         {
322                 ISettingChangeEventListener* pSettingsListener = static_cast< ISettingChangeEventListener* >(__listenerList.GetAt(index));
323                 if (pSettingsListener)
324                         pSettingsListener->OnClearFormData();
325         }
326 }
327
328 void
329 SettingPresentationModel::ClearPasswords(void)
330 {
331         for (int index = 0; index < __listenerList.GetCount(); index++)
332         {
333                 ISettingChangeEventListener* pSettingsListener = static_cast< ISettingChangeEventListener* >(__listenerList.GetAt(index));
334                 if (pSettingsListener)
335                         pSettingsListener->OnClearPasswords();
336         }
337 }
338
339 result
340 SettingPresentationModel::Construct(void)
341 {
342         result r = E_FAILURE;
343
344         for (int index = REGISTRY_SETTING_HOMEPAGE; index < MAX_REGISTRY_SETTING; index++)
345         {
346                 __values[index] = L"";
347         }
348
349         __entry[REGISTRY_SETTING_HOMEPAGE] = L"homePage";
350         __entry[REGISTRY_SETTING_DEFAULT_VIEW] = L"defaultViewLevel";
351         __entry[REGISTRY_SETTING_RUN_JAVASCRIPT] = L"runJs";
352         __entry[REGISTRY_SETTING_DISPLAY_IMAGES] = L"displayImages";
353         __entry[REGISTRY_SETTING_HTML5_VIDEOS] = L"html5Videos";
354         __entry[REGISTRY_SETTING_WORD_WRAPPING] = L"wordWrap";
355         __entry[REGISTRY_SETTING_BLOCK_POPUP] = L"blockPopUp";
356         __entry[REGISTRY_SETTING_ACCEPT_COOKIES] = L"cookies";
357         __entry[REGISTRY_SETTING_AUTOSAVE_ID_PASSWORD] = L"savePassword";
358         __entry[REGISTRY_SETTING_SHOW_SECURITY_WARNINGS] = L"securityWarnings";
359         __entry[REGISTRY_SETTING_SEARCH_ENGINE] = L"searchEngine";
360         __entry[REGISTRY_SETTING_CASE_SENSITIVE] = L"caseSensitive";
361         __entry[REGISTRY_SETTING_RUN_READER] = L"runReader";
362         __entry[REGISTRY_SETTING_READER_FONT_SIZE] = L"fontSize";
363         __entry[REGISTRY_SETTING_FAVORITE_URL_VALUE] = L"Favourite";
364         __entry[REGISTRY_SETTING_REMEMBER_FORM_DATA] = L"formData";
365         __entry[REGISTRY_SETTING_REMEMBER_PASSWORD] = L"rememberPassword";
366
367         r = LoadRegistry();
368         return E_SUCCESS;
369 }
370
371 result
372 SettingPresentationModel::SetValue(const int settingValueName, const String& val)
373 {
374         result r = E_FAILURE;
375
376         AppLogDebug("SettingsManager::SetValue settingValueName:%d val %ls", settingValueName, val.GetPointer());
377         if (__values[settingValueName] == L"")
378         {
379                 AppLogDebug("adding the new (std::nothrow) entry into registry");
380                 r = AppRegistry::GetInstance()->Add(__entry[settingValueName], val);
381         }
382         else
383         {
384                 AppLogDebug("modifying entry into registry");
385                 r = AppRegistry::GetInstance()->Set(__entry[settingValueName], val);
386         }
387         TryCatch(!IsFailed(r),,"Adding into registry failed %s",GetErrorMessage(r));
388
389         r = AppRegistry::GetInstance()->Save();
390         TryCatch(!IsFailed(r),,"Save Failed with error %s",GetErrorMessage(r));
391
392         for (int index = 0; index < __listenerList.GetCount(); index++)
393         {
394                 ISettingChangeEventListener* pSettingsListener = static_cast< ISettingChangeEventListener* >(__listenerList.GetAt(index));
395                 if (pSettingsListener)
396                         pSettingsListener->OnSettingsChange(settingValueName);
397         }
398
399         __values[settingValueName] = val;
400
401         CATCH:
402         return r;
403
404 }
405
406 result
407 SettingPresentationModel::SetFavoriteValue(const Tizen::Base::String& val)
408 {
409         result r = E_FAILURE;
410
411         if (__favouriteURL == L"")
412                 r = AppRegistry::GetInstance()->Add(__entry[REGISTRY_SETTING_FAVORITE_URL_VALUE], val);
413         else
414                 r = AppRegistry::GetInstance()->Set(__entry[REGISTRY_SETTING_FAVORITE_URL_VALUE], val);
415         TryCatch(!IsFailed(r),,"registry set failed with error %s",GetErrorMessage(r));
416         r = AppRegistry::GetInstance()->Save();
417         TryCatch(!IsFailed(r),,"registry set failed with error %s",GetErrorMessage(r));
418         __favouriteURL.Clear();
419         __favouriteURL.Append(val);
420
421         CATCH:
422         return r;
423 }
424
425 String
426 SettingPresentationModel::GetFavoriteUrl(void)
427 {
428         __favouriteURL.Clear();
429         __favouriteURL =  L"";
430         AppRegistry::GetInstance()->Get(__entry[REGISTRY_SETTING_FAVORITE_URL_VALUE], __favouriteURL);
431
432         return __favouriteURL;
433 }
434
435 void
436 SettingPresentationModel::AddSettingsEventListener(const ISettingChangeEventListener& listener)
437 {
438         __listenerList.Add(listener);
439 }
440
441 void
442 SettingPresentationModel::RemoveSettingsEventListener(ISettingChangeEventListener& listener)
443 {
444         __listenerList.Remove(listener, false);
445 }
446
447 void
448 SettingPresentationModel::SetHomepage(const String& homePage)
449 {
450         __homePage.Clear();
451         __homePage.Append(homePage);
452         AppLog("SettingPresentationModel::SetHomepage %ls",__homePage.GetPointer());
453         SetValue((int) REGISTRY_SETTING_HOMEPAGE, __homePage);
454 }
455
456 String
457 SettingPresentationModel::GetHomepage(void)
458 {
459         return __homePage;
460 }
461
462 void
463 SettingPresentationModel::SetDefaultView(const String& viewLevel)
464 {
465         __defaultViewLevel = viewLevel;
466         //CommonUtil::GetString(L"IDS_FIT_TO_WIDTH")
467         if (__defaultViewLevel.CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
468         {
469                 __setting.SetAutoFittingEnabled(true);
470         }
471         else if (__defaultViewLevel.CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
472         {
473                 __setting.SetAutoFittingEnabled(false);
474         }
475
476         SetValue((int) REGISTRY_SETTING_DEFAULT_VIEW, viewLevel);
477 }
478
479 String
480 SettingPresentationModel::GetDefaultView(void)
481 {
482         return __defaultViewLevel;
483 }
484
485 void
486 SettingPresentationModel::SetRunJavascriptEnabled(bool runJsEnabled)
487 {
488         __runJsEnabled = runJsEnabled;
489         SetValue((int) REGISTRY_SETTING_RUN_JAVASCRIPT, Boolean::ToString(runJsEnabled));
490         __setting.SetJavascriptEnabled(runJsEnabled);
491 }
492
493 bool
494 SettingPresentationModel::IsRunJavascriptEnabled(void)
495 {
496         return __runJsEnabled;
497 }
498
499 void
500 SettingPresentationModel::SetDisplayImagesEnabled(bool displayImages)
501 {
502         __displayImages = displayImages;
503         SetValue((int) REGISTRY_SETTING_DISPLAY_IMAGES, Boolean::ToString(displayImages));
504         __setting.SetAutoImageLoadEnabled(__displayImages);
505 }
506
507 bool
508 SettingPresentationModel::IsDisplayImagesEnabled(void)
509 {
510         return __displayImages;
511 }
512
513 void
514 SettingPresentationModel::SetHtml5VideosEnabled(bool html5Videos)
515 {
516         __html5Videos = html5Videos;
517         SetValue((int) REGISTRY_SETTING_HTML5_VIDEOS, Boolean::ToString(html5Videos));
518 }
519
520 bool
521 SettingPresentationModel::IsHtml5VideosEnabled(void)
522 {
523         return __html5Videos;
524 }
525
526 void
527 SettingPresentationModel::SetWordWrapEnabled(bool wordWrap)
528 {
529         __wordWrap = wordWrap;
530         SetValue((int) REGISTRY_SETTING_WORD_WRAPPING, Boolean::ToString(wordWrap));
531 }
532
533 bool
534 SettingPresentationModel::IsWordWrapEnabled(void)
535 {
536         return __wordWrap;
537 }
538
539 void
540 SettingPresentationModel::SetBlockPopUp(bool blockPopUp)
541 {
542         __blockPopUp = blockPopUp;
543         SetValue((int) REGISTRY_SETTING_BLOCK_POPUP, Boolean::ToString(blockPopUp));
544         __setting.SetJavaScriptPopupEnabled(__blockPopUp);
545 }
546
547 bool
548 SettingPresentationModel::IsBlockPopUp(void)
549 {
550         return __blockPopUp;
551 }
552
553 void
554 SettingPresentationModel::SetCookiesEnabled(bool cookiesEnabled)
555 {
556         __cookies = cookiesEnabled;
557         SetValue((int) REGISTRY_SETTING_ACCEPT_COOKIES, Boolean::ToString(cookiesEnabled));
558 }
559
560 bool
561 SettingPresentationModel::IsCookiesEnabled(void)
562 {
563         return __cookies;
564 }
565
566 void
567 SettingPresentationModel::SetRememberFormData(bool formData)
568 {
569         __rememberFormData = formData;
570         SetValue((int) REGISTRY_SETTING_REMEMBER_FORM_DATA, Boolean::ToString(__rememberFormData));
571         __setting.SetAutoFormDataShowEnabled(__rememberFormData);
572 }
573
574 bool
575 SettingPresentationModel::IsRememberFormData(void)
576 {
577         return __rememberFormData;
578 }
579
580 void SettingPresentationModel::SetRememberPassword(bool rememberPassword)
581 {
582         __rememberPassword = rememberPassword;
583         SetValue((int) REGISTRY_SETTING_REMEMBER_PASSWORD, Boolean::ToString(__rememberPassword));
584         __setting.SetAutoLoginFormFillEnabled(__rememberPassword);
585 }
586
587 bool SettingPresentationModel::IsRememberPassword(void)
588 {
589         return __rememberPassword;
590 }
591
592 void
593 SettingPresentationModel::SetSavePassword(const String& savePassword)
594 {
595         __savePassword = savePassword;
596         SetValue((int) REGISTRY_SETTING_AUTOSAVE_ID_PASSWORD, savePassword);
597 }
598
599 String
600 SettingPresentationModel::GetSavePassword(void)
601 {
602         return __savePassword;
603 }
604
605 void
606 SettingPresentationModel::SetSecurityWarningsEnabled(bool securityWarnings)
607 {
608         __securityWarnings = securityWarnings;
609         SetValue((int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS, Boolean::ToString(securityWarnings));
610         if (__securityWarnings == true)
611         {
612                 __setting.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
613         }
614         else
615         {
616                 __setting.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
617         }
618 }
619
620 bool
621 SettingPresentationModel::IsSecurityWarningsEnabled(void)
622 {
623         return __securityWarnings;
624 }
625
626 void
627 SettingPresentationModel::SetSearchEngine(const String& searchEngine)
628 {
629         __searchEngine = searchEngine;
630         SetValue((int) REGISTRY_SETTING_SEARCH_ENGINE, searchEngine);
631 }
632
633 String
634 SettingPresentationModel::GetSearchEngine(void)
635 {
636         return __searchEngine;
637 }
638
639 void
640 SettingPresentationModel::SetCaseSensitiveEnabled(bool caseSensitive)
641 {
642         __caseSensitive = caseSensitive;
643         SetValue((int) REGISTRY_SETTING_CASE_SENSITIVE, Boolean::ToString(caseSensitive));
644 }
645
646 bool
647 SettingPresentationModel::IsCaseSensitiveEnabled(void)
648 {
649         return __caseSensitive;
650 }
651
652 void
653 SettingPresentationModel::SetRunReaderEnabled(bool runReader)
654 {
655         __runReader = runReader;
656         SetValue((int) REGISTRY_SETTING_RUN_READER, Boolean::ToString(runReader));
657 }
658
659 bool
660 SettingPresentationModel::IsRunReaderEnabled(void)
661 {
662         return __runReader;
663 }
664
665 void
666 SettingPresentationModel::SetReaderFontSize(int fontSize)
667 {
668         __fontSize = fontSize;
669         SetValue((int) REGISTRY_SETTING_READER_FONT_SIZE, Integer::ToString(__fontSize));
670 }
671
672 int
673 SettingPresentationModel::GetReaderFontSize(void)
674 {
675         return __fontSize;
676 }
677
678 String
679 SettingPresentationModel::GetSearchUrl(const String& searchText)
680 {
681         String searchStr = L"";
682         if (GetSearchEngine().CompareTo(L"Yahoo") == 0)
683         {
684                 searchStr.Append(L"http://search.yahoo.com/search?p=");
685                 searchStr.Append(searchText);
686         }
687         else if (GetSearchEngine().CompareTo(L"Naver") == 0)
688         {
689                 searchStr.Append(L"http://search.naver.com/search.naver?query=");
690                 searchStr.Append(searchText);
691         }
692         else if (GetSearchEngine().CompareTo(L"Google") == 0)
693         {
694                 searchStr.Append(L"http://www.google.com/search?q=");
695                 searchStr.Append(searchText);
696         }
697         return searchStr;
698 }
699
700 Tizen::Web::Controls::WebSetting&
701 SettingPresentationModel::GetWebSettings(void)
702 {
703         return __setting;
704 }
705
706 void
707 SettingPresentationModel::SetPrivateOn(bool isPrivateOn)
708 {
709         __isPrivateOn = isPrivateOn;
710         return;
711 }
712
713 bool
714 SettingPresentationModel::GetPrivateOn(void)
715 {
716         return __isPrivateOn;
717 }