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;
144 __pFindWordPanel = 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;
219 String* pSelectedScene = NULL;
220 Object* pValue = NULL;
221 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
222 pSelectedScene = (String*) pValue;
224 /*if (pSelectedScene != null)
226 delete pSelectedScene;
228 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
232 MainForm::Initialize(void)
234 Construct(L"IDL_FORM");
239 MainForm::OnInitializing(void)
241 AppLog("get client area width = %d",GetClientAreaBounds().width);
242 AppLog("get client area height = %d",GetClientAreaBounds().height);
243 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
244 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
246 Panel* pFooterPanel = null;
248 __pSaveImage = new Image();
249 __pSaveImage->Construct();
251 // Setup back event listener
252 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
253 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
254 AddOrientationEventListener(*this);
255 AppLogDebug(" MainForm::OnInitializing ended");
256 if (__pMostVisitedSites == null)
258 __pMostVisitedSites = new(std::nothrow) ArrayList();
259 __pMostVisitedSites->Construct();
261 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
263 __pItemContext= new(std::nothrow) ListContextItem();
264 __pItemContext->Construct();
265 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
266 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
268 if (pBitmapNormal != null && pBitmapPressed != null)
270 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
273 if (pBitmapNormal != null)
275 delete pBitmapNormal;
278 if (pBitmapPressed != null)
280 delete pBitmapPressed;
283 __pItemContextLandscape= new(std::nothrow) ListContextItem();
284 __pItemContextLandscape->Construct();
285 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
286 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
288 if (pBitmapNormal != null && pBitmapPressed != null)
290 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
293 if (pBitmapNormal != null)
295 delete pBitmapNormal;
298 if (pBitmapPressed != null)
300 delete pBitmapPressed;
307 MainForm::InitAddressbar(void)
309 AppLogDebug("MainForm::InitAddressbar entered");
311 result r = E_SUCCESS;
313 if (__pAddressbar != null)
317 __pAddressbar = new(std::nothrow) Addressbar();
318 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
319 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
322 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
325 __pAddressbar->SetAddressbarEventListener(this);
326 AddControl(*__pAddressbar);
327 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
328 SetControlAlwaysOnTop(*__pAddressbar, true);
329 __adressPanelPosition = __pAddressbar->GetPosition();
331 AppLogDebug("MainForm::InitAddressbar exit");
337 MainForm::CreateReaderPanel(void)
339 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
340 result r = E_FAILURE;
342 Button *pSmallFontBtn = null;
343 Button *pLargeFontBtn = null;
345 __pBlankPanel = new (std::nothrow) Panel();
346 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
348 __pArticleReaderPanel = new (std::nothrow) Panel();
349 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
351 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
352 if (__pReaderCloseBtn)
354 AppLogDebug("CreateReaderPanel() 6");
355 __pReaderCloseBtn->AddActionEventListener(*this);
356 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
359 __pWebReader = new (std::nothrow) Web();
360 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
362 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
363 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
365 r = __pWebReader->SetSetting(settings);
367 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
370 __pArticleReaderLabel = new Label();
371 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
373 __pBlankPanel->AddControl(*__pArticleReaderLabel);
374 __pBlankPanel->AddControl(*__pArticleReaderPanel);
375 AddControl(*__pBlankPanel);
377 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
378 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
379 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
381 __pArticleReaderPanel->AddControl(*__pWebReader);
382 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
383 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
384 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
386 if (pBitmap != null && pSrcBitmap != null)
388 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
390 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
392 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
395 pSmallFontBtn->AddActionEventListener(*this);
396 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
399 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
402 pLargeFontBtn->AddActionEventListener(*this);
403 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
412 if (pSrcBitmap != null)
418 SetControlAlwaysOnTop(*__pBlankPanel, true);
419 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
426 MainForm::InitWebControl()
428 AppLogDebug("MainForm::InitWebControl enter");
429 result r = E_SUCCESS;
430 AppLogDebug("InitWebControl");
432 if (__pAddressbar == null || __pFooterPanel == null)
435 const int Y_WEBCONTROL_POSITION = 0;
436 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
437 if (__pMostVisitedListView)
439 __pMostVisitedListView->SetShowState(false);
441 if (__pWebViewer != null)
443 AppLogDebug("Already initialized");
446 __pWebViewer = new(std::nothrow) Web();
447 if(__pWebViewer == NULL)
449 AppLogDebug("Initialization failed");
452 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight));
456 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
463 r = AddControl(*__pWebViewer);
467 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
470 __webControlPosition = __pWebViewer->GetPosition();
471 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
474 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
478 __pWebViewer->SetLoadingListener(this);
479 __pWebViewer->SetWebUiEventListener(this);
480 __pWebViewer->SetWebKeypadEventListener(this);
481 __pWebViewer->SetFocus();
482 __pWebViewer->AddTouchEventListener(*this);
484 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
485 __pWebViewer->SetTextSearchListener(this);
488 AppLogDebug("MainForm :before return");
490 AppLogDebug("MainForm::InitWebControl Exit");
496 MainForm::OnFocusGained(const Control& source)
499 * We don't need any action here for focus.
500 * The focus of Addressbar will be set after keypad is opened.(OnAddressBarKeypadOpened())
501 if(__pAddressbar != null)
503 __pFooterUrlField->SetFocusable(false);
504 __pAddressbar->SetAddressbarURLFocus();
510 MainForm::SetJavascriptEnabled()
512 WebSetting settings = __pWebViewer->GetSetting();
513 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
514 __pWebViewer->SetSetting(settings);
518 MainForm::SetImageLoadEnabled()
520 WebSetting settings = __pWebViewer->GetSetting();
521 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
522 __pWebViewer->SetSetting(settings);
526 MainForm::InitFooter(void)
528 AppLogDebug("MainForm::InitFooter entered");
529 Button* pBackButton = null;
530 Button* pBookmarkButton = null;
531 Button* pMultiWindowButton = null;
532 Bitmap *pIconBitmap = null;
533 Bitmap *pBGBitmap = null;
534 Label *pBGLabel = null;
536 if (__pFooterPanel == null)
538 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
541 if (__pFooterPanel == null)
546 SetControlAlwaysOnTop(*__pFooterPanel, true);
548 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
549 if ( __pFooterLabel == NULL )
553 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
554 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
557 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
561 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
563 if ( __pMultiWindowButton == NULL )
568 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
570 if ( __pMoreButton == NULL )
575 if (__pMultiWindowButton != null)
577 Bitmap* pBitmap = null;
578 Bitmap* pPressedBitmap = null;
579 String imagePath = "I01_toolbar_icon_windows_manager_0";
580 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
581 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
582 imagePath.Append(totalCount);
583 imagePath.Append(".png");
585 pressedImagePath.Append(totalCount);
586 pressedImagePath.Append("_press.png");
588 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
589 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
590 if ( pBitmap == null )
595 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
598 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
599 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
604 __pMultiWindowButton->AddActionEventListener(*this);
605 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
610 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
611 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
614 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
615 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
616 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
620 __pMoreButton->AddActionEventListener(*this);
621 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
624 //Add the editfield for url
625 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
626 if (__pFooterUrlField == NULL)
628 return E_INVALID_KEY;
631 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
632 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
633 //__pFooterUrlField->AddFocusEventListener(*this);
634 __pFooterUrlField->AddKeypadEventListener(*this);
635 __pFooterUrlField->AddFocusEventListener(*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 (__pFindWordPanel != 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 __pFindWordPanel = static_cast<Panel*>(GetControl(L"IDC_FIND_ON_PAGE_PANEL"));
873 if (__pFindWordPanel == null)
875 AppLogException("There is some problem in the xml file. Please check.");
879 __pFindWordControl = new (std::nothrow) Panel();
880 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
883 AppLogException("There is some problem in the xml file. Please check.");
886 AddControl(*__pFindWordControl);
887 __pFindWordControl->SetBounds(0,0, __pFindWordPanel->GetWidth(), __pFindWordPanel->GetHeight());
888 SetControlAlwaysOnTop(*__pFindWordControl,true);
889 __pFindWordPanel->SetShowState(false);
890 __pFindWordPanel->Invalidate(false);
892 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
893 if (__pFindWordBgLabel != null)
895 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
896 Rectangle pRect = pPanel1->GetBounds();
897 pRect.x = pRect.y = 0;
898 __pFindWordBgLabel->SetBounds(pRect);
899 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
902 AppLogDebug("InitFindWordPanel: Coming here");
903 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
908 AppLogDebug("InitFindWordPanel: shouldn't Come here");
912 Button* pfindWordCancel = null;
913 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
914 if (pfindWordCancel == null)
916 AppLogException("There is some problem in the xml file. Please check.");
919 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
920 pfindWordCancel->AddActionEventListener(*this);
922 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
923 if (__pFindWordClear == null)
925 AppLogException("There is some problem in the xml file. Please check.");
929 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
930 __pFindWordClear->AddActionEventListener(*this);
932 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
933 if (__pFindWordNext == null)
935 AppLogException("There is some problem in the xml file. Please check.");
939 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
940 __pFindWordNext->AddActionEventListener(*this);
942 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
943 if (__pFindWordPrev == null)
945 AppLogException("There is some problem in the xml file. Please check.");
949 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
950 __pFindWordPrev->AddActionEventListener(*this);
952 __pFindWordNext->SetEnabled(false);
953 __pFindWordPrev->SetEnabled(false);
955 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
956 if (__pFindWordCountLabel == null)
958 AppLogException("There is some problem in the xml file. Please check.");
962 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
963 if (__pFindWordEditField == null)
965 AppLogException("There is some problem in the xml file. Please check.");
968 __pFindWordEditField->AddTextEventListener(*this);
969 __pFindWordEditField->AddKeypadEventListener(*this);
970 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
976 MainForm::CreateItem (int index, int itemWidth)
978 Rectangle listImageRect;
979 Rectangle pagetTitleRect;
980 Rectangle pageURLRect;
981 Rectangle deleteImageRect;
982 String pageTitle(L"");
984 result r = E_SUCCESS;
985 Bitmap* pListIconImage = null;
988 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
993 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
994 if ( pAppResource == NULL )
998 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1000 CustomItem* pItem = new(std::nothrow) CustomItem();
1001 pageTitle = pHistory->GetHistoryTitle();
1002 pageURL = pHistory->GetHistoryUrl();
1004 if (pageURL.GetLength() == 0)
1007 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1008 pageURL = L"<"+ nourl +">";
1012 Rectangle screenBounds = GetBounds();
1015 r = pItem->Construct(Dimension(itemWidth, 128), style);
1024 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1026 if ( pBitmap != NULL)
1028 pListIconImage = new Bitmap();
1029 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1033 if(pListIconImage == null)
1035 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1038 if ( pListIconImage != NULL)
1040 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1041 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1042 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1045 if (pItem != null && pListIconImage != NULL)
1047 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1051 if (pageTitle.CompareTo(L"") != 0)
1055 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1059 if (pageURL.CompareTo(L"") != 0)
1063 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1068 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1070 if ( __pItemContext!= NULL)
1074 pItem->SetContextItem(__pItemContext);
1080 if ( __pItemContextLandscape!= NULL)
1084 pItem->SetContextItem(__pItemContextLandscape);
1088 if( pListIconImage != NULL)
1090 delete pListIconImage;
1091 pListIconImage = null;
1098 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1105 MainForm::GetItemCount (void)
1107 if(__pMostVisitedSites != null)
1109 __pMostVisitedSites->RemoveAll(true);
1111 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1112 if(__pMostVisitedSites != null)
1114 return __pMostVisitedSites->GetCount();
1121 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1123 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1124 String url = pHistory->GetHistoryUrl();
1125 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1126 __pMostVisitedListView->UpdateList();
1130 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1132 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1133 String url = pHistory->GetHistoryUrl();
1141 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1147 MainForm::OnTerminating(void)
1149 result r = E_SUCCESS;
1152 delete __pItemContext;
1154 if(__pItemContextLandscape)
1156 delete __pItemContextLandscape;
1162 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1164 result r = E_SUCCESS;
1166 AppLogDebug("Clicked : %d", actionId);
1169 case IDA_BACKBTN_CLICKED:
1171 if (__pWebViewer && __pWebViewer->CanGoBack())
1173 __pWebViewer->GoBack();
1178 pApp = UiApp::GetInstance();
1181 r = pApp->Terminate();
1184 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1192 case IDA_FORWARD_CLICKED:
1193 if (__pWebViewer == null)
1196 if (__pWebViewer->CanGoForward())
1198 __pWebViewer->GoForward();
1200 __pMenu->SetShowState(false);
1201 __pMenu->Invalidate(false);
1204 case IDA_FINDONPAGE_CLICKED:
1206 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1207 __currentSearchStr.Clear();
1209 InitFindWordPanel();
1210 __pMenu->SetShowState(false);
1211 __pMenu->Invalidate(false);
1213 __pFindWordEditField->SetFocus();
1215 if (__pWebViewer != null)
1217 // releasing the set block
1218 __pWebViewer->ReleaseBlock();
1221 ShowFindWordPanel(true);
1224 case IDA_PRIVATEON_CLICKED:
1226 result r = E_SUCCESS;
1228 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1229 Bitmap* pBitmap = null;
1230 if (isPrivateBrowsing == true)
1232 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1235 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1239 if (__pWebViewer != NULL)
1241 __pWebViewer->SetPrivateBrowsingEnabled(false);
1244 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1246 if (__pAddressbar != null)
1248 __pAddressbar->UpdateFaviconBitmap(false);
1254 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1257 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1261 if (__pWebViewer != NULL)
1263 __pWebViewer->SetPrivateBrowsingEnabled(true);
1266 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1268 if (__pAddressbar != null)
1270 __pAddressbar->UpdateFaviconBitmap(true);
1275 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1276 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1277 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1278 __pMenu->Invalidate(true);
1280 if ( pBitmap != NULL )
1287 case IDA_SETTINGS_CLICKED:
1290 ArrayList* pArgList = new(std::nothrow) ArrayList();
1293 pArgList->Construct();
1294 pArgList->Add(*__pWindowInfo);
1295 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1297 __pMenu->SetShowState(false);
1298 __pMenu->Invalidate(false);
1299 if (pArgList != null)
1308 case IDA_ADDTOBOOKMARK_CLICKED:
1311 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1313 int bookmarkCount=0;
1316 url=__pWindowInfo->pageUrl;
1317 result r = E_SUCCESS;
1318 Bitmap* pBitmap = null;
1319 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1327 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1328 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1329 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1331 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1332 if (pNotification != null)
1334 pNotification->SetText(message);
1335 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1336 pNotification->ShowNotification();
1341 String title=__pWindowInfo->pageTitle;
1342 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1343 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1345 pBookmark->SetBookmarkTitle(title);
1346 pBookmark->SetUrl(url);
1347 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1349 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1351 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1352 pBookmark->SetFaviconId(id);
1353 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1354 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1357 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1358 if (pNotification != null)
1360 pNotification->SetText(message);
1361 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1362 pNotification->ShowNotification();
1363 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1366 if (pBitmap != null)
1368 r = __pMenu->SetItemAt(0,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1372 __pMenu->Invalidate(true);
1376 case IDA_SHARE_CLICKED:
1378 if(__pPopUp != null)
1383 __pPopUp = new(std::nothrow) SharePopup();
1384 __pPopUp->Initialize();
1385 if (__pWindowInfo != null)
1387 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1388 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1389 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1390 pShareInfo->SetImageAttached(false);
1391 __pPopUp->RemoveAllShareInfo();
1392 __pPopUp->AddShareInfo(pShareInfo);
1394 __pPopUp->SetShowState(true);
1398 case IDA_BOOKMARKBTN_CLICKED:
1400 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1401 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1404 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1409 case IDA_MOREBTN_CLICKED:
1411 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1412 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1413 AppLog("Anchot pos: %d %d", p.x, p.y);
1415 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1417 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1418 int bookmarkCount=0;
1421 url=__pWindowInfo->pageUrl;
1422 result r = E_SUCCESS;
1423 Bitmap* pBitmap = null;
1425 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1428 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1433 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1437 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1439 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1441 if (__pMenu->GetItemCount() == 8)
1443 r = __pMenu->SetItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1447 r = __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1452 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1456 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1457 if (__pMenu->GetItemCount() != 8)
1459 __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADDTOBOOKMARK_CLICKED);
1461 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1462 __pMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1463 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1464 __pMenu->SetMaxVisibleItemsCount(6);
1466 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1468 AppLog(" Orientation landscape");
1469 __pMenu->SetMaxVisibleItemsCount(5);
1473 AppLog(" Orientation potrait");
1474 __pMenu->SetMaxVisibleItemsCount(6);
1477 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1480 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1481 __pMenu->SetShowState(true);
1482 __pMenu->Invalidate(true);
1486 case IDA_HISTORY_CLICKED:
1488 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1489 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1492 case IDA_SAVED_PAGES_CLICKED:
1497 case IDA_DESKTOP_VIEW_CLICKED:
1502 case IDA_SAVE_CLICKED:
1507 case IDA_MULTIWINDOWBTN_CLICKED:
1509 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1510 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1514 case IDA_NEWWINDOWBTN_CLICKED:
1516 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1518 if (pNewWindowInfo == null)
1522 result r = E_SUCCESS;
1523 SceneManager* pSceneManager = SceneManager::GetInstance();
1525 if (pSceneManager == NULL)
1529 ArrayList* pArgList = new(std::nothrow) ArrayList();
1530 if (pArgList == NULL)
1534 r = pArgList->Construct();
1537 pArgList->Add(*pNewWindowInfo);
1538 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1544 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1549 case IDA_SMALLFONT_BTN_CLICKED:
1551 WebSetting setting = __pWebReader->GetSetting();
1552 setting.SetFontSize(15);
1553 __pWebReader->SetSetting(setting);
1556 case IDA_LARGEFONT_BTN_CLICKED:
1558 WebSetting setting = __pWebReader->GetSetting();
1559 setting.SetFontSize(25);
1560 __pWebReader->SetSetting(setting);
1563 case IDA_READER_CLOSE_CLICKED:
1565 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1567 //__pArticleReaderPanel->SetShowState(false);
1568 //__pArticleReaderPanel->Show();
1569 RemoveControl(*__pBlankPanel);
1570 //RemoveControl(*__pArticleReaderPanel);
1571 __pArticleReaderPanel = null;
1572 __pBlankPanel = null;
1573 __pArticleReaderLabel = null;
1575 //if (__pAddressbar)
1576 // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1577 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1580 case IDA_FINDWORD_CANCEL_CLICKED:
1582 __currentSearchStr = L"";
1583 __currentWordIndex = 0;
1584 __maxOccurrances = 0;
1585 __pFindWordEditField->SetText(L"");
1586 __pFindWordNext->SetEnabled(false);
1587 __pFindWordPrev->SetEnabled(false);
1588 __pFindWordCountLabel->SetText(L"0/0");
1589 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1590 ShowFindWordPanel(false);
1593 case IDA_FINDWORD_SEARCH_CLICKED:
1595 __currentSearchStr = __pFindWordEditField->GetText();
1596 if (__currentSearchStr.GetLength() > 0)
1602 AppLogDebug("Enter something");
1606 case IDA_FINDWORD_CLEAR_CLICKED:
1608 __pFindWordCountLabel->SetText(L"0/0");
1609 __pFindWordEditField->SetText(L"");
1610 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1612 __currentSearchStr = L"";
1613 __pFindWordNext->SetEnabled(false);
1614 __pFindWordPrev->SetEnabled(false);
1615 __pFindWordPanel->Invalidate(true);
1618 case IDA_FINDWORD_NEXT_CLICKED:
1623 case IDA_FINDWORD_PREV_CLICKED:
1625 FindNextWord(false);
1628 case IDA_BRIGHTNESS_BTN_CLICKED:
1630 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1631 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1634 case IDA_COPY_IMAGE_CLICKED:
1636 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1637 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1639 const Bitmap* pBitmap = null;
1640 if (__pHitElementResult != null)
1642 pBitmap = __pHitElementResult->GetImage();
1645 String resourcePath = App::GetInstance()->GetAppResourcePath();
1646 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1648 // copying the item to clipboard
1649 Clipboard* pClipboard = Clipboard::GetInstance();
1650 if (pClipboard != null)
1652 pClipboard->CopyItem(item);
1656 case IDA_VIEW_IMAGE_CLICKED:
1658 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1659 WindowInfo* pNewWindowInfo = null;
1660 if (__pHitElementResult != null)
1662 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1663 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1669 case IDA_SAVE_IMAGE_CLICKED:
1671 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1672 const Bitmap* pSaveBitmap = null;
1673 String imageName = GetImagePath();
1674 AppLog("Content manager image name %ls",imageName.GetPointer());
1677 imagePath.Append(imageName);
1678 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1679 AppLog("Content manager image path %ls",imagePath.GetPointer());
1680 if (__pHitElementResult != null)
1682 pSaveBitmap = __pHitElementResult->GetImage();
1684 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1688 UpdateImageContent(pBuffer, imageName);
1690 NotificationPanel *pNotification = new NotificationPanel(*this);
1692 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1693 msg.Append(imagePath);
1694 if (pNotification != null)
1696 pNotification->SetText(msg);
1697 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1698 pNotification->ShowNotification();
1703 int __modalMsgBoxResult;
1704 MessageBox* pMsgBox = new MessageBox();
1705 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1706 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1709 __modalMsgBoxResult = 0;
1713 case IDA_SHARE_IMAGE_CLICKED:
1715 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1716 if (__pPopUp != null)
1721 __pPopUp = new(std::nothrow) SharePopup();
1722 __pPopUp->Initialize();
1723 if (__pHitElementResult != null)
1725 const Bitmap* pSaveBitmap = null;
1726 String imageName = GetImagePath();
1727 AppLog("Content manager image name %ls",imageName.GetPointer());
1730 imagePath.Append(imageName);
1731 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1732 AppLog("Content manager image path %ls",imagePath.GetPointer());
1733 if (__pHitElementResult != null)
1735 pSaveBitmap = __pHitElementResult->GetImage();
1737 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1739 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1740 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1742 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1743 pShareInfo->SetPageTitle(L"");
1744 pShareInfo->SetPageUrl(srcUrl);
1745 pShareInfo->SetImageAttached(true);
1746 pShareInfo->SetImagePath(imagePath);
1747 __pPopUp->RemoveAllShareInfo();
1748 __pPopUp->AddShareInfo(pShareInfo);
1749 __pPopUp->SetShowState(true);
1754 case IDA_FIND_TEXT__CLICKED:
1756 AppLogDebug("MainForm::OnActionPerformed find word clicked");
1757 __currentSearchStr.Clear();
1758 __currentSearchStr.Append(__currentSelectedStr);
1759 InitFindWordPanel();
1762 __pMenu->SetShowState(false);
1763 __pMenu->Invalidate(false);
1766 __adressPanelPosition.y = 0;
1768 if (__pAddressbar != null && __pWebViewer != NULL)
1770 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
1771 //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
1772 //__pAddressbar->Invalidate(true);
1773 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
1775 if (__pFooterPanel->GetShowState() == false)
1776 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
1778 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
1779 // __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
1780 __pWebViewer->Invalidate(true);
1783 ShowFindWordPanel(true);
1784 if (__currentSearchStr.GetLength() > 0)
1790 AppLogDebug("Enter something");
1793 if (__pWebViewer != null)
1795 // releasing the set block
1796 __pWebViewer->ReleaseBlock();
1801 case IDA_SHARE_TEXT_CLICKED:
1803 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
1804 if(__pPopUp != null)
1809 __pPopUp = new(std::nothrow) SharePopup();
1810 __pPopUp->Initialize();
1811 if (__pHitElementResult != null)
1813 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1814 pShareInfo->SetPageTitle(L"");
1815 pShareInfo->SetPageUrl(__currentSelectedStr);
1816 pShareInfo->SetImageAttached(false);
1817 __pPopUp->RemoveAllShareInfo();
1818 __pPopUp->AddShareInfo(pShareInfo);
1819 __pPopUp->SetShowState(true);
1824 case IDA_COPY_TEXT_CLICKED:
1826 // need to implement
1827 //__currentSelectedStr
1828 // Sets data to a clip board item
1830 String resourcePath = App::GetInstance()->GetAppResourcePath();
1831 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
1833 // copying the item to clipboard
1834 Clipboard* pClipboard = Clipboard::GetInstance();
1835 if (pClipboard != null)
1837 pClipboard->CopyItem(item);
1841 case IDA_PASTE_TEXT_CLICKED:
1843 Clipboard* pClipboard = Clipboard::GetInstance();
1845 if(pClipboard == null)
1849 // Retrieves a latest item
1850 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
1856 //Gets data from the clipboard item
1857 String* pString = dynamic_cast<String*>(pItem->GetData());
1859 if (pString != null)
1861 String idElement = __pHitElementResult->GetAttributeValue(L"id");
1862 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
1863 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
1864 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; } } ";
1865 if(idElement.GetLength() != 0)
1867 script.Append("insertAtCursor(");
1868 script.Append(idElement);
1870 script.Append("\"");
1871 script.Append(*pString);
1872 script.Append("\");");
1874 else if (nameElement.GetLength() != 0)
1876 script.Append("insertAtCursor(document.getElementsByName('");
1877 script.Append(nameElement);
1878 script.Append("')[0],");
1879 script.Append("\"");
1880 script.Append(*pString);
1881 script.Append("\");");
1883 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
1884 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
1895 case IDA_GO_FORWARD:
1900 case IDA_REFRESH_BTN_CLICKED:
1902 __isLoadingCompleted = false;
1903 __isLoadingData = true;
1904 __progressPercentage = 0;
1905 __displayUrl = __pFooterUrlField->GetText();
1907 String url = __pFooterUrlField->GetText();
1908 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
1912 UpdateProgressBitmap();
1915 case IDA_STOP_BTN_CLICKED:
1917 __isLoadingCompleted = false;
1918 __isLoadingData = false;
1919 __progressPercentage = 0;
1920 __pFooterUrlField->HideKeypad();
1921 __displayUrl = __pFooterUrlField->GetText();
1925 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1926 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1927 __pWebViewer->StopLoading();
1928 RequestRedraw(true);
1931 UpdateProgressBitmap();
1936 if (__pFooterUrlField->GetText().IsEmpty() == false)
1938 //__displayUrl = __pUrlField->GetText();
1939 __pFooterUrlField->Clear();
1949 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
1952 UiApp* pApp = UiApp::GetInstance();
1961 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
1962 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
1964 String* pSelectedScene = NULL;
1965 Object* pValue = NULL;
1966 String* pUrl = null;
1967 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
1968 pSelectedScene = (String*) pValue;
1970 if (pSelectedScene != null)
1972 delete pSelectedScene;
1974 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
1975 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
1976 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
1977 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
1979 // setting the current scene ID
1980 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
1982 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
1984 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
1986 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
1987 if(__pWindowInfo == null)
1989 // if(__pWindowInfo == null)
1991 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
1994 else if ( pArgs != null && pArgs->GetCount() == 1)
1996 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2002 // hiding the address bar
2003 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2004 __pAddressbar->SetShowState(false);
2005 if(__pWebViewer != null)
2007 __pWebViewer->Resume();
2010 if(pUrl != null && pUrl->GetLength() > 0)
2014 else if(__pWindowInfo != null)
2016 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)
2018 LoadUrl(__pWindowInfo->pageUrl);
2020 else if (__pWindowInfo->isJavascriptInitiated == true)
2024 __pWindowInfo->pCurrentWeb = __pWebViewer;
2028 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2029 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2030 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2032 InitMostVisitedSitesView(GetOrientationStatus());
2035 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2037 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2039 if (pBookmarkUrl == null)
2041 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2042 //__pAddressbar->SetUrl(*pBookmarkUrl);
2043 SetUrl(*pBookmarkUrl);
2045 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2046 __pWebViewer->LoadUrl(*pBookmarkUrl);
2047 delete pBookmarkUrl;
2050 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2051 Bitmap* pBitmap = null;
2052 if (isPrivateBrowsing == true)
2054 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2056 if (__pWebViewer != null)
2058 __pWebViewer->SetPrivateBrowsingEnabled(true);
2061 if (__pAddressbar != null)
2063 // __pAddressbar->UpdateFaviconBitmap(true);
2069 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2071 if (__pWebViewer != null)
2073 __pWebViewer->SetPrivateBrowsingEnabled(false);
2076 if (__pAddressbar != null)
2078 // __pAddressbar->UpdateFaviconBitmap(false);
2082 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2084 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2086 else if (__pMenu != null )
2088 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2091 if (pBitmap != null)
2096 AppLog("ABC: OnSceneActivatedN started exit");
2101 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2102 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2104 Canvas* pWebCanvas = null;
2105 if (__pWebViewer != null)
2107 pWebCanvas = __pWebViewer->GetCanvasN();
2108 __pWebViewer->Pause();
2111 if (pWebCanvas == null)
2115 if (__pWindowInfo != null)
2117 if (__pWindowInfo->pWebCanvasBitmap != null)
2119 delete __pWindowInfo->pWebCanvasBitmap;
2121 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2122 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2123 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2125 Bitmap* pBitmap = GetCapturedBitmapN();
2126 AppLog("Coming here");
2127 Canvas* pCanvas = new(std::nothrow) Canvas();
2128 pCanvas->Construct(GetClientAreaBounds());
2131 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2134 if(__pWebViewer != null && __pWindowInfo != null)
2135 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2137 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2138 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2140 AppLog("Coming here");
2144 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2145 const Tizen::Base::String& realm,
2146 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2152 MainForm::OnHttpAuthenticationCanceled(void)
2157 MainForm::OnLoadingStarted(void)
2159 AppLogDebug("MainForm::OnLoadingStarted entered");
2161 if(__pAddressbar == NULL || __pWebViewer == null)
2165 String url = __pWebViewer->GetUrl();
2166 if(url.Contains(IDS_TIZEN_SERVICE))
2169 String delim(L":;");
2171 // Creates a StringTokenizer instance
2172 StringTokenizer strTok(url, delim);
2174 int count = strTok.GetTokenCount(); // count == 4
2176 HashMap *pMap = new HashMap();
2181 while (strTok.HasMoreTokens())
2183 AppLog("Token: %ls", token.GetPointer());
2184 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2185 if(token.Contains(IDS_APPID))
2187 token.SubString(6, appId);
2188 AppLog("AppID:%ls", appId.GetPointer());
2190 else if(token.Contains("="))
2192 String *pKey = new String();
2193 String *pValue = new String();
2195 token.IndexOf("=", 0, index);
2198 token.SubString(0, index, *pKey);
2199 token.SubString(index + 1, *pValue);
2200 pMap->Add(pKey, pValue);
2206 AppControl *pAppControl = null;
2207 String operationId = L"http://tizen.org/appcontrol/operation/main";
2208 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2211 AppLog("Starting AppControl");
2212 result r = pAppControl->Start(null, null, pMap, null);
2213 AppLog("Result of Start %s", GetErrorMessage(r));
2217 AppLogException("AppControl not found");
2222 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2225 __pAddressbar->SetFaviconBitmap(*pBitmap);
2228 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2230 // updating the address bar position with respect to web control
2231 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2232 __distanceMoved = 0;
2236 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2237 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2238 if (__pWebViewer != null)
2240 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2241 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2242 SetUrl(__pWebViewer->GetUrl());
2243 if (__pWindowInfo != NULL)
2245 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2247 __pAddressbar->Invalidate(true);
2253 MainForm::OnLoadingCanceled(void)
2260 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2262 AppLog("MainForm::OnKeypadWillOpen");
2263 if (__pAddressbar != null)
2265 OnAddressBarKeypadWillOpen(*__pAddressbar);
2271 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2273 if(__pAddressbar != null)
2275 OnAddressBarKeypadOpened(*__pAddressbar);
2281 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2283 if (__pAddressbar != null)
2285 OnAddressBarKeypadClosed(*__pAddressbar);
2290 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2292 AppLog("KeypadBoundsChanged");
2293 RelayoutControls(false);
2297 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2298 const Tizen::Base::String& reason)
2300 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2304 MainForm::OnLoadingCompleted(void)
2306 AppLog("MainForm::OnLoadingCompleted start");
2308 result r = E_SUCCESS;
2310 if (__pWebViewer == null)
2315 if (__pAddressbar == null)
2319 if (__pWebViewer->CanGoForward())
2321 //__pAddressbar->SetForwardButtonEnabled(true);
2322 SetForwardButtonEnabled(true);
2326 //__pAddressbar->SetForwardButtonEnabled(false);
2327 SetForwardButtonEnabled(false);
2330 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2332 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2334 //__pAddressbar->UpdateProgress(0);
2338 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2340 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2344 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2345 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2346 if (isPrivateBrowsing == false)
2348 History* pHistory = new(std::nothrow) History;
2350 HistoryPresentationModel::GetCurrentDateTime(date);
2353 pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2354 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2356 pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2357 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2359 pHistory->SetVisitedTime(date);
2362 id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2363 pHistory->SetFaviconId(id);*/
2365 if (__pWebViewer != null)
2367 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2369 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2370 if (pTempBitmap != null)
2372 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2373 pHistory->SetFavIconBitmap(*pTempBitmap);
2376 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2379 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2380 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2381 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2383 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2384 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2385 pHistory->SetThumbnail(pBitmap);
2387 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2390 pHistory->SetFavIconBitmap(*pFavIcon);
2394 HistoryPresentationModel::GetInstance()->SaveTempHistory(*pHistory);
2401 if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2403 // temperary fixed (webpage can be not loaded)
2406 AppLog("MainForm::OnLoadingCompleted done");
2410 MainForm::OnEstimatedProgress(int progress)
2412 AppLogDebug("MainForm::OnEstimatedProgress entered");
2413 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2414 progress = DEFAULT_PROGRESS_PERCENTAGE;
2416 // __pAddressbar->UpdateProgress(progress);
2417 UpdateProgress(progress);
2420 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2422 AppLog("MainForm::OnFaviconReceived");
2423 Bitmap* pFavIconBitmap = __pWebViewer->GetFaviconN();
2425 if (pFavIconBitmap != null)
2427 pFavIconBitmap->GetWidth();
2428 pFavIconBitmap->GetHeight();
2433 MainForm::OnUrlValueChanged(Addressbar&)
2439 MainForm::OnUrlSubmitted(Addressbar& addBar)
2441 AppLog("MainForm::OnUrlSubmitted");
2442 String url = addBar.GetUrl();
2443 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2445 // __pFooterPanel->SetShowState(true);
2446 OnAddressCancelledClicked(*__pAddressbar);
2447 // __pAddressbar->SetShowState(false);
2448 // RelayoutControls(false);
2453 MainForm::LoadUrl(String& url)
2456 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2457 AppLogDebug("MainForm::LoadUrl enter");
2459 if (__pWebViewer != null)
2461 __pWebViewer->SetShowState(true);
2462 __pWebViewer->Invalidate(true);
2465 if (url.CompareTo(L"") == 0)
2469 if(__pFooterPanel != null)
2471 __pFooterPanel->SetShowState(true);
2472 __pFooterPanel->Invalidate(true);
2479 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2480 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)
2482 RegularExpression firstRegex;
2483 RegularExpression secondRegex;
2485 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2486 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2489 ret = firstRegex.Match(url, false); // This returns true value
2490 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2492 if (ret == true && __pWebViewer != null)
2494 __pWebViewer->LoadUrl(url);
2496 else if(__pWebViewer != null)
2498 String tempUrl = L"http://";
2499 tempUrl.Append(url);
2503 __pWebViewer->LoadUrl(tempUrl);
2507 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2508 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2511 if (__pAddressbar != null)
2513 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2514 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2517 AppLogDebug("MainForm::LoadUrl exit");
2524 MainForm::OnStopClicked(Addressbar& addBar)
2526 AppLogDebug("MainForm::OnStopClicked called");
2529 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2530 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2531 __pWebViewer->StopLoading();
2532 RequestRedraw(true);
2537 MainForm::OnReaderClicked(const Addressbar& addBar)
2539 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2541 CreateReaderPanel();
2542 AppLogDebug("MainScene::OnReaderClicked entered");
2545 /*if (__pArticleReaderPanel)
2547 AppLogDebug("showstate true for reader panel");
2548 __pArticleReaderPanel->SetShowState(true);
2549 __pArticleReaderPanel->Show();
2551 int xPos = __pArticleReaderPanel->GetX();
2552 int yPos = __pArticleReaderPanel->GetY();
2553 AppLog("OnReaderClicked() xPos = %d",xPos);
2554 AppLog("OnReaderClicked() yPos = %d",yPos);
2556 if (__pReaderData == null)
2561 String loadData = L"<html>\
2563 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2568 background-color: transparent;\
2587 <body style='width:'";
2588 loadData.Append(bodyWidth);
2589 loadData.Append(L"px'>");
2590 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2591 loadData.Append(*__pReaderData);
2592 loadData.Append(L"</body></html>");
2595 buf.Construct(loadData.GetLength());
2596 AppLogDebug("data->GetLength %d",loadData.GetLength());
2597 for (int z=0;z<loadData.GetLength();z++)
2600 loadData.GetCharAt(z,b);
2601 buf.SetByte((byte)b);
2605 if (__pWebReader != null)
2607 __pWebReader->LoadData(L"",buf,L"text/html");
2608 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2612 AppLogDebug("cannot LoadData __pWebReader is null");
2618 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2620 AppLog("MainForm::OnBackClicked");
2621 result r = E_FAILURE;
2623 if (__pWebViewer != null && __pWebViewer->CanGoBack())
2625 __pWebViewer->GoBack();
2630 pApp = UiApp::GetInstance();
2633 r = pApp->Terminate();
2643 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
2645 AppLog("MainForm::OnForwardClicked");
2646 if (__pWebViewer == null)
2649 if (__pWebViewer->CanGoForward())
2651 __pWebViewer->GoForward();
2656 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
2658 result r = E_SUCCESS;
2659 // hiding the address bar
2660 __pAddressbar->SetShowState(false);
2661 __pFooterPanel->SetShowState(true);
2663 __pWebViewer->SetFocus();
2665 __pMostVisitedListView->SetFocus();
2666 __pFooterUrlField->SetFocusable(true);
2667 __pMoreButton->SetFocus();
2669 RelayoutControls(false);
2673 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
2675 __prevAddressBarMode = __curAddressBarMode;
2677 if (__pAddressbar != null)
2679 __curAddressBarMode = GetAddressbarMode();
2682 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
2684 __adressPanelPosition.y = 0;
2685 if (__pAddressbar != null)
2687 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2688 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2689 __pAddressbar->Invalidate(true);
2691 if (__pWebViewer != null)
2693 __pWebViewer->StopLoading();
2696 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
2698 __adressPanelPosition.y = 0;
2699 if (__pAddressbar != null)
2701 __webControlPosition.y = 0;
2702 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
2703 __pAddressbar->Invalidate(true);
2709 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
2712 __pAddressbar->SetShowState(false);
2714 __pFooterPanel->SetShowState(true);
2716 __pWebViewer->SetFocus();
2717 if(__pFooterUrlField)
2718 __pFooterUrlField->SetFocusable(true);
2719 RelayoutControls(false);
2723 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
2725 if (__pFindWordControl && __pFindWordControl->GetShowState() == true)
2727 __pAddressbar->SetShowState(false);
2731 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
2733 __pAddressbar->SetShowState(true);
2734 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2735 __pAddressbar->SetAddressbarURLFocus();
2739 RelayoutControls(false);
2743 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
2745 __pFooterPanel->SetShowState(false);
2749 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
2751 AppLog("KeypadBoundsChanged");
2752 RelayoutControls(false);
2756 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
2760 __pWindowInfo->pageTitle = title;
2761 if (__pWebViewer != null)
2763 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2766 if (__pAddressbar != null && __pWebViewer != null)
2768 SetUrl(__pWebViewer->GetUrl());
2769 __pAddressbar->Invalidate(true);
2774 MainForm::UpdateFavicon(void)
2776 bool urlImageType = false;
2777 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();");
2778 Bitmap* pBitmap = null;
2780 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
2782 if (__pWindowInfo != null)
2785 url.SetUri(*tempPath);
2786 if (url.GetHost().GetLength() == 0)
2789 webUrl.SetUri(__pWebViewer->GetUrl());
2790 result r = url.SetHost(webUrl.GetHost());
2797 if (url.GetScheme().GetLength() == 0)
2800 webUrl.SetUri(__pWebViewer->GetUrl());
2801 url.SetScheme(webUrl.GetScheme());
2803 __pWindowInfo->faviconUrl = url.ToString();
2805 pBitmap = __pWebViewer->GetFaviconN();
2807 if (pBitmap != null)
2809 if (__pWindowInfo->pFavicon != NULL)
2811 __pWindowInfo->pFavicon = null;
2813 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
2814 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
2816 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2818 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2820 else if(__pWindowInfo->pFavicon != null)
2822 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2826 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
2827 if(pDefaultBmp != null)
2829 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
2838 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
2845 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
2846 Tizen::Web::Controls::WebNavigationType type)
2848 // when load new page if find word panel is open its show state is false
2849 ShowFindWordPanel(false);
2851 __pFooterPanel->Invalidate(true);
2854 uriInfo.SetUri(url);
2856 if(url.Contains(IDS_TIZEN_SERVICE))
2859 String delim(L":;");
2861 // Creates a StringTokenizer instance
2862 StringTokenizer strTok(url, delim);
2864 int count = strTok.GetTokenCount(); // count == 4
2866 HashMap *pMap = new HashMap();
2872 while (strTok.HasMoreTokens())
2874 AppLog("Token: %ls", token.GetPointer());
2875 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2876 if(token.Contains(IDS_APPID))
2878 token.SubString(6, appId);
2879 AppLog("AppID:%ls", appId.GetPointer());
2881 else if(token.Contains("="))
2883 String *pKey = new String();
2884 String *pValue = new String();
2886 token.IndexOf("=", 0, index);
2889 token.SubString(0, index, *pKey);
2890 token.SubString(index + 1, *pValue);
2891 pMap->Add(pKey, pValue);
2897 AppControl *pAppControl = null;
2898 String operationId = L"http://tizen.org/appcontrol/operation/main";
2899 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2902 result r = pAppControl->Start(null, null, pMap, null);
2906 AppLogException("AppControl not found");
2912 if ( __pAddressbar != null)
2914 __pAddressbar->SetShowState(false);
2915 __pAddressbar->Invalidate(true);
2921 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
2922 const Tizen::Net::Http::HttpHeader& httpHeader)
2924 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
2929 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
2931 AppLog("MainForm::OnWebPageBlockSelected");
2932 if (__pHitElementResult != null)
2934 delete __pHitElementResult;
2935 __pHitElementResult = null;
2938 if (__pWebViewer != null)
2940 AppLog("MainForm::OnWebPageBlockSelected web not null");
2941 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
2944 if (__pHitElementResult == null)
2949 if (__pHitElementResult->HasImage() != true)
2951 String tagName = __pHitElementResult->GetTagName();
2952 String type = __pHitElementResult->GetAttributeValue("type");
2954 __currentSelectedStr.Clear();
2955 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
2956 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
2957 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
2959 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && __isLongPressedDone == true)
2961 AppLog("MainForm::OnWebPageBlockSelected show paste option");
2963 InitSelectTextContextMenu(endPoint,true);
2964 __pImageMenu->SetShowState(true);
2965 __pImageMenu->Show();
2966 __pImageMenu->Invalidate(true);
2968 else if(__isLongPressedDone == true)
2970 AppLog("MainForm::OnWebPageBlockSelected no paste option");
2972 if(__pHitElementResult->GetUrl().GetLength() > 0)
2974 __currentSelectedStr.Clear();
2975 __currentSelectedStr = __pHitElementResult->GetUrl();
2977 InitSelectTextContextMenu(endPoint,false);
2978 __pImageMenu->SetShowState(true);
2979 __pImageMenu->Show();
2980 __pImageMenu->Invalidate(true);
2983 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
2984 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
2985 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
2991 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
2997 MainForm::OnWebWindowCreateRequested(void)
2999 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
3001 if (pNewWindowInfo == null)
3005 result r = E_SUCCESS;
3006 SceneManager* pSceneManager = SceneManager::GetInstance();
3007 if (pSceneManager == NULL)
3011 ArrayList* pArgList = new(std::nothrow) ArrayList();
3012 if (pArgList == NULL)
3016 r = pArgList->Construct();
3019 pNewWindowInfo->isJavascriptInitiated = true;
3020 pArgList->Add(*pNewWindowInfo);
3021 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3025 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3032 return pNewWindowInfo->pCurrentWeb;
3036 MainForm::RelayoutControls(bool showAddressbar)
3038 __webControlPosition.y = 0;
3039 __webControlHeight = GetClientAreaBounds().height;
3040 AppLog("Client area height: %d", __webControlHeight);
3042 AppLog("Client area height: %d", __webControlHeight);
3043 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3045 __webControlPosition.y += __pAddressbar->GetHeight();
3046 __webControlHeight -= __pAddressbar->GetHeight();
3047 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3049 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3051 __webControlPosition.y += __pFindWordControl->GetHeight();
3052 __webControlHeight -= __pFindWordControl->GetHeight();
3053 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3056 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true)
3058 __webControlHeight -= __pFooterPanel->GetHeight();
3059 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3061 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3063 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight);
3064 __pWebViewer->Invalidate(false);
3066 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3068 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3075 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3077 if (__pFindWordControl == null)
3083 InitFindWordPanel();
3084 __pFindWordEditField->SetText(__currentSearchStr);
3085 //__pFindWordCountLabel->SetText(L"");
3086 __pFindWordCountLabel->SetText(L"0/0");
3087 __pFindWordPanel->SetShowState(true);
3091 if(__pFindWordControl != null)
3093 __pFindWordControl->SetShowState(false);
3097 AppLog("MainForm::ShowFindWordPanel %d",show);
3098 if (show && !isTouchPressed)
3100 if (__pFindWordEditField)
3102 __pFindWordEditField->SetFocus();
3103 __pFindWordEditField->ShowKeypad();
3108 if (__pFindWordEditField)
3109 __pFindWordEditField->HideKeypad();
3112 RelayoutControls(false);
3116 MainForm::StartWordSearch()
3118 //Get the count of occurances of the word in the current page
3119 __maxOccurrances = 0;
3120 __currentWordIndex = 0;
3122 __pFindWordPrev->SetEnabled(false);
3123 String *pCountStr = null;
3124 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3125 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3126 if (pCountStr != null)
3128 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3132 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3137 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3139 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3140 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3142 if(totalCount == -1 || totalCount == 0)
3144 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),64,__pFindWordCountLabel->GetHeight());
3145 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3148 else if(totalCount > 100)
3150 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3151 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3155 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3156 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3159 __maxOccurrances = totalCount;
3160 __currentWordIndex = currentOrdinal;
3162 //Reset the UI controls as per the maxOccurrance value
3163 if (totalCount <= 0)
3165 AppLog("Word not found");
3166 //Show error notification to user
3167 __pFindWordNext->SetEnabled(false);
3168 __pFindWordCountLabel->SetText(L"0/0");
3169 __pFindWordNext->Invalidate(false);
3170 __pFindWordPrev->Invalidate(false);
3171 __pFindWordCountLabel->Invalidate(false);
3175 if (totalCount == 1)
3177 __pFindWordNext->SetEnabled(false);
3181 __pFindWordNext->SetEnabled(true);
3184 String countStr = L"";
3185 countStr.Append(__currentWordIndex);
3186 countStr.Append(L"/");
3187 countStr.Append(__maxOccurrances);
3188 __pFindWordCountLabel->SetText(countStr);
3189 // __pFindWordCountLabel->SetShowState(true);
3190 __pFindWordCountLabel->Invalidate(false);
3192 //FindNextWord(true);
3193 //Update the controls
3194 __pFindWordNext->Invalidate(false);
3195 __pFindWordPrev->Invalidate(false);
3196 __pFindWordCountLabel->Invalidate(false);
3200 MainForm::FindNextWord(bool next)
3204 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3206 if(__currentWordIndex < __maxOccurrances)
3208 __currentWordIndex++;
3214 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3216 if(__currentWordIndex > 1)
3218 __currentWordIndex--;
3223 String countStr = L"";
3224 countStr.Append(__currentWordIndex);
3225 countStr.Append(L"/");
3226 countStr.Append(__maxOccurrances);
3227 __pFindWordCountLabel->SetText(countStr);
3228 // __pFindWordCountLabel->SetShowState(true);
3229 __pFindWordCountLabel->Invalidate(false);
3230 if (__currentWordIndex >= __maxOccurrances)
3232 __pFindWordNext->SetEnabled(false);
3236 __pFindWordNext->SetEnabled(true);
3238 if (__currentWordIndex <= 1)
3240 __pFindWordPrev->SetEnabled(false);
3244 __pFindWordPrev->SetEnabled(true);
3246 __pFindWordPrev->Invalidate(false);
3247 __pFindWordNext->Invalidate(false);
3248 __pFindWordCountLabel->Invalidate(false);
3249 __pFindWordPanel->Invalidate(true);
3252 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3254 AppLog("MainForm::OnWebKeypadWillOpen");
3255 __isWebKeypadOpened = true;
3256 // OnAddressBarKeypadOpened(*__pAddressbar);
3260 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3263 if (__pWebViewer != null && __pFooterPanel != null)
3265 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3266 if(__pAddressbar != null)
3268 __pAddressbar->SetShowState(false);
3270 if(__pFindWordControl != null)
3272 __pFindWordControl->SetShowState(false);
3274 __pFooterPanel->SetShowState(false);
3275 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
3281 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3283 __pFooterPanel->SetShowState(true);
3284 OnAddressBarKeypadClosed(*__pAddressbar);
3285 __isWebKeypadOpened = false;
3289 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3291 Control* temp = const_cast< Control* >(&source);
3292 Header* pHeader = dynamic_cast< Header* >(temp);
3293 if (pHeader != null)
3295 //Header double - clicked
3296 AppLog("Header double clicked");
3298 if(__pFindWordPanel)
3300 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3301 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3305 AppLog("MainScene::OnTouchDoublePressed");
3306 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3307 if (isReaderEnabled == true)
3311 delete __pReaderData;
3312 __pReaderData = null;
3314 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3315 filePath.Append(L"data/reader.js");
3321 result r = E_SUCCESS;
3322 FileAttributes attr;
3324 File::GetAttributes(filePath,attr);
3326 r = file.Construct(filePath, L"r+");
3329 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3332 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3335 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3338 file.Read(pScript,attr.GetFileSize());
3340 AppLogDebug("scipt length %d",strlen(pScript));
3341 String strScript = L"";
3342 strScript.Append(pScript);
3343 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3346 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3349 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3350 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3352 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3353 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3359 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3361 AppLog("MainForm::OnTouchLongPressed");
3363 if (__pHitElementResult != null)
3365 delete __pHitElementResult;
3366 __pHitElementResult = null;
3369 if (__pWebViewer != null)
3371 AppLog("MainForm::OnTouchLongPressed web not null");
3372 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3375 if (__pHitElementResult == null)
3380 if (__pHitElementResult->HasImage() == true)
3382 InitImageContextMenu(currentPosition);
3383 __pImageMenu->SetShowState(true);
3384 __pImageMenu->Show();
3385 __pImageMenu->Invalidate(true);
3389 String tagName = __pHitElementResult->GetTagName();
3390 String type = __pHitElementResult->GetAttributeValue("type");
3391 String value = __pHitElementResult->GetAttributeValue(L"value");
3392 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3394 __currentSelectedStr.Clear();
3395 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3397 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0 && __isWebKeypadOpened == true)
3399 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3401 InitSelectTextContextMenu(currentPosition,true, true);
3402 __pImageMenu->SetShowState(true);
3403 __pImageMenu->Show();
3404 __pImageMenu->Invalidate(true);
3406 __isLongPressedDone = true;
3407 __pWebViewer->SetBlockSelectionPosition(currentPosition);
3410 __inputEventToBeSupressed = true;
3414 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3416 AppLog("MainForm::OnTouchReleased");
3418 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3419 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3421 __pWebViewer->ConsumeInputEvent();
3423 if(pHitElement != null)
3427 __inputEventToBeSupressed = false;
3431 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
3433 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
3434 int widthContextItem = 0;
3435 if(__pFindWordPanel != null)
3436 ShowFindWordPanel(__pFindWordPanel->GetShowState(), false);
3437 if ( __pFooterLabel != null)
3439 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
3442 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
3447 if (__pFindWordBgLabel != null)
3449 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
3450 if (pBitmap != null)
3452 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
3458 __pMenu->SetShowState(false);
3459 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
3461 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
3465 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
3470 AppLog("__pFooterPanel->GetShowState() is true");
3472 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3473 __pFooterPanel->Invalidate(true);
3477 if(__pMoreButton && __pMenu)
3479 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
3480 __pMenu->SetAnchorPosition(p);
3481 __pMenu->Invalidate(true);
3484 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
3485 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
3487 InitMostVisitedSitesView(orientationStatus);
3490 RelayoutControls(false);
3491 if (__pArticleReaderPanel != null)
3493 if (__pArticleReaderPanel->GetShowState() == true)
3495 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
3497 if (__pBlankPanel != null)
3498 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
3500 if (__pWebReader != null)
3502 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
3504 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3505 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3507 if ( pBitmap != null && pSrcBitmap != null)
3509 AppLog("CreateReaderPanel ninepatchbitmap found");
3510 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
3513 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
3514 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
3515 if (pBitmap != null)
3520 if (pSrcBitmap != null)
3529 if (__pAddressbar != null)
3531 int width = GetClientAreaBounds().width;
3532 __pAddressbar->OrientationChanged(width);
3537 MainForm::OnSettingsChange(int settingvalue)
3539 AppLogDebug("MainForm::OnSettingsChange entered");
3540 if (__pWebViewer == null)
3542 AppLogDebug("Webviewer is not initialized yet.");
3545 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
3547 WebSetting settings = __pWebViewer->GetSetting();
3548 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
3550 settings.SetAutoFittingEnabled(true);
3552 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
3554 settings.SetAutoFittingEnabled(false);
3556 __pWebViewer->SetSetting(settings);
3558 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
3560 WebSetting settings = __pWebViewer->GetSetting();
3561 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
3562 __pWebViewer->SetSetting(settings);
3564 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
3566 WebSetting settings = __pWebViewer->GetSetting();
3567 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
3568 __pWebViewer->SetSetting(settings);
3570 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
3572 WebSetting settings = __pWebViewer->GetSetting();
3573 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
3574 __pWebViewer->SetSetting(settings);
3576 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
3580 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3584 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
3586 WebSetting settings = __pWebViewer->GetSetting();
3587 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
3589 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
3593 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
3595 __pWebViewer->SetSetting(settings);
3597 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
3601 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
3602 WebSetting settings = __pWebReader->GetSetting();
3603 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
3604 __pWebReader->SetSetting(settings);
3610 MainForm::OnSettingsReset()
3614 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3615 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
3620 MainForm::OnClearCache()
3622 result r = E_SUCCESS;
3624 if (__pWebViewer != NULL)
3626 r = __pWebViewer->ClearCache();
3629 AppLogDebug("Cache cleared success");
3633 AppLogDebug("Cache cleared fail");
3639 MainForm::OnClearCookie()
3641 result r = E_SUCCESS;
3643 if (__pWebViewer != NULL)
3645 __pWebViewer->ClearCookie();
3649 AppLogDebug("Cookie cleared success");
3653 AppLogDebug("Cache cleared fail");
3658 MainForm::findDistance(int x1,int y1,int x2, int y2)
3660 int deltaX = Math::Abs(x2 - x1);
3661 int deltaY = Math::Abs(y2 - y1);
3662 double num = deltaX*deltaX + deltaY*deltaY;
3668 for (i = 0; i < 20; i++)
3670 x = (((x*x)+ num)/(2*x));
3681 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3683 if(__pFindWordPanel)
3685 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3686 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3688 __isLongPressedDone = false;
3691 IList* pList = null;
3692 pList = touch.GetTouchInfoListN(source);
3696 int count = pList->GetCount();
3699 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3700 __touchPoint1 = pTouchInfo->position;
3702 /*if (__pAddressbar != null)
3704 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3706 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3708 __pAddressbar->SaveAddressbarEditText();
3710 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3713 __pAddressbar->Invalidate(true);
3715 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3717 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3719 //__pAddressbar->SaveAddressbarEditText();
3721 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3724 else if (count == 2)
3726 AppLogDebug("MainForm::OnTouchPressed count is two");
3727 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3728 __touchPoint1 = pTouchInfo->position;
3730 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
3731 __touchPoint2 = pTouchInfo->position;
3737 pList->RemoveAll(true);
3744 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3746 __currentWordIndex = 0;
3747 __isLongPressedDone = false;
3752 MainForm::MoveUiControls()
3757 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
3759 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
3761 if(__pFooterUrlField->GetTextLength() == 0)
3763 __pFooterUrlField->SetKeypadActionEnabled(false);
3767 __pFooterUrlField->SetKeypadActionEnabled(true);
3770 if (__pFindWordEditField != null)
3772 __currentSearchStr = __pFindWordEditField->GetText();
3773 __pFindWordNext->SetEnabled(false);
3774 __pFindWordPrev->SetEnabled(false);
3775 __pFindWordNext->Invalidate(true);
3776 __pFindWordPrev->Invalidate(true);
3777 __pFindWordCountLabel->SetText(L"0/0");
3778 __pFindWordCountLabel->Invalidate(true);
3780 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
3781 if (__currentSearchStr.GetLength() > 0)
3787 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
3789 __currentSearchStr = L"";
3790 AppLogDebug("Enter something");
3795 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
3802 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
3804 if(__pWebViewer != null)
3807 AppLog("MainForm::InitMostVisitedSitesView");
3808 result r = E_SUCCESS;
3811 if (__pWebViewer != null && __pMostVisitedListView != null)
3816 if (__pMostVisitedListView != null)
3818 RemoveControl(*__pMostVisitedListView);
3820 if(__pMostVisitedSites != null)
3822 __pMostVisitedSites->RemoveAll(true);
3825 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
3827 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
3828 __pMostVisitedListView = new(std::nothrow) ListView();
3830 int height = GetClientAreaBounds().height;
3832 if(__pFooterPanel->GetShowState() == true)
3834 height = height - __pFooterPanel->GetHeight();
3836 if(__pAddressbar->GetShowState() == true)
3838 height -= __pAddressbar->GetHeight();
3841 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
3845 delete __pMostVisitedListView;
3846 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
3849 __pMostVisitedListView->SetItemProvider(*this);
3850 __pMostVisitedListView->AddListViewItemEventListener(*this);
3851 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
3852 AddControl(*__pMostVisitedListView);
3853 __pMostVisitedListView->UpdateList();
3860 MainForm::GetImagePath(void)
3864 String formattedTime;
3865 DateTime currentTime;
3866 LocaleManager localManager;
3867 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
3869 localManager.Construct();
3870 Locale locale = localManager.GetSystemLocale();
3871 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
3873 // Get date formatter
3874 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
3878 pTimeFormatter->Format(currentTime, formattedTime);
3881 AppLog("current time stamp is %ls", formattedTime.GetPointer());
3882 String delim(L" :");
3883 StringTokenizer strTok(formattedTime, delim);
3886 String str1("GMT+00");
3887 while (strTok.HasMoreTokens())
3889 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
3890 if(token.Equals(str1))
3892 AppLog("token is %ls", token.GetPointer());
3893 imageName.Append(token);
3899 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
3901 result r = E_FAILURE;
3902 AppLog("Content manager 1");
3903 ContentId contentId;
3904 ContentManager contentManager;
3905 r = contentManager.Construct();
3908 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
3911 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
3912 contentPath.Append(imageName);
3913 contentPath.Append(".jpg");
3914 contentId = contentManager.CreateContent(*aBuffer, contentPath);
3915 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
3919 MainForm::SetForwardButtonEnabled(bool isEnabled)
3921 __pGoForwardBtn->SetEnabled(isEnabled);
3922 __pGoBackBtn->Invalidate(true);
3926 MainForm::SetBackButtonEnabled(bool isEnabled)
3928 __pGoBackBtn->SetEnabled(isEnabled);
3929 __pGoBackBtn->Invalidate(true);
3933 MainForm::UpdateProgress(int percentage)
3935 __progressPercentage = percentage;
3936 if (percentage == 0 || percentage == 100)
3938 __isLoadingData = false;
3939 if (percentage == 100)
3941 __isLoadingCompleted = true;
3942 __progressPercentage = 0;
3946 __isLoadingCompleted = false;
3951 __isLoadingData = true;
3953 UpdateProgressBitmap();
3957 MainForm::GetProgress(void)
3959 return __progressPercentage;
3963 MainForm::UpdateProgressBitmap(void)
3965 result r = E_SUCCESS;
3966 if (__pProgressbarLabel == null)
3968 int w = __pProgressbarLabel->GetWidth();
3969 int h = __pProgressbarLabel->GetHeight();
3971 int progressWidth = 0;
3972 Bitmap* pRetBitmap = null;
3974 if (__progressPercentage == 0 || __progressPercentage == 100)
3976 __pProgressbarLabel->SetShowState(false);
3977 __pProgressbarLabel->Invalidate(false);
3982 __pProgressbarLabel->SetShowState(true);
3983 __pProgressbarLabel->Invalidate(false);
3986 r = canvas.Construct(Rectangle(0, 0, w, h));
3990 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
3995 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
3999 pBgBmp->Scale(Dimension(w, h));
4000 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4004 progressWidth = (double) (w) * __progressPercentage / 100;
4005 AppLogDebug("progressWidth: %d", progressWidth);
4006 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4008 if (pProgressBmp != null)
4010 pProgressBmp->Scale(Dimension(progressWidth, h));
4011 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4012 delete pProgressBmp;
4015 pRetBitmap = new (std::nothrow) Bitmap();
4017 if (pRetBitmap == null)
4019 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4023 pRetBitmap->Construct(canvas, canvas.GetBounds());
4025 if (__pProgressbarLabel != null && pRetBitmap != null)
4027 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4028 __pProgressbarLabel->Invalidate(false);
4031 if (pRetBitmap != null)
4039 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4041 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4043 __currentAddMode = addMode;
4047 case ADDRESSBAR_MODE_INVALID:
4052 case ADDRESSBAR_MODE_READER:
4054 __pStopBtn->SetShowState(false);
4055 __pClearBtn->SetShowState(false);
4058 case ADDRESSBAR_MODE_LOADING:
4060 __pRefreshBtn->SetShowState(false);
4061 __pStopBtn->SetShowState(true);
4062 __pClearBtn->SetShowState(false);
4065 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4067 // SetUrl(__pAddressbar->GetUrl());
4069 __pRefreshBtn->SetShowState(true);
4070 __pStopBtn->SetShowState(false);
4071 __pClearBtn->SetShowState(false);
4074 case ADDRESSBAR_MODE_EDIT:
4076 __pRefreshBtn->SetShowState(false);
4077 __pStopBtn->SetShowState(false);
4078 __pClearBtn->SetShowState(true);
4085 OnAddressBarModeChanged();
4088 AddressBarMode MainForm::GetAddressbarMode(void)
4090 return __currentAddMode;
4093 void MainForm::SetUrl(const String& url)
4097 if (__pFooterUrlField != NULL)
4099 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4100 if (removedHttpUrl.IsEmpty() == false)
4102 __pFooterUrlField->SetText(removedHttpUrl);
4103 __pAddressbar->SetUrl(__displayUrl);
4107 __pFooterUrlField->SetText(__displayUrl);
4108 __pAddressbar->SetUrl(__displayUrl);
4111 __pFooterUrlField->Invalidate(false);
4112 __pAddressbar->Invalidate(true);
4113 __pFooterUrlField->SetCursorPosition(0);
4118 MainForm::RemoveHttpTextFromDisplayURL(void)
4120 bool isHttpText = __displayUrl.Contains(L"http://");
4121 String updatedDisplayUrl;
4122 updatedDisplayUrl.Clear();
4124 if (isHttpText == true)
4126 __displayUrl.SubString(7,updatedDisplayUrl);
4128 return updatedDisplayUrl;