Fixed Nabi Issues
[apps/osp/Internet.git] / src / IntMainForm.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 //!Internet MainForm class
18 /*@file:        MainForm.cpp
19  *@brief:       The %MainForm provides the common functionalities for the Main View of the Browser including the addressbar,
20  *                      loading,handling events etc.
21  */
22
23 #include <FApp.h>
24 #include <FGraphics.h>
25 #include <FMedia.h>
26 #include <FUi.h>
27 #include <FContent.h>
28 #include <FShell.h>
29 //#include <FShellNotificationManager.h>
30
31 #include "IntBookmarkData.h"
32 #include "IntBookmarkPresentationModel.h"
33 #include "IntCommonLib.h"
34 #include "IntFaviconManager.h"
35 #include "IntInternetApp.h"
36 #include "IntMainForm.h"
37 #include "IntSceneRegister.h"
38 #include "IntSettingPresentationModel.h"
39
40 using namespace Tizen::App;
41 using namespace Tizen::Base;
42 using namespace Tizen::Base::Collection;
43 using namespace Tizen::Base::Runtime;
44 using namespace Tizen::Base::Utility;
45 using namespace Tizen::Graphics;
46 using namespace Tizen::Io;
47 using namespace Tizen::Locales;
48 using namespace Tizen::Media;
49 using namespace Tizen::Shell;
50 using namespace Tizen::Ui;
51 using namespace Tizen::Ui::Controls;
52 using namespace Tizen::Content;
53 using namespace Tizen::Ui::Scenes;
54 using namespace Tizen::System;
55 using namespace Tizen::Web;
56 using namespace Tizen::Web::Controls;
57
58 static const wchar_t* IDB_SEARCH_INPUT_FIELD_BG = L"I01_toolbar_input_field.9.png";
59 static const wchar_t* IDB_FINDWORD_INPUT_FIELD_BG = L"I01_toolbar_input_field_findword.9.png";
60 static const wchar_t* IDB_BTN_BACK = L"I01_icon_Back.png";
61 static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
62 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
63 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
64 static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
65 static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
66 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
67 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
68 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
69 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
70 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
71 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
72 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
73 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
74 static const wchar_t* IDS_APPID = L"AppID";
75 static const wchar_t* IDS_KEY = L"key";
76 static const wchar_t* IDS_VALUE = L"value";
77 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
78 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
79 //static const wchar_t* IDB_ADDRESS_BAR_BACKGROUND = L"I01_toolbar_bg_02.9.png";
80
81 const int IDA_BACKBTN_CLICKED = 101;
82 const int IDA_BOOKMARKBTN_CLICKED = 102;
83 const int IDA_MOREBTN_CLICKED = 103;
84 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
85 const int IDA_NEWWINDOWBTN_CLICKED = 105;
86 const int IDA_FORWARD_CLICKED = 106;
87 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
88 const int IDA_SHARE_CLICKED = 108;
89 const int IDA_FINDONPAGE_CLICKED = 109;
90 const int IDA_PRIVATEON_CLICKED = 110;
91 const int IDA_SETTINGS_CLICKED = 111;
92 const int IDA_READER_CLOSE_CLICKED = 112;
93 const int IDA_SMALLFONT_BTN_CLICKED = 113;
94 const int IDA_LARGEFONT_BTN_CLICKED = 114;
95 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
96 const int IDA_HISTORY_CLICKED = 116;
97 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
98 const int IDA_ADD_TO_HOME_CLICKED = 118;
99 const int IDA_SAVED_PAGES_CLICKED = 119;
100 const int IDA_DESKTOP_VIEW_CLICKED = 120;
101 const int IDA_SAVE_CLICKED = 121;
102 const int IDA_PRINT_CLICKED = 122;
103
104 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
105 const int IDA_FINDWORD_NEXT_CLICKED = 202;
106 const int IDA_FINDWORD_PREV_CLICKED = 203;
107 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
108 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
109
110 const int IDA_COPY_IMAGE_CLICKED = 206;
111 const int IDA_VIEW_IMAGE_CLICKED = 207;
112 const int IDA_SAVE_IMAGE_CLICKED = 208;
113 const int IDA_SHARE_IMAGE_CLICKED = 209;
114
115 const int IDA_COPY_TEXT_CLICKED = 210;
116 const int IDA_PASTE_TEXT_CLICKED = 211;
117 const int IDA_FIND_TEXT__CLICKED = 212;
118 const int IDA_SHARE_TEXT_CLICKED = 213;
119
120 const int IDA_GO_BACK = 214;
121 const int IDA_GO_FORWARD = 215;
122 const int IDA_REFRESH_BTN_CLICKED = 216;
123 const int IDA_STOP_BTN_CLICKED = 217;
124 const int IDA_CLEAR_URL = 218;
125 const int IDA_READER_BTN_CLICKED = 219;
126
127
128 const int IDA_HYPERLINK_OPEN_CLICKED = 220;
129 const int IDA_HYPERLINK_COPY_LINK_CLICKED = 221;
130 const int IDA_HYPERLINK_SAVE_IMAGE_CLICKED = 222;
131 const int IDA_HYPERLINK_SHARE_IMAGE_CLICKED = 223;
132
133 const int IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED = 224;
134
135 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
136
137 const int MainForm::IDA_FORMAT_BITMAP = 500;
138 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
139 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
140 const int MainForm::IDA_FORMAT_URL_STRING = 503;
141 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
142
143 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
144 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
145 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
146
147 static const wchar_t* APPCONTROL_OPERATION_ID_IMAGE_VIEWER = L"http://tizen.org/appcontrol/operation/view";
148 MainForm::MainForm(void)
149 {
150         __isLongPressedDone = false;
151         __pHistory = null;
152         __pAddressbar = null;
153         //      __pMostVisitedSitesPanel = null;
154         __pMostVisitedListView = null;
155         __pFooterPanel = null;
156         __pHitElementResult = null;
157         __pWindowInfo = null;
158         __pWebViewer = null;
159         __pImageMenu = null;
160         __pOptionMenu = null;
161         __pFindWordControl = null;
162         __pFindWordPanelLeftToRight = null;
163         __pFindWordPanelRightToLeft = null;
164         __pFindWordBgLabel = null;
165         __pFindWordBgLabelRightToLeft = null;
166         __pFindWordEditField = null;
167         __pFindWordEditFieldRightToLeft = null;
168         __pFindWordClear = null;
169         __pFindWordClearRightToLeft = null;
170         __pFindWordCountLabel = null;
171         __pFindWordClearRightToLeft = null;
172         __pFindWordNext = null;
173         __pFindWordPrev = null;
174         __previousZoomLevel = 1.0;
175         __pSaveImage = null;
176         __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
177         __displayUrl = L"";
178         __editTextUrl = L"";
179         __currentSearchStr = L"";
180         __currentSelectedStr = L"";
181         __maxOccurrances = 0;
182         __currentWordIndex = 0;
183         __distanceMoved = 0;
184         __isLoaded = false;
185         //__inputEventToBeSupressed = false;
186         __isLoadingData = false;
187         __isLoadingCompleted = false;
188         __progressPercentage = 0;
189         __touchPoint1 = Point(-1,-1);
190         __touchPoint2 = Point(-1,-1);
191         __longPressPoint = Point(-1,-1);
192         __pWebReader = null;
193         //      __pReaderPopup = null;
194         __pReaderData = null;
195         __pPopUp = null;
196         __pReaderCloseBtn = null;
197         //__pNewWindowButton = null;
198         __pMoreButton = null;
199         __pMultiWindowButton = null;
200         __pArticleReaderPanel = null;
201         __pBlankPanel = null;
202         __pArticleReaderLabel = null;
203         __webControlHeight = 0;
204         __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
205         __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
206         __pMostVisitedSites = null;
207         __pFooterUrlField = null;
208         __pGoBackBtn = null;
209         __pGoForwardBtn = null;
210         __pRefreshBtn = null;
211         __pProgressbarLabel = null;
212         __pFooterLabel = null;
213         __pStopBtn = null;
214         __pClearBtn = null;
215         __pReaderBtn = null;
216         __isKeypadOpened = false;
217         __fontSize = 44;
218         __pNotification = null;
219 }
220
221 MainForm::~MainForm(void)
222 {
223         SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
224
225         if(__pAddressbar)
226         {
227                 __pAddressbar->SetAddressbarEventListener(null);
228         }
229
230         if(__pHistory != null)
231         {
232                 delete __pHistory;
233                 __pHistory = null;
234         }
235
236         if (__pReaderData != null)
237         {
238                 delete __pReaderData;
239                 __pReaderData = null;
240         }
241
242         if (__pPopUp != null)
243         {
244                 delete __pPopUp;
245                 __pPopUp = null;
246         }
247
248         if (__pHitElementResult != null)
249         {
250                 delete __pHitElementResult;
251                 __pHitElementResult = null;
252         }
253         if(__pOptionMenu)
254         {
255                 delete __pOptionMenu;
256                 __pOptionMenu = null;
257         }
258
259         String* pSelectedScene = NULL;
260         Object* pValue = NULL;
261         MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
262         pSelectedScene = (String*) pValue;
263
264         /*if (pSelectedScene != null)
265         {
266                 delete pSelectedScene;
267         }
268         MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
269 }
270
271 bool
272 MainForm::Initialize(void)
273 {
274         Construct(L"IDL_FORM");
275
276 //      SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_FOOTER);
277         return true;
278 }
279
280 result
281 MainForm::OnInitializing(void)
282 {
283         AppLog("get client area width = %d",GetClientAreaBounds().width);
284         AppLog("get client area height = %d",GetClientAreaBounds().height);
285         const int WIDTH_CONTEXT_MENU_BUTTON = 336;
286         const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
287
288         __fontSize = CommonUtil::GetFontSize();
289         Panel* pFooterPanel = null;
290
291         __pSaveImage = new Image();
292         __pSaveImage->Construct();
293
294         // Setup back event listener
295         SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
296         SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
297         AddOrientationEventListener(*this);
298
299         AppLogDebug(" MainForm::OnInitializing ended");
300         if (__pMostVisitedSites == null)
301         {
302                 __pMostVisitedSites = new(std::nothrow) ArrayList();
303                 __pMostVisitedSites->Construct();
304         }
305         HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
306
307         __pItemContext= new(std::nothrow) ListContextItem();
308         __pItemContext->Construct();
309
310         __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"),true);
311
312
313         __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
314         __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
315         __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
316
317         __pItemContextLandscape= new(std::nothrow) ListContextItem();
318         __pItemContextLandscape->Construct();
319
320         __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), true);
321         __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
322         __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
323         __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
324         SetFormMenuEventListener(this);
325         AppLog("SetFormMenuEventListener result %s",GetErrorMessage(GetLastResult()));
326         return E_SUCCESS;
327 }
328
329 result
330 MainForm::InitAddressbar(void)
331 {
332         AppLogDebug("MainForm::InitAddressbar entered");
333
334         result r = E_SUCCESS;
335
336         if (__pAddressbar != null)
337         {
338                 return E_SUCCESS;
339         }
340         __pAddressbar = new(std::nothrow) Addressbar();
341         AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
342         r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
343         if (r != E_SUCCESS)
344         {
345                 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
346                 return r;
347         }
348         __pAddressbar->SetAddressbarEventListener(this);
349         AddControl(__pAddressbar);
350         __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
351         SetControlAlwaysOnTop(*__pAddressbar, true);
352         __adressPanelPosition = __pAddressbar->GetPosition();
353
354         AppLogDebug("MainForm::InitAddressbar exit");
355
356         return E_SUCCESS;
357 }
358
359 result
360 MainForm::CreateReaderPanel(void)
361 {
362         AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
363         result r = E_FAILURE;
364         WebSetting settings;
365         Button *pSmallFontBtn = null;
366         Button *pLargeFontBtn = null;
367
368         __pBlankPanel = new (std::nothrow) Panel();
369         __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
370
371         __pArticleReaderPanel = new (std::nothrow) Panel();
372         __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
373
374         __pReaderCloseBtn =  static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
375         if (__pReaderCloseBtn)
376         {
377                 AppLogDebug("CreateReaderPanel() 6");
378                 __pReaderCloseBtn->AddActionEventListener(*this);
379                 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
380         }
381
382         __pWebReader = new (std::nothrow) Web();
383         __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
384
385         settings.SetInputStyle(INPUT_STYLE_OVERLAY);
386         settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
387
388         r = __pWebReader->SetSetting(settings);
389         if (IsFailed(r))
390                 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
391
392
393         __pArticleReaderLabel = new Label();
394         __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
395
396         __pBlankPanel->AddControl(__pArticleReaderLabel);
397         __pBlankPanel->AddControl(__pArticleReaderPanel);
398         AddControl(__pBlankPanel);
399
400         __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
401         __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
402         __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
403
404         __pArticleReaderPanel->AddControl(__pWebReader);
405         __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
406         Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
407         Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
408
409         if (pBitmap != null && pSrcBitmap != null)
410         {
411                 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
412         }
413         __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
414
415         pSmallFontBtn =  static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
416         if (pSmallFontBtn)
417         {
418                 pSmallFontBtn->AddActionEventListener(*this);
419                 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
420         }
421
422         pLargeFontBtn =  static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
423         if (pLargeFontBtn)
424         {
425                 pLargeFontBtn->AddActionEventListener(*this);
426                 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
427         }
428
429
430         if (pBitmap != null)
431         {
432                 delete pBitmap;
433                 pBitmap = null;
434         }
435         if (pSrcBitmap != null)
436         {
437                 delete pSrcBitmap;
438                 pSrcBitmap = null;
439         }
440
441         SetControlAlwaysOnTop(*__pBlankPanel, true);
442         //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
443         Invalidate(true);
444
445         return E_SUCCESS;
446 }
447
448 result
449 MainForm::InitWebControl()
450 {
451         AppLogDebug("MainForm::InitWebControl enter");
452         result r = E_SUCCESS;
453         AppLogDebug("InitWebControl");
454
455         if (__pAddressbar == null || __pFooterPanel == null)
456                 return E_FAILURE;
457
458         const int Y_WEBCONTROL_POSITION = 0;
459
460         __webControlHeight = GetHeight() - __pFooterPanel->GetHeight();
461
462         if (__pMostVisitedListView)
463         {
464                 __pMostVisitedListView->SetShowState(false);
465         }
466         if (__pWebViewer != null)
467         {
468                 AppLogDebug("Already initialized");
469                 return E_SUCCESS;
470         }
471         __pWebViewer = new(std::nothrow) Web();
472         if(__pWebViewer == NULL)
473         {
474                 AppLogDebug("Initialization failed");
475                 return E_FAILURE;
476         }
477         r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
478
479         if (IsFailed(r))
480         {
481                 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
482                 delete __pWebViewer;
483                 __pWebViewer = null;
484                 return r;
485         }
486         else
487         {
488                 r = AddControl(__pWebViewer);
489
490                 if (IsFailed(r))
491                 {
492                         delete __pWebViewer;
493                         __pWebViewer = null;
494                         AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
495                         return r;
496                 }
497                 __webControlPosition = __pWebViewer->GetPosition();
498                 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
499                 if (IsFailed(r))
500                 {
501                         AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
502                         return r;
503                 }
504
505                 __pWebViewer->SetLoadingListener(this);
506                 __pWebViewer->SetWebUiEventListenerF(this);
507                 __pWebViewer->SetWebKeypadEventListener(this);
508                 __pWebViewer->SetFocus();
509                 __pWebViewer->AddTouchEventListener(*this);
510
511                 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
512                 __pWebViewer->SetTextSearchListener(this);
513         }
514
515         AppLogDebug("MainForm :before return");
516         Invalidate(true);
517         AppLogDebug("MainForm::InitWebControl Exit");
518
519         return r;
520 }
521
522 void
523 MainForm::SetJavascriptEnabled()
524 {
525         WebSetting settings = __pWebViewer->GetSetting();
526         settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
527         __pWebViewer->SetSetting(settings);
528 }
529
530 void
531 MainForm::SetImageLoadEnabled()
532 {
533         WebSetting settings = __pWebViewer->GetSetting();
534         settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
535         __pWebViewer->SetSetting(settings);
536 }
537
538 result
539 MainForm::InitFooter(void)
540 {
541         AppLogDebug("MainForm::InitFooter entered");
542         Button* pBackButton = null;
543         Button* pBookmarkButton = null;
544         Button* pMultiWindowButton = null;
545         Bitmap *pIconBitmap = null;
546         Bitmap *pBGBitmap = null;
547         Label *pBGLabel = null;
548
549         if (__pFooterPanel == null)
550         {
551                 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
552         }
553
554         if (__pFooterPanel == null)
555         {
556                 return E_FAILURE;
557         }
558
559         SetControlAlwaysOnTop(*__pFooterPanel, true);
560
561         __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
562         if ( __pFooterLabel == NULL )
563         {
564                 return E_FAILURE;
565         }
566         //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
567         Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
568         if (pBitmap != null)
569         {
570                 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
571                 delete pBitmap;
572         }
573
574         __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
575
576         if ( __pMultiWindowButton == NULL )
577         {
578                 return E_FAILURE;
579         }
580
581
582         SetFormBackEventListener(this);
583         AppLog("SetFormBackEventListener result  %s",GetErrorMessage(GetLastResult()));
584         if (__pMultiWindowButton != null)
585         {
586                 Bitmap* pBitmap = null;
587                 Bitmap* pPressedBitmap = null;
588                 String imagePath = "I01_toolbar_icon_windows_manager_0";
589                 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
590                 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
591                 imagePath.Append(totalCount);
592                 imagePath.Append(".png");
593
594                 pressedImagePath.Append(totalCount);
595                 pressedImagePath.Append("_press.png");
596
597                 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
598                 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
599                 if ( pBitmap == null )
600                 {
601                         return E_FAILURE;
602                 }
603
604                 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
605                 if (pBitmap != null)
606                 {
607                         __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
608                         __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
609
610                         delete pBitmap;
611                 }
612
613                 __pMultiWindowButton->AddActionEventListener(*this);
614                 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
615                 if(pPressedBitmap)
616                 {
617                         delete pPressedBitmap;
618                         pPressedBitmap = null;
619                 }
620         }
621
622         if (__pMoreButton)
623         {
624                 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
625                 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
626                 if (pBitmap != null)
627                 {
628                         Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
629                         __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
630                         __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
631
632                         delete pBitmap;
633                 }
634                 __pMoreButton->AddActionEventListener(*this);
635                 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
636         }
637
638         //Add the editfield for url
639         __pFooterUrlField =  static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
640         if (__pFooterUrlField == NULL)
641         {
642                 return E_INVALID_KEY;
643         }
644
645         __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
646         __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
647         __pFooterUrlField->AddKeypadEventListener(*this);
648         __pFooterUrlField->SetPropagatedTouchEventListener(this);
649         __pFooterUrlField->AddFocusEventListener(*this);
650
651         if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
652         {
653                 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
654         }
655         else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
656         {
657                 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_BLANK_PAGE"));
658         }
659         else
660         {
661                 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
662                 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
663         }
664
665
666         //Add the go Back Button
667         __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
668         if (__pGoBackBtn == NULL)
669         {
670                 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
671                 return E_INVALID_KEY;
672         }
673         __pGoBackBtn->SetActionId(IDA_GO_BACK);
674         __pGoBackBtn->AddActionEventListener(*this);
675
676         //Add the go forward Button
677         __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
678         if (__pGoForwardBtn == NULL)
679         {
680                 AppLogDebug("Control not found returning E_INVALID_KEY");
681                 return E_INVALID_KEY;
682         }
683         __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
684         __pGoForwardBtn->AddActionEventListener(*this);
685         if (__pWebViewer && __pWebViewer->CanGoForward())
686         {
687                 SetForwardButtonEnabled(true);
688         }
689         else
690         {
691                 SetForwardButtonEnabled(false);
692         }
693
694         __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
695         if (__pRefreshBtn == NULL)
696         {
697                 AppLogDebug("Control not found returning E_INVALID_KEY");
698                 return E_INVALID_KEY;
699         }
700
701         __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
702         __pRefreshBtn->AddActionEventListener(*this);
703         __pRefreshBtn->SetShowState(true);
704
705         //Add the backround label for displaying progressbar
706         __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
707         if (__pProgressbarLabel == NULL)
708         {
709                 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
710                 return E_INVALID_KEY;
711         }
712         __pProgressbarLabel->SetShowState(false);
713
714         __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
715         if (__pStopBtn == NULL)
716         {
717                 AppLogDebug("Control not found returning E_INVALID_KEY");
718                 return E_INVALID_KEY;
719         }
720         __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
721         __pStopBtn->AddActionEventListener(*this);
722         __pStopBtn->SetShowState(false);
723
724         __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
725         if (__pClearBtn == NULL)
726         {
727                 AppLogDebug("Control not found returning E_INVALID_KEY");
728                 return E_INVALID_KEY;
729         }
730         __pClearBtn->SetActionId(IDA_CLEAR_URL);
731         __pClearBtn->AddActionEventListener(*this);
732         __pClearBtn->SetShowState(false);
733
734         __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
735         if (__pReaderBtn == NULL)
736         {
737                 AppLogDebug("Control not found returning E_INVALID_KEY");
738                 return E_INVALID_KEY;
739         }
740         __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
741         __pReaderBtn->AddActionEventListener(*this);
742         __pReaderBtn->SetShowState(false);
743
744         //      __pFooterPanel->Invalidate(true);
745         AppLogDebug("MainForm::InitFooter exit");
746         return E_SUCCESS;
747 }
748
749 result
750 MainForm::InitOptionMenu()
751 {
752         result r = E_SUCCESS;
753         bool isPrivateBrowsing = false;
754         Bitmap* pBitmap = null;
755
756         if (__pOptionMenu != null)
757         {
758                 __pOptionMenu->SetFocusable(true);
759                 __pOptionMenu->Invalidate(true);
760                 return r;
761         }
762
763         __pOptionMenu = new(std::nothrow) OptionMenu();
764         r = __pOptionMenu->Construct();
765         TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
766
767         __pOptionMenu->SetFocusable(true);
768         isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
769
770
771         if (isPrivateBrowsing == true)
772         {
773                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
774         }
775         else
776         {
777                 pBitmap  = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
778         }
779
780         r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
781
782         if ( pBitmap != NULL)
783         {
784                 __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
785                 delete pBitmap;
786         }
787         r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
788         r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
789         r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
790
791
792         __pOptionMenu->SetMaxVisibleItemsCount(6);
793         __pOptionMenu->SetShowState(false);
794         __pOptionMenu->AddActionEventListener(*this);
795         SetControlAlwaysOnTop(*__pOptionMenu, true);
796
797         CATCH:
798         return r;
799 }
800
801 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
802 {
803         result r = E_SUCCESS;
804         ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
805
806         AppLog("MainForm::InitImageContextMenu clicked on image");
807         if (__pImageMenu != null)
808         {
809                 delete __pImageMenu;
810                 __pImageMenu = null;
811         }
812         if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
813         {
814                 p.y = p.y + 54;
815         }
816
817         __pImageMenu = new (std::nothrow) ContextMenu();
818         r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
819         TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
820
821         r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
822         r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
823         r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
824         r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
825         __pImageMenu->SetMaxVisibleItemsCount(4);
826         __pImageMenu->AddActionEventListener(*this);
827         SetControlAlwaysOnTop(*__pImageMenu, true);
828         __pImageMenu->SetFocusable(true);
829
830         CATCH: return r;
831 }
832
833 result
834 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
835 {
836         result r = E_SUCCESS;
837         ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
838
839         AppLog("MainForm::InitImageContextMenu clicked on image");
840         if (__pImageMenu != null)
841         {
842                 delete __pImageMenu;
843                 __pImageMenu = null;
844         }
845
846 //      if(__pAddressbar->GetShowState() == true)
847 //              p.y = p.y + __pAddressbar->GetHeight();
848         if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
849         {
850                 p.y = p.y + 54;
851         }
852
853         __pImageMenu = new (std::nothrow) ContextMenu();
854         r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
855         TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
856
857         r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_OPEN_IN_NEW_WINDOW"),IDA_HYPERLINK_OPEN_CLICKED);
858         r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_LINK_URL"),IDA_HYPERLINK_COPY_LINK_CLICKED);
859         //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
860         r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
861
862         __pImageMenu->SetMaxVisibleItemsCount(3);
863         __pImageMenu->AddActionEventListener(*this);
864         SetControlAlwaysOnTop(*__pImageMenu, true);
865         __pImageMenu->SetFocusable(true);
866
867         CATCH: return r;
868
869 }
870
871 result
872 MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOption = false)
873 {
874         result r = E_SUCCESS;
875         ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
876
877         AppLog("MainForm::InitSelectTextContextMenu clicked on text");
878         if (__pImageMenu != null)
879         {
880                 delete __pImageMenu;
881                 __pImageMenu = null;
882         }
883
884         if(p.y < 150)
885         {
886                 p.y = p.y + 50;
887                 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
888         }
889         else
890         {
891                 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
892         }
893         __pImageMenu = new (std::nothrow) ContextMenu();
894         r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
895         TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
896
897         if(onlyPasteOption == false)
898         {
899                 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
900         }
901         if (pasteOption || onlyPasteOption)
902         {
903                 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
904         }
905         if(onlyPasteOption == false)
906         {
907                 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
908                 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
909         }
910
911         __pImageMenu->SetMaxVisibleItemsCount(3);
912         __pImageMenu->AddActionEventListener(*this);
913         SetControlAlwaysOnTop(*__pImageMenu, true);
914         __pImageMenu->SetFocusable(true);
915
916         CATCH: return r;
917
918 }
919
920 result
921 MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPasteOption = false)
922 {
923         result r = E_SUCCESS;
924         ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
925
926         AppLog("MainForm::InitSelectTextContextMenu clicked on text");
927         if (__pImageMenu != null)
928         {
929                 delete __pImageMenu;
930                 __pImageMenu = null;
931         }
932
933         if(p.y < 150)
934         {
935                 p.y = p.y + 50;
936                 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
937         }
938         else
939         {
940                 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
941         }
942         __pImageMenu = new (std::nothrow) ContextMenu();
943         r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
944         TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
945
946         if(onlyPasteOption == false)
947         {
948                 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
949         }
950         if (pasteOption || onlyPasteOption)
951         {
952                 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
953         }
954         if(onlyPasteOption == false)
955         {
956                 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
957                 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
958         }
959
960         __pImageMenu->SetMaxVisibleItemsCount(3);
961         __pImageMenu->AddActionEventListener(*this);
962         SetControlAlwaysOnTop(*__pImageMenu, true);
963         __pImageMenu->SetFocusable(true);
964
965         CATCH: return r;
966
967 }
968
969 result
970 MainForm::InitFindWordPanel(void)
971 {
972         result r = E_SUCCESS;
973         Bitmap *pIconBitmap = null;
974
975         if (__pFindWordControl != null)
976         {
977                 AppLogDebug("Findword panel already initialized");
978                 if (__pFindWordBgLabel != null)
979                 {
980                         Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
981                         if (pBitmap != null)
982                         {
983                                 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
984                                 delete pBitmap;
985                         }
986                 }
987                 if (__pFindWordBgLabelRightToLeft != null)
988                 {
989                         Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
990                         if (pBitmap != null)
991                         {
992                                 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
993                                 delete pBitmap;
994                         }
995                 }
996                 if(__pAddressbar)
997                         __pAddressbar->SetShowState(false);
998
999                 if(__isKeypadOpened == false)
1000                         __pFooterPanel->SetShowState(true);
1001                 return r;
1002         }
1003
1004         __pFindWordControl = new (std::nothrow) Panel();
1005         r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
1006         if (IsFailed(r))
1007         {
1008                 AppLogException("There is some problem in the xml file. Please check.");
1009                 return E_FAILURE;
1010         }
1011         AddControl(__pFindWordControl);
1012         __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
1013         SetControlAlwaysOnTop(*__pFindWordControl,true);
1014         __pFindWordControl->SetShowState(false);
1015         __pFindWordControl->Invalidate(false);
1016
1017         __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1018         __pFindWordPanelLeftToRight->SetShowState(true);
1019
1020         __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
1021         __pFindWordPanelRightToLeft->SetShowState(false);
1022
1023         __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
1024         if (__pFindWordBgLabel != null)
1025         {
1026                 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1027                 Rectangle pRect = pPanel1->GetBounds();
1028                 pRect.x = pRect.y = 0;
1029                 __pFindWordBgLabel->SetBounds(pRect);
1030                 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1031                 if (pBitmap != null)
1032                 {
1033                         AppLogDebug("InitFindWordPanel: Coming here");
1034                         __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1035                         delete pBitmap;
1036                 }
1037                 else
1038                 {
1039                         AppLogDebug("InitFindWordPanel: shouldn't Come here");
1040                 }
1041         }
1042
1043         __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
1044                 if (__pFindWordBgLabelRightToLeft != null)
1045                 {
1046                         Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1047                         Rectangle pRect = pPanel1->GetBounds();
1048                         pRect.x = pRect.y = 0;
1049                         __pFindWordBgLabelRightToLeft->SetBounds(pRect);
1050                         Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1051                         if (pBitmap != null)
1052                         {
1053                                 AppLogDebug("InitFindWordPanel: Coming here");
1054                                 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1055                                 delete pBitmap;
1056                         }
1057                         else
1058                         {
1059                                 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1060                         }
1061                 }
1062
1063         Button* pfindWordCancel = null;
1064         pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1065         if (pfindWordCancel == null)
1066         {
1067                 AppLogException("There is some problem in the xml file. Please check.");
1068                 return E_FAILURE;
1069         }
1070         pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1071         pfindWordCancel->AddActionEventListener(*this);
1072
1073         __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1074         if (__pFindWordClear == null)
1075         {
1076                 AppLogException("There is some problem in the xml file. Please check.");
1077                 return E_FAILURE;
1078         }
1079
1080         __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1081                 if (__pFindWordClearRightToLeft == null)
1082                 {
1083                         AppLogException("There is some problem in the xml file. Please check.");
1084                         return E_FAILURE;
1085                 }
1086
1087         __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1088         __pFindWordClear->AddActionEventListener(*this);
1089
1090         __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1091         __pFindWordClearRightToLeft->AddActionEventListener(*this);
1092
1093         __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1094         if (__pFindWordNext == null)
1095         {
1096                 AppLogException("There is some problem in the xml file. Please check.");
1097                 return E_FAILURE;
1098         }
1099
1100         __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1101         __pFindWordNext->AddActionEventListener(*this);
1102
1103         __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1104         if (__pFindWordPrev == null)
1105         {
1106                 AppLogException("There is some problem in the xml file. Please check.");
1107                 return E_FAILURE;
1108         }
1109
1110         __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1111         __pFindWordPrev->AddActionEventListener(*this);
1112
1113         __pFindWordNext->SetEnabled(false);
1114         __pFindWordPrev->SetEnabled(false);
1115
1116         __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1117         if (__pFindWordCountLabel == null)
1118         {
1119                 AppLogException("There is some problem in the xml file. Please check.");
1120                 return E_FAILURE;
1121         }
1122
1123         __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1124         if (__pFindWordCountLabel == null)
1125         {
1126                 AppLogException("There is some problem in the xml file. Please check.");
1127                 return E_FAILURE;
1128         }
1129
1130         __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1131         if (__pFindWordEditField == null)
1132         {
1133                 AppLogException("There is some problem in the xml file. Please check.");
1134                 return E_FAILURE;
1135         }
1136         __pFindWordEditField->AddTextEventListener(*this);
1137         __pFindWordEditField->AddKeypadEventListener(*this);
1138         __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1139         __pFindWordEditField->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1140
1141         __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1142         if (__pFindWordEditFieldRightToLeft == null)
1143         {
1144                 AppLogException("There is some problem in the xml file. Please check.");
1145                 return E_FAILURE;
1146         }
1147         __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1148         __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1149         __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1150         __pFindWordEditFieldRightToLeft->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1151
1152         if(__pAddressbar)
1153                 __pAddressbar->SetShowState(false);
1154
1155         if(__isKeypadOpened == false)
1156                 __pFooterPanel->SetShowState(true);
1157         return r;
1158 }
1159
1160 ListItemBase*
1161 MainForm::CreateItem (int index, int itemWidth)
1162 {
1163         Rectangle listImageRect;
1164         Rectangle pagetTitleRect;
1165         Rectangle pageURLRect;
1166         Rectangle deleteImageRect;
1167         String pageTitle(L"");
1168         String pageURL(L"");
1169         result r = E_SUCCESS;
1170         Bitmap* pListIconImage = null;
1171
1172
1173         History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1174         if(pHistory == null)
1175         {
1176                 return null;
1177         }
1178         AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1179         if ( pAppResource == NULL )
1180         {
1181                 return null;
1182         }
1183         ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1184
1185         CustomItem* pItem = new(std::nothrow) CustomItem();
1186         pageTitle = pHistory->GetHistoryTitle();
1187         pageURL = pHistory->GetHistoryUrl();
1188
1189         if (pageURL.GetLength() == 0)
1190         {
1191                 String nourl;
1192                 pAppResource->GetString(L"IDS_BR_BODY_BLANK_PAGE", nourl);
1193                 pageURL = L"<"+ nourl +">";
1194
1195         }
1196
1197         Rectangle screenBounds = GetBounds();
1198         if (pItem != null)
1199         {
1200                 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1201         }
1202         if (IsFailed(r))
1203         {
1204                 delete pItem;
1205                 return NULL;
1206         }
1207
1208
1209         Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1210
1211         if ( pBitmap != NULL)
1212         {
1213                 pListIconImage = new Bitmap();
1214                 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1215                 delete pBitmap;
1216         }
1217
1218         if(pListIconImage == null)
1219         {
1220                 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1221         }
1222
1223         if ( pListIconImage != NULL)
1224         {
1225                 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28  + (__fontSize - 44)/2 , 72, 72);
1226                 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 72  + (__fontSize - 44));
1227                 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1228
1229
1230                 if (pItem != null && pListIconImage != NULL)
1231                 {
1232                         pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1233                 }
1234         }
1235
1236         if (pageTitle.CompareTo(L"") != 0)
1237         {
1238                 if (pItem != null)
1239                 {
1240                         pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1241                 }
1242         }
1243
1244         if (pageURL.CompareTo(L"") != 0)
1245         {
1246                 if (pItem != null)
1247                 {
1248                         pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1249                 }
1250         }
1251
1252
1253         if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1254         {
1255                 if ( __pItemContext!= NULL)
1256                 {
1257                         if (pItem != null)
1258                         {
1259                                 pItem->SetContextItem(__pItemContext);
1260                         }
1261                 }
1262         }
1263         else
1264         {
1265                 if ( __pItemContextLandscape!= NULL)
1266                 {
1267                         if (pItem != null)
1268                         {
1269                                 pItem->SetContextItem(__pItemContextLandscape);
1270                         }
1271                 }
1272         }
1273         if( pListIconImage != NULL)
1274         {
1275                 delete pListIconImage;
1276                 pListIconImage = null;
1277         }
1278
1279         return pItem;
1280 }
1281
1282 bool
1283 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1284 {
1285         delete pItem;
1286         return true;
1287 }
1288
1289 int
1290 MainForm::GetItemCount (void)
1291 {
1292         if(__pMostVisitedSites != null)
1293         {
1294                 __pMostVisitedSites->RemoveAll(true);
1295         }
1296         HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1297         if(__pMostVisitedSites != null)
1298         {
1299                 return __pMostVisitedSites->GetCount();
1300         }
1301         else
1302                 return 0;
1303 }
1304
1305 void
1306 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1307 {
1308         AppLog("MainForm::OnListViewContextItemStateChanged called");
1309         if(__pMostVisitedSites != null)
1310         {
1311                 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1312                 if (pHistory != null)
1313                 {
1314                         String url = pHistory->GetHistoryUrl();
1315
1316                         HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1317                         __pMostVisitedListView->UpdateList();
1318                 }
1319         }
1320 }
1321
1322 void
1323 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1324 {
1325         History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1326         String url = pHistory->GetHistoryUrl();
1327         if (url != null)
1328         {
1329                 LoadUrl(url);
1330         }
1331 }
1332
1333 void
1334 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1335 {
1336
1337 }
1338
1339 result
1340 MainForm::OnTerminating(void)
1341 {
1342         result r = E_SUCCESS;
1343
1344         RemoveOrientationEventListener(*this);
1345
1346         if(__pAddressbar)
1347         {
1348                 __pAddressbar->SetAddressbarEventListener(null);
1349         }
1350
1351         if(__pWebViewer)
1352         {
1353                 __pWebViewer->RemoveTouchEventListener(*this);
1354                 __pWebViewer->SetWebUiEventListenerF(null);
1355                 __pWebViewer->SetWebKeypadEventListener(null);
1356                 __pWebViewer->SetTextSearchListener(null);
1357         }
1358
1359
1360         if (__pItemContext)
1361         {
1362                 delete __pItemContext;
1363         }
1364         if (__pItemContextLandscape)
1365         {
1366                 delete __pItemContextLandscape;
1367         }
1368         if (__pSaveImage)
1369         {
1370                 delete __pSaveImage;
1371         }
1372         if (__pMostVisitedSites)
1373         {
1374                 __pMostVisitedSites->RemoveAll(true);
1375                 delete __pMostVisitedSites;
1376         }
1377         return r;
1378 }
1379
1380 void
1381 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1382 {
1383         result r = E_SUCCESS;
1384
1385         AppLogDebug("Clicked : %d", actionId);
1386         switch (actionId)
1387         {
1388         case IDA_BACKBTN_CLICKED:
1389         {
1390                 if(__pImageMenu && __pImageMenu->GetShowState() == true)
1391                 {
1392                         AppLog("Hiding the menu");
1393                         __pImageMenu->SetShowState(false);
1394                 }
1395                 if (__pWebViewer && __pWebViewer->CanGoBack())
1396                 {
1397                         __pWebViewer->GoBack();
1398                 }
1399                 else if(__pWindowInfo->isJavascriptInitiated == false)
1400                 {
1401                         UiApp* pApp = null;
1402                         pApp = UiApp::GetInstance();
1403                         if (pApp != null)
1404                         {
1405                                 RemoveOrientationEventListener(*this);
1406
1407                                 if(__pAddressbar)
1408                                 {
1409                                         __pAddressbar->SetAddressbarEventListener(null);
1410                                 }
1411
1412                                 if(__pWebViewer)
1413                                 {
1414                                         __pWebViewer->RemoveTouchEventListener(*this);
1415                                         __pWebViewer->SetWebUiEventListenerF(null);
1416                                         __pWebViewer->SetWebKeypadEventListener(null);
1417                                         __pWebViewer->SetTextSearchListener(null);
1418                                         __pWebViewer->SetLoadingListener(null);
1419                                 }
1420                                 r = pApp->Terminate();
1421                                 if (IsFailed(r))
1422                                 {
1423                                         AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1424                                         return;
1425                                 }
1426                         }
1427                 }
1428                 else
1429                 {
1430                         UiApp* pApp = null;
1431                         WindowInfo* pWindowInfo = null;
1432                         int totalCount = 0;
1433                         SceneManager* pSceneManager = SceneManager::GetInstance();
1434                         if (pSceneManager == null)
1435                         {
1436                                 return;
1437                         }
1438                         ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1439                         if (pAllWindowList == NULL)
1440                         {
1441                                 pApp = UiApp::GetInstance();
1442                                 if (pApp != null)
1443                                 {
1444                                         RemoveOrientationEventListener(*this);
1445
1446                                         if(__pAddressbar)
1447                                         {
1448                                                 __pAddressbar->SetAddressbarEventListener(null);
1449                                         }
1450
1451                                         if(__pWebViewer)
1452                                         {
1453                                                 __pWebViewer->RemoveTouchEventListener(*this);
1454                                                 __pWebViewer->SetWebUiEventListenerF(null);
1455                                                 __pWebViewer->SetWebKeypadEventListener(null);
1456                                                 __pWebViewer->SetTextSearchListener(null);
1457                                                 __pWebViewer->SetLoadingListener(null);
1458                                         }
1459                                         r = pApp->Terminate();
1460                                         if (IsFailed(r))
1461                                         {
1462                                                 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1463                                                 return;
1464                                         }
1465                                 }
1466                         }
1467                         if (pAllWindowList != null)
1468                         {
1469                                 totalCount = pAllWindowList->GetCount();
1470                         }
1471                         for (int count = 0; count < totalCount; count++)
1472                         {
1473                                 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1474                                 if (pWindowInfo == null)
1475                                 {
1476                                         pApp = UiApp::GetInstance();
1477                                         if (pApp != null)
1478                                         {
1479                                                 RemoveOrientationEventListener(*this);
1480
1481                                                 if(__pAddressbar)
1482                                                 {
1483                                                         __pAddressbar->SetAddressbarEventListener(null);
1484                                                 }
1485
1486                                                 if(__pWebViewer)
1487                                                 {
1488                                                         __pWebViewer->RemoveTouchEventListener(*this);
1489                                                         __pWebViewer->SetWebUiEventListenerF(null);
1490                                                         __pWebViewer->SetWebKeypadEventListener(null);
1491                                                         __pWebViewer->SetTextSearchListener(null);
1492                                                         __pWebViewer->SetLoadingListener(null);
1493                                                 }
1494                                                 r = pApp->Terminate();
1495                                                 if (IsFailed(r))
1496                                                 {
1497                                                         AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1498                                                         return;
1499                                                 }
1500                                         }
1501                                 }
1502                                 else
1503                                 {
1504                                         if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1505                                         {
1506                                                 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1507                                                 if (IsFailed(r))
1508                                                 {
1509                                                         AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1510                                                         return;
1511                                                 }
1512                                                 r = pAllWindowList->RemoveAt(count, true);
1513                                                 __pWindowInfo = null;
1514                                                 if (IsFailed(r))
1515                                                 {
1516                                                         AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1517                                                         return;
1518                                                 }
1519                                                 if(count > 0)
1520                                                 {
1521                                                         pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1522                                                 }
1523                                                 else
1524                                                 {
1525                                                         pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1526                                                 }
1527                                                 if (pWindowInfo == null)
1528                                                 {
1529                                                         pApp = UiApp::GetInstance();
1530                                                         if (pApp != null)
1531                                                         {
1532
1533                                                                 RemoveOrientationEventListener(*this);
1534
1535                                                                 if(__pAddressbar)
1536                                                                 {
1537                                                                         __pAddressbar->SetAddressbarEventListener(null);
1538                                                                 }
1539
1540                                                                 if(__pWebViewer)
1541                                                                 {
1542                                                                         __pWebViewer->RemoveTouchEventListener(*this);
1543                                                                         __pWebViewer->SetWebUiEventListenerF(null);
1544                                                                         __pWebViewer->SetWebKeypadEventListener(null);
1545                                                                         __pWebViewer->SetTextSearchListener(null);
1546                                                                         __pWebViewer->SetLoadingListener(null);
1547                                                                 }
1548                                                                 r = pApp->Terminate();
1549                                                                 return;
1550                                                         }
1551                                                 }
1552                                                 else
1553                                                 {
1554                                                         r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1555                                                         if (IsFailed(r))
1556                                                         {
1557                                                                 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1558                                                                 return;
1559                                                         }
1560                                                 }
1561                                                 break;
1562                                         }
1563                                 }
1564                         }
1565                 }
1566         }
1567                 break;
1568
1569         case IDA_FORWARD_CLICKED:
1570                 if (__pWebViewer == null)
1571                         return;
1572
1573                 if (__pWebViewer->CanGoForward())
1574                 {
1575                         __pWebViewer->GoForward();
1576                 }
1577                 __pOptionMenu->SetShowState(false);
1578                 __pOptionMenu->Invalidate(false);
1579                 break;
1580
1581         case IDA_FINDONPAGE_CLICKED:
1582         {
1583                 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1584                 __currentSearchStr.Clear();
1585
1586                 InitFindWordPanel();
1587                 __pOptionMenu->SetShowState(false);
1588                 __pOptionMenu->Invalidate(false);
1589
1590                 ShowFindWordPanel(true);
1591
1592                 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1593                 {
1594                         __pFindWordEditField->SetFocus();
1595 //                      __pFindWordCountLabel->SetShowState(false);
1596                 }
1597                 else
1598                 {
1599                         __pFindWordEditFieldRightToLeft->SetFocus();
1600                         __pFindWordCountLabelRightToLeft->SetShowState(false);
1601                 }
1602         }
1603         break;
1604         case IDA_PRIVATEON_CLICKED:
1605         {
1606                 result r = E_SUCCESS;
1607                 int itemIndex = 0;
1608                 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1609                 Bitmap* pBitmap = null;
1610                 if (isPrivateBrowsing == true)
1611                 {
1612                         pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1613                         if (IsFailed(r))
1614                         {
1615                                 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1616                                 return ;
1617                         }
1618
1619                         if (__pWebViewer != NULL)
1620                         {
1621                                 __pWebViewer->SetPrivateBrowsingEnabled(false);
1622                         }
1623
1624                         SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1625
1626                         if (__pAddressbar != null)
1627                         {
1628                                 __pAddressbar->UpdateFaviconBitmap(false);
1629                         }
1630
1631                 }
1632                 else
1633                 {
1634                         pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1635                         if (IsFailed(r))
1636                         {
1637                                 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1638                                 return ;
1639                         }
1640
1641                         if (__pWebViewer != NULL)
1642                         {
1643                                 __pWebViewer->SetPrivateBrowsingEnabled(true);
1644                         }
1645
1646                         SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1647
1648                         if (__pAddressbar != null)
1649                         {
1650                                 __pAddressbar->UpdateFaviconBitmap(true);
1651                         }
1652                 }
1653
1654                 itemIndex = __pOptionMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1655                 r = __pOptionMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1656                 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1657                 __pOptionMenu->Invalidate(true);
1658                 if ( pBitmap != NULL )
1659                 {
1660                         delete pBitmap;
1661                 }
1662
1663         }
1664         break;
1665         case IDA_SETTINGS_CLICKED:
1666         {
1667
1668                 ArrayList* pArgList = new(std::nothrow) ArrayList();
1669                 if (pArgList)
1670                 {
1671                         pArgList->Construct();
1672                         pArgList->Add(*__pWindowInfo);
1673                         SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1674                 }
1675                 __pOptionMenu->SetShowState(false);
1676                 __pOptionMenu->Invalidate(false);
1677
1678                 if (pArgList != null)
1679                 {
1680                         delete pArgList;
1681                         pArgList = null;
1682                 }
1683
1684         }
1685         break;
1686
1687         case IDA_ADDTOBOOKMARK_CLICKED:
1688         {
1689
1690                 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1691                 {
1692                         int bookmarkCount=0;
1693                         bool exist = false;
1694                         String url=L"";
1695                         url=__pWindowInfo->pageUrl;
1696                         result r = E_SUCCESS;
1697                         Bitmap* pBitmap = null;
1698                         r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1699
1700                         if (IsFailed(r))
1701                         {
1702                                 return;
1703                         }
1704                         if ( exist == true)
1705                         {
1706                                 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1707                                 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1708                                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1709
1710                                 if(__pNotification != null)
1711                                 {
1712                                         RemoveControl(__pNotification);
1713                                         __pNotification = null;
1714                                 }
1715                                 __pNotification = new (std::nothrow) NotificationPanel(*this);
1716                                 if (__pNotification != null)
1717                                 {
1718                                         __pNotification->SetText(message);
1719                                         __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1720                                         __pNotification->ShowNotification();
1721                                 }
1722                         }
1723                         else
1724                         {
1725                                 String title=__pWindowInfo->pageTitle;
1726                                 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1727                                 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1728
1729                                 pBookmark->SetBookmarkTitle(title);
1730                                 pBookmark->SetUrl(url);
1731                                 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1732                                 {
1733                                         pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1734                                 }
1735                                 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1736                                 pBookmark->SetFaviconId(id);
1737                                 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1738                                 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1739                                 delete pBookmark;
1740                                 if(__pNotification != null)
1741                                 {
1742                                         RemoveControl(__pNotification);
1743                                         __pNotification = null;
1744                                 }
1745                                 __pNotification = new (std::nothrow) NotificationPanel(*this);
1746                                 if (__pNotification != null)
1747                                 {
1748                                         __pNotification->SetText(message);
1749                                         __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1750                                         __pNotification->ShowNotification();
1751                                         pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1752                                 }
1753                         }
1754                         if (pBitmap != null)
1755                         {
1756                                 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1757                                 delete pBitmap;
1758                         }
1759
1760
1761                         __pOptionMenu->Invalidate(true);
1762                 }
1763
1764         }
1765         break;
1766         case IDA_PRINT_CLICKED:
1767         {
1768                 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//shared//data//test.pdf");
1769                 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1770
1771                 AppLog("RequestPrint called!");
1772                 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1773                 result nResult = E_FAILURE;
1774                 if (pAc)
1775                 {
1776                         AppLog("TestPrint if (pAc) == true");
1777
1778                         HashMap map;
1779                         map.Construct();
1780
1781                         String fileType = L"service_print_files_type";
1782                         String typeVal = L"DOC";
1783
1784                         String fileCount = L"service_print_files_count";
1785                         String countVal = L"1";
1786                         String fileFolder= L"service_print_files_folder_name";
1787                         String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//shared//data";
1788
1789                         map.Add(&fileCount, &countVal);
1790                         map.Add(&fileFolder, &folderVal);
1791                         map.Add(&fileType, &typeVal);
1792
1793                         String fileName = L"service_print_files_files_name";
1794
1795                         ArrayList fileNameList;
1796                         fileNameList.Construct();
1797                         String file1 = L"test.pdf";
1798
1799                         fileNameList.Add(&file1);
1800                         map.Add(&fileName, &fileNameList);
1801
1802                         nResult = pAc->Start(NULL, NULL, &map, NULL);
1803
1804                         if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1805                         else if (nResult == E_MAX_EXCEEDED)
1806                                 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1807                         else if (nResult == E_OBJ_NOT_FOUND)
1808                                 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1809                         else if (nResult == E_IN_PROGRESS)
1810                                 AppLog("TestPrint ret == E_IN_PROGRESS");
1811                         else if (nResult == E_PRIVILEGE_DENIED)
1812                                 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1813                         else if(nResult == E_SYSTEM)
1814                                 AppLog("TestPrint ret == E_SYSTEM");
1815
1816                         delete pAc;
1817                 }
1818                 else
1819                 {
1820                         int __modalMsgBoxResult;
1821                         MessageBox* pMsgBox = new MessageBox();
1822                         pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1823                         pMsgBox->ShowAndWait(__modalMsgBoxResult);
1824                         delete pMsgBox;
1825                         pMsgBox = null;
1826                         __modalMsgBoxResult = 0;
1827                 }
1828         }
1829         break;
1830         case IDA_SHARE_CLICKED:
1831         {
1832                 if(__pPopUp != null)
1833                 {
1834                         delete __pPopUp;
1835                         __pPopUp = null;
1836                 }
1837                 if(__pAddressbar)
1838                 {
1839                         __pAddressbar->HideKeypad();
1840                 }
1841                 __pPopUp = new(std::nothrow) SharePopup();
1842                 __pPopUp->Initialize();
1843                 if (__pWindowInfo != null)
1844                 {
1845                         ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1846                         pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1847                         pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1848                         pShareInfo->SetImageAttached(false);
1849                         __pPopUp->RemoveAllShareInfo();
1850                         __pPopUp->AddShareInfo(pShareInfo);
1851                 }
1852                 __pPopUp->SetShowState(true);
1853                 __pPopUp->Show();
1854         }
1855         break;
1856         case IDA_BOOKMARKBTN_CLICKED:
1857         {
1858                 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1859                 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1860         }
1861         break;
1862         case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1863         {
1864
1865         }
1866         break;
1867         case IDA_MOREBTN_CLICKED:
1868         {
1869                 AppLog("IDA_MOREBTN_CLICKED");
1870                 InitOptionMenu();
1871                 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1872                 {
1873                         int bookmarkCount=0;
1874                         bool exist = false;
1875                         String url=L"";
1876                         url=__pWindowInfo->pageUrl;
1877                         result r = E_SUCCESS;
1878                         Bitmap* pBitmap = null;
1879
1880                         r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1881                         if (IsFailed(r))
1882                         {
1883                                 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1884                                 return;
1885                         }
1886                         if ( exist == true)
1887                         {
1888                                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1889                         }
1890                         else
1891                         {
1892                                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1893                         }
1894                         AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1895
1896                         if (__pOptionMenu->GetItemCount() == 9)
1897                         {
1898                                 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1899                         }
1900                         else
1901                         {
1902                                 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1903                         }
1904
1905                         if (IsFailed(r))
1906                         {
1907                                 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1908                                 delete pBitmap;
1909                                 return ;
1910                         }
1911                         AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1912                         if (__pOptionMenu->GetItemCount() != 9)
1913                         {
1914                                 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1915                                 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1916         //                              __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1917                                 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1918                                 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1919                                 __pOptionMenu->SetMaxVisibleItemsCount(6);
1920                         }
1921                         if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1922                         {
1923                                 AppLog(" Orientation landscape");
1924                                 __pOptionMenu->SetMaxVisibleItemsCount(5);
1925                         }
1926                         else
1927                         {
1928                                 AppLog(" Orientation potrait");
1929                                 __pOptionMenu->SetMaxVisibleItemsCount(6);
1930                         }
1931
1932                         AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1933                         delete pBitmap;
1934                 }
1935                 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1936                 __pOptionMenu->SetShowState(true);
1937                 __pOptionMenu->Invalidate(true);
1938                 __pOptionMenu->Show();
1939
1940 }
1941         break;
1942         case IDA_HISTORY_CLICKED:
1943         {
1944                 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1945                 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1946         }
1947         break;
1948         case IDA_SAVED_PAGES_CLICKED:
1949         {
1950
1951         }
1952         break;
1953         case IDA_DESKTOP_VIEW_CLICKED:
1954         {
1955
1956         }
1957         break;
1958         case IDA_SAVE_CLICKED:
1959         {
1960
1961         }
1962         break;
1963         case IDA_MULTIWINDOWBTN_CLICKED:
1964         {
1965                 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1966                 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1967         }
1968         break;
1969
1970         case IDA_NEWWINDOWBTN_CLICKED:
1971         {
1972                 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
1973
1974                 if (pNewWindowInfo == null)
1975                 {
1976                         return;
1977                 }
1978                 result r = E_SUCCESS;
1979                 SceneManager* pSceneManager = SceneManager::GetInstance();
1980
1981                 if (pSceneManager == NULL)
1982                 {
1983                         return;
1984                 }
1985                 ArrayList* pArgList = new(std::nothrow) ArrayList();
1986                 if (pArgList == NULL)
1987                 {
1988                         return;
1989                 }
1990                 r = pArgList->Construct();
1991                 if (r == E_SUCCESS)
1992                 {
1993                         pArgList->Add(*pNewWindowInfo);
1994                         r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1995                 } 
1996                 delete pArgList;
1997                 pArgList = null;
1998                 if (IsFailed(r))
1999                 {
2000                         AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
2001                         return;
2002                 }
2003         }
2004         break;
2005         case IDA_SMALLFONT_BTN_CLICKED:
2006         {
2007                 WebSetting setting = __pWebReader->GetSetting();
2008                 setting.SetFontSize(15);
2009                 __pWebReader->SetSetting(setting);
2010         }
2011         break;
2012         case IDA_LARGEFONT_BTN_CLICKED:
2013         {
2014                 WebSetting setting = __pWebReader->GetSetting();
2015                 setting.SetFontSize(25);
2016                 __pWebReader->SetSetting(setting);
2017         }
2018         break;
2019         case IDA_READER_CLOSE_CLICKED:
2020         {
2021                 if (__pArticleReaderPanel != null && __pBlankPanel != null)
2022                 {
2023                         RemoveControl(__pBlankPanel);
2024                         __pArticleReaderPanel = null;
2025                         __pBlankPanel = null;
2026                         __pArticleReaderLabel = null;
2027                 }
2028                 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2029         }
2030         break;
2031         case IDA_FINDWORD_CANCEL_CLICKED:
2032         {
2033                 __currentSearchStr = L"";
2034                 __currentWordIndex = 0;
2035                 __maxOccurrances = 0;
2036
2037                 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2038                 {
2039                         __pFindWordEditField->SetText(L"");
2040                         __pFindWordCountLabel->SetText(L"0/0");
2041                 }
2042                 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2043                 {
2044                         __pFindWordEditFieldRightToLeft->SetText(L"");
2045                         __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2046                 }
2047
2048                 __pFindWordNext->SetEnabled(false);
2049                 __pFindWordPrev->SetEnabled(false);
2050                 __pFindWordCountLabel->SetText(L"0/0");
2051                 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
2052                 AppLog("akjshdasd 1");
2053                 if(__isKeypadOpened == false)
2054                         __pFooterPanel->SetShowState(true);
2055                 ShowFindWordPanel(false);
2056         }
2057         break;
2058         case IDA_FINDWORD_SEARCH_CLICKED:
2059         {
2060                 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2061                 {
2062                         __currentSearchStr = __pFindWordEditField->GetText();
2063                 }
2064                 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2065                 {
2066                         __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
2067                 }
2068
2069                 if (__currentSearchStr.GetLength() > 0)
2070                 {
2071                         StartWordSearch();
2072                 }
2073                 else
2074                 {
2075                         AppLogDebug("Enter something");
2076                 }
2077         }
2078         break;
2079         case IDA_FINDWORD_CLEAR_CLICKED:
2080         {
2081                 __pFindWordCountLabel->SetText(L"0/0");
2082                 __pFindWordEditField->SetText(L"");
2083                 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2084                 StartWordSearch();
2085                 __currentSearchStr = L"";
2086                 __pFindWordNext->SetEnabled(false);
2087                 __pFindWordPrev->SetEnabled(false);
2088 //              __pFindWordCountLabel->SetShowState(false);
2089                 __pFindWordControl->Invalidate(true);
2090         }
2091         break;
2092         case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
2093         {
2094                 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2095                 __pFindWordEditFieldRightToLeft->SetText(L"");
2096                 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2097                 StartWordSearch();
2098                 __currentSearchStr = L"";
2099                 __pFindWordNext->SetEnabled(false);
2100                 __pFindWordPrev->SetEnabled(false);
2101 //              __pFindWordCountLabelRightToLeft->SetShowState(false);
2102                 __pFindWordControl->Invalidate(true);
2103         }
2104         break;
2105         case IDA_FINDWORD_NEXT_CLICKED:
2106         {
2107                 FindNextWord(true);
2108         }
2109         break;
2110         case IDA_FINDWORD_PREV_CLICKED:
2111         {
2112                 FindNextWord(false);
2113         }
2114         break;
2115         case IDA_BRIGHTNESS_BTN_CLICKED:
2116         {
2117                 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
2118                 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2119         }
2120         break;
2121         case IDA_COPY_IMAGE_CLICKED:
2122         {
2123                 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2124                 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2125                 ClipboardItem item;
2126                 const Bitmap* pBitmap = null;
2127                 if (__pHitElementResult != null && __pHitElementResult->HasImage())
2128                 {
2129                         pBitmap = __pHitElementResult->GetImage();
2130                 }
2131
2132                 String resourcePath = App::GetInstance()->GetAppResourcePath();
2133                 r = item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
2134                 AppLog("Platofrm construct failed result %s",GetErrorMessage(r));
2135                 // copying the item to clipboard
2136                 Clipboard* pClipboard = Clipboard::GetInstance();
2137                 if (pClipboard != null)
2138                 {
2139                         r = pClipboard->CopyItem(item);
2140                         AppLog("Platofrm copy failed result %s",GetErrorMessage(r));
2141                 }
2142         }
2143         break;
2144         case IDA_VIEW_IMAGE_CLICKED:
2145         {
2146                 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
2147                 WindowInfo* pNewWindowInfo = null;
2148                 if (__pHitElementResult != null)
2149                 {
2150                         String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2151                         AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2152                         LoadUrl(srcUrl);
2153
2154                 }
2155         }
2156         break;
2157         case IDA_SAVE_IMAGE_CLICKED:
2158         {
2159                 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
2160                 const Bitmap* pSaveBitmap = null;
2161                 String imageName = GetImagePath();
2162                 AppLog("Content manager image name %ls",imageName.GetPointer());
2163                 String imagePath;
2164                 imagePath.Clear();
2165                 imagePath.Append(imageName);
2166                 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(),  imageName.GetPointer());
2167                 AppLog("Content manager image path %ls",imagePath.GetPointer());
2168                 if (__pHitElementResult != null)
2169                 {
2170                         pSaveBitmap = __pHitElementResult->GetImage();
2171                 }
2172                 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2173
2174                 if(pBuffer)
2175                 {
2176                         UpdateImageContent(pBuffer, imageName);
2177                         delete pBuffer;
2178                         if(__pNotification != null)
2179                         {
2180                                 RemoveControl(__pNotification);
2181                                 __pNotification = null;
2182                         }
2183                         __pNotification = new NotificationPanel(*this);
2184                         String msg;
2185                         AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2186                         msg.Append(imagePath);
2187                         if (__pNotification != null)
2188                         {
2189                                 __pNotification->SetText(msg);
2190                                 if (__pFooterPanel->GetShowState() == true)
2191                                 {
2192                                         __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2193                                 }
2194                                 else
2195                                 {
2196                                         __pNotification->SetPositionDiff(0);
2197                                 }
2198
2199                                 __pNotification->ShowNotification();
2200                         }
2201                 }
2202                 else
2203                 {
2204                         int __modalMsgBoxResult;
2205                         MessageBox* pMsgBox = new MessageBox();
2206                         pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
2207                         pMsgBox->ShowAndWait(__modalMsgBoxResult);
2208                         delete pMsgBox;
2209                         pMsgBox = null;
2210                         __modalMsgBoxResult = 0;
2211                 }
2212         }
2213         break;
2214         case IDA_SHARE_IMAGE_CLICKED:
2215         {
2216                 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2217                 if (__pPopUp != null)
2218                 {
2219                         delete __pPopUp;
2220                         __pPopUp = null;
2221                 }
2222                 if(__pAddressbar)
2223                 {
2224                         __pAddressbar->HideKeypad();
2225                 }
2226                 __pPopUp = new(std::nothrow) SharePopup();
2227                 __pPopUp->Initialize();
2228                 if (__pHitElementResult != null)
2229                 {
2230                         const Bitmap* pSaveBitmap = null;
2231                         String imageName = GetImagePath();
2232                         AppLog("Content manager image name %ls",imageName.GetPointer());
2233                         String imagePath;
2234                         imagePath.Clear();
2235                         imagePath.Append(imageName);
2236                         imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(),  imageName.GetPointer());
2237                         AppLog("Content manager image path %ls",imagePath.GetPointer());
2238                         if (__pHitElementResult != null)
2239                         {
2240                                 pSaveBitmap = __pHitElementResult->GetImage();
2241                         }
2242                         __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2243
2244                         String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2245                         AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2246
2247                         ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2248                         pShareInfo->SetPageTitle(L"");
2249                         pShareInfo->SetPageUrl(srcUrl);
2250                         pShareInfo->SetImageAttached(true);
2251                         pShareInfo->SetImagePath(imagePath);
2252                         __pPopUp->RemoveAllShareInfo();
2253                         __pPopUp->AddShareInfo(pShareInfo);
2254                         __pPopUp->SetShowState(true);
2255                         __pPopUp->Show();
2256                 }
2257         }
2258         break;
2259         case IDA_HYPERLINK_OPEN_CLICKED:
2260         {
2261                 if (__pHitElementResult != null)
2262                 {
2263                         String srcUrl = __pHitElementResult->GetUrl();
2264
2265                         WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2266
2267                         if (pNewWindowInfo == null)
2268                         {
2269                                 return;
2270                         }
2271                         result r = E_SUCCESS;
2272                         SceneManager* pSceneManager = SceneManager::GetInstance();
2273                         if (pSceneManager == NULL)
2274                         {
2275                                 return;
2276                         }
2277                         ArrayList* pArgList = new(std::nothrow) ArrayList();
2278                         if (pArgList == NULL)
2279                         {
2280                                 return;
2281                         }
2282                         pArgList->Construct();
2283
2284                         pArgList->Add(*pNewWindowInfo);
2285                         r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2286                         if (pArgList != null)
2287                         {
2288                                 delete pArgList;
2289                                 pArgList = null;
2290                         }
2291                         if(IsFailed(r))
2292                         {
2293                                 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2294                                 return;
2295                         }
2296                 }
2297         }
2298         break;
2299         case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2300         {
2301                 if (__pHitElementResult == null)
2302                 {
2303                         return;
2304                 }
2305
2306                 if(__pPopUp != null)
2307                 {
2308                         delete __pPopUp;
2309                         __pPopUp = null;
2310                 }
2311                 if(__pAddressbar)
2312                 {
2313                         __pAddressbar->HideKeypad();
2314                 }
2315                 __pPopUp = new(std::nothrow) SharePopup();
2316                 __pPopUp->Initialize();
2317
2318                 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2319                 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2320                 pShareInfo->SetImageAttached(false);
2321                 __pPopUp->RemoveAllShareInfo();
2322                 __pPopUp->AddShareInfo(pShareInfo);
2323
2324                 __pPopUp->SetShowState(true);
2325                 __pPopUp->Show();
2326         }
2327         break;
2328         case IDA_HYPERLINK_COPY_LINK_CLICKED:
2329         {
2330                 ClipboardItem item;
2331                 String url;
2332                 if (__pHitElementResult != null)
2333                 {
2334                         url = __pHitElementResult->GetUrl();
2335                 }
2336
2337                 String resourcePath = App::GetInstance()->GetAppResourcePath();
2338                 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2339
2340                 // copying the item to clipboard
2341                 Clipboard* pClipboard = Clipboard::GetInstance();
2342                 if (pClipboard != null)
2343                 {
2344                         pClipboard->CopyItem(item);
2345                 }
2346         }
2347         break;
2348         case IDA_FIND_TEXT__CLICKED:
2349         {
2350 //              AddressBarCancelledClicked(*__pAddressbar);
2351                 RelayoutControls(false);
2352 //              __pFooterPanel->SetShowState(false);
2353                 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2354                 __currentSearchStr.Clear();
2355                 __currentSearchStr.Append(__currentSelectedStr);
2356                 InitFindWordPanel();
2357                 __pFindWordEditField->SetText(__currentSearchStr);
2358
2359                 if(__pOptionMenu != null)
2360                 {
2361                         __pOptionMenu->SetShowState(false);
2362                         __pOptionMenu->Invalidate(false);
2363                 }
2364                 __adressPanelPosition.y = 0;
2365
2366                 if (__pAddressbar != null && __pWebViewer != NULL)
2367                 {
2368                         __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2369                         __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2370
2371                         if (__pFooterPanel->GetShowState() == false)
2372                                 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2373                         else
2374                                 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2375                         __pWebViewer->Invalidate(true);
2376                 }
2377
2378                 ShowFindWordPanel(true);
2379                 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2380                 {
2381                         __pFindWordEditField->SetText(__currentSearchStr);
2382                         __pFindWordEditField->SetFocus();
2383                 }
2384                 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2385                 {
2386                         __pFindWordEditFieldRightToLeft->SetText(__currentSearchStr);
2387                         __pFindWordEditFieldRightToLeft->SetFocus();
2388                 }
2389
2390                 if (__currentSearchStr.GetLength() > 0)
2391                 {
2392                         StartWordSearch();
2393                 }
2394                 else
2395                 {
2396                         AppLogDebug("Enter something");
2397                 }
2398
2399                 if (__pWebViewer != null)
2400                 {
2401                         // releasing the set block
2402                         __pWebViewer->ReleaseBlock();
2403                 }
2404
2405         }
2406         break;
2407         case IDA_SHARE_TEXT_CLICKED:
2408         {
2409                 __pWebViewer->ReleaseBlock();
2410                 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2411                 if(__pPopUp != null)
2412                 {
2413                         delete __pPopUp;
2414                         __pPopUp = null;
2415                 }
2416                 if(__pAddressbar)
2417                 {
2418                         __pAddressbar->HideKeypad();
2419                 }
2420                 __pPopUp = new(std::nothrow) SharePopup();
2421                 __pPopUp->Initialize();
2422                 if (__pHitElementResult != null)
2423                 {
2424                         ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2425                         pShareInfo->SetPageTitle(L"");
2426                         pShareInfo->SetPageUrl(__currentSelectedStr);
2427                         pShareInfo->SetImageAttached(false);
2428                         __pPopUp->RemoveAllShareInfo();
2429                         __pPopUp->AddShareInfo(pShareInfo);
2430                         __pPopUp->SetShowState(true);
2431                         __pPopUp->Show();
2432                 }
2433         }
2434         break;
2435         case IDA_COPY_TEXT_CLICKED:
2436         {
2437                 __pWebViewer->ReleaseBlock();
2438                 // need to implement
2439                 //__currentSelectedStr
2440                 // Sets data to a clip board item
2441                 ClipboardItem item;
2442                 String resourcePath = App::GetInstance()->GetAppResourcePath();
2443                 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2444
2445                 // copying the item to clipboard
2446                 Clipboard* pClipboard = Clipboard::GetInstance();
2447                 if (pClipboard != null)
2448                 {
2449                         pClipboard->CopyItem(item);
2450                 }
2451         }
2452         break;
2453         case IDA_PASTE_TEXT_CLICKED:
2454         {
2455                 Clipboard* pClipboard = Clipboard::GetInstance();
2456
2457                 if(pClipboard == null)
2458                 {
2459                         return;
2460                 }
2461                 // Retrieves a latest item
2462                 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2463
2464                 if(pItem == null)
2465                 {
2466                         return;
2467                 }
2468                 //Gets data from the clipboard item
2469                 String* pString = dynamic_cast<String*>(pItem->GetData());
2470
2471                 if (pString != null)
2472                 {
2473                         String idElement = __pHitElementResult->GetAttributeValue(L"id");
2474                         String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2475                         String tagElement  = __pHitElementResult->GetTagName();
2476                         AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2477
2478                         String script;
2479                         if(idElement.GetLength() != 0)
2480                         {
2481                                 script = L"function insertAtCursor(myField, myValue) {  if (document.selection) {   document.getElementById(myField).focus();   sel = document.selection.createRange();   sel.text = myValue;  }   else if (document.getElementById(myField).selectionStart || document.getElementById(myField).selectionStart == '0'){   var startPos = document.getElementById(myField).selectionStart;   var endPos = document.getElementById(myField).selectionEnd;   document.getElementById(myField).value = document.getElementById(myField).value.substring(0, startPos)+ myValue + document.getElementById(myField).value.substring(endPos, document.getElementById(myField).value.length);   } else {    document.getElementById(myField).value += myValue;   }  } ";
2482                                 script.Append("insertAtCursor('");
2483                                 script.Append(idElement);
2484                                 script.Append("',");
2485                                 script.Append("\"");
2486                                 script.Append(*pString);
2487                                 script.Append("\");");
2488                         }
2489                         else if (nameElement.GetLength() != 0)
2490                         {
2491                                 script = L"function insertAtCursor(myField, myValue) {  if (document.selection) {   document.getElementByName(myField)[0].focus();   sel = document.selection.createRange();   sel.text = myValue;  }   else if (myField.selectionStart || myField.selectionStart == '0'){   var startPos = myField.selectionStart;   var endPos = myField.selectionEnd;   myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length);   } else {    document.getElementByName(myField)[0].value += myValue;   }  } ";
2492                                 script.Append("insertAtCursor(document.getElementsByName('");
2493                                 script.Append(nameElement);
2494                                 script.Append("')[0],");
2495                                 script.Append("\"");
2496                                 script.Append(*pString);
2497                                 script.Append("\");");
2498                         }
2499                         else//adding for twitter post page
2500                         {
2501                                 script = L"function insertAtCursor(myField, myValue) {  if (document.selection) {   document.getElementsByTagName(myField)[0].focus();   sel = document.selection.createRange();   sel.text = myValue;  }   else if (myField.selectionStart || myField.selectionStart == '0'){   var startPos = myField.selectionStart;   var endPos = myField.selectionEnd;   myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length);   } else {    document.getElementsByTagName(myField)[0].value += myValue;   }  } ";
2502                                 script.Append("insertAtCursor(document.getElementsByTagName('");
2503                                 script.Append(tagElement);
2504                                 script.Append("')[0],");
2505                                 script.Append("\"");
2506                                 script.Append(*pString);
2507                                 script.Append("\");");
2508                         }
2509                         AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2510                         String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2511                         delete pStr;
2512                 }
2513                 delete pItem;
2514         }
2515         break;
2516         case IDA_GO_BACK:
2517         {
2518                 OnBackClicked();
2519         }
2520         break;
2521         case IDA_GO_FORWARD:
2522         {
2523                 OnForwardClicked();
2524         }
2525         break;
2526         case IDA_REFRESH_BTN_CLICKED:
2527         {
2528                 __isLoadingCompleted = false;
2529                 __isLoadingData = true;
2530                 __progressPercentage = 0;
2531                 __displayUrl = __pFooterUrlField->GetText();
2532
2533                 String url = __pFooterUrlField->GetText();
2534                 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2535 //              LoadUrl(url);
2536                 if (__pWebViewer != null && __pAddressbar != null)
2537                 {
2538                         __pWebViewer->Reload();
2539                         SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2540                 }
2541
2542                 //OnUrlSubmitted();
2543                 UpdateProgressBitmap();
2544         }
2545         break;
2546         case IDA_STOP_BTN_CLICKED:
2547         {
2548                 __isLoadingCompleted = false;
2549                 __isLoadingData = false;
2550                 __progressPercentage = 0;
2551                 __pFooterUrlField->HideKeypad();
2552                 __displayUrl = __pFooterUrlField->GetText();
2553
2554                 if (__pWebViewer)
2555                 {
2556                         //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2557                         SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2558                         __pWebViewer->StopLoading();
2559                         RequestRedraw(true);
2560                 }
2561
2562                 UpdateProgressBitmap();
2563         }
2564         break;
2565         case IDA_CLEAR_URL:
2566         {
2567                 if (__pFooterUrlField->GetText().IsEmpty() == false)
2568                 {
2569                         //__displayUrl = __pUrlField->GetText();
2570                         __pFooterUrlField->Clear();
2571
2572                 }
2573         }
2574         break;
2575         case IDA_READER_BTN_CLICKED:
2576         {
2577                 ReaderClicked();
2578         }
2579         break;
2580         default:
2581                 break;
2582         }
2583 }
2584
2585 void
2586 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2587 {
2588         result r = E_FAILURE;
2589         if(__pImageMenu && __pImageMenu->GetShowState() == true)
2590         {
2591                 AppLog("Hiding the menu");
2592                 __pImageMenu->SetShowState(false);
2593         }
2594         if (__pWebViewer && __pWebViewer->CanGoBack())
2595         {
2596                 __pWebViewer->GoBack();
2597         }
2598         else if(__pWindowInfo->isJavascriptInitiated == false)
2599         {
2600                 UiApp* pApp = null;
2601                 pApp = UiApp::GetInstance();
2602                 if (pApp != null)
2603                 {
2604                         RemoveOrientationEventListener(*this);
2605
2606                         if(__pAddressbar)
2607                         {
2608                                 __pAddressbar->SetAddressbarEventListener(null);
2609                         }
2610
2611                         if(__pWebViewer)
2612                         {
2613                                 __pWebViewer->RemoveTouchEventListener(*this);
2614                                 __pWebViewer->SetWebUiEventListenerF(null);
2615                                 __pWebViewer->SetWebKeypadEventListener(null);
2616                                 __pWebViewer->SetTextSearchListener(null);
2617                                 __pWebViewer->SetLoadingListener(null);
2618                         }
2619                         r = pApp->Terminate();
2620                         if (IsFailed(r))
2621                         {
2622                                 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2623                                 return;
2624                         }
2625                 }
2626         }
2627         else
2628         {
2629                 UiApp* pApp = null;
2630                 WindowInfo* pWindowInfo = null;
2631                 int totalCount = 0;
2632                 SceneManager* pSceneManager = SceneManager::GetInstance();
2633                 if (pSceneManager == null)
2634                 {
2635                         return;
2636                 }
2637                 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2638                 if (pAllWindowList == NULL)
2639                 {
2640                         pApp = UiApp::GetInstance();
2641                         if (pApp != null)
2642                         {
2643                                 RemoveOrientationEventListener(*this);
2644
2645                                 if(__pAddressbar)
2646                                 {
2647                                         __pAddressbar->SetAddressbarEventListener(null);
2648                                 }
2649
2650                                 if(__pWebViewer)
2651                                 {
2652                                         __pWebViewer->RemoveTouchEventListener(*this);
2653                                         __pWebViewer->SetWebUiEventListenerF(null);
2654                                         __pWebViewer->SetWebKeypadEventListener(null);
2655                                         __pWebViewer->SetTextSearchListener(null);
2656                                         __pWebViewer->SetLoadingListener(null);
2657                                 }
2658                                 r = pApp->Terminate();
2659                                 if (IsFailed(r))
2660                                 {
2661                                         AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2662                                         return;
2663                                 }
2664                         }
2665                 }
2666                 if (pAllWindowList != null)
2667                 {
2668                         totalCount = pAllWindowList->GetCount();
2669                 }
2670                 for (int count = 0; count < totalCount; count++)
2671                 {
2672                         pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2673                         if (pWindowInfo == null)
2674                         {
2675                                 pApp = UiApp::GetInstance();
2676                                 if (pApp != null)
2677                                 {
2678                                         RemoveOrientationEventListener(*this);
2679
2680                                         if(__pAddressbar)
2681                                         {
2682                                                 __pAddressbar->SetAddressbarEventListener(null);
2683                                         }
2684
2685                                         if(__pWebViewer)
2686                                         {
2687                                                 __pWebViewer->RemoveTouchEventListener(*this);
2688                                                 __pWebViewer->SetWebUiEventListenerF(null);
2689                                                 __pWebViewer->SetWebKeypadEventListener(null);
2690                                                 __pWebViewer->SetTextSearchListener(null);
2691                                                 __pWebViewer->SetLoadingListener(null);
2692                                         }
2693                                         r = pApp->Terminate();
2694                                         if (IsFailed(r))
2695                                         {
2696                                                 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2697                                                 return;
2698                                         }
2699                                 }
2700                         }
2701                         else
2702                         {
2703                                 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2704                                 {
2705                                         r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2706                                         if (IsFailed(r))
2707                                         {
2708                                                 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2709                                                 return;
2710                                         }
2711                                         r = pAllWindowList->RemoveAt(count, true);
2712                                         __pWindowInfo = null;
2713                                         if (IsFailed(r))
2714                                         {
2715                                                 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2716                                                 return;
2717                                         }
2718                                         if(count > 0)
2719                                         {
2720                                                 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2721                                         }
2722                                         else
2723                                         {
2724                                                 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2725                                         }
2726                                         if (pWindowInfo == null)
2727                                         {
2728                                                 pApp = UiApp::GetInstance();
2729                                                 if (pApp != null)
2730                                                 {
2731                                                         RemoveOrientationEventListener(*this);
2732
2733                                                         if(__pAddressbar)
2734                                                         {
2735                                                                 __pAddressbar->SetAddressbarEventListener(null);
2736                                                         }
2737
2738                                                         if(__pWebViewer)
2739                                                         {
2740                                                                 __pWebViewer->RemoveTouchEventListener(*this);
2741                                                                 __pWebViewer->SetWebUiEventListenerF(null);
2742                                                                 __pWebViewer->SetWebKeypadEventListener(null);
2743                                                                 __pWebViewer->SetTextSearchListener(null);
2744                                                                 __pWebViewer->SetLoadingListener(null);
2745                                                         }
2746                                                         r = pApp->Terminate();
2747                                                         return;
2748                                                 }
2749                                         }
2750                                         else
2751                                         {
2752                                                 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2753                                                 if (IsFailed(r))
2754                                                 {
2755                                                         AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2756                                                         return;
2757                                                 }
2758                                         }
2759                                         break;
2760                                 }
2761                         }
2762                 }
2763         }
2764 }
2765
2766 void
2767 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2768                 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2769 {
2770
2771         AppLog("MainForm::OnSceneActivatedN called");
2772         String* pSelectedScene = NULL;
2773         Object* pValue = NULL;
2774         String* pUrl = null;
2775         MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2776         pSelectedScene = (String*) pValue;
2777
2778         if (pSelectedScene != null)
2779         {
2780                 delete pSelectedScene;
2781         }
2782         MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2783         String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2784         AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2785         AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2786
2787         // setting the current scene ID
2788         MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2789
2790         MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2791
2792         if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2793         {
2794                 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2795                 if(__pWindowInfo == null)
2796                         return;
2797                 //              if(__pWindowInfo == null)
2798                 {
2799                         pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2800                 }
2801         }
2802         else if ( pArgs != null && pArgs->GetCount() == 1)
2803         {
2804                 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2805         }
2806
2807         InitFooter();
2808         InitAddressbar();
2809
2810         __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2811
2812         // hiding the address bar
2813         //      __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2814         __pAddressbar->SetShowState(false);
2815 //      if(__pWebViewer != null)
2816 //      {
2817 //              __pWebViewer->Resume();
2818 //      }
2819
2820         if(pUrl != null && pUrl->GetLength() > 0)
2821         {
2822                 LoadUrl(*pUrl);
2823         }
2824         else if(__pWindowInfo != null)
2825         {
2826                 if(__pWindowInfo->pageUrl.GetLength() > 0 &&previousSceneId != IDSCN_BRIGHTNESS && previousSceneId != IDSCN_HISTORY_LIST && previousSceneId != IDSCN_MULTIPLE_WINDOW && previousSceneId != IDSCN_MULTIPLE_WINDOW_GRID && previousSceneId != IDSCN_BOOKMARK_VIEW && previousSceneId != IDSCN_SETTINGS && previousSceneId.Contains(IDSCN_MAIN_VIEW) == false)
2827                 {
2828                         LoadUrl(__pWindowInfo->pageUrl);
2829                 }
2830                 else if(__pWindowInfo->pageUrl.GetLength() > 0 && __pWindowInfo->isAppcontrolTriggered == true)
2831                 {
2832                         LoadUrl(__pWindowInfo->pageUrl);
2833                 }
2834                 else if (__pWindowInfo->isJavascriptInitiated == true)
2835                 {
2836                         AppLog("Called");
2837                         InitWebControl();
2838                         __pWindowInfo->pCurrentWeb = __pWebViewer;
2839                 }
2840         }
2841
2842         String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2843         AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2844         if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2845         {
2846                 InitMostVisitedSitesView(GetOrientationStatus());
2847         }
2848         else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2849         {
2850                 if(__pMostVisitedListView != null)
2851                 {
2852                         __pMostVisitedListView->SetShowState(false);
2853                 }
2854         }
2855
2856         if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2857         {
2858                 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2859
2860                 if (pBookmarkUrl == null)
2861                         return;
2862                 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2863                 //__pAddressbar->SetUrl(*pBookmarkUrl);
2864                 SetUrl(*pBookmarkUrl);
2865
2866                 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2867                         __pWebViewer->LoadUrl(*pBookmarkUrl);
2868                 delete pBookmarkUrl;
2869         }
2870
2871         bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2872         Bitmap* pBitmap = null;
2873         if (isPrivateBrowsing == true)
2874         {
2875                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2876
2877                 if (__pWebViewer != null)
2878                 {
2879                         __pWebViewer->SetPrivateBrowsingEnabled(true);
2880                 }
2881
2882                 if (__pAddressbar != null)
2883                 {
2884                         //      __pAddressbar->UpdateFaviconBitmap(true);
2885                 }
2886
2887         }
2888         else
2889         {
2890                 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2891
2892                 if (__pWebViewer != null)
2893                 {
2894                         __pWebViewer->SetPrivateBrowsingEnabled(false);
2895                 }
2896
2897                 if (__pAddressbar != null)
2898                 {
2899                         //      __pAddressbar->UpdateFaviconBitmap(false);
2900                 }
2901         }
2902
2903         if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
2904         {
2905                 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2906         }
2907         else if (__pOptionMenu != null )
2908         {
2909                 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2910         }
2911
2912         if (pBitmap != null)
2913         {
2914                 delete pBitmap;
2915         }
2916
2917         RelayoutControls(false);
2918         AppLog("ABC: OnSceneActivatedN started exit");
2919
2920 }
2921
2922 void
2923 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2924                 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2925 {
2926         Canvas* pWebCanvas = null;
2927         if (__pWebViewer != null)
2928         {
2929                 pWebCanvas = __pWebViewer->GetCanvasN();
2930
2931         }
2932         if (pWebCanvas == null)
2933         {
2934                 return;
2935         }
2936         if (__pWindowInfo != null)
2937         {
2938                 if (__pWindowInfo->pWebCanvasBitmap != null)
2939                 {
2940                         delete __pWindowInfo->pWebCanvasBitmap;
2941                 }
2942                 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2943                 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2944                 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2945         }
2946         Bitmap* pBitmap = GetCapturedBitmapN();
2947         AppLog("Coming here");
2948         Canvas* pCanvas = new(std::nothrow) Canvas();
2949         pCanvas->Construct(GetClientAreaBounds());
2950         if(pBitmap != null)
2951         {
2952                 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2953                 delete pBitmap;
2954         }
2955         if(__pWebViewer != null && __pWindowInfo != null)
2956                 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2957
2958         WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2959         WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2960         delete pCanvas;
2961         delete pWebCanvas;
2962         if(__pAddressbar)
2963                 __pAddressbar->SetShowState(false);
2964         AppLog("Coming here");
2965 }
2966
2967 bool
2968 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2969                 const Tizen::Base::String& realm,
2970                 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2971 {
2972         return false;
2973 }
2974
2975 void
2976 MainForm::OnHttpAuthenticationCanceled(void)
2977 {
2978 }
2979
2980 void
2981 MainForm::OnLoadingStarted(void)
2982 {
2983         AppLogDebug("MainForm::OnLoadingStarted entered");
2984         __isLoaded = true;
2985         if(__pAddressbar == NULL || __pWebViewer == null)
2986         {
2987                 return;
2988         }
2989
2990         // this is added in case if menu is opened and user load the page
2991         if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
2992         {
2993                 __pOptionMenu->SetShowState(false);
2994                 __pOptionMenu->Invalidate(true);
2995         }
2996
2997
2998
2999         if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
3000         {
3001                 __pImageMenu->SetShowState(false);
3002                 __pImageMenu->Invalidate(true);
3003         }
3004         String url = __pWebViewer->GetUrl();
3005         if(url.Contains(IDS_TIZEN_SERVICE))
3006         {
3007                 String appId;
3008                 String delim(L":;,");
3009
3010                 // Creates a StringTokenizer instance
3011                 StringTokenizer strTok(url, delim);
3012
3013                 int count = strTok.GetTokenCount();     // count == 4
3014
3015                 HashMap *pMap = new HashMap();
3016                 pMap->Construct();
3017                 String token;
3018                 String key;
3019                 String value;
3020                 while (strTok.HasMoreTokens())
3021                 {
3022                         AppLog("Token: %ls", token.GetPointer());
3023                         strTok.GetNextToken(token);         // Tizen, StringTokenizer, Sample, code
3024                         if(token.Contains(IDS_APPID))
3025                         {
3026                                 token.SubString(6, appId);
3027                                 AppLog("AppID:%ls", appId.GetPointer());
3028                         }
3029                         else if(token.Contains(IDS_KEY))
3030                         {
3031                                 token.SubString(4, key);
3032                                 AppLog("key:%ls", key.GetPointer());
3033                         }
3034                         else if(token.Contains(IDS_VALUE))
3035                         {
3036                                 token.SubString(6, value);
3037                                 AppLog("value:%ls", value.GetPointer());
3038                         }
3039                 }
3040                 pMap->Add(key, value);
3041
3042                 if(appId != "")
3043                 {
3044                         AppControl *pAppControl = null;
3045                         String operationId = L"http://tizen.org/appcontrol/operation/main";
3046                         pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3047                         if(pAppControl)
3048                         {
3049                                 AppLog("Starting AppControl");
3050                                 result r = pAppControl->Start(null, null, pMap, null);
3051                                 AppLog("Result of Start %s", GetErrorMessage(r));
3052                         }
3053                         else
3054                         {
3055                                 AppLogException("AppControl not found");
3056                         }
3057                         return;
3058                 }
3059         }
3060         if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
3061         {
3062                 __pAddressbar->SetShowState(false);
3063                 AddressBarCancelledClicked(*__pAddressbar);
3064                 __pAddressbar->Invalidate(true);
3065         }
3066         Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
3067         if(pBitmap != null)
3068         {
3069                 __pAddressbar->SetFaviconBitmap(*pBitmap);
3070         }
3071         delete pBitmap;
3072         if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
3073         {
3074                 // updating the address bar position with respect to web control
3075                 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
3076                 __distanceMoved = 0;
3077                 MoveUiControls();
3078         }
3079
3080         //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3081         SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3082         if (__pWebViewer != null)
3083         {
3084                 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
3085                 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
3086                 SetUrl(__pWebViewer->GetUrl());
3087                 if (__pWindowInfo != NULL)
3088                 {
3089                         // resetting the page title to blank, it will be received in OnPageTitleReceived()
3090                         __pWindowInfo->pageTitle = L"";
3091                         __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3092                 }
3093                 __pAddressbar->Invalidate(true);
3094         }
3095
3096 }
3097
3098 void
3099 MainForm::OnLoadingCanceled(void)
3100 {
3101
3102 }
3103
3104
3105 void
3106 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
3107 {
3108         AppLog("XYZ::MainForm::OnKeypadWillOpen");
3109
3110 }
3111
3112 void
3113 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
3114 {
3115         AppLog("XYZ::MainForm::OnKeypadOpened");
3116         __isKeypadOpened = true;
3117         __pFooterPanel->SetShowState(false);
3118
3119 }
3120
3121 void
3122 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
3123 {
3124         AppLog("XYZ::MainForm::OnKeypadClosed");
3125         __isKeypadOpened = false;
3126         __pFooterPanel->SetShowState(true);
3127         RelayoutControls(true);
3128 }
3129
3130 void
3131 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
3132 {
3133         AppLog("XYZ::KeypadBoundsChanged");
3134         RelayoutControls(false);
3135 }
3136
3137 void
3138 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
3139                 const Tizen::Base::String& reason)
3140 {
3141         AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
3142 }
3143
3144 void
3145 MainForm::OnLoadingCompleted(void)
3146 {
3147         AppLog("MainForm::OnLoadingCompleted start");
3148         DateTime date;
3149         result r = E_SUCCESS;
3150
3151         if (__pWebViewer == null)
3152         {
3153                 return;
3154         }
3155
3156         if (__pAddressbar == null)
3157         {
3158                 return;
3159         }
3160
3161         if(__pImageMenu && __pImageMenu->GetShowState())
3162         {
3163                 __pImageMenu->SetShowState(false);
3164                 __pImageMenu->Invalidate(true);
3165         }
3166
3167         if (__pWebViewer->CanGoForward())
3168         {
3169                 //__pAddressbar->SetForwardButtonEnabled(true);
3170                 SetForwardButtonEnabled(true);
3171         }
3172         else
3173         {
3174                 //__pAddressbar->SetForwardButtonEnabled(false);
3175                 SetForwardButtonEnabled(false);
3176         }
3177
3178         /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3179         {
3180                 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3181
3182                 //__pAddressbar->UpdateProgress(0);
3183                 UpdateProgress(0);
3184         }*/
3185
3186         if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3187         {
3188                 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3189                 UpdateProgress(0);
3190         }
3191
3192         AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
3193         bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
3194         if (isPrivateBrowsing == false)
3195         {
3196                 if(__pHistory != null)
3197                 {
3198                         delete __pHistory;
3199                         __pHistory = null;
3200                 }
3201
3202                 __pHistory = new(std::nothrow) History;
3203                 HistoryPresentationModel::GetCurrentDateTime(date);
3204                 if (__pWindowInfo)
3205                 {
3206                         __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
3207                         AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
3208
3209                         __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
3210                         AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3211                 }
3212                 __pHistory->SetVisitedTime(date);
3213
3214                 if (__pWebViewer != null)
3215                 {
3216                         AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3217
3218                         Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3219                         if (pTempBitmap != null)
3220                         {
3221                                 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3222                                 __pHistory->SetFavIconBitmap(*pTempBitmap);
3223                         }
3224
3225                         AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3226                 }
3227
3228                 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3229                 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3230                 if ( pCanvas != null &&  pCanvas != null && pBitmap != null)
3231                 {
3232                         pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3233                         pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3234                         __pHistory->SetThumbnail(pBitmap);
3235                 }
3236                 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3237                 if (pFavIcon)
3238                 {
3239                         __pHistory->SetFavIconBitmap(*pFavIcon);
3240                         delete pFavIcon;
3241                 }
3242
3243                 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3244                 //delete pHistory;
3245         }
3246         else
3247         {
3248                 return;
3249         }
3250 //      if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3251         {
3252                 // temperary fixed (webpage can be not loaded)
3253                 UpdateFavicon();
3254         }
3255
3256         bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3257         if (isReaderEnabled == true)
3258         {
3259                 if (__pReaderData)
3260                 {
3261                         delete __pReaderData;
3262                         __pReaderData = null;
3263                 }
3264                 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3265                 filePath.Append(L"data/reader.js");
3266                 File file;
3267                 char buffer[10];
3268                 char buffer2[5];
3269                 int i;
3270                 int readCnt;
3271                 result r = E_SUCCESS;
3272                 FileAttributes attr;
3273
3274                 File::GetAttributes(filePath,attr);
3275                 // Creates file
3276                 r = file.Construct(filePath, L"r+");
3277                 if (IsFailed(r))
3278                 {
3279                         AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3280                         return;
3281                 }
3282                 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3283                 if(pScript == null)
3284                 {
3285                         AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3286                         return;
3287                 }
3288 //              file.Read(pScript,attr.GetFileSize());
3289 //
3290 //              AppLogDebug("scipt length %d",strlen(pScript));
3291                 String strScript = L"";
3292 //              strScript.Append(pScript);
3293 //              for(int i=0; i<25; i++)
3294                 {
3295                         file.Read(pScript,attr.GetFileSize());
3296 //                      AppLog("xyzz tell %d",file.Tell());
3297 //                      r = strScript.Append(pScript);
3298 //                      AppLog("xyzz append result %s",GetErrorMessage(r));
3299 //                      AppLog("xyzz strScript length %d",strScript.GetLength());
3300                 }
3301 //              AppLog("xyzz final strScript length %d",strScript.GetLength());
3302
3303                 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3304                 if (__pReaderData == null)
3305                 {
3306                         AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3307                         __pReaderData = new String(L"<meta name=\"viewport\" content=\"width=0, initial-scale=1.0, maximum-scale=2.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=medium-dpi\">      <h1>Chinese PM Li Keqiang vows to open up markets to India</h1><div><span class=\"arttle\"><h1>Chinese PM Li Keqiang vows to open up markets to India</h1></span></div>");
3308 //                      return;
3309                 }
3310                 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3311                 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3312                 {
3313                         //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3314                         SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3315                 }
3316                 delete[] pScript;
3317         }
3318
3319
3320         AppLog("MainForm::OnLoadingCompleted done");
3321 }
3322
3323 void
3324 MainForm::OnEstimatedProgress(int progress)
3325 {
3326         AppLogDebug("MainForm::OnEstimatedProgress entered");
3327
3328         if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3329                 progress = DEFAULT_PROGRESS_PERCENTAGE;
3330         //if(__pAddressbar)
3331         //      __pAddressbar->UpdateProgress(progress);
3332         UpdateProgress(progress);
3333 }
3334
3335 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3336 {
3337         AppLog("MainForm::OnFaviconReceived");
3338         if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3339         {
3340                 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3341                 if(favIcon != null)
3342                 {
3343                         HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3344                         delete favIcon;
3345                 }
3346         }
3347 }
3348
3349 void
3350 MainForm::OnUrlValueChanged(Addressbar&)
3351 {
3352         Invalidate(true);
3353 }
3354
3355 void
3356 MainForm::OnUrlSubmitted(Addressbar& addBar)
3357 {
3358         AppLog("MainForm::OnUrlSubmitted");
3359         String url = addBar.GetUrl();
3360         AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3361
3362         if(__pFooterUrlField)
3363                 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3364         AddressBarCancelledClicked(*__pAddressbar);
3365         LoadUrl(url);
3366 }
3367
3368 void
3369 MainForm::LoadUrl(String& url)
3370 {
3371         url.Trim();
3372         String encodedUrl;
3373 //      UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3374         AppLogDebug("MainForm::LoadUrl enter");
3375
3376         if (__pWebViewer != null)
3377         {
3378                 __pWebViewer->SetShowState(true);
3379                 __pWebViewer->Invalidate(true);
3380         }
3381
3382         if (url.CompareTo(L"") == 0)
3383         {
3384                 return;
3385         }
3386         if(__pFooterPanel != null)
3387         {
3388                 __pFooterPanel->SetShowState(true);
3389                 __pFooterPanel->Invalidate(true);
3390         }
3391         InitWebControl();
3392
3393         bool ret = false;
3394         bool flag = false;
3395
3396         String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3397         String secondPattern(L"^[A-Za-z0-9\.\+-:#@%/;$~?]+\\.[A-Za-z0-9!\+-=:#@%/;$~()_?\\\.&]{2,}$");   // URL of type  abc.com (i.e without protocol in front of it)
3398
3399         RegularExpression firstRegex;
3400         RegularExpression secondRegex;
3401
3402         firstRegex.Construct(firstPattern, REGEX_CASELESS);
3403         secondRegex.Construct(secondPattern, REGEX_CASELESS);
3404
3405         // Match
3406         ret = firstRegex.Match(url, false); // This returns true value
3407         flag = secondRegex.Match(url, false);  // Checks whether URL typed is of type  abc.com (i.e without protocol in front of it)
3408
3409         if (ret == true && __pWebViewer != null)
3410         {
3411                 SetUrl(url);
3412                 __pWebViewer->LoadUrl(url);
3413         }
3414         else if(__pWebViewer != null)
3415         {
3416                 String tempUrl = L"http://";
3417                 tempUrl.Append(url);
3418
3419                 if (flag == true)
3420                 {
3421                         __pWebViewer->LoadUrl(tempUrl);
3422                 }
3423                 else
3424                 {
3425                                 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3426                         __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3427                 }
3428         }
3429         if (__pAddressbar != null)
3430         {
3431                 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3432                 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3433         }
3434
3435         AppLogDebug("MainForm::LoadUrl exit");
3436
3437         return;
3438
3439 }
3440
3441 void
3442 MainForm::OnFocusGained(const Tizen::Ui::Control& source)
3443 {
3444         AppLog("MainForm::OnFocusGained");
3445         if(__pFooterPanel)
3446         {
3447                 __pFooterPanel->SetShowState(false);
3448         }
3449
3450         if(__pAddressbar)
3451         {
3452                 __pAddressbar->SetShowState(true);
3453                 __pAddressbar->SetAddressbarURLFocus();
3454         }
3455         if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3456         {
3457                 __currentSearchStr = L"";
3458                 __currentWordIndex = 0;
3459                 __maxOccurrances = 0;
3460
3461                 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
3462                 {
3463                         __pFindWordEditField->SetText(L"");
3464                         __pFindWordEditField->HideKeypad();
3465                         __pFindWordControl->SetShowState(false);
3466                         __pFindWordCountLabel->SetText(L"0/0");
3467                 }
3468                 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
3469                 {
3470                         __pFindWordEditFieldRightToLeft->SetText(L"");
3471                         __pFindWordEditFieldRightToLeft->HideKeypad();
3472                         __pFindWordControl->SetShowState(false);
3473                         __pFindWordCountLabelRightToLeft->SetText(L"0/0");
3474                 }
3475
3476                 __pFindWordNext->SetEnabled(false);
3477                 __pFindWordPrev->SetEnabled(false);
3478
3479                 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
3480                 __pFindWordControl->SetShowState(false);
3481         }
3482         RelayoutControls(false);
3483 }
3484
3485 void
3486 MainForm::OnFocusLost(const Tizen::Ui::Control& source)
3487 {
3488         AppLog("MainForm::OnFocusLost called");
3489 }
3490
3491 void
3492 MainForm::OnStopClicked(Addressbar& addBar)
3493 {
3494         AppLogDebug("MainForm::OnStopClicked called");
3495         if (__pWebViewer)
3496         {
3497                 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3498                 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3499                 __pWebViewer->StopLoading();
3500                 RequestRedraw(true);
3501         }
3502 }
3503
3504 void
3505 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3506 {
3507         //      AppLog("MainForm::OnBackClicked");
3508         result r = E_FAILURE;
3509         if(__pImageMenu && __pImageMenu->GetShowState() == true)
3510         {
3511                 AppLog("Hiding the menu");
3512                 __pImageMenu->SetShowState(false);
3513         }
3514
3515         if (__pWebViewer && __pWebViewer->CanGoBack())
3516         {
3517                 __pWebViewer->GoBack();
3518         }
3519         else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3520         {
3521                 UiApp* pApp = null;
3522                 pApp = UiApp::GetInstance();
3523                 if (pApp != null)
3524                 {
3525
3526                         RemoveOrientationEventListener(*this);
3527
3528                         if(__pAddressbar)
3529                         {
3530                                 __pAddressbar->SetAddressbarEventListener(null);
3531                         }
3532
3533                         if(__pWebViewer)
3534                         {
3535                                 __pWebViewer->RemoveTouchEventListener(*this);
3536                                 __pWebViewer->SetWebUiEventListenerF(null);
3537                                 __pWebViewer->SetWebKeypadEventListener(null);
3538                                 __pWebViewer->SetTextSearchListener(null);
3539                                 __pWebViewer->SetLoadingListener(null);
3540                         }
3541
3542
3543                         r = pApp->Terminate();
3544                         if (IsFailed(r))
3545                         {
3546                                 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3547                                 return;
3548                         }
3549                 }
3550         }
3551         else
3552         {
3553                 UiApp* pApp = null;
3554                 WindowInfo* pWindowInfo = null;
3555                 int totalCount = 0;
3556                 SceneManager* pSceneManager = SceneManager::GetInstance();
3557                 if (pSceneManager == null)
3558                 {
3559                         return;
3560                 }
3561                 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3562                 if (pAllWindowList == NULL)
3563                 {
3564                         pApp = UiApp::GetInstance();
3565                         if (pApp != null)
3566                         {
3567                                 RemoveOrientationEventListener(*this);
3568
3569                                 if(__pAddressbar)
3570                                 {
3571                                         __pAddressbar->SetAddressbarEventListener(null);
3572                                 }
3573
3574                                 if(__pWebViewer)
3575                                 {
3576                                         __pWebViewer->RemoveTouchEventListener(*this);
3577                                         __pWebViewer->SetWebUiEventListenerF(null);
3578                                         __pWebViewer->SetWebKeypadEventListener(null);
3579                                         __pWebViewer->SetTextSearchListener(null);
3580                                         __pWebViewer->SetLoadingListener(null);
3581                                 }
3582
3583
3584                                 r = pApp->Terminate();
3585                                 if (IsFailed(r))
3586                                 {
3587                                         AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3588                                         return;
3589                                 }
3590                         }
3591                 }
3592                 if (pAllWindowList != null)
3593                 {
3594                         totalCount = pAllWindowList->GetCount();
3595                 }
3596                 for (int count = 0; count < totalCount; count++)
3597                 {
3598                         pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3599                         if (pWindowInfo == null)
3600                         {
3601                                 pApp = UiApp::GetInstance();
3602                                 if (pApp != null)
3603                                 {
3604                                         RemoveOrientationEventListener(*this);
3605
3606                                         if(__pAddressbar)
3607                                         {
3608                                                 __pAddressbar->SetAddressbarEventListener(null);
3609                                         }
3610
3611                                         if(__pWebViewer)
3612                                         {
3613                                                 __pWebViewer->RemoveTouchEventListener(*this);
3614                                                 __pWebViewer->SetWebUiEventListenerF(null);
3615                                                 __pWebViewer->SetWebKeypadEventListener(null);
3616                                                 __pWebViewer->SetTextSearchListener(null);
3617                                                 __pWebViewer->SetLoadingListener(null);
3618                                         }
3619
3620
3621                                         r = pApp->Terminate();
3622                                         if (IsFailed(r))
3623                                         {
3624                                                 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3625                                                 return;
3626                                         }
3627                                 }
3628                         }
3629                         if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3630                         {
3631                                 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3632                                 if (IsFailed(r))
3633                                 {
3634                                         AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3635                                         return;
3636                                 }
3637                                 r = pAllWindowList->RemoveAt(count, true);
3638                                 __pWindowInfo = null;
3639                                 if (IsFailed(r))
3640                                 {
3641                                         AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3642                                         return;
3643                                 }
3644                                 if(count > 0)
3645                                 {
3646                                         pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3647                                 }
3648                                 else if(pAllWindowList->GetCount() > 0)
3649                                 {
3650                                         pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3651                                 }
3652                                 else
3653                                 {
3654                                         pApp = UiApp::GetInstance();
3655                                         if (pApp != null)
3656                                         {
3657                                                 RemoveOrientationEventListener(*this);
3658
3659                                                 if(__pAddressbar)
3660                                                 {
3661                                                         __pAddressbar->SetAddressbarEventListener(null);
3662                                                 }
3663
3664                                                 if(__pWebViewer)
3665                                                 {
3666                                                         __pWebViewer->RemoveTouchEventListener(*this);
3667                                                         __pWebViewer->SetWebUiEventListenerF(null);
3668                                                         __pWebViewer->SetWebKeypadEventListener(null);
3669                                                         __pWebViewer->SetTextSearchListener(null);
3670                                                         __pWebViewer->SetLoadingListener(null);
3671                                                 }
3672
3673
3674                                                 r = pApp->Terminate();
3675                                                 return;
3676                                         }
3677
3678                                 }
3679                                 if (pWindowInfo == null)
3680                                 {
3681                                         pApp = UiApp::GetInstance();
3682                                         if (pApp != null)
3683                                         {
3684                                                 RemoveOrientationEventListener(*this);
3685
3686                                                 if(__pAddressbar)
3687                                                 {
3688                                                         __pAddressbar->SetAddressbarEventListener(null);
3689                                                 }
3690
3691                                                 if(__pWebViewer)
3692                                                 {
3693                                                         __pWebViewer->RemoveTouchEventListener(*this);
3694                                                         __pWebViewer->SetWebUiEventListenerF(null);
3695                                                         __pWebViewer->SetWebKeypadEventListener(null);
3696                                                         __pWebViewer->SetTextSearchListener(null);
3697                                                         __pWebViewer->SetLoadingListener(null);
3698                                                 }
3699
3700
3701                                                 r = pApp->Terminate();
3702                                                 return;
3703                                         }
3704                                 }
3705                                 else
3706                                 {
3707                                         r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3708                                         if (IsFailed(r))
3709                                         {
3710                                                 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3711                                                 return;
3712                                         }
3713                                 }
3714                                 break;
3715                         }
3716
3717                 }
3718
3719         }
3720
3721 }
3722
3723 void
3724 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3725 {
3726         AppLog("MainForm::OnForwardClicked");
3727         if (__pWebViewer == null)
3728                 return;
3729
3730         if (__pWebViewer->CanGoForward())
3731         {
3732                 __pWebViewer->GoForward();
3733         }
3734 }
3735
3736 void
3737 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3738 {
3739         AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3740         if(__pFooterPanel != null)
3741         {
3742                 __pFooterPanel->SetShowState(false);
3743         }
3744
3745         if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3746         {
3747                 __pAddressbar->SetShowState(true);
3748                 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3749         }
3750
3751         RelayoutControls(false);
3752 }
3753
3754 void
3755 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3756 {
3757         AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3758
3759         int Height = GetClientAreaBounds().height;
3760         AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3761
3762         RelayoutControls(false);
3763 }
3764
3765 void
3766 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3767 {
3768         AddressBarCancelledClicked(addBar);
3769 }
3770
3771 void
3772 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3773 {
3774         __prevAddressBarMode = __curAddressBarMode;
3775
3776         if (__pAddressbar != null)
3777         {
3778                 __curAddressBarMode = GetAddressbarMode();
3779         }
3780
3781         if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3782         {
3783                 __adressPanelPosition.y = 0;
3784                 if (__pAddressbar != null)
3785                 {
3786                         __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3787                         __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3788                         __pAddressbar->Invalidate(true);
3789                 }
3790                 if (__pWebViewer != null)
3791                 {
3792                         __pWebViewer->StopLoading();
3793                 }
3794         }
3795         else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3796         {
3797                 __adressPanelPosition.y = 0;
3798                 if (__pAddressbar != null)
3799                 {
3800                         __webControlPosition.y = 0;
3801                         __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3802                         __pAddressbar->Invalidate(true);
3803                 }
3804         }
3805 }
3806
3807 void
3808 MainForm::OnClipboardClosed(const Addressbar& addBar)
3809 {
3810         AppLog("XYZ::MainForm::OnClipboardClosed");
3811         RelayoutControls(false);
3812 }
3813
3814 void
3815 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3816 {
3817         AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3818         if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3819         {
3820                 AppLog("akjshdasd 3");
3821                 __pFooterPanel->SetShowState(true);
3822         }
3823
3824         RelayoutControls(false,footerState);
3825 }
3826
3827 void
3828 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3829 {
3830         AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3831         RelayoutControls(false);
3832 }
3833
3834 void
3835 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3836 {
3837         __pFooterPanel->SetShowState(false);
3838 }
3839
3840 void
3841 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3842 {
3843         AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3844         RelayoutControls(false);
3845 }
3846
3847 void
3848 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3849 {
3850         AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3851         if (__pWindowInfo)
3852         {
3853                 __pWindowInfo->pageTitle = title;
3854                 if (__pWebViewer != null)
3855                 {
3856                         __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3857                 }
3858         }
3859         if (__pAddressbar != null && __pWebViewer != null)
3860         {
3861                 SetUrl(__pWebViewer->GetUrl());
3862                 __pAddressbar->Invalidate(true);
3863         }
3864 }
3865
3866 void
3867 MainForm::UpdateFavicon(void)
3868 {
3869         bool urlImageType = false;
3870         String *tempPath = null;
3871         if(__pWebViewer)
3872                 tempPath = __pWebViewer->EvaluateJavascriptN(L"var getFavicon = function() {      var favicon = '/favicon.ico';      var nodeList = document.getElementsByTagName('link');    if(nodeList) {  for (var i = 0; i < nodeList.length; i++)      {          if ((nodeList[i].getAttribute('rel') == 'icon')||(nodeList[i].getAttribute('rel') == 'shortcut icon'))         {              favicon = nodeList[i].getAttribute('href');          }      } }     return favicon;          };  getFavicon();");
3873         Bitmap* pBitmap = null;
3874
3875         if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3876         {
3877                 if (__pWindowInfo != null)
3878                 {
3879                         Uri url;
3880                         url.SetUri(*tempPath);
3881                         if (url.GetHost().GetLength() == 0)
3882                         {
3883                                 Uri webUrl;
3884                                 webUrl.SetUri(__pWebViewer->GetUrl());
3885                                 result r = url.SetHost(webUrl.GetHost());
3886                                 if(IsFailed(r))
3887                                 {
3888                                         delete tempPath;
3889                                         return;
3890                                 }
3891                         }
3892                         if (url.GetScheme().GetLength() == 0)
3893                         {
3894                                 Uri webUrl;
3895                                 webUrl.SetUri(__pWebViewer->GetUrl());
3896                                 url.SetScheme(webUrl.GetScheme());
3897                         }
3898                         __pWindowInfo->faviconUrl = url.ToString();
3899
3900                         pBitmap = __pWebViewer->GetFaviconN();
3901
3902                         if (pBitmap != null)
3903                         {
3904                                 if (__pWindowInfo->pFavicon != NULL)
3905                                 {
3906                                         __pWindowInfo->pFavicon = null;
3907                                 }
3908                                 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3909                                 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3910
3911                                 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3912
3913                                 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3914                         }
3915                         else if(__pWindowInfo->pFavicon != null)
3916                         {
3917                                 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3918                         }
3919                         else
3920                         {
3921                                 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3922                                 if(pDefaultBmp != null)
3923                                 {
3924                                         __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3925                                 }
3926                         }
3927                         if(pBitmap)
3928                         {
3929                                 delete pBitmap;
3930                                 pBitmap = null;
3931                         }
3932                 }
3933                 delete tempPath;
3934         }
3935         else
3936         {
3937                 // do not remove
3938                 if(tempPath != null)
3939                 {
3940                         delete tempPath;
3941                 }
3942                 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3943         }
3944
3945 }
3946
3947 bool
3948 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3949                 Tizen::Web::Controls::WebNavigationType type)
3950 {
3951         AppLog("urlk %ls",url.GetPointer());
3952         // when load new page if find word panel is open its show state is false
3953         if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3954         {
3955                 __currentSearchStr = L"";
3956                 __currentWordIndex = 0;
3957                 __maxOccurrances = 0;
3958                 __pFindWordEditField->SetText(L"");
3959                 __pFindWordNext->SetEnabled(false);
3960                 __pFindWordPrev->SetEnabled(false);
3961                 __pFindWordCountLabel->SetText(L"0/0");
3962                 __pFindWordControl->SetShowState(false);
3963                 __pFindWordEditField->HideKeypad();
3964                 RelayoutControls(false);
3965         }
3966
3967         __pFooterPanel->Invalidate(true);
3968
3969         Uri uriInfo;
3970         uriInfo.SetUri(url);
3971
3972         if(url.Contains(IDS_TIZEN_SERVICE))
3973         {
3974                 String appId;
3975                 String delim(L":;,");
3976
3977                 // Creates a StringTokenizer instance
3978                 StringTokenizer strTok(url, delim);
3979
3980                 int count = strTok.GetTokenCount();     // count == 4
3981
3982                 HashMap *pMap = new HashMap();
3983                 pMap->Construct();
3984
3985                 String token;
3986                 String key;
3987                 String value;
3988                 while (strTok.HasMoreTokens())
3989                 {
3990                         AppLog("Token: %ls", token.GetPointer());
3991                         strTok.GetNextToken(token);         // Tizen, StringTokenizer, Sample, code
3992                         if(token.Contains(IDS_APPID))
3993                         {
3994                                 token.SubString(6, appId);
3995                                 AppLog("AppID:%ls", appId.GetPointer());
3996                         }
3997                         else if(token.Contains(IDS_KEY))
3998                         {
3999                                 token.SubString(4, key);
4000                                 AppLog("key:%ls", key.GetPointer());
4001                         }
4002                         else if(token.Contains(IDS_VALUE))
4003                         {
4004                                 token.SubString(6, value);
4005                                 AppLog("value:%ls", value.GetPointer());
4006                         }
4007                 }
4008                 pMap->Add(key, value);
4009
4010                 if(appId != "")
4011                 {
4012                         AppControl *pAppControl = null;
4013                         String operationId = L"http://tizen.org/appcontrol/operation/main";
4014                         pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
4015                         if(pAppControl)
4016                         {
4017                                 result r = pAppControl->Start(null, null, pMap, null);
4018                         }
4019                         else
4020                         {
4021                                 AppLogException("AppControl not found");
4022                         }
4023                         return true;
4024                 }
4025         }
4026
4027         return false;
4028 }
4029
4030 DecisionPolicy
4031 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
4032                 const Tizen::Net::Http::HttpHeader& httpHeader)
4033 {
4034         return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
4035 }
4036
4037 void
4038 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
4039 {
4040         if(__isLongPressedDone == false)
4041                 return;
4042         AppLog("MainForm::OnWebPageBlockSelected");
4043         if (__pHitElementResult != null)
4044         {
4045                 delete __pHitElementResult;
4046                 __pHitElementResult = null;
4047         }
4048
4049         if (__pWebViewer != null)
4050         {
4051                 AppLog("MainForm::OnWebPageBlockSelected web not null");
4052                 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
4053
4054                 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
4055                 {
4056                         AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
4057                         __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
4058                         if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
4059                         {
4060                                 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
4061                         }
4062                         AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
4063                 }
4064         }
4065
4066         if (__pHitElementResult == null)
4067         {
4068                 return;
4069         }
4070
4071         if (__pHitElementResult->HasImage() != true)
4072         {
4073                 String tagName = __pHitElementResult->GetTagName();
4074                 String type = __pHitElementResult->GetAttributeValue("type");
4075
4076
4077                 AppLog("TagName %ls",tagName.GetPointer());
4078                 __currentSelectedStr.Clear();
4079                 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
4080                 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4081                 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
4082
4083                 if (((tagName.CompareTo(L"INPUT") == 0)  || tagName.CompareTo(L"TEXTAREA") == 0) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
4084                 {
4085                         AppLog("MainForm::OnWebPageBlockSelected show paste option");
4086
4087                         InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),true);
4088                         __pImageMenu->SetShowState(true);
4089                         __pImageMenu->Show();
4090                         __pImageMenu->Invalidate(true);
4091                 }
4092                 else /*if(__isLongPressedDone == true)*/
4093                 {
4094                         AppLog("MainForm::OnWebPageBlockSelected no paste option");
4095
4096                         if(__pHitElementResult->GetUrl().GetLength() > 0)
4097                         {
4098                                 __currentSelectedStr.Clear();
4099                                 __currentSelectedStr = __pHitElementResult->GetUrl();
4100                         }
4101                         InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),false);
4102                         __pImageMenu->SetShowState(true);
4103                         __pImageMenu->Show();
4104                         __pImageMenu->Invalidate(true);
4105                 }
4106
4107                 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
4108                 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
4109                 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
4110         }
4111
4112 }
4113
4114 void
4115 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
4116 {
4117
4118 }
4119
4120 Web*
4121 MainForm::OnWebWindowCreateRequested(void)
4122 {
4123         WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
4124
4125         if (pNewWindowInfo == null)
4126         {
4127                 return null;
4128         }
4129         result r = E_SUCCESS;
4130         SceneManager* pSceneManager = SceneManager::GetInstance();
4131         if (pSceneManager == NULL)
4132         {
4133                 return null;
4134         }
4135         ArrayList* pArgList = new(std::nothrow) ArrayList();
4136         if (pArgList == NULL)
4137         {
4138                 return null;
4139         }
4140         r = pArgList->Construct();
4141         if (r == E_SUCCESS)
4142         {
4143                 pNewWindowInfo->isJavascriptInitiated = true;
4144                 pArgList->Add(*pNewWindowInfo);
4145                 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4146                 delete pArgList;
4147                 if (IsFailed(r))
4148                 {
4149                         AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
4150                         return null;
4151                 }
4152         } else {
4153                 delete pArgList;
4154         }
4155
4156         return pNewWindowInfo->pCurrentWeb;
4157 }
4158
4159 void
4160 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
4161 {
4162         AppLog("xyz:: MainForm::RelayoutControls called");
4163         __webControlPosition.y = 0;
4164         __webControlHeight = GetClientAreaBounds().height;
4165         AppLog("Client area height: %d", __webControlHeight);
4166
4167         AppLog("Client area height: %d", __webControlHeight);
4168         if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
4169         {
4170                 __webControlPosition.y += __pAddressbar->GetHeight();
4171                 __webControlHeight -= __pAddressbar->GetHeight();
4172                 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
4173         }
4174         else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
4175         {
4176                 __webControlPosition.y += __pFindWordControl->GetHeight();
4177                 __webControlHeight -= __pFindWordControl->GetHeight();
4178                 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
4179         }
4180
4181         if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
4182         {
4183                 __webControlHeight -= __pFooterPanel->GetHeight();
4184
4185                 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
4186         }
4187         if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
4188         {
4189                 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight + 12 )
4190                 {
4191                 }
4192                 else
4193                 {
4194                         __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12);
4195                         AppLog("xyz:: MainForm::RelayoutControls called __webControlHeight %d",__webControlHeight);
4196                         __pWebViewer->Invalidate(false);
4197                 }
4198         }
4199         if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
4200         {
4201                 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
4202         }
4203
4204         Invalidate(true);
4205 }
4206
4207 void
4208 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
4209 {
4210         if (__pFindWordControl == null)
4211         {
4212                 return;
4213         }
4214
4215         Tizen::Locales::LocaleManager localeManager;
4216         Tizen::Locales::Locale local = localeManager.GetSystemLocale();
4217
4218         String languageCode;
4219         result r = SettingInfo::GetValue(L"Language", languageCode);
4220         // int languagecode = local.GetLanguageCode();
4221         AppLog("rahul language is %S", languageCode.GetPointer());
4222
4223         if (show == true)
4224         {
4225                 InitFindWordPanel();
4226
4227                 if (languageCode.CompareTo("ara") == 0)
4228                 {
4229                         AppLog("rahul language is arabic");
4230
4231                         __pFindWordPanelLeftToRight->SetShowState(false);
4232                         __pFindWordPanelRightToLeft->SetShowState(true);
4233
4234                         __pFindWordClear->SetShowState(false);
4235 //                      __pFindWordCountLabel->SetShowState(false);
4236                         __pFindWordEditField->SetShowState(false);
4237
4238                         __pFindWordClearRightToLeft->SetShowState(true);
4239                         __pFindWordCountLabelRightToLeft->SetShowState(true);
4240                         __pFindWordEditFieldRightToLeft->SetShowState(true);
4241                 }
4242                 else
4243                 {
4244                         AppLog("rahul language is not arabic");
4245
4246
4247                         __pFindWordPanelLeftToRight->SetShowState(true);
4248                         __pFindWordPanelRightToLeft->SetShowState(false);
4249
4250                         __pFindWordClear->SetShowState(true);
4251                         __pFindWordCountLabel->SetShowState(true);
4252                         __pFindWordEditField->SetShowState(true);
4253
4254                         __pFindWordClearRightToLeft->SetShowState(false);
4255                         __pFindWordCountLabelRightToLeft->SetShowState(false);
4256                         __pFindWordEditFieldRightToLeft->SetShowState(false);
4257                 }
4258                 __pFindWordControl->SetShowState(true);
4259         }
4260         else
4261         {
4262                 if(__pFindWordControl != null)
4263                 {
4264                         __pFindWordControl->SetShowState(false);
4265                 }
4266         }
4267
4268         AppLog("MainForm::ShowFindWordPanel %d",show);
4269         if (show && !isTouchPressed)
4270         {
4271                 if (languageCode.CompareTo("ara") == 0)
4272                 {
4273                         if (__pFindWordEditFieldRightToLeft)
4274                         {
4275                                 __pFindWordEditFieldRightToLeft->SetFocus();
4276                                 __pFindWordEditFieldRightToLeft->ShowKeypad();
4277                         }
4278                 }
4279                 else
4280                 {
4281                         if (__pFindWordEditField)
4282                         {
4283                                 __pFindWordEditField->SetFocus();
4284                                 __pFindWordEditField->ShowKeypad();
4285                         }
4286                 }
4287         }
4288         else
4289         {
4290                 if (languageCode.CompareTo("ara") == 0)
4291                 {
4292                         if (__pFindWordEditFieldRightToLeft)
4293                                 __pFindWordEditFieldRightToLeft->HideKeypad();
4294                 }
4295                 else
4296                 {
4297                         if (__pFindWordEditField)
4298                                 __pFindWordEditField->HideKeypad();
4299                 }
4300         }
4301
4302         RelayoutControls(false);
4303 }
4304
4305 void
4306 MainForm::StartWordSearch()
4307 {
4308         //Get the count of occurances of the word in the current page
4309         __maxOccurrances = 0;
4310         __currentWordIndex = 0;
4311
4312         __pFindWordPrev->SetEnabled(false);
4313         String *pCountStr = null;
4314         result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
4315         AppLog("Search Result %s",GetErrorMessage(r));
4316         /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/"  + __currentSearchStr + "/gi).length;");
4317         if (pCountStr != null)
4318         {
4319                 Integer::Parse(*pCountStr, 10, __maxOccurrances);
4320                 delete pCountStr;
4321         }
4322
4323         AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
4324          */
4325
4326 }
4327
4328 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
4329 {
4330         AppLog("MainForm::OnTextFound totalCount %d",totalCount);
4331         AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
4332
4333         if(totalCount == -1 || totalCount == 0)
4334         {
4335                 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
4336                 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
4337 //              return;
4338         }
4339         else if(totalCount > 100)
4340         {
4341                 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4342                 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4343         }
4344         else
4345         {
4346                 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4347                 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4348         }
4349
4350         __maxOccurrances = totalCount;
4351         __currentWordIndex = currentOrdinal;
4352
4353         //Reset the UI controls as per the maxOccurrance value
4354         if (totalCount <= 0)
4355         {
4356                 AppLog("Word not found");
4357                 //Show error notification to user
4358                 __pFindWordNext->SetEnabled(false);
4359                 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4360                 {
4361                         __pFindWordCountLabel->SetText(L"0/0");
4362                         __pFindWordCountLabel->Invalidate(false);
4363                 }
4364                 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4365                 {
4366                         __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4367                         __pFindWordCountLabelRightToLeft->Invalidate(false);
4368                 }
4369                 __pFindWordNext->Invalidate(false);
4370                 __pFindWordPrev->Invalidate(false);
4371
4372                 return;
4373         }
4374
4375         if (totalCount == 1)
4376         {
4377                 __pFindWordNext->SetEnabled(false);
4378         }
4379         else
4380         {
4381                 __pFindWordNext->SetEnabled(true);
4382         }
4383
4384         String countStr = L"";
4385         countStr.Append(__currentWordIndex);
4386         countStr.Append(L"/");
4387         countStr.Append(__maxOccurrances);
4388         if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4389         {
4390         __pFindWordCountLabel->SetText(countStr);
4391         __pFindWordCountLabel->Invalidate(false);
4392         __pFindWordCountLabel->Invalidate(false);
4393         }
4394         else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4395         {
4396                 __pFindWordCountLabelRightToLeft->SetText(countStr);
4397                 __pFindWordCountLabelRightToLeft->Invalidate(false);
4398                 __pFindWordCountLabelRightToLeft->Invalidate(false);
4399         }
4400         //FindNextWord(true);
4401         //Update the controls
4402         __pFindWordNext->Invalidate(false);
4403         __pFindWordPrev->Invalidate(false);
4404
4405 }
4406
4407 void
4408 MainForm::FindNextWord(bool next)
4409 {
4410         if (next == true)
4411         {
4412                 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4413                         if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4414                         {
4415                                 if (__currentWordIndex < __maxOccurrances)
4416                                 {
4417                                         __currentWordIndex++;
4418                                 }
4419                         }
4420         }
4421         else
4422         {
4423                 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4424                 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4425                 {
4426                         if(__currentWordIndex > 1)
4427                         {
4428                                 __currentWordIndex--;
4429                         }
4430                 }
4431         }
4432
4433         String countStr = L"";
4434         countStr.Append(__currentWordIndex);
4435         countStr.Append(L"/");
4436         countStr.Append(__maxOccurrances);
4437
4438         if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4439         {
4440         __pFindWordCountLabel->SetText(countStr);
4441         __pFindWordCountLabel->Invalidate(false);
4442         }
4443         else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4444         {
4445                 __pFindWordCountLabelRightToLeft->SetText(countStr);
4446                 __pFindWordCountLabelRightToLeft->Invalidate(false);
4447         }
4448
4449         if (__currentWordIndex >= __maxOccurrances)
4450         {
4451                 __pFindWordNext->SetEnabled(false);
4452         }
4453         else
4454         {
4455                 __pFindWordNext->SetEnabled(true);
4456         }
4457         if (__currentWordIndex <= 1)
4458         {
4459                 __pFindWordPrev->SetEnabled(false);
4460         }
4461         else
4462         {
4463                 __pFindWordPrev->SetEnabled(true);
4464         }
4465         __pFindWordPrev->Invalidate(false);
4466         __pFindWordNext->Invalidate(false);
4467
4468         __pFindWordControl->Invalidate(true);
4469 }
4470
4471 void
4472 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4473 {
4474         AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4475         __isKeypadOpened = true;
4476         __pFooterPanel->SetShowState(false);
4477         //      OnAddressBarKeypadOpened(*__pAddressbar);
4478 }
4479
4480 void
4481 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4482 {
4483         __isKeypadOpened = true;
4484         AppLog("xyz::MainForm::OnWebKeypadOpened");
4485
4486         if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4487         {
4488                 __currentSearchStr = L"";
4489                 __currentWordIndex = 0;
4490                 __maxOccurrances = 0;
4491                 __pFindWordEditField->SetText(L"");
4492                 __pFindWordNext->SetEnabled(false);
4493                 __pFindWordPrev->SetEnabled(false);
4494                 __pFindWordCountLabel->SetText(L"0/0");
4495                 __pWebViewer->SearchTextAllAsync(L"",false);
4496                 __pFindWordControl->SetShowState(false);
4497                 __pFindWordEditField->HideKeypad();
4498         }
4499
4500
4501         if (__pWebViewer != null && __pFooterPanel != null)
4502         {
4503                 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4504                 if(__pAddressbar != null)
4505                 {
4506                         __pAddressbar->SetShowState(false);
4507                 }
4508                 if(__pFindWordControl != null)
4509                 {
4510                         __pFindWordControl->SetShowState(false);
4511                 }
4512                 __pFooterPanel->SetShowState(false);
4513                 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4514         }
4515 //      if(__pImageMenu && __pImageMenu->GetShowState() == true)
4516 //      {
4517 //              __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4518 //              AppLog("omgomgomg");
4519 //      }
4520         Invalidate(true);
4521 }
4522
4523 void
4524 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4525 {
4526         AppLog("xyz::MainForm::OnWebKeypadClosed");
4527         AppLog("akjshdasd 4");
4528         __pFooterPanel->SetShowState(true);
4529 //      OnAddressBarKeypadClosed(*__pAddressbar);
4530         RelayoutControls(false);
4531         __isKeypadOpened = false;
4532 }
4533
4534 void
4535 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4536 {
4537         //      RelativeLayout(false);
4538         if(__pWebViewer != null)
4539         {
4540                 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4541         }
4542 }
4543
4544 void
4545 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4546 {
4547         Control* temp = const_cast< Control* >(&source);
4548         Header* pHeader = dynamic_cast< Header* >(temp);
4549         if (pHeader != null)
4550         {
4551                 //Header double - clicked
4552                 AppLog("Header double clicked");
4553         }
4554         if(__pFindWordControl)
4555         {
4556                 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4557                 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4558         }
4559
4560
4561         AppLog("MainScene::OnTouchDoublePressed");
4562
4563 }
4564
4565 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4566 {
4567         AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4568         if(TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1)
4569         {
4570                 AppLog("Returning because of more than one touch point.");
4571                 return;
4572         }
4573         __longPressPoint = currentPosition;
4574
4575         if (__pHitElementResult != null)
4576         {
4577                 delete __pHitElementResult;
4578                 __pHitElementResult = null;
4579         }
4580
4581         if (__pWebViewer != null)
4582         {
4583                 AppLog("MainForm::OnTouchLongPressed web not null");
4584                 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4585         }
4586
4587         if (__pHitElementResult == null)
4588         {
4589                 return;
4590         }
4591
4592         if (__pHitElementResult->HasImage() == true)
4593         {
4594                 if(__pWebViewer != null)
4595                         InitImageContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4596                 __pImageMenu->SetShowState(true);
4597                 __pImageMenu->Show();
4598                 __pImageMenu->Invalidate(true);
4599         }
4600         else if(__pHitElementResult->HasUrl() == true)
4601         {
4602                 String tempURl = __pHitElementResult->GetUrl();
4603                 AppLog("tempURl is %ls", tempURl.GetPointer());
4604                 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4605                 if (pBitmap != null)
4606                 {
4607                         AppLog("not null");
4608                 }
4609                 else
4610                 {
4611                         AppLog(null);
4612                 }
4613                 InitImageLinkContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4614                 __pImageMenu->SetShowState(true);
4615                 __pImageMenu->Show();
4616                 __pImageMenu->Invalidate(true);
4617         }
4618         else
4619         {
4620                 String tagName = __pHitElementResult->GetTagName();
4621                 String type = __pHitElementResult->GetAttributeValue("type");
4622                 String value = __pHitElementResult->GetAttributeValue(L"value");
4623                 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4624
4625                 __currentSelectedStr.Clear();
4626                 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4627
4628                 AppLog("tag name is %ls", tagName.GetPointer());
4629                 AppLog("type is %ls", type.GetPointer());
4630
4631
4632
4633                 __isLongPressedDone = true;
4634                 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4635                 if (((tagName.CompareTo(L"INPUT") == 0)  || tagName.CompareTo(L"TEXTAREA") == 0) && innerHtml.GetLength() == 0  && type.CompareTo(L"submit") !=0/*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.CompareTo(L"") == 0 && r == E_INVALID_ARG)
4636                 {
4637                         AppLog("MainForm::OnWebPageBlockSelected show paste option");
4638
4639                         InitSelectTextContextMenu(Point(currentPosition.x , currentPosition.y + __pWebViewer->GetY()),true, true);
4640                         if(__pImageMenu)
4641                         {
4642                                 __pImageMenu->SetShowState(true);
4643                                 __pImageMenu->Show();
4644                                 __pImageMenu->Invalidate(true);
4645                         }
4646                 }
4647                 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4648
4649         }
4650 //      __inputEventToBeSupressed = true;
4651 }
4652
4653 void
4654 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4655 {
4656         AppLog("xyz:: MainForm::OnTouchReleased called");
4657
4658         if (__pAddressbar && __pAddressbar->GetShowState() == true)
4659         {
4660                 __pAddressbar->SetShowState(false);
4661         }
4662         if(__pFooterPanel && __isKeypadOpened == false)
4663         {
4664                 __pFooterPanel->SetShowState(true);
4665         }
4666
4667         // Not reuired now.
4668         /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4669         if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4670         {
4671                 __pWebViewer->ConsumeInputEvent();
4672         }
4673         if(pHitElement != null)
4674         {
4675                 delete pHitElement;
4676         }
4677         __inputEventToBeSupressed = false;*/
4678 }
4679
4680 bool
4681 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4682 {
4683
4684         return true;
4685 }
4686
4687 bool
4688 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4689 {
4690         if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4691         {
4692                 __currentSearchStr = L"";
4693                 __currentWordIndex = 0;
4694                 __maxOccurrances = 0;
4695
4696                 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4697                 {
4698                         __pFindWordEditField->SetText(L"");
4699                         __pFindWordEditField->HideKeypad();
4700                         __pFindWordControl->SetShowState(false);
4701                         __pFindWordCountLabel->SetText(L"0/0");
4702                 }
4703                 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4704                 {
4705                         __pFindWordEditFieldRightToLeft->SetText(L"");
4706                         __pFindWordEditFieldRightToLeft->HideKeypad();
4707                         __pFindWordControl->SetShowState(false);
4708                         __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4709                 }
4710
4711                 __pFindWordNext->SetEnabled(false);
4712                 __pFindWordPrev->SetEnabled(false);
4713
4714                 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
4715                 __pFindWordControl->SetShowState(false);
4716         }
4717         AppLog("__pAddressbar->GetShowState() %d",__pAddressbar->GetShowState());
4718         if(__pAddressbar->GetShowState() == false)
4719         {
4720                 __pAddressbar->SetAddressbarURLFocus();
4721                 __pFooterPanel->SetShowState(false);
4722         }
4723
4724         return false;
4725 }
4726
4727 bool
4728 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4729 {
4730         return true;
4731 }
4732
4733 bool
4734 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4735 {
4736         return true;
4737 }
4738
4739 bool
4740 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4741 {
4742         return true;
4743 }
4744
4745 bool
4746 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4747 {
4748         return true;
4749 }
4750
4751 bool
4752 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4753 {
4754         return true;
4755 }
4756
4757 void
4758 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4759 {
4760         AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4761         int widthContextItem = 0;
4762         if(__pFindWordCountLabel)
4763                 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4764         // As per the platform engineer comment removed this line
4765         /*if(__pWebViewer != null)
4766         {
4767                 // this is added because if any text is selected on long press followed by on rotation we are hiding the context menu therefore we should release the text block also
4768                 __pWebViewer->ReleaseBlock();
4769         }*/
4770
4771 //      if(__pFindWordControl != null)
4772 //              ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4773
4774         if(__pOptionMenu && __pOptionMenu->GetShowState() == true)
4775         {
4776                 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
4777                 {
4778                         AppLog(" Orientation landscape");
4779                         __pOptionMenu->SetMaxVisibleItemsCount(5);
4780                 }
4781                 else
4782                 {
4783                         AppLog(" Orientation potrait");
4784                         __pOptionMenu->SetMaxVisibleItemsCount(6);
4785                 }
4786         }
4787         if(__pNotification && __pNotification->GetShowState() == true)
4788         {
4789                 __pNotification->SetShowState(false);
4790                 __pNotification->Invalidate(false);
4791         }
4792         if ( __pFooterLabel != null)
4793         {
4794                 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4795                 if(pBitmap != null)
4796                 {
4797                         __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4798                         delete pBitmap;
4799                 }
4800
4801
4802         }
4803         if (__pFindWordBgLabel != null)
4804         {
4805                 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4806                 if (pBitmap != null)
4807                 {
4808                         __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4809                         delete pBitmap;
4810                 }
4811         }
4812
4813         if (__pFindWordBgLabelRightToLeft != null)
4814         {
4815                 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4816                 if (pBitmap != null)
4817                 {
4818                         __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4819                         delete pBitmap;
4820                 }
4821         }
4822
4823
4824 //      if(__pOptionMenu != null)
4825 //              __pOptionMenu->SetShowState(false);
4826
4827         if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4828         {
4829                 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4830         }
4831         else
4832         {
4833                 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4834         }
4835
4836         if (__pFooterPanel)
4837         {
4838                 AppLog("__pFooterPanel->GetShowState() is true");
4839                 InitFooter();
4840                 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4841                 __pFooterPanel->Invalidate(true);
4842         }
4843         InitAddressbar();
4844
4845         String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4846         if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4847         {
4848                 InitMostVisitedSitesView(orientationStatus);
4849         }
4850
4851         RelayoutControls(false);
4852         if (__pArticleReaderPanel != null)
4853         {
4854                 if (__pArticleReaderPanel->GetShowState() == true)
4855                 {
4856                         __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4857
4858                         if (__pBlankPanel != null)
4859                                 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4860
4861                         if (__pWebReader != null)
4862                         {
4863                                 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4864                         }
4865                         Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4866                         Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4867
4868                         if ( pBitmap != null && pSrcBitmap != null)
4869                         {
4870                                 AppLog("CreateReaderPanel ninepatchbitmap found");
4871                                 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4872                         }
4873
4874                         __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4875                         __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4876                         if (pBitmap != null)
4877                         {
4878                                 delete pBitmap;
4879                                 pBitmap = null;
4880                         }
4881                         if (pSrcBitmap != null)
4882                         {
4883                                 delete pSrcBitmap;
4884                                 pSrcBitmap = null;
4885                         }
4886                 }
4887         }
4888         Invalidate(true);
4889         
4890     if (__pAddressbar != null)
4891         {
4892                 int width = GetClientAreaBounds().width;
4893                 __pAddressbar->OrientationChanged(width);
4894         }
4895 }
4896
4897 void
4898 MainForm::OnSettingsChange(int settingvalue)
4899 {
4900         AppLogDebug("MainForm::OnSettingsChange entered");
4901
4902         if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4903         {
4904                 __pAddressbar->ResetGuideText();
4905         }
4906         if (__pWebViewer == null)
4907         {
4908                 AppLogDebug("Webviewer is not initialized yet.");
4909                 return;
4910         }
4911
4912         if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4913         {
4914                 WebSetting settings = __pWebViewer->GetSetting();
4915                 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4916                 {
4917                         settings.SetAutoFittingEnabled(true);
4918                 }
4919                 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
4920                 {
4921                         settings.SetAutoFittingEnabled(false);
4922                 }
4923                 __pWebViewer->SetSetting(settings);
4924         }
4925         else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4926         {
4927                 WebSetting settings = __pWebViewer->GetSetting();
4928                 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4929                 __pWebViewer->SetSetting(settings);
4930         }
4931         else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4932         {
4933                 WebSetting settings = __pWebViewer->GetSetting();
4934                 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4935                 __pWebViewer->SetSetting(settings);
4936                 __pWebViewer->Reload();
4937         }
4938         else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4939         {
4940                 WebSetting settings = __pWebViewer->GetSetting();
4941                 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4942                 __pWebViewer->SetSetting(settings);
4943         }
4944         else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4945         {
4946                 if (__pWebViewer)
4947                 {
4948                         __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4949                 }
4950         }
4951         else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
4952         {
4953                 if (__pWebViewer)
4954                 {
4955                         WebSetting settings = __pWebViewer->GetSetting();
4956                         settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
4957                         __pWebViewer->SetSetting(settings);
4958                 }
4959         }
4960         else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
4961         {
4962                 if (__pWebViewer)
4963                 {
4964                         WebSetting settings = __pWebViewer->GetSetting();
4965                         settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
4966                         __pWebViewer->SetSetting(settings);
4967                 }
4968         }
4969         else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4970         {
4971                 WebSetting settings = __pWebViewer->GetSetting();
4972                 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4973                 {
4974                         settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4975                 }
4976                 else
4977                 {
4978                         settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4979                 }
4980                 __pWebViewer->SetSetting(settings);
4981         }
4982         else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4983         {
4984                 if (__pWebReader)
4985                 {
4986                         AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4987                         WebSetting settings = __pWebReader->GetSetting();
4988                         settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4989                         __pWebReader->SetSetting(settings);
4990                 }
4991         }
4992 }
4993
4994 void
4995 MainForm::OnSettingsReset()
4996 {
4997         if (__pWebViewer)
4998         {
4999                 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
5000                 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
5001         }
5002 }
5003
5004 void
5005 MainForm::OnClearCache()
5006 {
5007         result r = E_SUCCESS;
5008
5009         if (__pWebViewer != NULL)
5010         {
5011                 r = __pWebViewer->ClearCache();
5012                 if (r == E_SUCCESS)
5013                 {
5014                         AppLogDebug("Cache cleared success");
5015                 }
5016                 else
5017                 {
5018                         AppLogDebug("Cache cleared fail");
5019                 }
5020         }
5021 }
5022
5023 void
5024 MainForm::OnClearCookie()
5025 {
5026         result r = E_SUCCESS;
5027
5028         if (__pWebViewer != NULL)
5029         {
5030                 __pWebViewer->ClearCookie();
5031         }
5032         if (r == E_SUCCESS)
5033         {
5034                 AppLogDebug("Cookie cleared success");
5035         }
5036         else
5037         {
5038                 AppLogDebug("Cache cleared fail");
5039         }
5040 }
5041
5042 void
5043 MainForm::OnClearFormData()
5044 {
5045         result r = E_SUCCESS;
5046
5047         if (__pWebViewer != NULL)
5048         {
5049                 __pWebViewer->ClearFormData();
5050         }
5051         if (r == E_SUCCESS)
5052         {
5053                 AppLogDebug("Cookie cleared success");
5054         }
5055         else
5056         {
5057                 AppLogDebug("Cache cleared fail");
5058         }
5059 }
5060
5061 void
5062 MainForm::OnClearPasswords()
5063 {
5064         result r = E_SUCCESS;
5065
5066         if (__pWebViewer != NULL)
5067         {
5068                 __pWebViewer->ClearLoginFormData();
5069         }
5070         if (r == E_SUCCESS)
5071         {
5072                 AppLogDebug("Cookie cleared success");
5073         }
5074         else
5075         {
5076                 AppLogDebug("Cache cleared fail");
5077         }
5078 }
5079
5080
5081 double
5082 MainForm::findDistance(int x1,int y1,int x2, int y2)
5083 {
5084         int deltaX = Math::Abs(x2 - x1);
5085         int deltaY = Math::Abs(y2 - y1);
5086         double num = deltaX*deltaX + deltaY*deltaY;
5087
5088         if (num >= 0)
5089         {
5090                 double x = num;
5091                 int i;
5092                 for (i = 0; i < 20; i++)
5093                 {
5094                         x = (((x*x)+ num)/(2*x));
5095                 }
5096                 return num;
5097         }
5098         else
5099         {
5100                 return 0.0;
5101         }
5102 }
5103
5104 void
5105 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5106 {
5107         AppLog("xyz:: MainForm::OnTouchPressed called");
5108         if(__pFindWordControl)
5109         {
5110                 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
5111 //              ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
5112         }
5113         __isLongPressedDone = false;
5114
5115
5116
5117         Touch touch;
5118         IList* pList = null;
5119         pList = touch.GetTouchInfoListN(source);
5120
5121         if (pList != null)
5122         {
5123                 int count = pList->GetCount();
5124                 if (count == 1)
5125                 {
5126                         TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5127                         __touchPoint1 = pTouchInfo->position;
5128
5129                         /*if (__pAddressbar != null)
5130                         {
5131                                 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5132                                 {
5133                                         if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5134                                         {
5135                                                 __pAddressbar->SaveAddressbarEditText();
5136                                         }
5137                                         __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5138                                 }
5139
5140                                 __pAddressbar->Invalidate(true);
5141                         }*/
5142                         if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5143                         {
5144                                 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5145                                 {
5146                                         //__pAddressbar->SaveAddressbarEditText();
5147                                 }
5148                                 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5149                         }
5150                 }
5151                 else if (count == 2)
5152                 {
5153                         AppLogDebug("MainForm::OnTouchPressed count is two");
5154                         TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5155                         __touchPoint1 = pTouchInfo->position;
5156
5157                         pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
5158                         __touchPoint2 = pTouchInfo->position;
5159                 }
5160         }
5161         if( pList != NULL)
5162         {
5163                 pList->RemoveAll(true);
5164                 delete pList;
5165         }
5166         if(__pAddressbar)
5167         {
5168                 __pAddressbar->SetShowState(false);
5169         }
5170         if(__pFooterPanel && __isKeypadOpened == false)
5171         {
5172                 __pFooterPanel->SetShowState(true);
5173         }
5174         RelayoutControls(false);
5175         return;
5176 }
5177
5178 void
5179 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5180 {
5181 //      __currentWordIndex = 0;
5182         __isLongPressedDone = false;
5183
5184 }
5185
5186 void
5187 MainForm::MoveUiControls()
5188 {
5189 }
5190
5191 void
5192 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
5193 {
5194         if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
5195         {
5196                 if(__pFooterUrlField->GetTextLength() == 0)
5197                 {
5198                         __pFooterUrlField->SetKeypadActionEnabled(false);
5199                 }
5200                 else
5201                 {
5202                         __pFooterUrlField->SetKeypadActionEnabled(true);
5203                 }
5204         }
5205         if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
5206         {
5207                 __currentSearchStr = __pFindWordEditField->GetText();
5208                 if (__currentSearchStr.GetLength() > 0)
5209                 {
5210                         __pFindWordCountLabel->SetShowState(true);
5211                 }
5212                 else
5213                 {
5214 //                      __pFindWordCountLabel->SetShowState(false);
5215                         __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
5216                         __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
5217
5218                 }
5219                 __pFindWordNext->SetEnabled(false);
5220                 __pFindWordPrev->SetEnabled(false);
5221                 __pFindWordNext->Invalidate(true);
5222                 __pFindWordPrev->Invalidate(true);
5223                 __pFindWordCountLabel->SetText(L"0/0");
5224                 __pFindWordCountLabel->Invalidate(true);
5225         }
5226         else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
5227         {
5228                 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
5229                 if (__currentSearchStr.GetLength() > 0)
5230                 {
5231                         __pFindWordCountLabelRightToLeft->SetShowState(true);
5232                 }
5233                 else
5234                 {
5235                         __pFindWordCountLabelRightToLeft->SetShowState(false);
5236                 }
5237
5238                 __pFindWordNext->SetEnabled(false);
5239                 __pFindWordPrev->SetEnabled(false);
5240                 __pFindWordNext->Invalidate(true);
5241                 __pFindWordPrev->Invalidate(true);
5242                 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
5243                 __pFindWordCountLabelRightToLeft->Invalidate(true);
5244         }
5245         AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
5246         if (__currentSearchStr.GetLength() > 0)
5247         {
5248                 StartWordSearch();
5249         }
5250         else
5251         {
5252                 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
5253                 StartWordSearch();
5254                 __currentSearchStr = L"";
5255                 AppLogDebug("Enter something");
5256         }
5257 }
5258
5259 result
5260 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
5261 {
5262         return E_SUCCESS;
5263
5264 }
5265
5266 result
5267 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
5268 {
5269         if(__pWebViewer != null)
5270                 return E_SUCCESS;
5271
5272         AppLog("MainForm::InitMostVisitedSitesView");
5273         result r = E_SUCCESS;
5274
5275
5276         if (__pWebViewer != null && __pMostVisitedListView != null)
5277         {
5278                 return E_SUCCESS;
5279         }
5280
5281         if (__pMostVisitedListView != null)
5282         {
5283                 RemoveControl(__pMostVisitedListView);
5284         }
5285         if(__pMostVisitedSites != null)
5286         {
5287                 __pMostVisitedSites->RemoveAll(true);
5288         }
5289
5290         HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
5291
5292         __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
5293         __pMostVisitedListView = new(std::nothrow) ListView();
5294
5295         int height = GetClientAreaBounds().height;
5296
5297         if(__pFooterPanel->GetShowState() == true)
5298         {
5299                 height = height - __pFooterPanel->GetHeight();
5300         }
5301         if(__pAddressbar->GetShowState() == true)
5302         {
5303                 height -= __pAddressbar->GetHeight();
5304         }
5305
5306         r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
5307
5308         if (r != E_SUCCESS)
5309         {
5310                 delete __pMostVisitedListView;
5311                 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
5312                 return r;
5313         }
5314         __pMostVisitedListView->SetItemProvider(*this);
5315         __pMostVisitedListView->AddListViewItemEventListener(*this);
5316         __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_VISITED_SITES"));
5317         AddControl(__pMostVisitedListView);
5318         __pMostVisitedListView->UpdateList();
5319
5320         return E_SUCCESS;
5321
5322 }
5323
5324 String
5325 MainForm::GetImagePath(void)
5326 {
5327
5328         String str;
5329         String formattedTime;
5330         DateTime currentTime;
5331         LocaleManager localManager;
5332         SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
5333
5334         localManager.Construct();
5335         Locale locale = localManager.GetSystemLocale();
5336         //Locale locale(LANGUAGE_ENG, COUNTRY_US);
5337
5338         // Get date formatter
5339         DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
5340
5341         if (pTimeFormatter)
5342         {
5343                 pTimeFormatter->Format(currentTime, formattedTime);
5344         }
5345
5346         AppLog("current time stamp is %ls", formattedTime.GetPointer());
5347         String delim(L" :");
5348         StringTokenizer strTok(formattedTime, delim);
5349         String token;
5350         String imageName;
5351         String str1("GMT+00");
5352         while (strTok.HasMoreTokens())
5353         {
5354                 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
5355                 if(token.Equals(str1))
5356                         break;
5357                 AppLog("token is %ls", token.GetPointer());
5358                 imageName.Append(token);
5359         }
5360         return imageName;
5361
5362 }
5363
5364 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
5365 {
5366         result r = E_FAILURE;
5367         AppLog("Content manager 1");
5368         ContentId contentId;
5369         ContentManager contentManager;
5370         r = contentManager.Construct();
5371         if(IsFailed(r))
5372         {
5373                 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
5374                 return;
5375         }
5376         Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
5377         Tizen::Io::Directory::Create(contentPath,true);
5378         if(GetLastResult() == E_FILE_ALREADY_EXIST)
5379         {
5380                 AppLog("Already exists");
5381         }
5382         else if(GetLastResult() == E_SUCCESS)
5383         {
5384                 AppLog("created success");
5385         }
5386         contentPath.Append(imageName);
5387         contentPath.Append(".jpg");
5388         contentId = contentManager.CreateContent(*aBuffer, contentPath);
5389         ShowIndicatorNotification(L"Download Complete",contentPath);
5390         AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5391 }
5392
5393 void
5394 MainForm::ShowIndicatorNotification(const String& messageText, const String& contentPath)
5395 {
5396         AppLogDebug("ENTER");
5397
5398         NotificationRequest request;
5399         request.SetAlertText(messageText);
5400         request.SetTitleText(L"");
5401         request.SetAppMessage(contentPath);
5402         request.SetOngoingActivityType(ONGOING_ACTIVITY_TYPE_TEXT);
5403         request.SetNotificationStyle(NOTIFICATION_STYLE_THUMBNAIL);
5404         Tizen::App::App* pApp = Tizen::App::App::GetInstance();
5405         String homePath = pApp->GetAppRootPath();
5406         String iconPath = homePath + L"res/screen-density-xhigh/Notification_download_complete.png";
5407         AppLog("The iconPath is : %ls", homePath.GetPointer());
5408         request.SetIconFilePath(iconPath);
5409
5410         Tizen::Shell::NotificationManager notiMgr;
5411         notiMgr.Construct();
5412         notiMgr.Notify(request);
5413         AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));
5414         return;
5415 }
5416
5417 void
5418 MainForm::SetForwardButtonEnabled(bool isEnabled)
5419 {
5420         __pGoForwardBtn->SetEnabled(isEnabled);
5421         __pGoForwardBtn->Invalidate(true);
5422 }
5423
5424 void
5425 MainForm::SetBackButtonEnabled(bool isEnabled)
5426 {
5427         __pGoBackBtn->SetEnabled(isEnabled);
5428         __pGoBackBtn->Invalidate(true);
5429 }
5430
5431 void
5432 MainForm::UpdateProgress(int percentage)
5433 {
5434         __progressPercentage = percentage;
5435         if (percentage == 0 || percentage == 100)
5436         {
5437                 __isLoadingData = false;
5438                 if (percentage == 100)
5439                 {
5440                         __isLoadingCompleted = true;
5441                         __progressPercentage = 0;
5442                 }
5443                 else
5444                 {
5445                         __isLoadingCompleted = false;
5446                 }
5447         }
5448         else
5449         {
5450                 __isLoadingData = true;
5451         }
5452         UpdateProgressBitmap();
5453 }
5454
5455 int
5456 MainForm::GetProgress(void)
5457 {
5458         return __progressPercentage;
5459 }
5460
5461 void
5462 MainForm::UpdateProgressBitmap(void)
5463 {
5464         result r = E_SUCCESS;
5465         if (__pProgressbarLabel == null)
5466                 return;
5467         int w = __pProgressbarLabel->GetWidth();
5468         int h = __pProgressbarLabel->GetHeight();
5469         Canvas canvas;
5470         int progressWidth = 0;
5471         Bitmap* pRetBitmap = null;
5472
5473         if (__progressPercentage == 0 || __progressPercentage == 100)
5474         {
5475                 __pProgressbarLabel->SetShowState(false);
5476                 __pProgressbarLabel->Invalidate(false);
5477                 return;
5478         }
5479         else
5480         {
5481                 __pProgressbarLabel->SetShowState(true);
5482                 __pProgressbarLabel->Invalidate(false);
5483         }
5484
5485         r = canvas.Construct(Rectangle(0, 0, w, h));
5486
5487         if (r != E_SUCCESS)
5488         {
5489                 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5490                 return;
5491         }
5492
5493         canvas.Clear();
5494         Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5495
5496         if (pBgBmp != null)
5497         {
5498                 pBgBmp->Scale(Dimension(w, h));
5499                 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5500                 delete pBgBmp;
5501         }
5502
5503         progressWidth = (double) (w) * __progressPercentage / 100;
5504         AppLogDebug("progressWidth: %d", progressWidth);
5505         Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5506
5507         if (pProgressBmp != null)
5508         {
5509                 pProgressBmp->Scale(Dimension(progressWidth, h));
5510                 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5511                 delete pProgressBmp;
5512         }
5513
5514         pRetBitmap = new (std::nothrow) Bitmap();
5515
5516         if (pRetBitmap == null)
5517         {
5518                 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5519                 return;
5520         }
5521
5522         pRetBitmap->Construct(canvas, canvas.GetBounds());
5523
5524         if (__pProgressbarLabel != null && pRetBitmap != null)
5525         {
5526                 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5527                 __pProgressbarLabel->Invalidate(false);
5528         }
5529
5530         if (pRetBitmap != null)
5531         {
5532                 delete pRetBitmap;
5533                 pRetBitmap = null;
5534         }
5535         return;
5536 }
5537
5538 void
5539 MainForm::ReaderClicked()
5540 {
5541         result r = E_SUCCESS;
5542         ArrayList* pArgList = new(std::nothrow) ArrayList();
5543         if (pArgList != null)
5544         {
5545                 r = pArgList->Construct();
5546                 if (IsFailed(r))
5547                 {
5548                         delete pArgList;
5549                         return;
5550                 }
5551
5552                 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5553                 if (IsFailed(r))
5554                 {
5555                         delete pArgList;
5556                         return;
5557                 }
5558
5559                 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5560                 if (IsFailed(r))
5561                 {
5562                         delete pArgList;
5563                         return;
5564                 }
5565
5566                 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5567                 if (IsFailed(r))
5568                 {
5569                         delete pArgList;
5570                         return;
5571                 }
5572         }
5573
5574         SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5575         return;
5576
5577
5578 }
5579
5580 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5581 {
5582         AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5583
5584         __currentAddMode = addMode;
5585
5586         switch(addMode)
5587         {
5588         case ADDRESSBAR_MODE_INVALID:
5589         {
5590                 // do nothing
5591         }
5592         break;
5593         case ADDRESSBAR_MODE_READER:
5594         {
5595                 __pStopBtn->SetShowState(false);
5596                 __pRefreshBtn->SetShowState(false);
5597                 __pClearBtn->SetShowState(false);
5598                 __pReaderBtn->SetShowState(false);
5599         }
5600         break;
5601         case ADDRESSBAR_MODE_LOADING:
5602         {
5603                 __pRefreshBtn->SetShowState(false);
5604                 __pStopBtn->SetShowState(true);
5605                 __pClearBtn->SetShowState(false);
5606                 __pReaderBtn->SetShowState(false);
5607         }
5608         break;
5609         case ADDRESSBAR_MODE_LOADING_COMPLETE:
5610         {
5611 //              SetUrl(__pAddressbar->GetUrl());
5612
5613                 __pRefreshBtn->SetShowState(true);
5614                 __pStopBtn->SetShowState(false);
5615                 __pClearBtn->SetShowState(false);
5616                 __pReaderBtn->SetShowState(false);
5617         }
5618         break;
5619         case ADDRESSBAR_MODE_EDIT:
5620         {
5621                 __pRefreshBtn->SetShowState(false);
5622                 __pStopBtn->SetShowState(false);
5623                 __pReaderBtn->SetShowState(false);
5624                 __pClearBtn->SetShowState(true);
5625         }
5626         break;
5627         }
5628
5629         Invalidate(true);
5630
5631         OnAddressBarModeChanged();
5632 }
5633
5634 AddressBarMode MainForm::GetAddressbarMode(void)
5635 {
5636         return __currentAddMode;
5637 }
5638
5639 void MainForm::SetUrl(const String& url)
5640 {
5641         __displayUrl = url;
5642         if(__displayUrl.GetLength() > 2048)
5643                 __displayUrl.SubString(0,2048,__displayUrl);
5644
5645         if (__pFooterUrlField != NULL)
5646         {
5647                 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5648                 if (removedHttpUrl.IsEmpty() == false)
5649                 {
5650                         __pFooterUrlField->SetText(removedHttpUrl);
5651                         if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5652                                 __pAddressbar->SetUrl(__displayUrl);
5653                 }
5654                 else
5655                 {
5656                         __pFooterUrlField->SetText(__displayUrl);
5657                         if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5658                                 __pAddressbar->SetUrl(__displayUrl);
5659                 }
5660                 if(__pFooterUrlField)
5661                         __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5662                 __pFooterUrlField->Invalidate(false);
5663                 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5664                         __pAddressbar->Invalidate(true);
5665 //              __pFooterUrlField->SetCursorPosition(0);
5666         }
5667 }
5668
5669 String
5670 MainForm::RemoveHttpTextFromDisplayURL(void)
5671 {
5672         AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5673         int index = -1;
5674 //      bool isHttpText = __displayUrl.Contains(L"http://");
5675         String updatedDisplayUrl;
5676         updatedDisplayUrl.Clear();
5677         if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5678         {
5679                 __displayUrl.SubString(7,updatedDisplayUrl);
5680         }
5681         else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5682         {
5683                 __displayUrl.SubString(8,updatedDisplayUrl);
5684         }
5685         return updatedDisplayUrl;
5686 }
5687
5688 void MainForm::OnSharePopupControlStarted(void)
5689 {
5690         __pWebViewer->AddTouchEventListener(*this);
5691 }
5692
5693 void
5694 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5695 {
5696         if (requestId == BACK_GROUND_APP_EVENT)
5697         {
5698                 if(__pWebViewer != null)
5699                 {
5700                         __pWebViewer->Pause();
5701                 }
5702                 if(__pImageMenu)
5703                 {
5704                         __pImageMenu->SetShowState(false);
5705                 }
5706                 if(__pAddressbar != null)
5707                 {
5708                         __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5709                 }
5710         }
5711         else if(requestId == FORE_GROUND_APP_EVENT)
5712         {
5713                 if(__pWebViewer != null)
5714                 {
5715                         __pWebViewer->Resume();
5716                 }
5717                 if(__pAddressbar != null)
5718                 {
5719                         __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5720                 }
5721         }
5722 }
5723
5724 void
5725 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5726 {
5727         AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5728         result r = E_SUCCESS;
5729
5730         if (__pAddressbar)
5731                 __pAddressbar->SetShowState(false);
5732
5733         AppLog("akjshdasd 5");
5734         __pFooterPanel->SetShowState(true);
5735
5736         if(__pWebViewer)
5737                 __pWebViewer->SetFocus();
5738         else if(__pMostVisitedListView)
5739                 __pMostVisitedListView->SetFocus();
5740         else if(__pMultiWindowButton)
5741                 __pMultiWindowButton->SetFocus();
5742         else if(__pMoreButton)
5743                 __pMoreButton->SetFocus();
5744
5745         __pAddressbar->SetShowState(false);
5746
5747         RelayoutControls(false);
5748 }
5749
5750 void
5751 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5752 {
5753         AppLog("MainForm::OnFormMenuRequested called");
5754         InitOptionMenu();
5755         if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer && __pWebViewer->GetShowState() == true)
5756         {
5757                 int bookmarkCount=0;
5758                 bool exist = false;
5759                 String url=L"";
5760                 url=__pWindowInfo->pageUrl;
5761                 AppLog("MainForm::OnFormMenuRequested url %ls",url.GetPointer());
5762                 result r = E_SUCCESS;
5763                 Bitmap* pBitmap = null;
5764                 String lastChar = L"";
5765 //              if(url.SubString(url.GetLength()-1,lastChar));
5766 //              if(lastChar == L"/")
5767 //              {
5768 //                      bool exist1 = false;
5769 //                      bool exist2 = false;
5770 //                      r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist1);
5771 //                      url.SubString(0,url.GetLength() - 1,url);
5772 //                      r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist2);
5773 //                      exist = exist1 | exist2;
5774 //              }
5775 //              else
5776 //              {
5777                         r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5778                         if (IsFailed(r))
5779                         {
5780                                 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5781                                 return;
5782                         }
5783 //              }
5784                 if ( exist == true)
5785                 {
5786                         pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5787                 }
5788                 else
5789                 {
5790                         pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5791                 }
5792                 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5793
5794                 if (__pOptionMenu->GetItemCount() == 9)
5795                 {
5796                         r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5797                 }
5798                 else
5799                 {
5800                         r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5801                 }
5802
5803                 if (IsFailed(r))
5804                 {
5805                         AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
5806                         delete pBitmap;
5807                         return ;
5808                 }
5809                 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
5810                 if (__pOptionMenu->GetItemCount() != 9)
5811                 {
5812                         __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
5813                         __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
5814 //                              __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
5815                         __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
5816                         __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
5817                         __pOptionMenu->SetMaxVisibleItemsCount(6);
5818                 }
5819                 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
5820                 {
5821                         AppLog(" Orientation landscape");
5822                         __pOptionMenu->SetMaxVisibleItemsCount(5);
5823                 }
5824                 else
5825                 {
5826                         AppLog(" Orientation potrait");
5827                         __pOptionMenu->SetMaxVisibleItemsCount(6);
5828                 }
5829
5830                 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
5831                 delete pBitmap;
5832         }
5833         AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
5834         if(__pAddressbar)
5835                 __pAddressbar->SetShowState(false);
5836         SetFocus();
5837         __pFooterPanel->SetShowState(true);
5838         result r = __pOptionMenu->SetShowState(true);
5839         AppLog("ajsghd %s",GetErrorMessage(r));
5840         __pOptionMenu->Invalidate(true);
5841         __pOptionMenu->Show();
5842
5843 }