2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (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
8 // http://floralicense.org/license/
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.
17 //!Internet MainForm class
19 *@brief: The %MainForm provides the common functionalities for the Main View of the Browser including the addressbar,
20 * loading,handling events etc.
24 #include <FGraphics.h>
29 #include "IntBookmarkData.h"
30 #include "IntBookmarkPresentationModel.h"
31 #include "IntCommonLib.h"
32 #include "IntFaviconManager.h"
33 #include "IntMainForm.h"
34 #include "IntNotificationPanel.h"
35 #include "IntSceneRegister.h"
36 #include "IntSettingPresentationModel.h"
38 using namespace Tizen::App;
39 using namespace Tizen::Base;
40 using namespace Tizen::Base::Collection;
41 using namespace Tizen::Base::Runtime;
42 using namespace Tizen::Base::Utility;
43 using namespace Tizen::Graphics;
44 using namespace Tizen::Io;
45 using namespace Tizen::Locales;
46 using namespace Tizen::Media;
47 using namespace Tizen::Ui;
48 using namespace Tizen::Ui::Controls;
49 using namespace Tizen::Content;
50 using namespace Tizen::Ui::Scenes;
51 using namespace Tizen::System;
52 using namespace Tizen::Web;
53 using namespace Tizen::Web::Controls;
55 static const wchar_t* IDB_SEARCH_INPUT_FIELD_BG = L"I01_toolbar_input_field.9.png";
56 static const wchar_t* IDB_FINDWORD_INPUT_FIELD_BG = L"I01_toolbar_input_field_findword.9.png";
57 static const wchar_t* IDB_BTN_BACK = L"I01_icon_Back.png";
58 static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
59 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
60 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
61 static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
62 static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
63 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
64 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
65 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
66 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
67 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
68 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
69 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
70 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
71 static const wchar_t* IDS_APPID = L"AppID";
72 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
73 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
75 const int IDA_BACKBTN_CLICKED = 101;
76 const int IDA_BOOKMARKBTN_CLICKED = 102;
77 const int IDA_MOREBTN_CLICKED = 103;
78 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
79 const int IDA_NEWWINDOWBTN_CLICKED = 105;
80 const int IDA_FORWARD_CLICKED = 106;
81 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
82 const int IDA_SHARE_CLICKED = 108;
83 const int IDA_FINDONPAGE_CLICKED = 109;
84 const int IDA_PRIVATEON_CLICKED = 110;
85 const int IDA_SETTINGS_CLICKED = 111;
86 const int IDA_READER_CLOSE_CLICKED = 112;
87 const int IDA_SMALLFONT_BTN_CLICKED = 113;
88 const int IDA_LARGEFONT_BTN_CLICKED = 114;
89 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
90 const int IDA_HISTORY_CLICKED = 116;
91 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
92 const int IDA_ADD_TO_HOME_CLICKED = 118;
93 const int IDA_SAVED_PAGES_CLICKED = 119;
94 const int IDA_DESKTOP_VIEW_CLICKED = 120;
95 const int IDA_SAVE_CLICKED = 121;
97 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
98 const int IDA_FINDWORD_NEXT_CLICKED = 202;
99 const int IDA_FINDWORD_PREV_CLICKED = 203;
100 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
101 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
103 const int IDA_COPY_IMAGE_CLICKED = 206;
104 const int IDA_VIEW_IMAGE_CLICKED = 207;
105 const int IDA_SAVE_IMAGE_CLICKED = 208;
106 const int IDA_SHARE_IMAGE_CLICKED = 209;
108 const int IDA_COPY_TEXT_CLICKED = 210;
109 const int IDA_PASTE_TEXT_CLICKED = 211;
110 const int IDA_FIND_TEXT__CLICKED = 212;
111 const int IDA_SHARE_TEXT_CLICKED = 213;
113 const int IDA_GO_BACK = 214;
114 const int IDA_GO_FORWARD = 215;
115 const int IDA_REFRESH_BTN_CLICKED = 216;
116 const int IDA_STOP_BTN_CLICKED = 217;
117 const int IDA_CLEAR_URL = 218;
119 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
121 const int MainForm::IDA_FORMAT_BITMAP = 500;
122 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
123 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
124 const int MainForm::IDA_FORMAT_URL_STRING = 503;
125 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
127 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
128 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
129 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
131 MainForm::MainForm(void)
133 __isLongPressedDone = false;
134 __pAddressbar = null;
135 // __pMostVisitedSitesPanel = null;
136 __pMostVisitedListView = null;
137 __pFooterPanel = null;
138 __pHitElementResult = null;
139 __pWindowInfo = null;
143 __pFindWordControl = null;
145 __pFindWordBgLabel = null;
146 __pFindWordEditField = null;
147 __pFindWordClear = null;
148 __pFindWordCountLabel = null;
149 __pFindWordNext = null;
150 __pFindWordPrev = null;
151 __previousZoomLevel = 1.0;
153 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
156 __currentSearchStr = L"";
157 __currentSelectedStr = L"";
158 __maxOccurrances = 0;
159 __currentWordIndex = 0;
162 __inputEventToBeSupressed = false;
163 __isLoadingData = false;
164 __isLoadingCompleted = false;
165 __progressPercentage = 0;
166 __touchPoint1 = Point(-1,-1);
167 __touchPoint2 = Point(-1,-1);
169 // __pReaderPopup = null;
170 __pReaderData = null;
172 __pReaderCloseBtn = null;
173 //__pNewWindowButton = null;
174 __pMoreButton = null;
175 __pMultiWindowButton = null;
176 __pArticleReaderPanel = null;
177 __pBlankPanel = null;
178 __pArticleReaderLabel = null;
179 __webControlHeight = 0;
180 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
181 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
182 __pMostVisitedSites = null;
183 __pFooterUrlField = null;
185 __pGoForwardBtn = null;
186 __pRefreshBtn = null;
187 __pProgressbarLabel = null;
188 __pFooterLabel = null;
191 __isWebKeypadOpened = false;
194 MainForm::~MainForm(void)
196 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
200 __pAddressbar->SetAddressbarEventListener(null);
202 if (__pReaderData != null)
204 delete __pReaderData;
205 __pReaderData = null;
208 if (__pPopUp != null)
214 if (__pHitElementResult != null)
216 delete __pHitElementResult;
217 __pHitElementResult = null;
220 String* pSelectedScene = NULL;
221 Object* pValue = NULL;
222 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
223 pSelectedScene = (String*) pValue;
225 /*if (pSelectedScene != null)
227 delete pSelectedScene;
229 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
233 MainForm::Initialize(void)
235 Construct(L"IDL_FORM");
240 MainForm::OnInitializing(void)
242 AppLog("get client area width = %d",GetClientAreaBounds().width);
243 AppLog("get client area height = %d",GetClientAreaBounds().height);
244 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
245 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
247 Panel* pFooterPanel = null;
249 __pSaveImage = new Image();
250 __pSaveImage->Construct();
252 // Setup back event listener
253 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
254 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
255 AddOrientationEventListener(*this);
256 AppLogDebug(" MainForm::OnInitializing ended");
257 if (__pMostVisitedSites == null)
259 __pMostVisitedSites = new(std::nothrow) ArrayList();
260 __pMostVisitedSites->Construct();
262 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
264 __pItemContext= new(std::nothrow) ListContextItem();
265 __pItemContext->Construct();
266 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
267 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
269 if (pBitmapNormal != null && pBitmapPressed != null)
271 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
274 if (pBitmapNormal != null)
276 delete pBitmapNormal;
279 if (pBitmapPressed != null)
281 delete pBitmapPressed;
284 __pItemContextLandscape= new(std::nothrow) ListContextItem();
285 __pItemContextLandscape->Construct();
286 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
287 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
289 if (pBitmapNormal != null && pBitmapPressed != null)
291 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
294 if (pBitmapNormal != null)
296 delete pBitmapNormal;
299 if (pBitmapPressed != null)
301 delete pBitmapPressed;
308 MainForm::InitAddressbar(void)
310 AppLogDebug("MainForm::InitAddressbar entered");
312 result r = E_SUCCESS;
314 if (__pAddressbar != null)
318 __pAddressbar = new(std::nothrow) Addressbar();
319 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
320 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
323 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
326 __pAddressbar->SetAddressbarEventListener(this);
327 AddControl(*__pAddressbar);
328 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
329 SetControlAlwaysOnTop(*__pAddressbar, true);
330 __adressPanelPosition = __pAddressbar->GetPosition();
332 AppLogDebug("MainForm::InitAddressbar exit");
338 MainForm::CreateReaderPanel(void)
340 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
341 result r = E_FAILURE;
343 Button *pSmallFontBtn = null;
344 Button *pLargeFontBtn = null;
346 __pBlankPanel = new (std::nothrow) Panel();
347 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
349 __pArticleReaderPanel = new (std::nothrow) Panel();
350 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
352 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
353 if (__pReaderCloseBtn)
355 AppLogDebug("CreateReaderPanel() 6");
356 __pReaderCloseBtn->AddActionEventListener(*this);
357 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
360 __pWebReader = new (std::nothrow) Web();
361 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
363 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
364 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
366 r = __pWebReader->SetSetting(settings);
368 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
371 __pArticleReaderLabel = new Label();
372 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
374 __pBlankPanel->AddControl(*__pArticleReaderLabel);
375 __pBlankPanel->AddControl(*__pArticleReaderPanel);
376 AddControl(*__pBlankPanel);
378 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
379 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
380 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
382 __pArticleReaderPanel->AddControl(*__pWebReader);
383 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
384 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
385 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
387 if (pBitmap != null && pSrcBitmap != null)
389 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
391 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
393 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
396 pSmallFontBtn->AddActionEventListener(*this);
397 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
400 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
403 pLargeFontBtn->AddActionEventListener(*this);
404 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
413 if (pSrcBitmap != null)
419 SetControlAlwaysOnTop(*__pBlankPanel, true);
420 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
427 MainForm::InitWebControl()
429 AppLogDebug("MainForm::InitWebControl enter");
430 result r = E_SUCCESS;
431 AppLogDebug("InitWebControl");
433 if (__pAddressbar == null || __pFooterPanel == null)
436 const int Y_WEBCONTROL_POSITION = 0;
437 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
438 if (__pMostVisitedListView)
440 __pMostVisitedListView->SetShowState(false);
442 if (__pWebViewer != null)
444 AppLogDebug("Already initialized");
447 __pWebViewer = new(std::nothrow) Web();
448 if(__pWebViewer == NULL)
450 AppLogDebug("Initialization failed");
453 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight));
457 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
464 r = AddControl(*__pWebViewer);
468 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
471 __webControlPosition = __pWebViewer->GetPosition();
472 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
475 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
479 __pWebViewer->SetLoadingListener(this);
480 __pWebViewer->SetWebUiEventListener(this);
481 __pWebViewer->SetWebKeypadEventListener(this);
482 __pWebViewer->SetFocus();
483 __pWebViewer->AddTouchEventListener(*this);
485 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
486 __pWebViewer->SetTextSearchListener(this);
489 AppLogDebug("MainForm :before return");
491 AppLogDebug("MainForm::InitWebControl Exit");
497 MainForm::OnFocusGained(const Control& source)
499 AppLog("MainForm::OnFocusGained");
503 MainForm::OnFocusLost(const Control& source)
505 AppLog("MainForm::OnFocusLost");
509 MainForm::SetJavascriptEnabled()
511 WebSetting settings = __pWebViewer->GetSetting();
512 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
513 __pWebViewer->SetSetting(settings);
517 MainForm::SetImageLoadEnabled()
519 WebSetting settings = __pWebViewer->GetSetting();
520 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
521 __pWebViewer->SetSetting(settings);
525 MainForm::InitFooter(void)
527 AppLogDebug("MainForm::InitFooter entered");
528 Button* pBackButton = null;
529 Button* pBookmarkButton = null;
530 Button* pMultiWindowButton = null;
531 Bitmap *pIconBitmap = null;
532 Bitmap *pBGBitmap = null;
533 Label *pBGLabel = null;
535 if (__pFooterPanel == null)
537 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
540 if (__pFooterPanel == null)
545 SetControlAlwaysOnTop(*__pFooterPanel, true);
547 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
548 if ( __pFooterLabel == NULL )
552 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
553 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
556 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
560 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
562 if ( __pMultiWindowButton == NULL )
567 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
569 if ( __pMoreButton == NULL )
574 if (__pMultiWindowButton != null)
576 Bitmap* pBitmap = null;
577 Bitmap* pPressedBitmap = null;
578 String imagePath = "I01_toolbar_icon_windows_manager_0";
579 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
580 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
581 imagePath.Append(totalCount);
582 imagePath.Append(".png");
584 pressedImagePath.Append(totalCount);
585 pressedImagePath.Append("_press.png");
587 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
588 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
589 if ( pBitmap == null )
594 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
597 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
598 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
603 __pMultiWindowButton->AddActionEventListener(*this);
604 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
609 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
610 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
613 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
614 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
615 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
619 __pMoreButton->AddActionEventListener(*this);
620 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
623 //Add the editfield for url
624 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
625 if (__pFooterUrlField == NULL)
627 return E_INVALID_KEY;
630 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
631 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
632 //__pFooterUrlField->AddFocusEventListener(*this);
633 __pFooterUrlField->AddKeypadEventListener(*this);
634 //__pFooterUrlField->AddFocusEventListener(*this);
635 __pFooterUrlField->SetPropagatedTouchEventListener(this);
637 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
639 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
641 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
643 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
647 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
648 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
651 //Add the go Back Button
652 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
653 if (__pGoBackBtn == NULL)
655 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
656 return E_INVALID_KEY;
658 __pGoBackBtn->SetActionId(IDA_GO_BACK);
659 __pGoBackBtn->AddActionEventListener(*this);
661 //Add the go forward Button
662 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
663 if (__pGoForwardBtn == NULL)
665 AppLogDebug("Control not found returning E_INVALID_KEY");
666 return E_INVALID_KEY;
668 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
669 __pGoForwardBtn->AddActionEventListener(*this);
670 __pGoForwardBtn->SetEnabled(false);
672 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
673 if (__pRefreshBtn == NULL)
675 AppLogDebug("Control not found returning E_INVALID_KEY");
676 return E_INVALID_KEY;
679 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
680 __pRefreshBtn->AddActionEventListener(*this);
681 __pRefreshBtn->SetShowState(true);
683 //Add the backround label for displaying progressbar
684 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
685 if (__pProgressbarLabel == NULL)
687 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
688 return E_INVALID_KEY;
690 __pProgressbarLabel->SetShowState(false);
692 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
693 if (__pStopBtn == NULL)
695 AppLogDebug("Control not found returning E_INVALID_KEY");
696 return E_INVALID_KEY;
698 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
699 __pStopBtn->AddActionEventListener(*this);
700 __pStopBtn->SetShowState(false);
702 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
703 if (__pClearBtn == NULL)
705 AppLogDebug("Control not found returning E_INVALID_KEY");
706 return E_INVALID_KEY;
708 __pClearBtn->SetActionId(IDA_CLEAR_URL);
709 __pClearBtn->AddActionEventListener(*this);
710 __pClearBtn->SetShowState(false);
712 // __pFooterPanel->Invalidate(true);
713 AppLogDebug("MainForm::InitFooter exit");
719 MainForm::InitContextMenu(Point& p)
721 result r = E_SUCCESS;
722 bool isPrivateBrowsing = false;
723 Bitmap* pBitmap = null;
727 __pMenu->SetAnchorPosition(p);
728 __pMenu->Invalidate(true);
732 __pMenu = new(std::nothrow) ContextMenu();
733 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST);
734 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
736 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
739 if (isPrivateBrowsing == true)
741 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
745 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
748 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
750 if ( pBitmap != NULL)
752 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"), IDA_PRIVATEON_CLICKED,*pBitmap);
755 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
756 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
757 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
760 __pMenu->SetMaxVisibleItemsCount(6);
761 __pMenu->SetShowState(false);
762 __pMenu->AddActionEventListener(*this);
763 SetControlAlwaysOnTop(*__pMenu, true);
769 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
771 result r = E_SUCCESS;
772 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
774 AppLog("MainForm::InitImageContextMenu clicked on image");
775 if (__pImageMenu != null)
781 p.y = p.y + __pAddressbar->GetHeight() + 12;
784 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
788 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
790 __pImageMenu = new (std::nothrow) ContextMenu();
791 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
792 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
794 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
795 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
796 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
797 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_IMAGE_CLICKED);
798 __pImageMenu->SetMaxVisibleItemsCount(4);
799 __pImageMenu->AddActionEventListener(*this);
800 SetControlAlwaysOnTop(*__pImageMenu, true);
805 result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
807 result r = E_SUCCESS;
808 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
810 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
811 if (__pImageMenu != null)
816 p.y = p.y + __pAddressbar->GetHeight() + 12;
819 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
823 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
825 __pImageMenu = new (std::nothrow) ContextMenu();
826 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
827 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
829 if(onlyPasteOption == false)
831 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
833 if (pasteOption || onlyPasteOption)
835 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
837 if(onlyPasteOption == false)
839 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
840 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
843 __pImageMenu->SetMaxVisibleItemsCount(3);
844 __pImageMenu->AddActionEventListener(*this);
845 SetControlAlwaysOnTop(*__pImageMenu, true);
852 MainForm::InitFindWordPanel(void)
854 result r = E_SUCCESS;
855 Bitmap *pIconBitmap = null;
857 if (__pFindWordControl != null)
859 AppLogDebug("Findword panel already initialized");
860 if (__pFindWordBgLabel != null)
862 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
865 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
872 __pFindWordControl = new (std::nothrow) Panel();
873 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
876 AppLogException("There is some problem in the xml file. Please check.");
879 AddControl(*__pFindWordControl);
880 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
881 SetControlAlwaysOnTop(*__pFindWordControl,true);
882 __pFindWordControl->SetShowState(false);
883 __pFindWordControl->Invalidate(false);
885 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
886 if (__pFindWordBgLabel != null)
888 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
889 Rectangle pRect = pPanel1->GetBounds();
890 pRect.x = pRect.y = 0;
891 __pFindWordBgLabel->SetBounds(pRect);
892 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
895 AppLogDebug("InitFindWordPanel: Coming here");
896 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
901 AppLogDebug("InitFindWordPanel: shouldn't Come here");
905 Button* pfindWordCancel = null;
906 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
907 if (pfindWordCancel == null)
909 AppLogException("There is some problem in the xml file. Please check.");
912 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
913 pfindWordCancel->AddActionEventListener(*this);
915 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
916 if (__pFindWordClear == null)
918 AppLogException("There is some problem in the xml file. Please check.");
922 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
923 __pFindWordClear->AddActionEventListener(*this);
925 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
926 if (__pFindWordNext == null)
928 AppLogException("There is some problem in the xml file. Please check.");
932 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
933 __pFindWordNext->AddActionEventListener(*this);
935 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
936 if (__pFindWordPrev == null)
938 AppLogException("There is some problem in the xml file. Please check.");
942 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
943 __pFindWordPrev->AddActionEventListener(*this);
945 __pFindWordNext->SetEnabled(false);
946 __pFindWordPrev->SetEnabled(false);
948 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
949 if (__pFindWordCountLabel == null)
951 AppLogException("There is some problem in the xml file. Please check.");
955 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
956 if (__pFindWordEditField == null)
958 AppLogException("There is some problem in the xml file. Please check.");
961 __pFindWordEditField->AddTextEventListener(*this);
962 __pFindWordEditField->AddKeypadEventListener(*this);
963 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
969 MainForm::CreateItem (int index, int itemWidth)
971 Rectangle listImageRect;
972 Rectangle pagetTitleRect;
973 Rectangle pageURLRect;
974 Rectangle deleteImageRect;
975 String pageTitle(L"");
977 result r = E_SUCCESS;
978 Bitmap* pListIconImage = null;
981 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
986 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
987 if ( pAppResource == NULL )
991 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
993 CustomItem* pItem = new(std::nothrow) CustomItem();
994 pageTitle = pHistory->GetHistoryTitle();
995 pageURL = pHistory->GetHistoryUrl();
997 if (pageURL.GetLength() == 0)
1000 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1001 pageURL = L"<"+ nourl +">";
1005 Rectangle screenBounds = GetBounds();
1008 r = pItem->Construct(Dimension(itemWidth, 128), style);
1017 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1019 if ( pBitmap != NULL)
1021 pListIconImage = new Bitmap();
1022 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1026 if(pListIconImage == null)
1028 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1031 if ( pListIconImage != NULL)
1033 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1034 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1035 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1038 if (pItem != null && pListIconImage != NULL)
1040 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1044 if (pageTitle.CompareTo(L"") != 0)
1048 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1052 if (pageURL.CompareTo(L"") != 0)
1056 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1061 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1063 if ( __pItemContext!= NULL)
1067 pItem->SetContextItem(__pItemContext);
1073 if ( __pItemContextLandscape!= NULL)
1077 pItem->SetContextItem(__pItemContextLandscape);
1081 if( pListIconImage != NULL)
1083 delete pListIconImage;
1084 pListIconImage = null;
1091 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1098 MainForm::GetItemCount (void)
1100 if(__pMostVisitedSites != null)
1102 __pMostVisitedSites->RemoveAll(true);
1104 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1105 if(__pMostVisitedSites != null)
1107 return __pMostVisitedSites->GetCount();
1114 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1116 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1117 String url = pHistory->GetHistoryUrl();
1118 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1119 __pMostVisitedListView->UpdateList();
1123 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1125 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1126 String url = pHistory->GetHistoryUrl();
1134 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1140 MainForm::OnTerminating(void)
1142 result r = E_SUCCESS;
1145 delete __pItemContext;
1147 if(__pItemContextLandscape)
1149 delete __pItemContextLandscape;
1155 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1157 result r = E_SUCCESS;
1159 AppLogDebug("Clicked : %d", actionId);
1162 case IDA_BACKBTN_CLICKED:
1164 if (__pWebViewer && __pWebViewer->CanGoBack())
1166 __pWebViewer->GoBack();
1171 pApp = UiApp::GetInstance();
1174 r = pApp->Terminate();
1177 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1185 case IDA_FORWARD_CLICKED:
1186 if (__pWebViewer == null)
1189 if (__pWebViewer->CanGoForward())
1191 __pWebViewer->GoForward();
1193 __pMenu->SetShowState(false);
1194 __pMenu->Invalidate(false);
1197 case IDA_FINDONPAGE_CLICKED:
1199 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1200 __currentSearchStr.Clear();
1202 InitFindWordPanel();
1203 __pMenu->SetShowState(false);
1204 __pMenu->Invalidate(false);
1205 ShowFindWordPanel(true);
1207 __pFindWordEditField->SetFocus();
1209 if (__pWebViewer != null)
1211 // releasing the set block
1212 __pWebViewer->ReleaseBlock();
1218 case IDA_PRIVATEON_CLICKED:
1220 result r = E_SUCCESS;
1222 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1223 Bitmap* pBitmap = null;
1224 if (isPrivateBrowsing == true)
1226 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1229 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1233 if (__pWebViewer != NULL)
1235 __pWebViewer->SetPrivateBrowsingEnabled(false);
1238 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1240 if (__pAddressbar != null)
1242 __pAddressbar->UpdateFaviconBitmap(false);
1248 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1251 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1255 if (__pWebViewer != NULL)
1257 __pWebViewer->SetPrivateBrowsingEnabled(true);
1260 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1262 if (__pAddressbar != null)
1264 __pAddressbar->UpdateFaviconBitmap(true);
1269 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1270 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1271 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1272 __pMenu->Invalidate(true);
1274 if ( pBitmap != NULL )
1281 case IDA_SETTINGS_CLICKED:
1284 ArrayList* pArgList = new(std::nothrow) ArrayList();
1287 pArgList->Construct();
1288 pArgList->Add(*__pWindowInfo);
1289 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1291 __pMenu->SetShowState(false);
1292 __pMenu->Invalidate(false);
1293 if (pArgList != null)
1302 case IDA_ADDTOBOOKMARK_CLICKED:
1305 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1307 int bookmarkCount=0;
1310 url=__pWindowInfo->pageUrl;
1311 result r = E_SUCCESS;
1312 Bitmap* pBitmap = null;
1313 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1321 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1322 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1323 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1325 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1326 if (pNotification != null)
1328 pNotification->SetText(message);
1329 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1330 pNotification->ShowNotification();
1335 String title=__pWindowInfo->pageTitle;
1336 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1337 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1339 pBookmark->SetBookmarkTitle(title);
1340 pBookmark->SetUrl(url);
1341 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1343 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1345 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1346 pBookmark->SetFaviconId(id);
1347 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1348 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1351 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1352 if (pNotification != null)
1354 pNotification->SetText(message);
1355 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1356 pNotification->ShowNotification();
1357 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1360 if (pBitmap != null)
1362 r = __pMenu->SetItemAt(0,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1366 __pMenu->Invalidate(true);
1370 case IDA_SHARE_CLICKED:
1372 if(__pPopUp != null)
1377 __pPopUp = new(std::nothrow) SharePopup();
1378 __pPopUp->Initialize();
1379 if (__pWindowInfo != null)
1381 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1382 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1383 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1384 pShareInfo->SetImageAttached(false);
1385 __pPopUp->RemoveAllShareInfo();
1386 __pPopUp->AddShareInfo(pShareInfo);
1388 __pPopUp->SetShowState(true);
1392 case IDA_BOOKMARKBTN_CLICKED:
1394 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1395 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1398 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1403 case IDA_MOREBTN_CLICKED:
1405 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1406 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1407 AppLog("Anchot pos: %d %d", p.x, p.y);
1409 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1411 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1412 int bookmarkCount=0;
1415 url=__pWindowInfo->pageUrl;
1416 result r = E_SUCCESS;
1417 Bitmap* pBitmap = null;
1419 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1422 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1427 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1431 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1433 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1435 if (__pMenu->GetItemCount() == 8)
1437 r = __pMenu->SetItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1441 r = __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1446 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1450 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1451 if (__pMenu->GetItemCount() != 8)
1453 __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADDTOBOOKMARK_CLICKED);
1455 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1456 __pMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1457 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1458 __pMenu->SetMaxVisibleItemsCount(6);
1460 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1462 AppLog(" Orientation landscape");
1463 __pMenu->SetMaxVisibleItemsCount(5);
1467 AppLog(" Orientation potrait");
1468 __pMenu->SetMaxVisibleItemsCount(6);
1471 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1474 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1475 __pMenu->SetShowState(true);
1476 __pMenu->Invalidate(true);
1480 case IDA_HISTORY_CLICKED:
1482 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1483 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1486 case IDA_SAVED_PAGES_CLICKED:
1491 case IDA_DESKTOP_VIEW_CLICKED:
1496 case IDA_SAVE_CLICKED:
1501 case IDA_MULTIWINDOWBTN_CLICKED:
1503 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1504 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1508 case IDA_NEWWINDOWBTN_CLICKED:
1510 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1512 if (pNewWindowInfo == null)
1516 result r = E_SUCCESS;
1517 SceneManager* pSceneManager = SceneManager::GetInstance();
1519 if (pSceneManager == NULL)
1523 ArrayList* pArgList = new(std::nothrow) ArrayList();
1524 if (pArgList == NULL)
1528 r = pArgList->Construct();
1531 pArgList->Add(*pNewWindowInfo);
1532 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1538 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1543 case IDA_SMALLFONT_BTN_CLICKED:
1545 WebSetting setting = __pWebReader->GetSetting();
1546 setting.SetFontSize(15);
1547 __pWebReader->SetSetting(setting);
1550 case IDA_LARGEFONT_BTN_CLICKED:
1552 WebSetting setting = __pWebReader->GetSetting();
1553 setting.SetFontSize(25);
1554 __pWebReader->SetSetting(setting);
1557 case IDA_READER_CLOSE_CLICKED:
1559 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1561 //__pArticleReaderPanel->SetShowState(false);
1562 //__pArticleReaderPanel->Show();
1563 RemoveControl(*__pBlankPanel);
1564 //RemoveControl(*__pArticleReaderPanel);
1565 __pArticleReaderPanel = null;
1566 __pBlankPanel = null;
1567 __pArticleReaderLabel = null;
1569 //if (__pAddressbar)
1570 // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1571 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1574 case IDA_FINDWORD_CANCEL_CLICKED:
1576 __currentSearchStr = L"";
1577 __currentWordIndex = 0;
1578 __maxOccurrances = 0;
1579 __pFindWordEditField->SetText(L"");
1580 __pFindWordNext->SetEnabled(false);
1581 __pFindWordPrev->SetEnabled(false);
1582 __pFindWordCountLabel->SetText(L"0/0");
1583 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1584 ShowFindWordPanel(false);
1587 case IDA_FINDWORD_SEARCH_CLICKED:
1589 __currentSearchStr = __pFindWordEditField->GetText();
1590 if (__currentSearchStr.GetLength() > 0)
1596 AppLogDebug("Enter something");
1600 case IDA_FINDWORD_CLEAR_CLICKED:
1602 __pFindWordCountLabel->SetText(L"0/0");
1603 __pFindWordEditField->SetText(L"");
1604 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1606 __currentSearchStr = L"";
1607 __pFindWordNext->SetEnabled(false);
1608 __pFindWordPrev->SetEnabled(false);
1609 __pFindWordControl->Invalidate(true);
1612 case IDA_FINDWORD_NEXT_CLICKED:
1617 case IDA_FINDWORD_PREV_CLICKED:
1619 FindNextWord(false);
1622 case IDA_BRIGHTNESS_BTN_CLICKED:
1624 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1625 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1628 case IDA_COPY_IMAGE_CLICKED:
1630 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1631 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1633 const Bitmap* pBitmap = null;
1634 if (__pHitElementResult != null)
1636 pBitmap = __pHitElementResult->GetImage();
1639 String resourcePath = App::GetInstance()->GetAppResourcePath();
1640 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1642 // copying the item to clipboard
1643 Clipboard* pClipboard = Clipboard::GetInstance();
1644 if (pClipboard != null)
1646 pClipboard->CopyItem(item);
1650 case IDA_VIEW_IMAGE_CLICKED:
1652 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1653 WindowInfo* pNewWindowInfo = null;
1654 if (__pHitElementResult != null)
1656 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1657 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1663 case IDA_SAVE_IMAGE_CLICKED:
1665 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1666 const Bitmap* pSaveBitmap = null;
1667 String imageName = GetImagePath();
1668 AppLog("Content manager image name %ls",imageName.GetPointer());
1671 imagePath.Append(imageName);
1672 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1673 AppLog("Content manager image path %ls",imagePath.GetPointer());
1674 if (__pHitElementResult != null)
1676 pSaveBitmap = __pHitElementResult->GetImage();
1678 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1682 UpdateImageContent(pBuffer, imageName);
1684 NotificationPanel *pNotification = new NotificationPanel(*this);
1686 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1687 msg.Append(imagePath);
1688 if (pNotification != null)
1690 pNotification->SetText(msg);
1691 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1692 pNotification->ShowNotification();
1697 int __modalMsgBoxResult;
1698 MessageBox* pMsgBox = new MessageBox();
1699 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1700 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1703 __modalMsgBoxResult = 0;
1707 case IDA_SHARE_IMAGE_CLICKED:
1709 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1710 if (__pPopUp != null)
1715 __pPopUp = new(std::nothrow) SharePopup();
1716 __pPopUp->Initialize();
1717 if (__pHitElementResult != null)
1719 const Bitmap* pSaveBitmap = null;
1720 String imageName = GetImagePath();
1721 AppLog("Content manager image name %ls",imageName.GetPointer());
1724 imagePath.Append(imageName);
1725 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1726 AppLog("Content manager image path %ls",imagePath.GetPointer());
1727 if (__pHitElementResult != null)
1729 pSaveBitmap = __pHitElementResult->GetImage();
1731 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1733 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1734 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1736 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1737 pShareInfo->SetPageTitle(L"");
1738 pShareInfo->SetPageUrl(srcUrl);
1739 pShareInfo->SetImageAttached(true);
1740 pShareInfo->SetImagePath(imagePath);
1741 __pPopUp->RemoveAllShareInfo();
1742 __pPopUp->AddShareInfo(pShareInfo);
1743 __pPopUp->SetShowState(true);
1748 case IDA_FIND_TEXT__CLICKED:
1750 AppLogDebug("MainForm::OnActionPerformed find word clicked");
1751 __currentSearchStr.Clear();
1752 __currentSearchStr.Append(__currentSelectedStr);
1753 InitFindWordPanel();
1756 __pMenu->SetShowState(false);
1757 __pMenu->Invalidate(false);
1760 __adressPanelPosition.y = 0;
1762 if (__pAddressbar != null && __pWebViewer != NULL)
1764 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
1765 //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
1766 //__pAddressbar->Invalidate(true);
1767 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
1769 if (__pFooterPanel->GetShowState() == false)
1770 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
1772 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
1773 // __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
1774 __pWebViewer->Invalidate(true);
1777 ShowFindWordPanel(true);
1778 __pFindWordEditField->SetFocus();
1780 if (__currentSearchStr.GetLength() > 0)
1786 AppLogDebug("Enter something");
1789 if (__pWebViewer != null)
1791 // releasing the set block
1792 __pWebViewer->ReleaseBlock();
1797 case IDA_SHARE_TEXT_CLICKED:
1799 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
1800 if(__pPopUp != null)
1805 __pPopUp = new(std::nothrow) SharePopup();
1806 __pPopUp->Initialize();
1807 if (__pHitElementResult != null)
1809 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1810 pShareInfo->SetPageTitle(L"");
1811 pShareInfo->SetPageUrl(__currentSelectedStr);
1812 pShareInfo->SetImageAttached(false);
1813 __pPopUp->RemoveAllShareInfo();
1814 __pPopUp->AddShareInfo(pShareInfo);
1815 __pPopUp->SetShowState(true);
1820 case IDA_COPY_TEXT_CLICKED:
1822 // need to implement
1823 //__currentSelectedStr
1824 // Sets data to a clip board item
1826 String resourcePath = App::GetInstance()->GetAppResourcePath();
1827 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
1829 // copying the item to clipboard
1830 Clipboard* pClipboard = Clipboard::GetInstance();
1831 if (pClipboard != null)
1833 pClipboard->CopyItem(item);
1837 case IDA_PASTE_TEXT_CLICKED:
1839 Clipboard* pClipboard = Clipboard::GetInstance();
1841 if(pClipboard == null)
1845 // Retrieves a latest item
1846 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
1852 //Gets data from the clipboard item
1853 String* pString = dynamic_cast<String*>(pItem->GetData());
1855 if (pString != null)
1857 String idElement = __pHitElementResult->GetAttributeValue(L"id");
1858 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
1859 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
1860 String script = L"function insertAtCursor(myField, myValue) { if (document.selection) { myField.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 { myField.value += myValue; } } ";
1861 if(idElement.GetLength() != 0)
1863 script.Append("insertAtCursor(");
1864 script.Append(idElement);
1866 script.Append("\"");
1867 script.Append(*pString);
1868 script.Append("\");");
1870 else if (nameElement.GetLength() != 0)
1872 script.Append("insertAtCursor(document.getElementsByName('");
1873 script.Append(nameElement);
1874 script.Append("')[0],");
1875 script.Append("\"");
1876 script.Append(*pString);
1877 script.Append("\");");
1879 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
1880 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
1891 case IDA_GO_FORWARD:
1896 case IDA_REFRESH_BTN_CLICKED:
1898 __isLoadingCompleted = false;
1899 __isLoadingData = true;
1900 __progressPercentage = 0;
1901 __displayUrl = __pFooterUrlField->GetText();
1903 String url = __pFooterUrlField->GetText();
1904 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
1908 UpdateProgressBitmap();
1911 case IDA_STOP_BTN_CLICKED:
1913 __isLoadingCompleted = false;
1914 __isLoadingData = false;
1915 __progressPercentage = 0;
1916 __pFooterUrlField->HideKeypad();
1917 __displayUrl = __pFooterUrlField->GetText();
1921 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1922 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1923 __pWebViewer->StopLoading();
1924 RequestRedraw(true);
1927 UpdateProgressBitmap();
1932 if (__pFooterUrlField->GetText().IsEmpty() == false)
1934 //__displayUrl = __pUrlField->GetText();
1935 __pFooterUrlField->Clear();
1945 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
1948 UiApp* pApp = UiApp::GetInstance();
1957 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
1958 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
1960 String* pSelectedScene = NULL;
1961 Object* pValue = NULL;
1962 String* pUrl = null;
1963 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
1964 pSelectedScene = (String*) pValue;
1966 if (pSelectedScene != null)
1968 delete pSelectedScene;
1970 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
1971 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
1972 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
1973 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
1975 // setting the current scene ID
1976 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
1978 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
1980 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
1982 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
1983 if(__pWindowInfo == null)
1985 // if(__pWindowInfo == null)
1987 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
1990 else if ( pArgs != null && pArgs->GetCount() == 1)
1992 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
1998 // hiding the address bar
1999 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2000 __pAddressbar->SetShowState(false);
2001 if(__pWebViewer != null)
2003 __pWebViewer->Resume();
2006 if(pUrl != null && pUrl->GetLength() > 0)
2010 else if(__pWindowInfo != null)
2012 if(__pWindowInfo->pageUrl.GetLength() > 0 && previousSceneId != IDSCN_MULTIPLE_WINDOW && previousSceneId != IDSCN_MULTIPLE_WINDOW_GRID && previousSceneId != IDSCN_BOOKMARK_VIEW && previousSceneId != IDSCN_SETTINGS && previousSceneId != IDSCN_MAIN_VIEW)
2014 LoadUrl(__pWindowInfo->pageUrl);
2016 else if (__pWindowInfo->isJavascriptInitiated == true)
2020 __pWindowInfo->pCurrentWeb = __pWebViewer;
2024 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2025 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2026 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2028 InitMostVisitedSitesView(GetOrientationStatus());
2031 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2033 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2035 if (pBookmarkUrl == null)
2037 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2038 //__pAddressbar->SetUrl(*pBookmarkUrl);
2039 SetUrl(*pBookmarkUrl);
2041 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2042 __pWebViewer->LoadUrl(*pBookmarkUrl);
2043 delete pBookmarkUrl;
2046 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2047 Bitmap* pBitmap = null;
2048 if (isPrivateBrowsing == true)
2050 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2052 if (__pWebViewer != null)
2054 __pWebViewer->SetPrivateBrowsingEnabled(true);
2057 if (__pAddressbar != null)
2059 // __pAddressbar->UpdateFaviconBitmap(true);
2065 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2067 if (__pWebViewer != null)
2069 __pWebViewer->SetPrivateBrowsingEnabled(false);
2072 if (__pAddressbar != null)
2074 // __pAddressbar->UpdateFaviconBitmap(false);
2078 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2080 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2082 else if (__pMenu != null )
2084 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2087 if (pBitmap != null)
2092 AppLog("ABC: OnSceneActivatedN started exit");
2097 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2098 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2100 Canvas* pWebCanvas = null;
2101 if (__pWebViewer != null)
2103 pWebCanvas = __pWebViewer->GetCanvasN();
2104 __pWebViewer->Pause();
2107 if (pWebCanvas == null)
2111 if (__pWindowInfo != null)
2113 if (__pWindowInfo->pWebCanvasBitmap != null)
2115 delete __pWindowInfo->pWebCanvasBitmap;
2117 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2118 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2119 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2121 Bitmap* pBitmap = GetCapturedBitmapN();
2122 AppLog("Coming here");
2123 Canvas* pCanvas = new(std::nothrow) Canvas();
2124 pCanvas->Construct(GetClientAreaBounds());
2127 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2130 if(__pWebViewer != null && __pWindowInfo != null)
2131 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2133 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2134 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2136 AppLog("Coming here");
2140 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2141 const Tizen::Base::String& realm,
2142 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2148 MainForm::OnHttpAuthenticationCanceled(void)
2153 MainForm::OnLoadingStarted(void)
2155 AppLogDebug("MainForm::OnLoadingStarted entered");
2157 if(__pAddressbar == NULL || __pWebViewer == null)
2161 String url = __pWebViewer->GetUrl();
2162 if(url.Contains(IDS_TIZEN_SERVICE))
2165 String delim(L":;");
2167 // Creates a StringTokenizer instance
2168 StringTokenizer strTok(url, delim);
2170 int count = strTok.GetTokenCount(); // count == 4
2172 HashMap *pMap = new HashMap();
2177 while (strTok.HasMoreTokens())
2179 AppLog("Token: %ls", token.GetPointer());
2180 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2181 if(token.Contains(IDS_APPID))
2183 token.SubString(6, appId);
2184 AppLog("AppID:%ls", appId.GetPointer());
2186 else if(token.Contains("="))
2188 String *pKey = new String();
2189 String *pValue = new String();
2191 token.IndexOf("=", 0, index);
2194 token.SubString(0, index, *pKey);
2195 token.SubString(index + 1, *pValue);
2196 pMap->Add(pKey, pValue);
2202 AppControl *pAppControl = null;
2203 String operationId = L"http://tizen.org/appcontrol/operation/main";
2204 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2207 AppLog("Starting AppControl");
2208 result r = pAppControl->Start(null, null, pMap, null);
2209 AppLog("Result of Start %s", GetErrorMessage(r));
2213 AppLogException("AppControl not found");
2218 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2221 __pAddressbar->SetFaviconBitmap(*pBitmap);
2224 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2226 // updating the address bar position with respect to web control
2227 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2228 __distanceMoved = 0;
2232 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2233 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2234 if (__pWebViewer != null)
2236 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2237 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2238 SetUrl(__pWebViewer->GetUrl());
2239 if (__pWindowInfo != NULL)
2241 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2243 __pAddressbar->Invalidate(true);
2249 MainForm::OnLoadingCanceled(void)
2256 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2258 AppLog("MainForm::OnKeypadWillOpen");
2259 if (__pAddressbar != null)
2261 OnAddressBarKeypadWillOpen(*__pAddressbar);
2267 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2269 if(__pAddressbar != null)
2271 OnAddressBarKeypadOpened(*__pAddressbar);
2277 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2279 if (__pAddressbar != null)
2281 OnAddressBarKeypadClosed(*__pAddressbar);
2286 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2288 AppLog("KeypadBoundsChanged");
2289 RelayoutControls(false);
2293 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2294 const Tizen::Base::String& reason)
2296 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2300 MainForm::OnLoadingCompleted(void)
2302 AppLog("MainForm::OnLoadingCompleted start");
2304 result r = E_SUCCESS;
2306 if (__pWebViewer == null)
2311 if (__pAddressbar == null)
2315 if (__pWebViewer->CanGoForward())
2317 //__pAddressbar->SetForwardButtonEnabled(true);
2318 SetForwardButtonEnabled(true);
2322 //__pAddressbar->SetForwardButtonEnabled(false);
2323 SetForwardButtonEnabled(false);
2326 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2328 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2330 //__pAddressbar->UpdateProgress(0);
2334 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2336 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2340 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2341 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2342 if (isPrivateBrowsing == false)
2344 History* pHistory = new(std::nothrow) History;
2346 HistoryPresentationModel::GetCurrentDateTime(date);
2349 pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2350 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2352 pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2353 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2355 pHistory->SetVisitedTime(date);
2358 id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2359 pHistory->SetFaviconId(id);*/
2361 if (__pWebViewer != null)
2363 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2365 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2366 if (pTempBitmap != null)
2368 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2369 pHistory->SetFavIconBitmap(*pTempBitmap);
2372 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2375 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2376 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2377 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2379 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2380 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2381 pHistory->SetThumbnail(pBitmap);
2383 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2386 pHistory->SetFavIconBitmap(*pFavIcon);
2390 HistoryPresentationModel::GetInstance()->SaveTempHistory(*pHistory);
2397 if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2399 // temperary fixed (webpage can be not loaded)
2402 AppLog("MainForm::OnLoadingCompleted done");
2406 MainForm::OnEstimatedProgress(int progress)
2408 AppLogDebug("MainForm::OnEstimatedProgress entered");
2409 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2410 progress = DEFAULT_PROGRESS_PERCENTAGE;
2412 // __pAddressbar->UpdateProgress(progress);
2413 UpdateProgress(progress);
2416 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2418 AppLog("MainForm::OnFaviconReceived");
2419 Bitmap* pFavIconBitmap = __pWebViewer->GetFaviconN();
2421 if (pFavIconBitmap != null)
2423 pFavIconBitmap->GetWidth();
2424 pFavIconBitmap->GetHeight();
2429 MainForm::OnUrlValueChanged(Addressbar&)
2435 MainForm::OnUrlSubmitted(Addressbar& addBar)
2437 AppLog("MainForm::OnUrlSubmitted");
2438 String url = addBar.GetUrl();
2439 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2441 // __pFooterPanel->SetShowState(true);
2442 if(__pFooterUrlField)
2443 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
2444 OnAddressCancelledClicked(*__pAddressbar);
2445 // __pAddressbar->SetShowState(false);
2446 // RelayoutControls(false);
2451 MainForm::LoadUrl(String& url)
2454 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2455 AppLogDebug("MainForm::LoadUrl enter");
2457 if (__pWebViewer != null)
2459 __pWebViewer->SetShowState(true);
2460 __pWebViewer->Invalidate(true);
2463 if (url.CompareTo(L"") == 0)
2467 if(__pFooterPanel != null)
2469 __pFooterPanel->SetShowState(true);
2470 __pFooterPanel->Invalidate(true);
2477 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2478 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)
2480 RegularExpression firstRegex;
2481 RegularExpression secondRegex;
2483 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2484 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2487 ret = firstRegex.Match(url, false); // This returns true value
2488 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2490 if (ret == true && __pWebViewer != null)
2492 __pWebViewer->LoadUrl(url);
2494 else if(__pWebViewer != null)
2496 String tempUrl = L"http://";
2497 tempUrl.Append(url);
2501 __pWebViewer->LoadUrl(tempUrl);
2505 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2506 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2509 if (__pAddressbar != null)
2511 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2512 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2515 AppLogDebug("MainForm::LoadUrl exit");
2522 MainForm::OnStopClicked(Addressbar& addBar)
2524 AppLogDebug("MainForm::OnStopClicked called");
2527 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2528 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2529 __pWebViewer->StopLoading();
2530 RequestRedraw(true);
2535 MainForm::OnReaderClicked(const Addressbar& addBar)
2537 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2539 CreateReaderPanel();
2540 AppLogDebug("MainScene::OnReaderClicked entered");
2543 /*if (__pArticleReaderPanel)
2545 AppLogDebug("showstate true for reader panel");
2546 __pArticleReaderPanel->SetShowState(true);
2547 __pArticleReaderPanel->Show();
2549 int xPos = __pArticleReaderPanel->GetX();
2550 int yPos = __pArticleReaderPanel->GetY();
2551 AppLog("OnReaderClicked() xPos = %d",xPos);
2552 AppLog("OnReaderClicked() yPos = %d",yPos);
2554 if (__pReaderData == null)
2559 String loadData = L"<html>\
2561 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2566 background-color: transparent;\
2585 <body style='width:'";
2586 loadData.Append(bodyWidth);
2587 loadData.Append(L"px'>");
2588 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2589 loadData.Append(*__pReaderData);
2590 loadData.Append(L"</body></html>");
2593 buf.Construct(loadData.GetLength());
2594 AppLogDebug("data->GetLength %d",loadData.GetLength());
2595 for (int z=0;z<loadData.GetLength();z++)
2598 loadData.GetCharAt(z,b);
2599 buf.SetByte((byte)b);
2603 if (__pWebReader != null)
2605 __pWebReader->LoadData(L"",buf,L"text/html");
2606 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2610 AppLogDebug("cannot LoadData __pWebReader is null");
2616 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2618 AppLog("MainForm::OnBackClicked");
2619 result r = E_FAILURE;
2621 if (__pWebViewer != null && __pWebViewer->CanGoBack())
2623 __pWebViewer->GoBack();
2628 pApp = UiApp::GetInstance();
2631 r = pApp->Terminate();
2641 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
2643 AppLog("MainForm::OnForwardClicked");
2644 if (__pWebViewer == null)
2647 if (__pWebViewer->CanGoForward())
2649 __pWebViewer->GoForward();
2654 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
2656 result r = E_SUCCESS;
2658 __pFooterPanel->SetShowState(true);
2659 __pFooterUrlField->SetFocusable(true);
2662 __pWebViewer->SetFocus();
2663 else if(__pMostVisitedListView)
2664 __pMostVisitedListView->SetFocus();
2665 else if(__pMultiWindowButton)
2666 __pMultiWindowButton->SetFocus();
2667 __pMoreButton->SetFocus();
2669 __pAddressbar->SetShowState(false);
2671 RelayoutControls(false);
2676 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
2678 __prevAddressBarMode = __curAddressBarMode;
2680 if (__pAddressbar != null)
2682 __curAddressBarMode = GetAddressbarMode();
2685 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
2687 __adressPanelPosition.y = 0;
2688 if (__pAddressbar != null)
2690 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2691 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2692 __pAddressbar->Invalidate(true);
2694 if (__pWebViewer != null)
2696 __pWebViewer->StopLoading();
2699 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
2701 __adressPanelPosition.y = 0;
2702 if (__pAddressbar != null)
2704 __webControlPosition.y = 0;
2705 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
2706 __pAddressbar->Invalidate(true);
2712 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
2715 __pAddressbar->SetShowState(false);
2717 __pFooterPanel->SetShowState(true);
2719 __pWebViewer->SetFocus();
2720 if(__pFooterUrlField)
2721 __pFooterUrlField->SetFocusable(true);
2722 RelayoutControls(false);
2726 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
2728 if (__pFindWordControl && __pFindWordControl->GetShowState() == true)
2730 __pAddressbar->SetShowState(false);
2734 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
2736 __pAddressbar->SetShowState(true);
2737 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2738 __pAddressbar->SetAddressbarURLFocus();
2742 RelayoutControls(false);
2746 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
2748 __pFooterPanel->SetShowState(false);
2752 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
2754 AppLog("KeypadBoundsChanged");
2755 RelayoutControls(false);
2759 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
2763 __pWindowInfo->pageTitle = title;
2764 if (__pWebViewer != null)
2766 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2769 if (__pAddressbar != null && __pWebViewer != null)
2771 SetUrl(__pWebViewer->GetUrl());
2772 __pAddressbar->Invalidate(true);
2777 MainForm::UpdateFavicon(void)
2779 bool urlImageType = false;
2780 String *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();");
2781 Bitmap* pBitmap = null;
2783 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
2785 if (__pWindowInfo != null)
2788 url.SetUri(*tempPath);
2789 if (url.GetHost().GetLength() == 0)
2792 webUrl.SetUri(__pWebViewer->GetUrl());
2793 result r = url.SetHost(webUrl.GetHost());
2800 if (url.GetScheme().GetLength() == 0)
2803 webUrl.SetUri(__pWebViewer->GetUrl());
2804 url.SetScheme(webUrl.GetScheme());
2806 __pWindowInfo->faviconUrl = url.ToString();
2808 pBitmap = __pWebViewer->GetFaviconN();
2810 if (pBitmap != null)
2812 if (__pWindowInfo->pFavicon != NULL)
2814 __pWindowInfo->pFavicon = null;
2816 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
2817 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
2819 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2821 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2823 else if(__pWindowInfo->pFavicon != null)
2825 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2829 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
2830 if(pDefaultBmp != null)
2832 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
2841 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
2848 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
2849 Tizen::Web::Controls::WebNavigationType type)
2851 // when load new page if find word panel is open its show state is false
2852 ShowFindWordPanel(false);
2854 __pFooterPanel->Invalidate(true);
2857 uriInfo.SetUri(url);
2859 if(url.Contains(IDS_TIZEN_SERVICE))
2862 String delim(L":;");
2864 // Creates a StringTokenizer instance
2865 StringTokenizer strTok(url, delim);
2867 int count = strTok.GetTokenCount(); // count == 4
2869 HashMap *pMap = new HashMap();
2875 while (strTok.HasMoreTokens())
2877 AppLog("Token: %ls", token.GetPointer());
2878 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2879 if(token.Contains(IDS_APPID))
2881 token.SubString(6, appId);
2882 AppLog("AppID:%ls", appId.GetPointer());
2884 else if(token.Contains("="))
2886 String *pKey = new String();
2887 String *pValue = new String();
2889 token.IndexOf("=", 0, index);
2892 token.SubString(0, index, *pKey);
2893 token.SubString(index + 1, *pValue);
2894 pMap->Add(pKey, pValue);
2900 AppControl *pAppControl = null;
2901 String operationId = L"http://tizen.org/appcontrol/operation/main";
2902 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2905 result r = pAppControl->Start(null, null, pMap, null);
2909 AppLogException("AppControl not found");
2915 if ( __pAddressbar != null)
2917 __pAddressbar->SetShowState(false);
2918 __pAddressbar->Invalidate(true);
2924 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
2925 const Tizen::Net::Http::HttpHeader& httpHeader)
2927 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
2932 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
2934 AppLog("MainForm::OnWebPageBlockSelected");
2935 if (__pHitElementResult != null)
2937 delete __pHitElementResult;
2938 __pHitElementResult = null;
2941 if (__pWebViewer != null)
2943 AppLog("MainForm::OnWebPageBlockSelected web not null");
2944 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
2947 if (__pHitElementResult == null)
2952 if (__pHitElementResult->HasImage() != true)
2954 String tagName = __pHitElementResult->GetTagName();
2955 String type = __pHitElementResult->GetAttributeValue("type");
2957 __currentSelectedStr.Clear();
2958 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
2959 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
2960 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
2962 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && __isLongPressedDone == true)
2964 AppLog("MainForm::OnWebPageBlockSelected show paste option");
2966 InitSelectTextContextMenu(endPoint,true);
2967 __pImageMenu->SetShowState(true);
2968 __pImageMenu->Show();
2969 __pImageMenu->Invalidate(true);
2971 else if(__isLongPressedDone == true)
2973 AppLog("MainForm::OnWebPageBlockSelected no paste option");
2975 if(__pHitElementResult->GetUrl().GetLength() > 0)
2977 __currentSelectedStr.Clear();
2978 __currentSelectedStr = __pHitElementResult->GetUrl();
2980 InitSelectTextContextMenu(endPoint,false);
2981 __pImageMenu->SetShowState(true);
2982 __pImageMenu->Show();
2983 __pImageMenu->Invalidate(true);
2986 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
2987 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
2988 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
2994 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3000 MainForm::OnWebWindowCreateRequested(void)
3002 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
3004 if (pNewWindowInfo == null)
3008 result r = E_SUCCESS;
3009 SceneManager* pSceneManager = SceneManager::GetInstance();
3010 if (pSceneManager == NULL)
3014 ArrayList* pArgList = new(std::nothrow) ArrayList();
3015 if (pArgList == NULL)
3019 r = pArgList->Construct();
3022 pNewWindowInfo->isJavascriptInitiated = true;
3023 pArgList->Add(*pNewWindowInfo);
3024 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3028 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3035 return pNewWindowInfo->pCurrentWeb;
3039 MainForm::RelayoutControls(bool showAddressbar)
3041 __webControlPosition.y = 0;
3042 __webControlHeight = GetClientAreaBounds().height;
3043 AppLog("Client area height: %d", __webControlHeight);
3045 AppLog("Client area height: %d", __webControlHeight);
3046 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3048 __webControlPosition.y += __pAddressbar->GetHeight();
3049 __webControlHeight -= __pAddressbar->GetHeight();
3050 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3052 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3054 __webControlPosition.y += __pFindWordControl->GetHeight();
3055 __webControlHeight -= __pFindWordControl->GetHeight();
3056 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3059 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true)
3061 __webControlHeight -= __pFooterPanel->GetHeight();
3062 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3064 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3066 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight);
3067 __pWebViewer->Invalidate(false);
3069 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3071 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3078 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3080 if (__pFindWordControl == null)
3086 InitFindWordPanel();
3087 __pFindWordEditField->SetText(__currentSearchStr);
3088 //__pFindWordCountLabel->SetText(L"");
3089 __pFindWordCountLabel->SetText(L"0/0");
3090 __pFindWordControl->SetShowState(true);
3094 if(__pFindWordControl != null)
3096 __pFindWordControl->SetShowState(false);
3100 AppLog("MainForm::ShowFindWordPanel %d",show);
3101 if (show && !isTouchPressed)
3103 if (__pFindWordEditField)
3105 __pFindWordEditField->SetFocus();
3106 __pFindWordEditField->ShowKeypad();
3111 if (__pFindWordEditField)
3112 __pFindWordEditField->HideKeypad();
3115 RelayoutControls(false);
3119 MainForm::StartWordSearch()
3121 //Get the count of occurances of the word in the current page
3122 __maxOccurrances = 0;
3123 __currentWordIndex = 0;
3125 __pFindWordPrev->SetEnabled(false);
3126 String *pCountStr = null;
3127 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3128 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3129 if (pCountStr != null)
3131 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3135 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3140 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3142 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3143 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3145 if(totalCount == -1 || totalCount == 0)
3147 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),64,__pFindWordCountLabel->GetHeight());
3148 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3151 else if(totalCount > 100)
3153 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3154 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3158 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3159 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3162 __maxOccurrances = totalCount;
3163 __currentWordIndex = currentOrdinal;
3165 //Reset the UI controls as per the maxOccurrance value
3166 if (totalCount <= 0)
3168 AppLog("Word not found");
3169 //Show error notification to user
3170 __pFindWordNext->SetEnabled(false);
3171 __pFindWordCountLabel->SetText(L"0/0");
3172 __pFindWordNext->Invalidate(false);
3173 __pFindWordPrev->Invalidate(false);
3174 __pFindWordCountLabel->Invalidate(false);
3178 if (totalCount == 1)
3180 __pFindWordNext->SetEnabled(false);
3184 __pFindWordNext->SetEnabled(true);
3187 String countStr = L"";
3188 countStr.Append(__currentWordIndex);
3189 countStr.Append(L"/");
3190 countStr.Append(__maxOccurrances);
3191 __pFindWordCountLabel->SetText(countStr);
3192 // __pFindWordCountLabel->SetShowState(true);
3193 __pFindWordCountLabel->Invalidate(false);
3195 //FindNextWord(true);
3196 //Update the controls
3197 __pFindWordNext->Invalidate(false);
3198 __pFindWordPrev->Invalidate(false);
3199 __pFindWordCountLabel->Invalidate(false);
3203 MainForm::FindNextWord(bool next)
3207 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3209 if(__currentWordIndex < __maxOccurrances)
3211 __currentWordIndex++;
3217 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3219 if(__currentWordIndex > 1)
3221 __currentWordIndex--;
3226 String countStr = L"";
3227 countStr.Append(__currentWordIndex);
3228 countStr.Append(L"/");
3229 countStr.Append(__maxOccurrances);
3230 __pFindWordCountLabel->SetText(countStr);
3231 // __pFindWordCountLabel->SetShowState(true);
3232 __pFindWordCountLabel->Invalidate(false);
3233 if (__currentWordIndex >= __maxOccurrances)
3235 __pFindWordNext->SetEnabled(false);
3239 __pFindWordNext->SetEnabled(true);
3241 if (__currentWordIndex <= 1)
3243 __pFindWordPrev->SetEnabled(false);
3247 __pFindWordPrev->SetEnabled(true);
3249 __pFindWordPrev->Invalidate(false);
3250 __pFindWordNext->Invalidate(false);
3251 __pFindWordCountLabel->Invalidate(false);
3252 __pFindWordControl->Invalidate(true);
3255 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3257 AppLog("MainForm::OnWebKeypadWillOpen");
3258 __isWebKeypadOpened = true;
3259 // OnAddressBarKeypadOpened(*__pAddressbar);
3263 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3266 if (__pWebViewer != null && __pFooterPanel != null)
3268 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3269 if(__pAddressbar != null)
3271 __pAddressbar->SetShowState(false);
3273 if(__pFindWordControl != null)
3275 __pFindWordControl->SetShowState(false);
3277 __pFooterPanel->SetShowState(false);
3278 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
3284 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3286 __pFooterPanel->SetShowState(true);
3287 OnAddressBarKeypadClosed(*__pAddressbar);
3288 __isWebKeypadOpened = false;
3292 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3294 Control* temp = const_cast< Control* >(&source);
3295 Header* pHeader = dynamic_cast< Header* >(temp);
3296 if (pHeader != null)
3298 //Header double - clicked
3299 AppLog("Header double clicked");
3301 if(__pFindWordControl)
3303 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
3304 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
3308 AppLog("MainScene::OnTouchDoublePressed");
3309 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3310 if (isReaderEnabled == true)
3314 delete __pReaderData;
3315 __pReaderData = null;
3317 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3318 filePath.Append(L"data/reader.js");
3324 result r = E_SUCCESS;
3325 FileAttributes attr;
3327 File::GetAttributes(filePath,attr);
3329 r = file.Construct(filePath, L"r+");
3332 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3335 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3338 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3341 file.Read(pScript,attr.GetFileSize());
3343 AppLogDebug("scipt length %d",strlen(pScript));
3344 String strScript = L"";
3345 strScript.Append(pScript);
3346 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3349 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3352 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3353 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3355 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3356 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3362 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3364 AppLog("MainForm::OnTouchLongPressed");
3366 if (__pHitElementResult != null)
3368 delete __pHitElementResult;
3369 __pHitElementResult = null;
3372 if (__pWebViewer != null)
3374 AppLog("MainForm::OnTouchLongPressed web not null");
3375 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3378 if (__pHitElementResult == null)
3383 if (__pHitElementResult->HasImage() == true)
3385 InitImageContextMenu(currentPosition);
3386 __pImageMenu->SetShowState(true);
3387 __pImageMenu->Show();
3388 __pImageMenu->Invalidate(true);
3392 String tagName = __pHitElementResult->GetTagName();
3393 String type = __pHitElementResult->GetAttributeValue("type");
3394 String value = __pHitElementResult->GetAttributeValue(L"value");
3395 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3397 __currentSelectedStr.Clear();
3398 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3400 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0 && __isWebKeypadOpened == true)
3402 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3404 InitSelectTextContextMenu(currentPosition,true, true);
3405 __pImageMenu->SetShowState(true);
3406 __pImageMenu->Show();
3407 __pImageMenu->Invalidate(true);
3409 __isLongPressedDone = true;
3410 __pWebViewer->SetBlockSelectionPosition(currentPosition);
3413 __inputEventToBeSupressed = true;
3417 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3419 AppLog("MainForm::OnTouchReleased");
3421 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3422 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3424 __pWebViewer->ConsumeInputEvent();
3426 if(pHitElement != null)
3430 __inputEventToBeSupressed = false;
3434 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3441 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3443 if(__pAddressbar->GetShowState() == false)
3445 __pAddressbar->SetShowState(true);
3446 __pAddressbar->SetAddressbarURLFocus();
3447 __pFooterUrlField->SetFocusable(false);
3448 __pFooterPanel->SetShowState(false);
3455 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3461 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3467 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3473 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3479 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3485 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
3487 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
3488 int widthContextItem = 0;
3489 if(__pFindWordControl != null)
3490 ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
3491 if ( __pFooterLabel != null)
3493 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
3496 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
3501 if (__pFindWordBgLabel != null)
3503 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
3504 if (pBitmap != null)
3506 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
3512 __pMenu->SetShowState(false);
3513 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
3515 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
3519 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
3524 AppLog("__pFooterPanel->GetShowState() is true");
3526 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3527 __pFooterPanel->Invalidate(true);
3531 if(__pMoreButton && __pMenu)
3533 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
3534 __pMenu->SetAnchorPosition(p);
3535 __pMenu->Invalidate(true);
3538 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
3539 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
3541 InitMostVisitedSitesView(orientationStatus);
3544 RelayoutControls(false);
3545 if (__pArticleReaderPanel != null)
3547 if (__pArticleReaderPanel->GetShowState() == true)
3549 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
3551 if (__pBlankPanel != null)
3552 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
3554 if (__pWebReader != null)
3556 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
3558 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3559 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3561 if ( pBitmap != null && pSrcBitmap != null)
3563 AppLog("CreateReaderPanel ninepatchbitmap found");
3564 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
3567 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
3568 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
3569 if (pBitmap != null)
3574 if (pSrcBitmap != null)
3583 if (__pAddressbar != null)
3585 int width = GetClientAreaBounds().width;
3586 __pAddressbar->OrientationChanged(width);
3591 MainForm::OnSettingsChange(int settingvalue)
3593 AppLogDebug("MainForm::OnSettingsChange entered");
3595 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
3597 __pAddressbar->ResetGuideText();
3599 if (__pWebViewer == null)
3601 AppLogDebug("Webviewer is not initialized yet.");
3605 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
3607 WebSetting settings = __pWebViewer->GetSetting();
3608 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
3610 settings.SetAutoFittingEnabled(true);
3612 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
3614 settings.SetAutoFittingEnabled(false);
3616 __pWebViewer->SetSetting(settings);
3618 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
3620 WebSetting settings = __pWebViewer->GetSetting();
3621 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
3622 __pWebViewer->SetSetting(settings);
3624 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
3626 WebSetting settings = __pWebViewer->GetSetting();
3627 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
3628 __pWebViewer->SetSetting(settings);
3630 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
3632 WebSetting settings = __pWebViewer->GetSetting();
3633 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
3634 __pWebViewer->SetSetting(settings);
3636 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
3640 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3644 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
3646 WebSetting settings = __pWebViewer->GetSetting();
3647 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
3649 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
3653 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
3655 __pWebViewer->SetSetting(settings);
3657 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
3661 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
3662 WebSetting settings = __pWebReader->GetSetting();
3663 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
3664 __pWebReader->SetSetting(settings);
3670 MainForm::OnSettingsReset()
3674 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3675 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
3680 MainForm::OnClearCache()
3682 result r = E_SUCCESS;
3684 if (__pWebViewer != NULL)
3686 r = __pWebViewer->ClearCache();
3689 AppLogDebug("Cache cleared success");
3693 AppLogDebug("Cache cleared fail");
3699 MainForm::OnClearCookie()
3701 result r = E_SUCCESS;
3703 if (__pWebViewer != NULL)
3705 __pWebViewer->ClearCookie();
3709 AppLogDebug("Cookie cleared success");
3713 AppLogDebug("Cache cleared fail");
3718 MainForm::findDistance(int x1,int y1,int x2, int y2)
3720 int deltaX = Math::Abs(x2 - x1);
3721 int deltaY = Math::Abs(y2 - y1);
3722 double num = deltaX*deltaX + deltaY*deltaY;
3728 for (i = 0; i < 20; i++)
3730 x = (((x*x)+ num)/(2*x));
3741 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3743 if(__pFindWordControl)
3745 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
3746 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
3748 __isLongPressedDone = false;
3751 IList* pList = null;
3752 pList = touch.GetTouchInfoListN(source);
3756 int count = pList->GetCount();
3759 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3760 __touchPoint1 = pTouchInfo->position;
3762 /*if (__pAddressbar != null)
3764 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3766 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3768 __pAddressbar->SaveAddressbarEditText();
3770 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3773 __pAddressbar->Invalidate(true);
3775 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3777 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3779 //__pAddressbar->SaveAddressbarEditText();
3781 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3784 else if (count == 2)
3786 AppLogDebug("MainForm::OnTouchPressed count is two");
3787 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3788 __touchPoint1 = pTouchInfo->position;
3790 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
3791 __touchPoint2 = pTouchInfo->position;
3797 pList->RemoveAll(true);
3804 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3806 __currentWordIndex = 0;
3807 __isLongPressedDone = false;
3812 MainForm::MoveUiControls()
3817 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
3819 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
3821 if(__pFooterUrlField->GetTextLength() == 0)
3823 __pFooterUrlField->SetKeypadActionEnabled(false);
3827 __pFooterUrlField->SetKeypadActionEnabled(true);
3830 if (__pFindWordEditField != null)
3832 __currentSearchStr = __pFindWordEditField->GetText();
3833 __pFindWordNext->SetEnabled(false);
3834 __pFindWordPrev->SetEnabled(false);
3835 __pFindWordNext->Invalidate(true);
3836 __pFindWordPrev->Invalidate(true);
3837 __pFindWordCountLabel->SetText(L"0/0");
3838 __pFindWordCountLabel->Invalidate(true);
3840 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
3841 if (__currentSearchStr.GetLength() > 0)
3847 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
3849 __currentSearchStr = L"";
3850 AppLogDebug("Enter something");
3855 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
3862 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
3864 if(__pWebViewer != null)
3867 AppLog("MainForm::InitMostVisitedSitesView");
3868 result r = E_SUCCESS;
3871 if (__pWebViewer != null && __pMostVisitedListView != null)
3876 if (__pMostVisitedListView != null)
3878 RemoveControl(*__pMostVisitedListView);
3880 if(__pMostVisitedSites != null)
3882 __pMostVisitedSites->RemoveAll(true);
3885 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
3887 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
3888 __pMostVisitedListView = new(std::nothrow) ListView();
3890 int height = GetClientAreaBounds().height;
3892 if(__pFooterPanel->GetShowState() == true)
3894 height = height - __pFooterPanel->GetHeight();
3896 if(__pAddressbar->GetShowState() == true)
3898 height -= __pAddressbar->GetHeight();
3901 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
3905 delete __pMostVisitedListView;
3906 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
3909 __pMostVisitedListView->SetItemProvider(*this);
3910 __pMostVisitedListView->AddListViewItemEventListener(*this);
3911 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
3912 AddControl(*__pMostVisitedListView);
3913 __pMostVisitedListView->UpdateList();
3920 MainForm::GetImagePath(void)
3924 String formattedTime;
3925 DateTime currentTime;
3926 LocaleManager localManager;
3927 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
3929 localManager.Construct();
3930 Locale locale = localManager.GetSystemLocale();
3931 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
3933 // Get date formatter
3934 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
3938 pTimeFormatter->Format(currentTime, formattedTime);
3941 AppLog("current time stamp is %ls", formattedTime.GetPointer());
3942 String delim(L" :");
3943 StringTokenizer strTok(formattedTime, delim);
3946 String str1("GMT+00");
3947 while (strTok.HasMoreTokens())
3949 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
3950 if(token.Equals(str1))
3952 AppLog("token is %ls", token.GetPointer());
3953 imageName.Append(token);
3959 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
3961 result r = E_FAILURE;
3962 AppLog("Content manager 1");
3963 ContentId contentId;
3964 ContentManager contentManager;
3965 r = contentManager.Construct();
3968 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
3971 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
3972 contentPath.Append(imageName);
3973 contentPath.Append(".jpg");
3974 contentId = contentManager.CreateContent(*aBuffer, contentPath);
3975 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
3979 MainForm::SetForwardButtonEnabled(bool isEnabled)
3981 __pGoForwardBtn->SetEnabled(isEnabled);
3982 __pGoBackBtn->Invalidate(true);
3986 MainForm::SetBackButtonEnabled(bool isEnabled)
3988 __pGoBackBtn->SetEnabled(isEnabled);
3989 __pGoBackBtn->Invalidate(true);
3993 MainForm::UpdateProgress(int percentage)
3995 __progressPercentage = percentage;
3996 if (percentage == 0 || percentage == 100)
3998 __isLoadingData = false;
3999 if (percentage == 100)
4001 __isLoadingCompleted = true;
4002 __progressPercentage = 0;
4006 __isLoadingCompleted = false;
4011 __isLoadingData = true;
4013 UpdateProgressBitmap();
4017 MainForm::GetProgress(void)
4019 return __progressPercentage;
4023 MainForm::UpdateProgressBitmap(void)
4025 result r = E_SUCCESS;
4026 if (__pProgressbarLabel == null)
4028 int w = __pProgressbarLabel->GetWidth();
4029 int h = __pProgressbarLabel->GetHeight();
4031 int progressWidth = 0;
4032 Bitmap* pRetBitmap = null;
4034 if (__progressPercentage == 0 || __progressPercentage == 100)
4036 __pProgressbarLabel->SetShowState(false);
4037 __pProgressbarLabel->Invalidate(false);
4042 __pProgressbarLabel->SetShowState(true);
4043 __pProgressbarLabel->Invalidate(false);
4046 r = canvas.Construct(Rectangle(0, 0, w, h));
4050 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
4055 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
4059 pBgBmp->Scale(Dimension(w, h));
4060 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4064 progressWidth = (double) (w) * __progressPercentage / 100;
4065 AppLogDebug("progressWidth: %d", progressWidth);
4066 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4068 if (pProgressBmp != null)
4070 pProgressBmp->Scale(Dimension(progressWidth, h));
4071 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4072 delete pProgressBmp;
4075 pRetBitmap = new (std::nothrow) Bitmap();
4077 if (pRetBitmap == null)
4079 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4083 pRetBitmap->Construct(canvas, canvas.GetBounds());
4085 if (__pProgressbarLabel != null && pRetBitmap != null)
4087 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4088 __pProgressbarLabel->Invalidate(false);
4091 if (pRetBitmap != null)
4099 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4101 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4103 __currentAddMode = addMode;
4107 case ADDRESSBAR_MODE_INVALID:
4112 case ADDRESSBAR_MODE_READER:
4114 __pStopBtn->SetShowState(false);
4115 __pClearBtn->SetShowState(false);
4118 case ADDRESSBAR_MODE_LOADING:
4120 __pRefreshBtn->SetShowState(false);
4121 __pStopBtn->SetShowState(true);
4122 __pClearBtn->SetShowState(false);
4125 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4127 // SetUrl(__pAddressbar->GetUrl());
4129 __pRefreshBtn->SetShowState(true);
4130 __pStopBtn->SetShowState(false);
4131 __pClearBtn->SetShowState(false);
4134 case ADDRESSBAR_MODE_EDIT:
4136 __pRefreshBtn->SetShowState(false);
4137 __pStopBtn->SetShowState(false);
4138 __pClearBtn->SetShowState(true);
4145 OnAddressBarModeChanged();
4148 AddressBarMode MainForm::GetAddressbarMode(void)
4150 return __currentAddMode;
4153 void MainForm::SetUrl(const String& url)
4157 if (__pFooterUrlField != NULL)
4159 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4160 if (removedHttpUrl.IsEmpty() == false)
4162 __pFooterUrlField->SetText(removedHttpUrl);
4163 __pAddressbar->SetUrl(__displayUrl);
4167 __pFooterUrlField->SetText(__displayUrl);
4168 __pAddressbar->SetUrl(__displayUrl);
4171 __pFooterUrlField->Invalidate(false);
4172 __pAddressbar->Invalidate(true);
4173 __pFooterUrlField->SetCursorPosition(0);
4178 MainForm::RemoveHttpTextFromDisplayURL(void)
4180 bool isHttpText = __displayUrl.Contains(L"http://");
4181 String updatedDisplayUrl;
4182 updatedDisplayUrl.Clear();
4184 if (isHttpText == true)
4186 __displayUrl.SubString(7,updatedDisplayUrl);
4188 return updatedDisplayUrl;