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_BTN_BACK = L"I01_icon_Back.png";
57 static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
58 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
59 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
60 static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
61 static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
62 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
63 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
64 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
65 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
66 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
67 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
68 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
69 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
70 static const wchar_t* IDS_APPID = L"AppID";
71 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
72 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
74 const int IDA_BACKBTN_CLICKED = 101;
75 const int IDA_BOOKMARKBTN_CLICKED = 102;
76 const int IDA_MOREBTN_CLICKED = 103;
77 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
78 const int IDA_NEWWINDOWBTN_CLICKED = 105;
79 const int IDA_FORWARD_CLICKED = 106;
80 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
81 const int IDA_SHARE_CLICKED = 108;
82 const int IDA_FINDONPAGE_CLICKED = 109;
83 const int IDA_PRIVATEON_CLICKED = 110;
84 const int IDA_SETTINGS_CLICKED = 111;
85 const int IDA_READER_CLOSE_CLICKED = 112;
86 const int IDA_SMALLFONT_BTN_CLICKED = 113;
87 const int IDA_LARGEFONT_BTN_CLICKED = 114;
88 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
89 const int IDA_HISTORY_CLICKED = 116;
90 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
91 const int IDA_ADD_TO_HOME_CLICKED = 118;
92 const int IDA_SAVED_PAGES_CLICKED = 119;
93 const int IDA_DESKTOP_VIEW_CLICKED = 120;
94 const int IDA_SAVE_CLICKED = 121;
96 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
97 const int IDA_FINDWORD_NEXT_CLICKED = 202;
98 const int IDA_FINDWORD_PREV_CLICKED = 203;
99 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
100 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
102 const int IDA_COPY_IMAGE_CLICKED = 206;
103 const int IDA_VIEW_IMAGE_CLICKED = 207;
104 const int IDA_SAVE_IMAGE_CLICKED = 208;
105 const int IDA_SHARE_IMAGE_CLICKED = 209;
107 const int IDA_COPY_TEXT_CLICKED = 210;
108 const int IDA_PASTE_TEXT_CLICKED = 211;
109 const int IDA_FIND_TEXT__CLICKED = 212;
110 const int IDA_SHARE_TEXT_CLICKED = 213;
112 const int IDA_GO_BACK = 214;
113 const int IDA_GO_FORWARD = 215;
114 const int IDA_REFRESH_BTN_CLICKED = 216;
115 const int IDA_STOP_BTN_CLICKED = 217;
116 const int IDA_CLEAR_URL = 218;
118 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
120 const int MainForm::IDA_FORMAT_BITMAP = 500;
121 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
122 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
123 const int MainForm::IDA_FORMAT_URL_STRING = 503;
124 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
126 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
127 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
128 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
130 MainForm::MainForm(void)
132 __isLongPressedDone = false;
133 __pAddressbar = null;
134 // __pMostVisitedSitesPanel = null;
135 __pMostVisitedListView = null;
136 __pFooterPanel = null;
137 __pHitElementResult = null;
138 __pWindowInfo = null;
142 __pFindWordControl = null;
143 __pFindWordPanel = null;
144 __pFindWordBgLabel = null;
145 __pFindWordEditField = null;
146 __pFindWordClear = null;
147 __pFindWordCountLabel = null;
148 __pFindWordNext = null;
149 __pFindWordPrev = null;
150 __previousZoomLevel = 1.0;
152 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
155 __currentSearchStr = L"";
156 __currentSelectedStr = L"";
157 __maxOccurrances = 0;
158 __currentWordIndex = 0;
161 __inputEventToBeSupressed = false;
162 __isLoadingData = false;
163 __isLoadingCompleted = false;
164 __progressPercentage = 0;
165 __touchPoint1 = Point(-1,-1);
166 __touchPoint2 = Point(-1,-1);
168 // __pReaderPopup = null;
169 __pReaderData = null;
171 __pReaderCloseBtn = null;
172 //__pNewWindowButton = null;
173 __pMoreButton = null;
174 __pMultiWindowButton = null;
175 __pArticleReaderPanel = null;
176 __pBlankPanel = null;
177 __pArticleReaderLabel = null;
178 __webControlHeight = 0;
179 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
180 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
181 __pMostVisitedSites = null;
182 __pFooterUrlField = null;
184 __pGoForwardBtn = null;
185 __pRefreshBtn = null;
186 __pProgressbarLabel = null;
187 __pFooterLabel = null;
192 MainForm::~MainForm(void)
194 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
198 __pAddressbar->SetAddressbarEventListener(null);
200 if (__pReaderData != null)
202 delete __pReaderData;
203 __pReaderData = null;
206 if (__pPopUp != null)
212 if (__pHitElementResult != null)
214 delete __pHitElementResult;
215 __pHitElementResult = null;
217 String* pSelectedScene = NULL;
218 Object* pValue = NULL;
219 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
220 pSelectedScene = (String*) pValue;
222 /*if (pSelectedScene != null)
224 delete pSelectedScene;
226 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
230 MainForm::Initialize(void)
232 Construct(L"IDL_FORM");
237 MainForm::OnInitializing(void)
239 AppLog("get client area width = %d",GetClientAreaBounds().width);
240 AppLog("get client area height = %d",GetClientAreaBounds().height);
241 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
242 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
244 Panel* pFooterPanel = null;
246 __pSaveImage = new Image();
247 __pSaveImage->Construct();
249 // Setup back event listener
250 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
251 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
252 AddOrientationEventListener(*this);
253 AppLogDebug(" MainForm::OnInitializing ended");
254 if (__pMostVisitedSites == null)
256 __pMostVisitedSites = new(std::nothrow) ArrayList();
257 __pMostVisitedSites->Construct();
259 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
261 __pItemContext= new(std::nothrow) ListContextItem();
262 __pItemContext->Construct();
263 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
264 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
266 if (pBitmapNormal != null && pBitmapPressed != null)
268 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
271 if (pBitmapNormal != null)
273 delete pBitmapNormal;
276 if (pBitmapPressed != null)
278 delete pBitmapPressed;
281 __pItemContextLandscape= new(std::nothrow) ListContextItem();
282 __pItemContextLandscape->Construct();
283 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
284 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
286 if (pBitmapNormal != null && pBitmapPressed != null)
288 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
291 if (pBitmapNormal != null)
293 delete pBitmapNormal;
296 if (pBitmapPressed != null)
298 delete pBitmapPressed;
305 MainForm::InitAddressbar(void)
307 AppLogDebug("MainForm::InitAddressbar entered");
309 result r = E_SUCCESS;
311 if (__pAddressbar != null)
315 __pAddressbar = new(std::nothrow) Addressbar();
316 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
317 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
320 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
323 __pAddressbar->SetAddressbarEventListener(this);
324 AddControl(*__pAddressbar);
325 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
326 SetControlAlwaysOnTop(*__pAddressbar, true);
327 __adressPanelPosition = __pAddressbar->GetPosition();
329 AppLogDebug("MainForm::InitAddressbar exit");
335 MainForm::CreateReaderPanel(void)
337 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
338 result r = E_FAILURE;
340 Button *pSmallFontBtn = null;
341 Button *pLargeFontBtn = null;
343 __pBlankPanel = new (std::nothrow) Panel();
344 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
346 __pArticleReaderPanel = new (std::nothrow) Panel();
347 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
349 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
350 if (__pReaderCloseBtn)
352 AppLogDebug("CreateReaderPanel() 6");
353 __pReaderCloseBtn->AddActionEventListener(*this);
354 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
357 __pWebReader = new (std::nothrow) Web();
358 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
360 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
361 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
363 r = __pWebReader->SetSetting(settings);
365 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
368 __pArticleReaderLabel = new Label();
369 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
371 __pBlankPanel->AddControl(*__pArticleReaderLabel);
372 __pBlankPanel->AddControl(*__pArticleReaderPanel);
373 AddControl(*__pBlankPanel);
375 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
376 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
377 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
379 __pArticleReaderPanel->AddControl(*__pWebReader);
380 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
381 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
382 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
384 if (pBitmap != null && pSrcBitmap != null)
386 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
388 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
390 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
393 pSmallFontBtn->AddActionEventListener(*this);
394 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
397 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
400 pLargeFontBtn->AddActionEventListener(*this);
401 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
410 if (pSrcBitmap != null)
416 SetControlAlwaysOnTop(*__pBlankPanel, true);
417 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
424 MainForm::InitWebControl()
426 AppLogDebug("MainForm::InitWebControl enter");
427 result r = E_SUCCESS;
428 AppLogDebug("InitWebControl");
430 if (__pAddressbar == null || __pFooterPanel == null)
433 const int Y_WEBCONTROL_POSITION = 0;
434 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
435 if (__pMostVisitedListView)
437 __pMostVisitedListView->SetShowState(false);
439 if (__pWebViewer != null)
441 AppLogDebug("Already initialized");
444 __pWebViewer = new(std::nothrow) Web();
445 if(__pWebViewer == NULL)
447 AppLogDebug("Initialization failed");
450 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight));
454 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
459 r = AddControl(*__pWebViewer);
463 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
466 __webControlPosition = __pWebViewer->GetPosition();
467 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
470 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
474 __pWebViewer->SetLoadingListener(this);
475 __pWebViewer->SetWebUiEventListener(this);
476 __pWebViewer->SetWebKeypadEventListener(this);
477 __pWebViewer->SetFocus();
478 __pWebViewer->AddTouchEventListener(*this);
480 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
481 __pWebViewer->SetTextSearchListener(this);
484 AppLogDebug("MainForm :before return");
486 AppLogDebug("MainForm::InitWebControl Exit");
492 MainForm::SetJavascriptEnabled()
494 WebSetting settings = __pWebViewer->GetSetting();
495 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
496 __pWebViewer->SetSetting(settings);
500 MainForm::SetImageLoadEnabled()
502 WebSetting settings = __pWebViewer->GetSetting();
503 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
504 __pWebViewer->SetSetting(settings);
508 MainForm::InitFooter(void)
510 AppLogDebug("MainForm::InitFooter entered");
511 Button* pBackButton = null;
512 Button* pBookmarkButton = null;
513 Button* pMultiWindowButton = null;
514 Bitmap *pIconBitmap = null;
515 Bitmap *pBGBitmap = null;
516 Label *pBGLabel = null;
518 if (__pFooterPanel == null)
520 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
523 if (__pFooterPanel == null)
528 SetControlAlwaysOnTop(*__pFooterPanel, true);
530 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
531 if ( __pFooterLabel == NULL )
535 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
536 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
539 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
543 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
545 if ( __pMultiWindowButton == NULL )
550 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
552 if ( __pMoreButton == NULL )
557 if (__pMultiWindowButton != null)
559 Bitmap* pBitmap = null;
560 Bitmap* pPressedBitmap = null;
561 String imagePath = "I01_toolbar_icon_windows_manager_0";
562 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
563 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
564 imagePath.Append(totalCount);
565 imagePath.Append(".png");
567 pressedImagePath.Append(totalCount);
568 pressedImagePath.Append("_press.png");
570 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
571 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
572 if ( pBitmap == null )
577 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
580 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
581 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
586 __pMultiWindowButton->AddActionEventListener(*this);
587 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
592 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
593 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
596 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
597 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
598 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
602 __pMoreButton->AddActionEventListener(*this);
603 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
606 //Add the editfield for url
607 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
608 if (__pFooterUrlField == NULL)
610 return E_INVALID_KEY;
613 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
614 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
615 //__pFooterUrlField->AddFocusEventListener(*this);
616 __pFooterUrlField->AddKeypadEventListener(*this);
618 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
620 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
622 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
624 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
628 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
629 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
632 //Add the go Back Button
633 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
634 if (__pGoBackBtn == NULL)
636 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
637 return E_INVALID_KEY;
639 __pGoBackBtn->SetActionId(IDA_GO_BACK);
640 __pGoBackBtn->AddActionEventListener(*this);
642 //Add the go forward Button
643 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
644 if (__pGoForwardBtn == NULL)
646 AppLogDebug("Control not found returning E_INVALID_KEY");
647 return E_INVALID_KEY;
649 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
650 __pGoForwardBtn->AddActionEventListener(*this);
651 __pGoForwardBtn->SetEnabled(false);
653 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
654 if (__pRefreshBtn == NULL)
656 AppLogDebug("Control not found returning E_INVALID_KEY");
657 return E_INVALID_KEY;
660 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
661 __pRefreshBtn->AddActionEventListener(*this);
662 __pRefreshBtn->SetShowState(true);
664 //Add the backround label for displaying progressbar
665 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
666 if (__pProgressbarLabel == NULL)
668 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
669 return E_INVALID_KEY;
671 __pProgressbarLabel->SetShowState(false);
673 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
674 if (__pStopBtn == NULL)
676 AppLogDebug("Control not found returning E_INVALID_KEY");
677 return E_INVALID_KEY;
679 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
680 __pStopBtn->AddActionEventListener(*this);
681 __pStopBtn->SetShowState(false);
683 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
684 if (__pClearBtn == NULL)
686 AppLogDebug("Control not found returning E_INVALID_KEY");
687 return E_INVALID_KEY;
689 __pClearBtn->SetActionId(IDA_CLEAR_URL);
690 __pClearBtn->AddActionEventListener(*this);
691 __pClearBtn->SetShowState(false);
693 // __pFooterPanel->Invalidate(true);
694 AppLogDebug("MainForm::InitFooter exit");
700 MainForm::InitContextMenu(Point& p)
702 result r = E_SUCCESS;
703 bool isPrivateBrowsing = false;
704 Bitmap* pBitmap = null;
708 __pMenu->SetAnchorPosition(p);
709 __pMenu->Invalidate(true);
713 __pMenu = new(std::nothrow) ContextMenu();
714 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST);
715 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
717 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
720 if (isPrivateBrowsing == true)
722 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
726 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
729 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
731 if ( pBitmap != NULL)
733 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"), IDA_PRIVATEON_CLICKED,*pBitmap);
736 r = __pMenu->AddItem(L"History"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_HISTORY_CLICKED);
737 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
738 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
741 __pMenu->SetMaxVisibleItemsCount(6);
742 __pMenu->SetShowState(false);
743 __pMenu->AddActionEventListener(*this);
744 SetControlAlwaysOnTop(*__pMenu, true);
750 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
752 result r = E_SUCCESS;
753 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
755 AppLog("MainForm::InitImageContextMenu clicked on image");
756 if (__pImageMenu != null)
762 p.y = p.y + __pAddressbar->GetHeight() + 12;
765 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
769 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
771 __pImageMenu = new (std::nothrow) ContextMenu();
772 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
773 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
775 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
776 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
777 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
778 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_IMAGE_CLICKED);
779 __pImageMenu->SetMaxVisibleItemsCount(4);
780 __pImageMenu->AddActionEventListener(*this);
781 SetControlAlwaysOnTop(*__pImageMenu, true);
786 result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
788 result r = E_SUCCESS;
789 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
791 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
792 if (__pImageMenu != null)
797 p.y = p.y + __pAddressbar->GetHeight() + 12;
800 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
804 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
806 __pImageMenu = new (std::nothrow) ContextMenu();
807 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
808 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
810 if(onlyPasteOption == false)
812 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
814 if (pasteOption || onlyPasteOption)
816 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
818 if(onlyPasteOption == false)
820 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
821 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
824 __pImageMenu->SetMaxVisibleItemsCount(3);
825 __pImageMenu->AddActionEventListener(*this);
826 SetControlAlwaysOnTop(*__pImageMenu, true);
833 MainForm::InitFindWordPanel(void)
835 result r = E_SUCCESS;
836 Bitmap *pIconBitmap = null;
838 if (__pFindWordPanel != null)
840 AppLogDebug("Findword panel already initialized");
841 if (__pFindWordBgLabel != null)
843 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
846 AppLogDebug("InitFindWordPanel: Coming here");
847 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
854 __pFindWordPanel = static_cast<Panel*>(GetControl(L"IDC_FIND_ON_PAGE_PANEL"));
855 if (__pFindWordPanel == null)
857 AppLogException("There is some problem in the xml file. Please check.");
861 __pFindWordControl = new (std::nothrow) Panel();
862 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
865 AppLogException("There is some problem in the xml file. Please check.");
868 __pFindWordPanel->AddControl(*__pFindWordControl);
869 __pFindWordControl->SetBounds(0,0, __pFindWordPanel->GetWidth(), __pFindWordPanel->GetHeight());
870 SetControlAlwaysOnTop(*__pFindWordPanel,true);
871 __pFindWordPanel->SetShowState(false);
872 __pFindWordPanel->Invalidate(false);
874 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
875 if (__pFindWordBgLabel != null)
877 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
878 Rectangle pRect = pPanel1->GetBounds();
879 pRect.x = pRect.y = 0;
880 __pFindWordBgLabel->SetBounds(pRect);
881 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
884 AppLogDebug("InitFindWordPanel: Coming here");
885 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
890 AppLogDebug("InitFindWordPanel: shouldn't Come here");
894 Button* pfindWordCancel = null;
895 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
896 if (pfindWordCancel == null)
898 AppLogException("There is some problem in the xml file. Please check.");
901 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
902 pfindWordCancel->AddActionEventListener(*this);
904 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
905 if (__pFindWordClear == null)
907 AppLogException("There is some problem in the xml file. Please check.");
911 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
912 __pFindWordClear->AddActionEventListener(*this);
914 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
915 if (__pFindWordNext == null)
917 AppLogException("There is some problem in the xml file. Please check.");
921 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
922 __pFindWordNext->AddActionEventListener(*this);
924 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
925 if (__pFindWordPrev == null)
927 AppLogException("There is some problem in the xml file. Please check.");
931 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
932 __pFindWordPrev->AddActionEventListener(*this);
934 __pFindWordNext->SetEnabled(false);
935 __pFindWordPrev->SetEnabled(false);
937 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
938 if (__pFindWordCountLabel == null)
940 AppLogException("There is some problem in the xml file. Please check.");
944 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
945 if (__pFindWordEditField == null)
947 AppLogException("There is some problem in the xml file. Please check.");
950 __pFindWordEditField->AddTextEventListener(*this);
951 __pFindWordEditField->AddKeypadEventListener(*this);
952 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
958 MainForm::CreateItem (int index, int itemWidth)
960 Rectangle listImageRect;
961 Rectangle pagetTitleRect;
962 Rectangle pageURLRect;
963 Rectangle deleteImageRect;
964 String pageTitle(L"");
966 result r = E_SUCCESS;
967 Bitmap* pListIconImage = null;
970 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
975 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
976 if ( pAppResource == NULL )
980 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
982 CustomItem* pItem = new(std::nothrow) CustomItem();
983 pageTitle = pHistory->GetHistoryTitle();
984 pageURL = pHistory->GetHistoryUrl();
986 if (pageURL.GetLength() == 0)
989 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
990 pageURL = L"<"+ nourl +">";
994 Rectangle screenBounds = GetBounds();
997 r = pItem->Construct(Dimension(itemWidth, 128), style);
1006 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1008 if ( pBitmap != NULL)
1010 pListIconImage = new Bitmap();
1011 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1015 if(pListIconImage == null)
1017 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1020 if ( pListIconImage != NULL)
1022 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1023 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1024 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1027 if (pItem != null && pListIconImage != NULL)
1029 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1033 if (pageTitle.CompareTo(L"") != 0)
1037 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1041 if (pageURL.CompareTo(L"") != 0)
1045 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1050 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1052 if ( __pItemContext!= NULL)
1056 pItem->SetContextItem(__pItemContext);
1062 if ( __pItemContextLandscape!= NULL)
1066 pItem->SetContextItem(__pItemContextLandscape);
1070 if( pListIconImage != NULL)
1072 delete pListIconImage;
1073 pListIconImage = null;
1080 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1087 MainForm::GetItemCount (void)
1089 if(__pMostVisitedSites != null)
1091 __pMostVisitedSites->RemoveAll(true);
1093 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1094 if(__pMostVisitedSites != null)
1096 return __pMostVisitedSites->GetCount();
1103 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1105 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1106 String url = pHistory->GetHistoryUrl();
1107 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1108 __pMostVisitedListView->UpdateList();
1112 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1114 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1115 String url = pHistory->GetHistoryUrl();
1123 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1129 MainForm::OnTerminating(void)
1131 result r = E_SUCCESS;
1134 delete __pItemContext;
1136 if(__pItemContextLandscape)
1138 delete __pItemContextLandscape;
1144 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1146 result r = E_SUCCESS;
1148 AppLogDebug("Clicked : %d", actionId);
1151 case IDA_BACKBTN_CLICKED:
1153 if (__pWebViewer && __pWebViewer->CanGoBack())
1155 __pWebViewer->GoBack();
1160 pApp = UiApp::GetInstance();
1163 r = pApp->Terminate();
1166 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1174 case IDA_FORWARD_CLICKED:
1175 if (__pWebViewer == null)
1178 if (__pWebViewer->CanGoForward())
1180 __pWebViewer->GoForward();
1182 __pMenu->SetShowState(false);
1183 __pMenu->Invalidate(false);
1186 case IDA_FINDONPAGE_CLICKED:
1188 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1189 __currentSearchStr.Clear();
1191 InitFindWordPanel();
1192 __pMenu->SetShowState(false);
1193 __pMenu->Invalidate(false);
1195 __pFindWordEditField->SetFocus();
1196 if (__pWebViewer != null)
1198 // releasing the set block
1199 __pWebViewer->ReleaseBlock();
1201 ShowFindWordPanel(true);
1204 case IDA_PRIVATEON_CLICKED:
1206 result r = E_SUCCESS;
1208 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1209 Bitmap* pBitmap = null;
1210 if (isPrivateBrowsing == true)
1212 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1215 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1219 if (__pWebViewer != NULL)
1221 __pWebViewer->SetPrivateBrowsingEnabled(false);
1224 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1226 if (__pAddressbar != null)
1228 __pAddressbar->UpdateFaviconBitmap(false);
1234 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1237 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1241 if (__pWebViewer != NULL)
1243 __pWebViewer->SetPrivateBrowsingEnabled(true);
1246 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1248 if (__pAddressbar != null)
1250 __pAddressbar->UpdateFaviconBitmap(true);
1255 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1256 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1257 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1258 __pMenu->Invalidate(true);
1260 if ( pBitmap != NULL )
1267 case IDA_SETTINGS_CLICKED:
1270 ArrayList* pArgList = new(std::nothrow) ArrayList();
1273 pArgList->Construct();
1274 pArgList->Add(*__pWindowInfo);
1275 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1277 __pMenu->SetShowState(false);
1278 __pMenu->Invalidate(false);
1279 if (pArgList != null)
1288 case IDA_ADDTOBOOKMARK_CLICKED:
1291 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1293 int bookmarkCount=0;
1296 url=__pWindowInfo->pageUrl;
1297 result r = E_SUCCESS;
1298 Bitmap* pBitmap = null;
1299 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1307 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1308 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1309 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1311 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1312 if (pNotification != null)
1314 pNotification->SetText(message);
1315 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1316 pNotification->ShowNotification();
1321 String title=__pWindowInfo->pageTitle;
1322 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1323 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1325 pBookmark->SetBookmarkTitle(title);
1326 pBookmark->SetUrl(url);
1327 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1329 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1331 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1332 pBookmark->SetFaviconId(id);
1333 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1334 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1337 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1338 if (pNotification != null)
1340 pNotification->SetText(message);
1341 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1342 pNotification->ShowNotification();
1343 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1346 if (pBitmap != null)
1348 r = __pMenu->SetItemAt(0,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1352 __pMenu->Invalidate(true);
1356 case IDA_SHARE_CLICKED:
1358 if(__pPopUp != null)
1363 __pPopUp = new(std::nothrow) SharePopup();
1364 __pPopUp->Initialize();
1365 if (__pWindowInfo != null)
1367 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1368 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1369 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1370 pShareInfo->SetImageAttached(false);
1371 __pPopUp->RemoveAllShareInfo();
1372 __pPopUp->AddShareInfo(pShareInfo);
1374 __pPopUp->SetShowState(true);
1378 case IDA_BOOKMARKBTN_CLICKED:
1380 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1381 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1384 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1389 case IDA_MOREBTN_CLICKED:
1391 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1392 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1393 AppLog("Anchot pos: %d %d", p.x, p.y);
1395 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1397 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1398 int bookmarkCount=0;
1401 url=__pWindowInfo->pageUrl;
1402 result r = E_SUCCESS;
1403 Bitmap* pBitmap = null;
1405 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1408 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1413 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1417 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1419 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1421 if (__pMenu->GetItemCount() == 9)
1423 r = __pMenu->SetItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1427 r = __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1432 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1436 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1437 if (__pMenu->GetItemCount() != 9)
1439 __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADDTOBOOKMARK_CLICKED);
1441 __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1442 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1443 __pMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1444 __pMenu->SetMaxVisibleItemsCount(6);
1446 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1448 AppLog(" Orientation landscape");
1449 __pMenu->SetMaxVisibleItemsCount(5);
1453 AppLog(" Orientation potrait");
1454 __pMenu->SetMaxVisibleItemsCount(6);
1457 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1460 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1461 __pMenu->SetShowState(true);
1462 __pMenu->Invalidate(true);
1466 case IDA_HISTORY_CLICKED:
1468 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1469 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1472 case IDA_SAVED_PAGES_CLICKED:
1477 case IDA_DESKTOP_VIEW_CLICKED:
1482 case IDA_SAVE_CLICKED:
1487 case IDA_MULTIWINDOWBTN_CLICKED:
1489 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1490 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1494 case IDA_NEWWINDOWBTN_CLICKED:
1496 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1498 if (pNewWindowInfo == null)
1502 result r = E_SUCCESS;
1503 SceneManager* pSceneManager = SceneManager::GetInstance();
1505 if (pSceneManager == NULL)
1509 ArrayList* pArgList = new(std::nothrow) ArrayList();
1510 if (pArgList == NULL)
1514 r = pArgList->Construct();
1517 pArgList->Add(*pNewWindowInfo);
1518 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1524 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1529 case IDA_SMALLFONT_BTN_CLICKED:
1531 WebSetting setting = __pWebReader->GetSetting();
1532 setting.SetFontSize(15);
1533 __pWebReader->SetSetting(setting);
1536 case IDA_LARGEFONT_BTN_CLICKED:
1538 WebSetting setting = __pWebReader->GetSetting();
1539 setting.SetFontSize(25);
1540 __pWebReader->SetSetting(setting);
1543 case IDA_READER_CLOSE_CLICKED:
1545 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1547 //__pArticleReaderPanel->SetShowState(false);
1548 //__pArticleReaderPanel->Show();
1549 RemoveControl(*__pBlankPanel);
1550 //RemoveControl(*__pArticleReaderPanel);
1551 __pArticleReaderPanel = null;
1552 __pBlankPanel = null;
1553 __pArticleReaderLabel = null;
1555 //if (__pAddressbar)
1556 // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1557 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1560 case IDA_FINDWORD_CANCEL_CLICKED:
1562 __currentSearchStr = L"";
1563 __currentWordIndex = 0;
1564 __maxOccurrances = 0;
1565 __pFindWordEditField->SetText(L"");
1566 __pFindWordNext->SetEnabled(false);
1567 __pFindWordPrev->SetEnabled(false);
1568 __pFindWordCountLabel->SetText(L"0/0");
1569 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1570 ShowFindWordPanel(false);
1573 case IDA_FINDWORD_SEARCH_CLICKED:
1575 __currentSearchStr = __pFindWordEditField->GetText();
1576 if (__currentSearchStr.GetLength() > 0)
1582 AppLogDebug("Enter something");
1586 case IDA_FINDWORD_CLEAR_CLICKED:
1588 __pFindWordCountLabel->SetText(L"0/0");
1589 __pFindWordEditField->SetText(L"");
1590 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1592 __currentSearchStr = L"";
1593 __pFindWordNext->SetEnabled(false);
1594 __pFindWordPrev->SetEnabled(false);
1595 __pFindWordPanel->Invalidate(true);
1598 case IDA_FINDWORD_NEXT_CLICKED:
1603 case IDA_FINDWORD_PREV_CLICKED:
1605 FindNextWord(false);
1608 case IDA_BRIGHTNESS_BTN_CLICKED:
1610 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1611 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1614 case IDA_COPY_IMAGE_CLICKED:
1616 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1617 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1619 const Bitmap* pBitmap = null;
1620 if (__pHitElementResult != null)
1622 pBitmap = __pHitElementResult->GetImage();
1625 String resourcePath = App::GetInstance()->GetAppResourcePath();
1626 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1628 // copying the item to clipboard
1629 Clipboard* pClipboard = Clipboard::GetInstance();
1630 if (pClipboard != null)
1632 pClipboard->CopyItem(item);
1636 case IDA_VIEW_IMAGE_CLICKED:
1638 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1639 WindowInfo* pNewWindowInfo = null;
1640 if (__pHitElementResult != null)
1642 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1643 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1649 case IDA_SAVE_IMAGE_CLICKED:
1651 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1652 const Bitmap* pSaveBitmap = null;
1653 String imageName = GetImagePath();
1654 AppLog("Content manager image name %ls",imageName.GetPointer());
1657 imagePath.Append(imageName);
1658 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1659 AppLog("Content manager image path %ls",imagePath.GetPointer());
1660 if (__pHitElementResult != null)
1662 pSaveBitmap = __pHitElementResult->GetImage();
1664 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1668 UpdateImageContent(pBuffer, imageName);
1670 NotificationPanel *pNotification = new NotificationPanel(*this);
1672 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1673 msg.Append(imagePath);
1674 if (pNotification != null)
1676 pNotification->SetText(msg);
1677 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1678 pNotification->ShowNotification();
1683 int __modalMsgBoxResult;
1684 MessageBox* pMsgBox = new MessageBox();
1685 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1686 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1689 __modalMsgBoxResult = 0;
1693 case IDA_SHARE_IMAGE_CLICKED:
1695 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1696 if (__pPopUp != null)
1701 __pPopUp = new(std::nothrow) SharePopup();
1702 __pPopUp->Initialize();
1703 if (__pHitElementResult != null)
1705 const Bitmap* pSaveBitmap = null;
1706 String imageName = GetImagePath();
1707 AppLog("Content manager image name %ls",imageName.GetPointer());
1710 imagePath.Append(imageName);
1711 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1712 AppLog("Content manager image path %ls",imagePath.GetPointer());
1713 if (__pHitElementResult != null)
1715 pSaveBitmap = __pHitElementResult->GetImage();
1717 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1719 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1720 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1722 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1723 pShareInfo->SetPageTitle(L"");
1724 pShareInfo->SetPageUrl(srcUrl);
1725 pShareInfo->SetImageAttached(true);
1726 pShareInfo->SetImagePath(imagePath);
1727 __pPopUp->RemoveAllShareInfo();
1728 __pPopUp->AddShareInfo(pShareInfo);
1729 __pPopUp->SetShowState(true);
1734 case IDA_FIND_TEXT__CLICKED:
1736 AppLogDebug("MainForm::OnActionPerformed find word clicked");
1737 __currentSearchStr.Clear();
1738 __currentSearchStr.Append(__currentSelectedStr);
1739 InitFindWordPanel();
1742 __pMenu->SetShowState(false);
1743 __pMenu->Invalidate(false);
1746 __adressPanelPosition.y = 0;
1748 if (__pAddressbar != null && __pWebViewer != NULL)
1750 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
1751 //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
1752 //__pAddressbar->Invalidate(true);
1753 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
1755 if (__pFooterPanel->GetShowState() == false)
1756 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
1758 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
1759 // __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
1760 __pWebViewer->Invalidate(true);
1763 ShowFindWordPanel(true);
1764 if (__currentSearchStr.GetLength() > 0)
1770 AppLogDebug("Enter something");
1773 if (__pWebViewer != null)
1775 // releasing the set block
1776 __pWebViewer->ReleaseBlock();
1781 case IDA_SHARE_TEXT_CLICKED:
1783 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
1784 if(__pPopUp != null)
1789 __pPopUp = new(std::nothrow) SharePopup();
1790 __pPopUp->Initialize();
1791 if (__pHitElementResult != null)
1793 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1794 pShareInfo->SetPageTitle(L"");
1795 pShareInfo->SetPageUrl(__currentSelectedStr);
1796 pShareInfo->SetImageAttached(false);
1797 __pPopUp->RemoveAllShareInfo();
1798 __pPopUp->AddShareInfo(pShareInfo);
1799 __pPopUp->SetShowState(true);
1804 case IDA_COPY_TEXT_CLICKED:
1806 // need to implement
1807 //__currentSelectedStr
1808 // Sets data to a clip board item
1810 String resourcePath = App::GetInstance()->GetAppResourcePath();
1811 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
1813 // copying the item to clipboard
1814 Clipboard* pClipboard = Clipboard::GetInstance();
1815 if (pClipboard != null)
1817 pClipboard->CopyItem(item);
1821 case IDA_PASTE_TEXT_CLICKED:
1823 Clipboard* pClipboard = Clipboard::GetInstance();
1825 if(pClipboard == null)
1829 // Retrieves a latest item
1830 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
1836 //Gets data from the clipboard item
1837 String* pString = dynamic_cast<String*>(pItem->GetData());
1839 if (pString != null)
1841 String idElement = __pHitElementResult->GetAttributeValue(L"id");
1842 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
1843 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
1844 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; } } ";
1845 if(idElement.GetLength() != 0)
1847 script.Append("insertAtCursor(");
1848 script.Append(idElement);
1850 script.Append("\"");
1851 script.Append(*pString);
1852 script.Append("\");");
1854 else if (nameElement.GetLength() != 0)
1856 script.Append("insertAtCursor(document.getElementsByName('");
1857 script.Append(nameElement);
1858 script.Append("')[0],");
1859 script.Append("\"");
1860 script.Append(*pString);
1861 script.Append("\");");
1863 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
1864 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
1875 case IDA_GO_FORWARD:
1880 case IDA_REFRESH_BTN_CLICKED:
1882 __isLoadingCompleted = false;
1883 __isLoadingData = true;
1884 __progressPercentage = 0;
1885 __displayUrl = __pFooterUrlField->GetText();
1887 String url = __pFooterUrlField->GetText();
1888 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
1892 UpdateProgressBitmap();
1895 case IDA_STOP_BTN_CLICKED:
1897 __isLoadingCompleted = false;
1898 __isLoadingData = false;
1899 __progressPercentage = 0;
1900 __pFooterUrlField->HideKeypad();
1901 __displayUrl = __pFooterUrlField->GetText();
1905 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1906 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1907 __pWebViewer->StopLoading();
1908 RequestRedraw(true);
1911 UpdateProgressBitmap();
1916 if (__pFooterUrlField->GetText().IsEmpty() == false)
1918 //__displayUrl = __pUrlField->GetText();
1919 __pFooterUrlField->Clear();
1929 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
1932 UiApp* pApp = UiApp::GetInstance();
1941 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
1942 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
1944 String* pSelectedScene = NULL;
1945 Object* pValue = NULL;
1946 String* pUrl = null;
1947 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
1948 pSelectedScene = (String*) pValue;
1950 if (pSelectedScene != null)
1952 delete pSelectedScene;
1954 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
1955 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
1956 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
1957 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
1959 // setting the current scene ID
1960 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
1962 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
1964 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
1966 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
1967 if(__pWindowInfo == null)
1969 // if(__pWindowInfo == null)
1971 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
1974 else if ( pArgs != null && pArgs->GetCount() == 1)
1976 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
1982 // hiding the address bar
1983 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
1984 __pAddressbar->SetShowState(false);
1985 if(__pWebViewer != null)
1987 __pWebViewer->Resume();
1990 if(pUrl != null && pUrl->GetLength() > 0)
1994 else if(__pWindowInfo != null)
1996 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)
1998 LoadUrl(__pWindowInfo->pageUrl);
2000 else if (__pWindowInfo->isJavascriptInitiated == true)
2004 __pWindowInfo->pCurrentWeb = __pWebViewer;
2008 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2009 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2010 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2012 InitMostVisitedSitesView(GetOrientationStatus());
2015 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2017 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2019 if (pBookmarkUrl == null)
2021 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2022 //__pAddressbar->SetUrl(*pBookmarkUrl);
2023 SetUrl(*pBookmarkUrl);
2025 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2026 __pWebViewer->LoadUrl(*pBookmarkUrl);
2027 delete pBookmarkUrl;
2030 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2031 Bitmap* pBitmap = null;
2032 if (isPrivateBrowsing == true)
2034 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2036 if (__pWebViewer != null)
2038 __pWebViewer->SetPrivateBrowsingEnabled(true);
2041 if (__pAddressbar != null)
2043 // __pAddressbar->UpdateFaviconBitmap(true);
2049 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2051 if (__pWebViewer != null)
2053 __pWebViewer->SetPrivateBrowsingEnabled(false);
2056 if (__pAddressbar != null)
2058 // __pAddressbar->UpdateFaviconBitmap(false);
2062 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2064 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2066 else if (__pMenu != null )
2068 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2071 if (pBitmap != null)
2076 AppLog("ABC: OnSceneActivatedN started exit");
2081 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2082 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2084 Canvas* pWebCanvas = null;
2085 if (__pWebViewer != null)
2087 pWebCanvas = __pWebViewer->GetCanvasN();
2088 __pWebViewer->Pause();
2091 if (pWebCanvas == null)
2095 if (__pWindowInfo != null)
2097 if (__pWindowInfo->pWebCanvasBitmap != null)
2099 delete __pWindowInfo->pWebCanvasBitmap;
2101 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2102 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2103 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2105 Bitmap* pBitmap = GetCapturedBitmapN();
2106 AppLog("Coming here");
2107 Canvas* pCanvas = new(std::nothrow) Canvas();
2108 pCanvas->Construct(GetClientAreaBounds());
2111 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2114 if(__pWebViewer != null && __pWindowInfo != null)
2115 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2117 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2118 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2120 AppLog("Coming here");
2124 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2125 const Tizen::Base::String& realm,
2126 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2132 MainForm::OnHttpAuthenticationCanceled(void)
2137 MainForm::OnLoadingStarted(void)
2139 AppLogDebug("MainForm::OnLoadingStarted entered");
2141 if(__pAddressbar == NULL)
2145 String url = __pWebViewer->GetUrl();
2146 if(url.Contains(IDS_TIZEN_SERVICE))
2149 String delim(L":;");
2151 // Creates a StringTokenizer instance
2152 StringTokenizer strTok(url, delim);
2154 int count = strTok.GetTokenCount(); // count == 4
2156 HashMap *pMap = new HashMap();
2161 while (strTok.HasMoreTokens())
2163 AppLog("Token: %ls", token.GetPointer());
2164 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2165 if(token.Contains(IDS_APPID))
2167 token.SubString(6, appId);
2168 AppLog("AppID:%ls", appId.GetPointer());
2170 else if(token.Contains("="))
2172 String *pKey = new String();
2173 String *pValue = new String();
2175 token.IndexOf("=", 0, index);
2178 token.SubString(0, index, *pKey);
2179 token.SubString(index + 1, *pValue);
2180 pMap->Add(pKey, pValue);
2186 AppControl *pAppControl = null;
2187 String operationId = L"http://tizen.org/appcontrol/operation/main";
2188 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2191 AppLog("Starting AppControl");
2192 result r = pAppControl->Start(null, null, pMap, null);
2193 AppLog("Result of Start %s", GetErrorMessage(r));
2197 AppLogException("AppControl not found");
2202 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2205 __pAddressbar->SetFaviconBitmap(*pBitmap);
2208 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2210 // updating the address bar position with respect to web control
2211 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2212 __distanceMoved = 0;
2216 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2217 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2220 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2221 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2222 SetUrl(__pWebViewer->GetUrl());
2223 if (__pWindowInfo != NULL)
2225 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2227 __pAddressbar->Invalidate(true);
2233 MainForm::OnLoadingCanceled(void)
2240 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2242 AppLog("MainForm::OnKeypadWillOpen");
2243 if (__pAddressbar != null)
2245 OnAddressBarKeypadWillOpen(*__pAddressbar);
2251 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2253 if(__pAddressbar != null)
2255 OnAddressBarKeypadOpened(*__pAddressbar);
2261 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2263 if (__pAddressbar != null)
2265 OnAddressBarKeypadClosed(*__pAddressbar);
2270 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2272 AppLog("KeypadBoundsChanged");
2273 RelayoutControls(false);
2277 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2278 const Tizen::Base::String& reason)
2280 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2284 MainForm::OnLoadingCompleted(void)
2286 AppLog("MainForm::OnLoadingCompleted start");
2288 result r = E_SUCCESS;
2290 if (__pWebViewer == null)
2295 if (__pAddressbar == null)
2299 if (__pWebViewer->CanGoForward())
2301 //__pAddressbar->SetForwardButtonEnabled(true);
2302 SetForwardButtonEnabled(true);
2306 //__pAddressbar->SetForwardButtonEnabled(false);
2307 SetForwardButtonEnabled(false);
2310 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2312 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2314 //__pAddressbar->UpdateProgress(0);
2318 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2320 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2324 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2325 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2326 if (isPrivateBrowsing == false)
2328 History* pHistory = new(std::nothrow) History;
2330 HistoryPresentationModel::GetCurrentDateTime(date);
2333 pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2334 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2336 pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2337 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2339 pHistory->SetVisitedTime(date);
2342 id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2343 pHistory->SetFaviconId(id);*/
2345 if (__pWebViewer != null)
2347 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2349 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2350 if (pTempBitmap != null)
2352 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2353 pHistory->SetFavIconBitmap(*pTempBitmap);
2356 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2359 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2360 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2361 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2363 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2364 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2365 pHistory->SetThumbnail(pBitmap);
2367 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2370 pHistory->SetFavIconBitmap(*pFavIcon);
2374 HistoryPresentationModel::GetInstance()->SaveTempHistory(*pHistory);
2381 if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2383 // temperary fixed (webpage can be not loaded)
2386 AppLog("MainForm::OnLoadingCompleted done");
2390 MainForm::OnEstimatedProgress(int progress)
2392 AppLogDebug("MainForm::OnEstimatedProgress entered");
2393 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2394 progress = DEFAULT_PROGRESS_PERCENTAGE;
2396 // __pAddressbar->UpdateProgress(progress);
2397 UpdateProgress(progress);
2400 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2402 AppLog("MainForm::OnFaviconReceived");
2403 Bitmap* pFavIconBitmap = __pWebViewer->GetFaviconN();
2405 if (pFavIconBitmap != null)
2407 pFavIconBitmap->GetWidth();
2408 pFavIconBitmap->GetHeight();
2413 MainForm::OnUrlValueChanged(Addressbar&)
2419 MainForm::OnUrlSubmitted(Addressbar& addBar)
2421 AppLog("MainForm::OnUrlSubmitted");
2422 String url = addBar.GetUrl();
2423 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2425 __pFooterPanel->SetShowState(true);
2426 // __pAddressbar->SetShowState(false);
2427 // RelayoutControls(false);
2432 MainForm::LoadUrl(String& url)
2435 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2436 AppLogDebug("MainForm::LoadUrl enter");
2438 if (__pWebViewer != null)
2440 __pWebViewer->SetShowState(true);
2441 __pWebViewer->Invalidate(true);
2444 if (url.CompareTo(L"") == 0)
2448 if(__pFooterPanel != null)
2450 __pFooterPanel->SetShowState(true);
2451 __pFooterPanel->Invalidate(true);
2458 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2459 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)
2461 RegularExpression firstRegex;
2462 RegularExpression secondRegex;
2464 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2465 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2468 ret = firstRegex.Match(url, false); // This returns true value
2469 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2471 if (ret == true && __pWebViewer != null)
2473 __pWebViewer->LoadUrl(url);
2475 else if(__pWebViewer != null)
2477 String tempUrl = L"http://";
2478 tempUrl.Append(url);
2482 __pWebViewer->LoadUrl(tempUrl);
2486 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2487 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2490 if (__pAddressbar != null)
2492 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2493 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2496 AppLogDebug("MainForm::LoadUrl exit");
2503 MainForm::OnStopClicked(Addressbar& addBar)
2505 AppLogDebug("MainForm::OnStopClicked called");
2508 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2509 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2510 __pWebViewer->StopLoading();
2511 RequestRedraw(true);
2516 MainForm::OnReaderClicked(const Addressbar& addBar)
2518 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2520 CreateReaderPanel();
2521 AppLogDebug("MainScene::OnReaderClicked entered");
2524 /*if (__pArticleReaderPanel)
2526 AppLogDebug("showstate true for reader panel");
2527 __pArticleReaderPanel->SetShowState(true);
2528 __pArticleReaderPanel->Show();
2530 int xPos = __pArticleReaderPanel->GetX();
2531 int yPos = __pArticleReaderPanel->GetY();
2532 AppLog("OnReaderClicked() xPos = %d",xPos);
2533 AppLog("OnReaderClicked() yPos = %d",yPos);
2535 if (__pReaderData == null)
2540 String loadData = L"<html>\
2542 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2547 background-color: transparent;\
2566 <body style='width:'";
2567 loadData.Append(bodyWidth);
2568 loadData.Append(L"px'>");
2569 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2570 loadData.Append(*__pReaderData);
2571 loadData.Append(L"</body></html>");
2574 buf.Construct(loadData.GetLength());
2575 AppLogDebug("data->GetLength %d",loadData.GetLength());
2576 for (int z=0;z<loadData.GetLength();z++)
2579 loadData.GetCharAt(z,b);
2580 buf.SetByte((byte)b);
2584 if (__pWebReader != null)
2586 __pWebReader->LoadData(L"",buf,L"text/html");
2587 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2591 AppLogDebug("cannot LoadData __pWebReader is null");
2597 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2599 AppLog("MainForm::OnBackClicked");
2600 result r = E_FAILURE;
2602 if (__pWebViewer != null && __pWebViewer->CanGoBack())
2604 __pWebViewer->GoBack();
2609 pApp = UiApp::GetInstance();
2612 r = pApp->Terminate();
2622 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
2624 AppLog("MainForm::OnForwardClicked");
2625 if (__pWebViewer == null)
2628 if (__pWebViewer->CanGoForward())
2630 __pWebViewer->GoForward();
2635 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
2637 result r = E_SUCCESS;
2638 // hiding the address bar
2639 __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2640 __pAddressbar->SetShowState(false);
2642 if (__pMostVisitedListView != null && __pMostVisitedListView->GetShowState() == true)
2644 AppLog("MainForm::OnAddressCancelledClicked 1");
2645 if (__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
2646 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2648 if (__pMostVisitedListView != null)
2649 __pMostVisitedListView->Invalidate(true);
2652 __pFooterPanel->SetShowState(true);
2653 __pFooterPanel->Invalidate(false);
2657 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
2659 __prevAddressBarMode = __curAddressBarMode;
2661 if (__pAddressbar != null)
2663 __curAddressBarMode = GetAddressbarMode();
2666 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
2668 __adressPanelPosition.y = 0;
2669 if (__pAddressbar != null)
2671 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2672 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2673 __pAddressbar->Invalidate(true);
2675 if (__pWebViewer != null)
2677 __pWebViewer->StopLoading();
2680 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
2682 __adressPanelPosition.y = 0;
2683 if (__pAddressbar != null)
2685 __webControlPosition.y = 0;
2686 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
2687 __pAddressbar->Invalidate(true);
2693 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
2695 __pFooterPanel->SetShowState(true);
2696 RelayoutControls(false);
2700 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
2702 if (__pFindWordPanel && __pFindWordPanel->GetShowState() == true)
2704 __pAddressbar->SetShowState(false);
2708 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
2710 __pAddressbar->SetShowState(true);
2711 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2712 __pAddressbar->SetAddressbarURLFocus();
2716 RelayoutControls(false);
2720 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
2722 __pFooterPanel->SetShowState(false);
2726 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
2728 AppLog("KeypadBoundsChanged");
2729 RelayoutControls(false);
2733 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
2737 __pWindowInfo->pageTitle = title;
2738 if (__pWebViewer != null)
2740 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2743 if (__pAddressbar != null && __pWebViewer != null)
2745 SetUrl(__pWebViewer->GetUrl());
2746 __pAddressbar->Invalidate(true);
2751 MainForm::UpdateFavicon(void)
2753 bool urlImageType = false;
2754 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();");
2755 Bitmap* pBitmap = null;
2757 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
2759 if (__pWindowInfo != null)
2762 url.SetUri(*tempPath);
2763 if (url.GetHost().GetLength() == 0)
2766 webUrl.SetUri(__pWebViewer->GetUrl());
2767 result r = url.SetHost(webUrl.GetHost());
2774 if (url.GetScheme().GetLength() == 0)
2777 webUrl.SetUri(__pWebViewer->GetUrl());
2778 url.SetScheme(webUrl.GetScheme());
2780 __pWindowInfo->faviconUrl = url.ToString();
2782 pBitmap = __pWebViewer->GetFaviconN();
2784 if (pBitmap != null)
2786 if (__pWindowInfo->pFavicon != NULL)
2788 __pWindowInfo->pFavicon = null;
2790 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
2791 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
2793 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2795 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2797 else if(__pWindowInfo->pFavicon != null)
2799 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2803 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
2804 if(pDefaultBmp != null)
2806 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
2815 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
2822 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
2823 Tizen::Web::Controls::WebNavigationType type)
2825 // when load new page if find word panel is open its show state is false
2826 ShowFindWordPanel(false);
2827 AppLog("__pAddressbar->GetAddressbarURL() is %ls",__pAddressbar->GetAddressbarURL().GetPointer());
2829 __pFooterPanel->Invalidate(true);
2832 uriInfo.SetUri(url);
2834 if(url.Contains(IDS_TIZEN_SERVICE))
2837 String delim(L":;");
2839 // Creates a StringTokenizer instance
2840 StringTokenizer strTok(url, delim);
2842 int count = strTok.GetTokenCount(); // count == 4
2844 HashMap *pMap = new HashMap();
2850 while (strTok.HasMoreTokens())
2852 AppLog("Token: %ls", token.GetPointer());
2853 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2854 if(token.Contains(IDS_APPID))
2856 token.SubString(6, appId);
2857 AppLog("AppID:%ls", appId.GetPointer());
2859 else if(token.Contains("="))
2861 String *pKey = new String();
2862 String *pValue = new String();
2864 token.IndexOf("=", 0, index);
2867 token.SubString(0, index, *pKey);
2868 token.SubString(index + 1, *pValue);
2869 pMap->Add(pKey, pValue);
2875 AppControl *pAppControl = null;
2876 String operationId = L"http://tizen.org/appcontrol/operation/main";
2877 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2880 result r = pAppControl->Start(null, null, pMap, null);
2884 AppLogException("AppControl not found");
2890 if (__pWebViewer && __pAddressbar)
2892 __pAddressbar->SetShowState(false);
2893 /*AppLog("__pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2894 __pAddressbar->SetUrl(__pWebViewer->GetUrl());
2895 __pAddressbar->UpdateProgress(DEFAULT_PROGRESS_PERCENTAGE);
2899 __pWindowInfo->pageTitle = CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK");
2900 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2901 __pWindowInfo->faviconUrl = "";
2902 __pWindowInfo->faviconFilePath = "";
2904 if (__pWindowInfo->pFavicon != NULL)
2906 // delete __pWindowInfo->pFavicon;
2907 __pWindowInfo->pFavicon = null ;
2909 __pWindowInfo->pFavicon = FaviconManager::GetInstance()->GetDefaultFaviconN();
2913 __pAddressbar->Invalidate(true);
2919 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
2920 const Tizen::Net::Http::HttpHeader& httpHeader)
2922 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
2927 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
2929 AppLog("MainForm::OnWebPageBlockSelected");
2930 if (__pHitElementResult != null)
2932 delete __pHitElementResult;
2933 __pHitElementResult = null;
2936 if (__pWebViewer != null)
2938 AppLog("MainForm::OnWebPageBlockSelected web not null");
2939 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
2942 if (__pHitElementResult == null)
2947 if (__pHitElementResult->HasImage() != true)
2949 String tagName = __pHitElementResult->GetTagName();
2950 String type = __pHitElementResult->GetAttributeValue("type");
2952 __currentSelectedStr.Clear();
2953 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
2954 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
2955 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
2957 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && __isLongPressedDone == true)
2959 AppLog("MainForm::OnWebPageBlockSelected show paste option");
2961 InitSelectTextContextMenu(endPoint,true);
2962 __pImageMenu->SetShowState(true);
2963 __pImageMenu->Show();
2964 __pImageMenu->Invalidate(true);
2966 else if(__isLongPressedDone == true)
2968 AppLog("MainForm::OnWebPageBlockSelected no paste option");
2970 if(__pHitElementResult->GetUrl().GetLength() > 0)
2972 __currentSelectedStr.Clear();
2973 __currentSelectedStr = __pHitElementResult->GetUrl();
2975 InitSelectTextContextMenu(endPoint,false);
2976 __pImageMenu->SetShowState(true);
2977 __pImageMenu->Show();
2978 __pImageMenu->Invalidate(true);
2981 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
2982 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
2983 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
2989 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
2995 MainForm::OnWebWindowCreateRequested(void)
2997 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
2999 if (pNewWindowInfo == null)
3003 result r = E_SUCCESS;
3004 SceneManager* pSceneManager = SceneManager::GetInstance();
3005 if (pSceneManager == NULL)
3009 ArrayList* pArgList = new(std::nothrow) ArrayList();
3010 if (pArgList == NULL)
3014 r = pArgList->Construct();
3017 pNewWindowInfo->isJavascriptInitiated = true;
3018 pArgList->Add(*pNewWindowInfo);
3019 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3023 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3030 return pNewWindowInfo->pCurrentWeb;
3034 MainForm::RelayoutControls(bool showAddressbar)
3036 __webControlPosition.y = 0;
3037 __webControlHeight = GetClientAreaBounds().height;
3039 AppLog("Client area height: %d", __webControlHeight);
3040 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3042 __webControlPosition.y += __pAddressbar->GetHeight();
3043 __webControlHeight -= __pAddressbar->GetHeight();
3045 else if(__pFindWordPanel != null && __pFindWordPanel->GetShowState() == true)
3047 __webControlPosition.y += __pFindWordPanel->GetHeight();
3048 __webControlHeight -= __pFindWordPanel->GetHeight();
3051 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true)
3053 __webControlHeight -= __pFooterPanel->GetHeight();
3055 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3057 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight);
3058 __pWebViewer->Invalidate(false);
3060 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3061 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3066 void MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3068 if (__pFindWordPanel == null)
3074 InitFindWordPanel();
3075 __pFindWordEditField->SetText(__currentSearchStr);
3076 //__pFindWordCountLabel->SetText(L"");
3077 __pFindWordCountLabel->SetText(L"0/0");
3078 __pFindWordPanel->SetShowState(true);
3082 if(__pFindWordPanel != null)
3084 __pFindWordPanel->SetShowState(false);
3088 AppLog("MainForm::ShowFindWordPanel %d",show);
3089 if (show && !isTouchPressed)
3091 if (__pFindWordEditField)
3093 __pFindWordEditField->SetFocus();
3094 __pFindWordEditField->ShowKeypad();
3099 if (__pFindWordEditField)
3100 __pFindWordEditField->HideKeypad();
3103 RelayoutControls(false);
3107 MainForm::StartWordSearch()
3109 //Get the count of occurances of the word in the current page
3110 __maxOccurrances = 0;
3111 __currentWordIndex = 0;
3113 __pFindWordPrev->SetEnabled(false);
3114 String *pCountStr = null;
3115 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3116 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3117 if (pCountStr != null)
3119 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3123 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3128 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3130 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3131 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3133 if(totalCount == -1 || totalCount == 0)
3135 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),64,__pFindWordCountLabel->GetHeight());
3136 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3139 else if(totalCount > 100)
3141 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3142 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3145 __maxOccurrances = totalCount;
3146 __currentWordIndex = currentOrdinal;
3148 //Reset the UI controls as per the maxOccurrance value
3149 if (totalCount <= 0)
3151 AppLog("Word not found");
3152 //Show error notification to user
3153 __pFindWordNext->SetEnabled(false);
3154 __pFindWordCountLabel->SetText(L"0/0");
3155 __pFindWordNext->Invalidate(false);
3156 __pFindWordPrev->Invalidate(false);
3157 __pFindWordCountLabel->Invalidate(false);
3161 if (totalCount == 1)
3163 __pFindWordNext->SetEnabled(false);
3167 __pFindWordNext->SetEnabled(true);
3170 String countStr = L"";
3171 countStr.Append(__currentWordIndex);
3172 countStr.Append(L"/");
3173 countStr.Append(__maxOccurrances);
3174 __pFindWordCountLabel->SetText(countStr);
3175 // __pFindWordCountLabel->SetShowState(true);
3176 __pFindWordCountLabel->Invalidate(false);
3178 //FindNextWord(true);
3179 //Update the controls
3180 __pFindWordNext->Invalidate(false);
3181 __pFindWordPrev->Invalidate(false);
3182 __pFindWordCountLabel->Invalidate(false);
3186 MainForm::FindNextWord(bool next)
3190 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3192 if(__currentWordIndex < __maxOccurrances)
3194 __currentWordIndex++;
3200 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3202 if(__currentWordIndex > 1)
3204 __currentWordIndex--;
3209 String countStr = L"";
3210 countStr.Append(__currentWordIndex);
3211 countStr.Append(L"/");
3212 countStr.Append(__maxOccurrances);
3213 __pFindWordCountLabel->SetText(countStr);
3214 // __pFindWordCountLabel->SetShowState(true);
3215 __pFindWordCountLabel->Invalidate(false);
3216 if (__currentWordIndex >= __maxOccurrances)
3218 __pFindWordNext->SetEnabled(false);
3222 __pFindWordNext->SetEnabled(true);
3224 if (__currentWordIndex <= 1)
3226 __pFindWordPrev->SetEnabled(false);
3230 __pFindWordPrev->SetEnabled(true);
3232 __pFindWordPrev->Invalidate(false);
3233 __pFindWordNext->Invalidate(false);
3234 __pFindWordCountLabel->Invalidate(false);
3235 __pFindWordPanel->Invalidate(true);
3238 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3240 AppLog("MainForm::OnWebKeypadWillOpen");
3241 // OnAddressBarKeypadOpened(*__pAddressbar);
3245 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3248 if (__pWebViewer != null && __pFooterPanel != null)
3250 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3252 // __pFooterPanel->SetShowState(false);
3253 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height));
3256 //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));
3261 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3263 OnAddressBarKeypadClosed(*__pAddressbar);
3267 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3269 Control* temp = const_cast< Control* >(&source);
3270 Header* pHeader = dynamic_cast< Header* >(temp);
3271 if (pHeader != null)
3273 //Header double - clicked
3274 AppLog("Header double clicked");
3276 if(__pFindWordPanel)
3278 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3279 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3283 AppLog("MainScene::OnTouchDoublePressed");
3284 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3285 if (isReaderEnabled == true)
3289 delete __pReaderData;
3290 __pReaderData = null;
3292 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3293 filePath.Append(L"data/reader.js");
3299 result r = E_SUCCESS;
3300 FileAttributes attr;
3302 File::GetAttributes(filePath,attr);
3304 r = file.Construct(filePath, L"r+");
3307 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3310 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3313 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3316 file.Read(pScript,attr.GetFileSize());
3318 AppLogDebug("scipt length %d",strlen(pScript));
3319 String strScript = L"";
3320 strScript.Append(pScript);
3321 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3324 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3327 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3328 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3330 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3331 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3337 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3339 AppLog("MainForm::OnTouchLongPressed");
3341 if (__pHitElementResult != null)
3343 delete __pHitElementResult;
3344 __pHitElementResult = null;
3347 if (__pWebViewer != null)
3349 AppLog("MainForm::OnTouchLongPressed web not null");
3350 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3353 if (__pHitElementResult == null)
3358 if (__pHitElementResult->HasImage() == true)
3360 InitImageContextMenu(currentPosition);
3361 __pImageMenu->SetShowState(true);
3362 __pImageMenu->Show();
3363 __pImageMenu->Invalidate(true);
3367 String tagName = __pHitElementResult->GetTagName();
3368 String type = __pHitElementResult->GetAttributeValue("type");
3369 String value = __pHitElementResult->GetAttributeValue(L"value");
3370 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3372 __currentSelectedStr.Clear();
3373 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3375 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0)
3377 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3379 InitSelectTextContextMenu(currentPosition,true, true);
3380 __pImageMenu->SetShowState(true);
3381 __pImageMenu->Show();
3382 __pImageMenu->Invalidate(true);
3384 __isLongPressedDone = true;
3385 __pWebViewer->SetBlockSelectionPosition(currentPosition);
3390 __inputEventToBeSupressed = true;
3394 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3396 AppLog("MainForm::OnTouchReleased");
3398 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3399 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3401 __pWebViewer->ConsumeInputEvent();
3403 if(pHitElement != null)
3407 __inputEventToBeSupressed = false;
3411 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
3413 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
3414 int widthContextItem = 0;
3416 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
3417 if (pBitmap != null && __pFooterLabel != null)
3419 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
3424 __pMenu->SetShowState(false);
3425 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
3427 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
3431 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
3434 if (__pFindWordBgLabel != null)
3436 // __pFindWordBgLabel->SetSize(GetClientAreaBounds().width,GetClientAreaBounds().height);
3437 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
3438 if (pBitmap != null)
3440 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
3446 AppLog("__pFooterPanel->GetShowState() is true");
3448 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3449 __pFooterPanel->Invalidate(true);
3453 if(__pMoreButton && __pMenu)
3455 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
3456 __pMenu->SetAnchorPosition(p);
3457 __pMenu->Invalidate(true);
3460 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
3461 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
3463 InitMostVisitedSitesView(orientationStatus);
3466 RelayoutControls(false);
3467 if (__pArticleReaderPanel != null)
3469 if (__pArticleReaderPanel->GetShowState() == true)
3471 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
3473 if (__pBlankPanel != null)
3474 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
3476 if (__pWebReader != null)
3478 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
3480 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3481 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3483 if ( pBitmap != null && pSrcBitmap != null)
3485 AppLog("CreateReaderPanel ninepatchbitmap found");
3486 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
3489 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
3490 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
3491 if (pBitmap != null)
3496 if (pSrcBitmap != null)
3504 if(__pAddressbar != null)
3506 __pAddressbar->OrientationChanged();
3511 MainForm::OnSettingsChange(int settingvalue)
3513 AppLogDebug("MainForm::OnSettingsChange entered");
3514 if (__pWebViewer == null)
3516 AppLogDebug("Webviewer is not initialized yet.");
3519 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
3521 WebSetting settings = __pWebViewer->GetSetting();
3522 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
3524 settings.SetAutoFittingEnabled(true);
3526 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
3528 settings.SetAutoFittingEnabled(false);
3530 __pWebViewer->SetSetting(settings);
3532 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
3534 WebSetting settings = __pWebViewer->GetSetting();
3535 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
3536 __pWebViewer->SetSetting(settings);
3538 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
3540 WebSetting settings = __pWebViewer->GetSetting();
3541 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
3542 __pWebViewer->SetSetting(settings);
3544 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
3546 WebSetting settings = __pWebViewer->GetSetting();
3547 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
3548 __pWebViewer->SetSetting(settings);
3550 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
3554 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3558 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
3560 WebSetting settings = __pWebViewer->GetSetting();
3561 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
3563 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
3567 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
3569 __pWebViewer->SetSetting(settings);
3571 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
3575 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
3576 WebSetting settings = __pWebReader->GetSetting();
3577 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
3578 __pWebReader->SetSetting(settings);
3584 MainForm::OnSettingsReset()
3588 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3589 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
3594 MainForm::OnClearCache()
3596 result r = E_SUCCESS;
3598 if (__pWebViewer != NULL)
3600 r = __pWebViewer->ClearCache();
3603 AppLogDebug("Cache cleared success");
3607 AppLogDebug("Cache cleared fail");
3613 MainForm::OnClearCookie()
3615 result r = E_SUCCESS;
3617 if (__pWebViewer != NULL)
3619 __pWebViewer->ClearCookie();
3623 AppLogDebug("Cookie cleared success");
3627 AppLogDebug("Cache cleared fail");
3632 MainForm::findDistance(int x1,int y1,int x2, int y2)
3634 int deltaX = Math::Abs(x2 - x1);
3635 int deltaY = Math::Abs(y2 - y1);
3636 double num = deltaX*deltaX + deltaY*deltaY;
3642 for (i = 0; i < 20; i++)
3644 x = (((x*x)+ num)/(2*x));
3655 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3657 if(__pFindWordPanel)
3659 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3660 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3662 __isLongPressedDone = false;
3665 IList* pList = null;
3666 pList = touch.GetTouchInfoListN(source);
3670 int count = pList->GetCount();
3673 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3674 __touchPoint1 = pTouchInfo->position;
3676 /*if (__pAddressbar != null)
3678 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3680 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3682 __pAddressbar->SaveAddressbarEditText();
3684 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3687 __pAddressbar->Invalidate(true);
3689 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3691 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3693 //__pAddressbar->SaveAddressbarEditText();
3695 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3698 else if (count == 2)
3700 AppLogDebug("MainForm::OnTouchPressed count is two");
3701 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3702 __touchPoint1 = pTouchInfo->position;
3704 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
3705 __touchPoint2 = pTouchInfo->position;
3711 pList->RemoveAll(true);
3718 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3720 __currentWordIndex = 0;
3721 __isLongPressedDone = false;
3726 MainForm::MoveUiControls()
3731 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
3733 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
3735 if(__pFooterUrlField->GetTextLength() == 0)
3737 __pFooterUrlField->SetKeypadActionEnabled(false);
3741 __pFooterUrlField->SetKeypadActionEnabled(true);
3744 if (__pFindWordEditField != null)
3746 __currentSearchStr = __pFindWordEditField->GetText();
3747 __pFindWordNext->SetEnabled(false);
3748 __pFindWordPrev->SetEnabled(false);
3749 __pFindWordNext->Invalidate(true);
3750 __pFindWordPrev->Invalidate(true);
3751 __pFindWordCountLabel->SetText(L"0/0");
3752 __pFindWordCountLabel->Invalidate(true);
3754 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
3755 if (__currentSearchStr.GetLength() > 0)
3761 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
3763 AppLogDebug("Enter something");
3768 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
3775 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
3777 if(__pWebViewer != null)
3780 AppLog("MainForm::InitMostVisitedSitesView");
3781 result r = E_SUCCESS;
3784 if (__pWebViewer != null && __pMostVisitedListView != null)
3789 if (__pMostVisitedListView != null)
3791 RemoveControl(*__pMostVisitedListView);
3793 if(__pMostVisitedSites != null)
3795 __pMostVisitedSites->RemoveAll(true);
3798 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
3800 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
3801 __pMostVisitedListView = new(std::nothrow) ListView();
3803 int height = GetClientAreaBounds().height;
3805 if(__pFooterPanel->GetShowState() == true)
3807 height = height - __pFooterPanel->GetHeight();
3809 if(__pAddressbar->GetShowState() == true)
3811 height -= __pAddressbar->GetHeight();
3814 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
3818 delete __pMostVisitedListView;
3819 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
3822 __pMostVisitedListView->SetItemProvider(*this);
3823 __pMostVisitedListView->AddListViewItemEventListener(*this);
3824 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
3825 AddControl(*__pMostVisitedListView);
3826 __pMostVisitedListView->UpdateList();
3833 MainForm::GetImagePath(void)
3837 String formattedTime;
3838 DateTime currentTime;
3839 LocaleManager localManager;
3840 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
3842 localManager.Construct();
3843 Locale locale = localManager.GetSystemLocale();
3844 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
3846 // Get date formatter
3847 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
3851 pTimeFormatter->Format(currentTime, formattedTime);
3854 AppLog("current time stamp is %ls", formattedTime.GetPointer());
3855 String delim(L" :");
3856 StringTokenizer strTok(formattedTime, delim);
3859 String str1("GMT+00");
3860 while (strTok.HasMoreTokens())
3862 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
3863 if(token.Equals(str1))
3865 AppLog("token is %ls", token.GetPointer());
3866 imageName.Append(token);
3872 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
3874 result r = E_FAILURE;
3875 AppLog("Content manager 1");
3876 ContentId contentId;
3877 ContentManager contentManager;
3878 r = contentManager.Construct();
3881 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
3884 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
3885 contentPath.Append(imageName);
3886 contentPath.Append(".jpg");
3887 contentId = contentManager.CreateContent(*aBuffer, contentPath);
3888 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
3892 MainForm::SetForwardButtonEnabled(bool isEnabled)
3894 __pGoForwardBtn->SetEnabled(isEnabled);
3895 __pGoBackBtn->Invalidate(true);
3899 MainForm::SetBackButtonEnabled(bool isEnabled)
3901 __pGoBackBtn->SetEnabled(isEnabled);
3902 __pGoBackBtn->Invalidate(true);
3906 MainForm::UpdateProgress(int percentage)
3908 __progressPercentage = percentage;
3909 if (percentage == 0 || percentage == 100)
3911 __isLoadingData = false;
3912 if (percentage == 100)
3914 __isLoadingCompleted = true;
3915 __progressPercentage = 0;
3919 __isLoadingCompleted = false;
3924 __isLoadingData = true;
3926 UpdateProgressBitmap();
3930 MainForm::GetProgress(void)
3932 return __progressPercentage;
3936 MainForm::UpdateProgressBitmap(void)
3938 result r = E_SUCCESS;
3939 if (__pProgressbarLabel == null)
3941 int w = __pProgressbarLabel->GetWidth();
3942 int h = __pProgressbarLabel->GetHeight();
3944 int progressWidth = 0;
3945 Bitmap* pRetBitmap = null;
3947 if (__progressPercentage == 0 || __progressPercentage == 100)
3949 __pProgressbarLabel->SetShowState(false);
3950 __pProgressbarLabel->Invalidate(false);
3955 __pProgressbarLabel->SetShowState(true);
3956 __pProgressbarLabel->Invalidate(false);
3959 r = canvas.Construct(Rectangle(0, 0, w, h));
3963 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
3968 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
3972 pBgBmp->Scale(Dimension(w, h));
3973 canvas.DrawBitmap(Point(0,0), *pBgBmp);
3977 progressWidth = (double) (w) * __progressPercentage / 100;
3978 AppLogDebug("progressWidth: %d", progressWidth);
3979 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
3981 if (pProgressBmp != null)
3983 pProgressBmp->Scale(Dimension(progressWidth, h));
3984 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
3985 delete pProgressBmp;
3988 pRetBitmap = new (std::nothrow) Bitmap();
3990 if (pRetBitmap == null)
3992 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
3996 pRetBitmap->Construct(canvas, canvas.GetBounds());
3998 if (__pProgressbarLabel != null && pRetBitmap != null)
4000 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4001 __pProgressbarLabel->Invalidate(false);
4004 if (pRetBitmap != null)
4012 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4014 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4016 __currentAddMode = addMode;
4020 case ADDRESSBAR_MODE_INVALID:
4025 case ADDRESSBAR_MODE_READER:
4027 __pStopBtn->SetShowState(false);
4028 __pClearBtn->SetShowState(false);
4031 case ADDRESSBAR_MODE_LOADING:
4033 __pRefreshBtn->SetShowState(false);
4034 __pStopBtn->SetShowState(true);
4035 __pClearBtn->SetShowState(false);
4038 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4040 // SetUrl(__pAddressbar->GetUrl());
4042 __pRefreshBtn->SetShowState(true);
4043 __pStopBtn->SetShowState(false);
4044 __pClearBtn->SetShowState(false);
4047 case ADDRESSBAR_MODE_EDIT:
4049 __pRefreshBtn->SetShowState(false);
4050 __pStopBtn->SetShowState(false);
4051 __pClearBtn->SetShowState(true);
4058 OnAddressBarModeChanged();
4061 AddressBarMode MainForm::GetAddressbarMode(void)
4063 return __currentAddMode;
4066 void MainForm::SetUrl(const String& url)
4070 if (__pFooterUrlField != NULL)
4072 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4073 if (removedHttpUrl.IsEmpty() == false)
4075 __pFooterUrlField->SetText(removedHttpUrl);
4076 __pAddressbar->SetUrl(__displayUrl);
4080 __pFooterUrlField->SetText(__displayUrl);
4081 __pAddressbar->SetUrl(__displayUrl);
4084 __pFooterUrlField->Invalidate(false);
4085 __pAddressbar->Invalidate(true);
4086 __pFooterUrlField->SetCursorPosition(0);
4091 MainForm::RemoveHttpTextFromDisplayURL(void)
4093 bool isHttpText = __displayUrl.Contains(L"http://");
4094 String updatedDisplayUrl;
4095 updatedDisplayUrl.Clear();
4097 if (isHttpText == true)
4099 __displayUrl.SubString(7,updatedDisplayUrl);
4101 return updatedDisplayUrl;