2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 //!Internet MainForm class
19 *@brief: The %MainForm provides the common functionalities for the Main View of the Browser including the addressbar,
20 * loading,handling events etc.
24 #include <FGraphics.h>
29 #include "IntBookmarkData.h"
30 #include "IntBookmarkPresentationModel.h"
31 #include "IntCommonLib.h"
32 #include "IntFaviconManager.h"
33 #include "IntMainForm.h"
34 #include "IntNotificationPanel.h"
35 #include "IntSceneRegister.h"
36 #include "IntSettingPresentationModel.h"
38 using namespace Tizen::App;
39 using namespace Tizen::Base;
40 using namespace Tizen::Base::Collection;
41 using namespace Tizen::Base::Runtime;
42 using namespace Tizen::Base::Utility;
43 using namespace Tizen::Graphics;
44 using namespace Tizen::Io;
45 using namespace Tizen::Locales;
46 using namespace Tizen::Media;
47 using namespace Tizen::Ui;
48 using namespace Tizen::Ui::Controls;
49 using namespace Tizen::Content;
50 using namespace Tizen::Ui::Scenes;
51 using namespace Tizen::System;
52 using namespace Tizen::Web;
53 using namespace Tizen::Web::Controls;
55 static const wchar_t* IDB_SEARCH_INPUT_FIELD_BG = L"I01_toolbar_input_field.9.png";
56 static const wchar_t* IDB_FINDWORD_INPUT_FIELD_BG = L"I01_toolbar_input_field_findword.9.png";
57 static const wchar_t* IDB_BTN_BACK = L"I01_icon_Back.png";
58 static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
59 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
60 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
61 static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
62 static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
63 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
64 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
65 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
66 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
67 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
68 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
69 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
70 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
71 static const wchar_t* IDS_APPID = L"AppID";
72 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
73 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
75 const int IDA_BACKBTN_CLICKED = 101;
76 const int IDA_BOOKMARKBTN_CLICKED = 102;
77 const int IDA_MOREBTN_CLICKED = 103;
78 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
79 const int IDA_NEWWINDOWBTN_CLICKED = 105;
80 const int IDA_FORWARD_CLICKED = 106;
81 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
82 const int IDA_SHARE_CLICKED = 108;
83 const int IDA_FINDONPAGE_CLICKED = 109;
84 const int IDA_PRIVATEON_CLICKED = 110;
85 const int IDA_SETTINGS_CLICKED = 111;
86 const int IDA_READER_CLOSE_CLICKED = 112;
87 const int IDA_SMALLFONT_BTN_CLICKED = 113;
88 const int IDA_LARGEFONT_BTN_CLICKED = 114;
89 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
90 const int IDA_HISTORY_CLICKED = 116;
91 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
92 const int IDA_ADD_TO_HOME_CLICKED = 118;
93 const int IDA_SAVED_PAGES_CLICKED = 119;
94 const int IDA_DESKTOP_VIEW_CLICKED = 120;
95 const int IDA_SAVE_CLICKED = 121;
97 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
98 const int IDA_FINDWORD_NEXT_CLICKED = 202;
99 const int IDA_FINDWORD_PREV_CLICKED = 203;
100 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
101 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
103 const int IDA_COPY_IMAGE_CLICKED = 206;
104 const int IDA_VIEW_IMAGE_CLICKED = 207;
105 const int IDA_SAVE_IMAGE_CLICKED = 208;
106 const int IDA_SHARE_IMAGE_CLICKED = 209;
108 const int IDA_COPY_TEXT_CLICKED = 210;
109 const int IDA_PASTE_TEXT_CLICKED = 211;
110 const int IDA_FIND_TEXT__CLICKED = 212;
111 const int IDA_SHARE_TEXT_CLICKED = 213;
113 const int IDA_GO_BACK = 214;
114 const int IDA_GO_FORWARD = 215;
115 const int IDA_REFRESH_BTN_CLICKED = 216;
116 const int IDA_STOP_BTN_CLICKED = 217;
117 const int IDA_CLEAR_URL = 218;
119 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
121 const int MainForm::IDA_FORMAT_BITMAP = 500;
122 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
123 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
124 const int MainForm::IDA_FORMAT_URL_STRING = 503;
125 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
127 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
128 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
129 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
131 MainForm::MainForm(void)
133 __isLongPressedDone = false;
134 __pAddressbar = null;
135 // __pMostVisitedSitesPanel = null;
136 __pMostVisitedListView = null;
137 __pFooterPanel = null;
138 __pHitElementResult = null;
139 __pWindowInfo = null;
143 __pFindWordControl = null;
144 __pFindWordPanel = null;
145 __pFindWordBgLabel = null;
146 __pFindWordEditField = null;
147 __pFindWordClear = null;
148 __pFindWordCountLabel = null;
149 __pFindWordNext = null;
150 __pFindWordPrev = null;
151 __previousZoomLevel = 1.0;
153 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
156 __currentSearchStr = L"";
157 __currentSelectedStr = L"";
158 __maxOccurrances = 0;
159 __currentWordIndex = 0;
162 __inputEventToBeSupressed = false;
163 __isLoadingData = false;
164 __isLoadingCompleted = false;
165 __progressPercentage = 0;
166 __touchPoint1 = Point(-1,-1);
167 __touchPoint2 = Point(-1,-1);
169 // __pReaderPopup = null;
170 __pReaderData = null;
172 __pReaderCloseBtn = null;
173 //__pNewWindowButton = null;
174 __pMoreButton = null;
175 __pMultiWindowButton = null;
176 __pArticleReaderPanel = null;
177 __pBlankPanel = null;
178 __pArticleReaderLabel = null;
179 __webControlHeight = 0;
180 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
181 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
182 __pMostVisitedSites = null;
183 __pFooterUrlField = null;
185 __pGoForwardBtn = null;
186 __pRefreshBtn = null;
187 __pProgressbarLabel = null;
188 __pFooterLabel = null;
191 __isWebKeypadOpened = false;
194 MainForm::~MainForm(void)
196 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
200 __pAddressbar->SetAddressbarEventListener(null);
202 if (__pReaderData != null)
204 delete __pReaderData;
205 __pReaderData = null;
208 if (__pPopUp != null)
214 if (__pHitElementResult != null)
216 delete __pHitElementResult;
217 __pHitElementResult = null;
219 String* pSelectedScene = NULL;
220 Object* pValue = NULL;
221 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
222 pSelectedScene = (String*) pValue;
224 /*if (pSelectedScene != null)
226 delete pSelectedScene;
228 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
232 MainForm::Initialize(void)
234 Construct(L"IDL_FORM");
239 MainForm::OnInitializing(void)
241 AppLog("get client area width = %d",GetClientAreaBounds().width);
242 AppLog("get client area height = %d",GetClientAreaBounds().height);
243 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
244 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
246 Panel* pFooterPanel = null;
248 __pSaveImage = new Image();
249 __pSaveImage->Construct();
251 // Setup back event listener
252 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
253 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
254 AddOrientationEventListener(*this);
255 AppLogDebug(" MainForm::OnInitializing ended");
256 if (__pMostVisitedSites == null)
258 __pMostVisitedSites = new(std::nothrow) ArrayList();
259 __pMostVisitedSites->Construct();
261 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
263 __pItemContext= new(std::nothrow) ListContextItem();
264 __pItemContext->Construct();
265 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
266 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
268 if (pBitmapNormal != null && pBitmapPressed != null)
270 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
273 if (pBitmapNormal != null)
275 delete pBitmapNormal;
278 if (pBitmapPressed != null)
280 delete pBitmapPressed;
283 __pItemContextLandscape= new(std::nothrow) ListContextItem();
284 __pItemContextLandscape->Construct();
285 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
286 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
288 if (pBitmapNormal != null && pBitmapPressed != null)
290 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
293 if (pBitmapNormal != null)
295 delete pBitmapNormal;
298 if (pBitmapPressed != null)
300 delete pBitmapPressed;
307 MainForm::InitAddressbar(void)
309 AppLogDebug("MainForm::InitAddressbar entered");
311 result r = E_SUCCESS;
313 if (__pAddressbar != null)
317 __pAddressbar = new(std::nothrow) Addressbar();
318 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
319 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
322 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
325 __pAddressbar->SetAddressbarEventListener(this);
326 AddControl(*__pAddressbar);
327 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
328 SetControlAlwaysOnTop(*__pAddressbar, true);
329 __adressPanelPosition = __pAddressbar->GetPosition();
331 AppLogDebug("MainForm::InitAddressbar exit");
337 MainForm::CreateReaderPanel(void)
339 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
340 result r = E_FAILURE;
342 Button *pSmallFontBtn = null;
343 Button *pLargeFontBtn = null;
345 __pBlankPanel = new (std::nothrow) Panel();
346 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
348 __pArticleReaderPanel = new (std::nothrow) Panel();
349 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
351 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
352 if (__pReaderCloseBtn)
354 AppLogDebug("CreateReaderPanel() 6");
355 __pReaderCloseBtn->AddActionEventListener(*this);
356 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
359 __pWebReader = new (std::nothrow) Web();
360 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
362 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
363 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
365 r = __pWebReader->SetSetting(settings);
367 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
370 __pArticleReaderLabel = new Label();
371 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
373 __pBlankPanel->AddControl(*__pArticleReaderLabel);
374 __pBlankPanel->AddControl(*__pArticleReaderPanel);
375 AddControl(*__pBlankPanel);
377 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
378 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
379 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
381 __pArticleReaderPanel->AddControl(*__pWebReader);
382 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
383 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
384 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
386 if (pBitmap != null && pSrcBitmap != null)
388 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
390 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
392 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
395 pSmallFontBtn->AddActionEventListener(*this);
396 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
399 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
402 pLargeFontBtn->AddActionEventListener(*this);
403 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
412 if (pSrcBitmap != null)
418 SetControlAlwaysOnTop(*__pBlankPanel, true);
419 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
426 MainForm::InitWebControl()
428 AppLogDebug("MainForm::InitWebControl enter");
429 result r = E_SUCCESS;
430 AppLogDebug("InitWebControl");
432 if (__pAddressbar == null || __pFooterPanel == null)
435 const int Y_WEBCONTROL_POSITION = 0;
436 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
437 if (__pMostVisitedListView)
439 __pMostVisitedListView->SetShowState(false);
441 if (__pWebViewer != null)
443 AppLogDebug("Already initialized");
446 __pWebViewer = new(std::nothrow) Web();
447 if(__pWebViewer == NULL)
449 AppLogDebug("Initialization failed");
452 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight));
456 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
463 r = AddControl(*__pWebViewer);
467 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
470 __webControlPosition = __pWebViewer->GetPosition();
471 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
474 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
478 __pWebViewer->SetLoadingListener(this);
479 __pWebViewer->SetWebUiEventListener(this);
480 __pWebViewer->SetWebKeypadEventListener(this);
481 __pWebViewer->SetFocus();
482 __pWebViewer->AddTouchEventListener(*this);
484 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
485 __pWebViewer->SetTextSearchListener(this);
488 AppLogDebug("MainForm :before return");
490 AppLogDebug("MainForm::InitWebControl Exit");
496 MainForm::OnFocusGained(const Control& source)
498 if(__pAddressbar != null)
500 __pFooterUrlField->SetFocusable(false);
501 __pAddressbar->SetAddressbarURLFocus();
508 MainForm::SetJavascriptEnabled()
510 WebSetting settings = __pWebViewer->GetSetting();
511 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
512 __pWebViewer->SetSetting(settings);
516 MainForm::SetImageLoadEnabled()
518 WebSetting settings = __pWebViewer->GetSetting();
519 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
520 __pWebViewer->SetSetting(settings);
524 MainForm::InitFooter(void)
526 AppLogDebug("MainForm::InitFooter entered");
527 Button* pBackButton = null;
528 Button* pBookmarkButton = null;
529 Button* pMultiWindowButton = null;
530 Bitmap *pIconBitmap = null;
531 Bitmap *pBGBitmap = null;
532 Label *pBGLabel = null;
534 if (__pFooterPanel == null)
536 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
539 if (__pFooterPanel == null)
544 SetControlAlwaysOnTop(*__pFooterPanel, true);
546 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
547 if ( __pFooterLabel == NULL )
551 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
552 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
555 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
559 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
561 if ( __pMultiWindowButton == NULL )
566 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
568 if ( __pMoreButton == NULL )
573 if (__pMultiWindowButton != null)
575 Bitmap* pBitmap = null;
576 Bitmap* pPressedBitmap = null;
577 String imagePath = "I01_toolbar_icon_windows_manager_0";
578 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
579 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
580 imagePath.Append(totalCount);
581 imagePath.Append(".png");
583 pressedImagePath.Append(totalCount);
584 pressedImagePath.Append("_press.png");
586 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
587 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
588 if ( pBitmap == null )
593 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
596 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
597 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
602 __pMultiWindowButton->AddActionEventListener(*this);
603 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
608 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
609 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
612 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
613 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
614 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
618 __pMoreButton->AddActionEventListener(*this);
619 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
622 //Add the editfield for url
623 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
624 if (__pFooterUrlField == NULL)
626 return E_INVALID_KEY;
629 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
630 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
631 //__pFooterUrlField->AddFocusEventListener(*this);
632 __pFooterUrlField->AddKeypadEventListener(*this);
633 __pFooterUrlField->AddFocusEventListener(*this);
635 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
637 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
639 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
641 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
645 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
646 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
649 //Add the go Back Button
650 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
651 if (__pGoBackBtn == NULL)
653 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
654 return E_INVALID_KEY;
656 __pGoBackBtn->SetActionId(IDA_GO_BACK);
657 __pGoBackBtn->AddActionEventListener(*this);
659 //Add the go forward Button
660 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
661 if (__pGoForwardBtn == NULL)
663 AppLogDebug("Control not found returning E_INVALID_KEY");
664 return E_INVALID_KEY;
666 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
667 __pGoForwardBtn->AddActionEventListener(*this);
668 __pGoForwardBtn->SetEnabled(false);
670 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
671 if (__pRefreshBtn == NULL)
673 AppLogDebug("Control not found returning E_INVALID_KEY");
674 return E_INVALID_KEY;
677 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
678 __pRefreshBtn->AddActionEventListener(*this);
679 __pRefreshBtn->SetShowState(true);
681 //Add the backround label for displaying progressbar
682 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
683 if (__pProgressbarLabel == NULL)
685 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
686 return E_INVALID_KEY;
688 __pProgressbarLabel->SetShowState(false);
690 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
691 if (__pStopBtn == NULL)
693 AppLogDebug("Control not found returning E_INVALID_KEY");
694 return E_INVALID_KEY;
696 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
697 __pStopBtn->AddActionEventListener(*this);
698 __pStopBtn->SetShowState(false);
700 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
701 if (__pClearBtn == NULL)
703 AppLogDebug("Control not found returning E_INVALID_KEY");
704 return E_INVALID_KEY;
706 __pClearBtn->SetActionId(IDA_CLEAR_URL);
707 __pClearBtn->AddActionEventListener(*this);
708 __pClearBtn->SetShowState(false);
710 // __pFooterPanel->Invalidate(true);
711 AppLogDebug("MainForm::InitFooter exit");
717 MainForm::InitContextMenu(Point& p)
719 result r = E_SUCCESS;
720 bool isPrivateBrowsing = false;
721 Bitmap* pBitmap = null;
725 __pMenu->SetAnchorPosition(p);
726 __pMenu->Invalidate(true);
730 __pMenu = new(std::nothrow) ContextMenu();
731 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST);
732 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
734 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
737 if (isPrivateBrowsing == true)
739 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
743 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
746 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
748 if ( pBitmap != NULL)
750 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"), IDA_PRIVATEON_CLICKED,*pBitmap);
753 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
754 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
755 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
758 __pMenu->SetMaxVisibleItemsCount(6);
759 __pMenu->SetShowState(false);
760 __pMenu->AddActionEventListener(*this);
761 SetControlAlwaysOnTop(*__pMenu, true);
767 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
769 result r = E_SUCCESS;
770 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
772 AppLog("MainForm::InitImageContextMenu clicked on image");
773 if (__pImageMenu != null)
779 p.y = p.y + __pAddressbar->GetHeight() + 12;
782 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
786 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
788 __pImageMenu = new (std::nothrow) ContextMenu();
789 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
790 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
792 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
793 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
794 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
795 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_IMAGE_CLICKED);
796 __pImageMenu->SetMaxVisibleItemsCount(4);
797 __pImageMenu->AddActionEventListener(*this);
798 SetControlAlwaysOnTop(*__pImageMenu, true);
803 result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
805 result r = E_SUCCESS;
806 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
808 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
809 if (__pImageMenu != null)
814 p.y = p.y + __pAddressbar->GetHeight() + 12;
817 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
821 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
823 __pImageMenu = new (std::nothrow) ContextMenu();
824 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
825 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
827 if(onlyPasteOption == false)
829 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
831 if (pasteOption || onlyPasteOption)
833 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
835 if(onlyPasteOption == false)
837 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
838 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
841 __pImageMenu->SetMaxVisibleItemsCount(3);
842 __pImageMenu->AddActionEventListener(*this);
843 SetControlAlwaysOnTop(*__pImageMenu, true);
850 MainForm::InitFindWordPanel(void)
852 result r = E_SUCCESS;
853 Bitmap *pIconBitmap = null;
855 if (__pFindWordPanel != null)
857 AppLogDebug("Findword panel already initialized");
858 if (__pFindWordBgLabel != null)
860 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
863 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
870 __pFindWordPanel = static_cast<Panel*>(GetControl(L"IDC_FIND_ON_PAGE_PANEL"));
871 if (__pFindWordPanel == null)
873 AppLogException("There is some problem in the xml file. Please check.");
877 __pFindWordControl = new (std::nothrow) Panel();
878 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
881 AppLogException("There is some problem in the xml file. Please check.");
884 AddControl(*__pFindWordControl);
885 __pFindWordControl->SetBounds(0,0, __pFindWordPanel->GetWidth(), __pFindWordPanel->GetHeight());
886 SetControlAlwaysOnTop(*__pFindWordControl,true);
887 __pFindWordPanel->SetShowState(false);
888 __pFindWordPanel->Invalidate(false);
890 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
891 if (__pFindWordBgLabel != null)
893 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
894 Rectangle pRect = pPanel1->GetBounds();
895 pRect.x = pRect.y = 0;
896 __pFindWordBgLabel->SetBounds(pRect);
897 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
900 AppLogDebug("InitFindWordPanel: Coming here");
901 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
906 AppLogDebug("InitFindWordPanel: shouldn't Come here");
910 Button* pfindWordCancel = null;
911 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
912 if (pfindWordCancel == null)
914 AppLogException("There is some problem in the xml file. Please check.");
917 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
918 pfindWordCancel->AddActionEventListener(*this);
920 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
921 if (__pFindWordClear == null)
923 AppLogException("There is some problem in the xml file. Please check.");
927 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
928 __pFindWordClear->AddActionEventListener(*this);
930 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
931 if (__pFindWordNext == null)
933 AppLogException("There is some problem in the xml file. Please check.");
937 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
938 __pFindWordNext->AddActionEventListener(*this);
940 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
941 if (__pFindWordPrev == null)
943 AppLogException("There is some problem in the xml file. Please check.");
947 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
948 __pFindWordPrev->AddActionEventListener(*this);
950 __pFindWordNext->SetEnabled(false);
951 __pFindWordPrev->SetEnabled(false);
953 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
954 if (__pFindWordCountLabel == null)
956 AppLogException("There is some problem in the xml file. Please check.");
960 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
961 if (__pFindWordEditField == null)
963 AppLogException("There is some problem in the xml file. Please check.");
966 __pFindWordEditField->AddTextEventListener(*this);
967 __pFindWordEditField->AddKeypadEventListener(*this);
968 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
974 MainForm::CreateItem (int index, int itemWidth)
976 Rectangle listImageRect;
977 Rectangle pagetTitleRect;
978 Rectangle pageURLRect;
979 Rectangle deleteImageRect;
980 String pageTitle(L"");
982 result r = E_SUCCESS;
983 Bitmap* pListIconImage = null;
986 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
991 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
992 if ( pAppResource == NULL )
996 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
998 CustomItem* pItem = new(std::nothrow) CustomItem();
999 pageTitle = pHistory->GetHistoryTitle();
1000 pageURL = pHistory->GetHistoryUrl();
1002 if (pageURL.GetLength() == 0)
1005 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1006 pageURL = L"<"+ nourl +">";
1010 Rectangle screenBounds = GetBounds();
1013 r = pItem->Construct(Dimension(itemWidth, 128), style);
1022 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1024 if ( pBitmap != NULL)
1026 pListIconImage = new Bitmap();
1027 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1031 if(pListIconImage == null)
1033 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1036 if ( pListIconImage != NULL)
1038 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1039 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1040 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1043 if (pItem != null && pListIconImage != NULL)
1045 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1049 if (pageTitle.CompareTo(L"") != 0)
1053 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1057 if (pageURL.CompareTo(L"") != 0)
1061 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1066 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1068 if ( __pItemContext!= NULL)
1072 pItem->SetContextItem(__pItemContext);
1078 if ( __pItemContextLandscape!= NULL)
1082 pItem->SetContextItem(__pItemContextLandscape);
1086 if( pListIconImage != NULL)
1088 delete pListIconImage;
1089 pListIconImage = null;
1096 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1103 MainForm::GetItemCount (void)
1105 if(__pMostVisitedSites != null)
1107 __pMostVisitedSites->RemoveAll(true);
1109 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1110 if(__pMostVisitedSites != null)
1112 return __pMostVisitedSites->GetCount();
1119 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1121 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1122 String url = pHistory->GetHistoryUrl();
1123 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1124 __pMostVisitedListView->UpdateList();
1128 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1130 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1131 String url = pHistory->GetHistoryUrl();
1139 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1145 MainForm::OnTerminating(void)
1147 result r = E_SUCCESS;
1150 delete __pItemContext;
1152 if(__pItemContextLandscape)
1154 delete __pItemContextLandscape;
1160 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1162 result r = E_SUCCESS;
1164 AppLogDebug("Clicked : %d", actionId);
1167 case IDA_BACKBTN_CLICKED:
1169 if (__pWebViewer && __pWebViewer->CanGoBack())
1171 __pWebViewer->GoBack();
1176 pApp = UiApp::GetInstance();
1179 r = pApp->Terminate();
1182 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1190 case IDA_FORWARD_CLICKED:
1191 if (__pWebViewer == null)
1194 if (__pWebViewer->CanGoForward())
1196 __pWebViewer->GoForward();
1198 __pMenu->SetShowState(false);
1199 __pMenu->Invalidate(false);
1202 case IDA_FINDONPAGE_CLICKED:
1204 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1205 __currentSearchStr.Clear();
1207 InitFindWordPanel();
1208 __pMenu->SetShowState(false);
1209 __pMenu->Invalidate(false);
1211 __pFindWordEditField->SetFocus();
1213 if (__pWebViewer != null)
1215 // releasing the set block
1216 __pWebViewer->ReleaseBlock();
1219 ShowFindWordPanel(true);
1222 case IDA_PRIVATEON_CLICKED:
1224 result r = E_SUCCESS;
1226 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1227 Bitmap* pBitmap = null;
1228 if (isPrivateBrowsing == true)
1230 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1233 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1237 if (__pWebViewer != NULL)
1239 __pWebViewer->SetPrivateBrowsingEnabled(false);
1242 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1244 if (__pAddressbar != null)
1246 __pAddressbar->UpdateFaviconBitmap(false);
1252 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1255 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1259 if (__pWebViewer != NULL)
1261 __pWebViewer->SetPrivateBrowsingEnabled(true);
1264 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1266 if (__pAddressbar != null)
1268 __pAddressbar->UpdateFaviconBitmap(true);
1273 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1274 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1275 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1276 __pMenu->Invalidate(true);
1278 if ( pBitmap != NULL )
1285 case IDA_SETTINGS_CLICKED:
1288 ArrayList* pArgList = new(std::nothrow) ArrayList();
1291 pArgList->Construct();
1292 pArgList->Add(*__pWindowInfo);
1293 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1295 __pMenu->SetShowState(false);
1296 __pMenu->Invalidate(false);
1297 if (pArgList != null)
1306 case IDA_ADDTOBOOKMARK_CLICKED:
1309 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1311 int bookmarkCount=0;
1314 url=__pWindowInfo->pageUrl;
1315 result r = E_SUCCESS;
1316 Bitmap* pBitmap = null;
1317 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1325 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1326 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1327 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1329 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1330 if (pNotification != null)
1332 pNotification->SetText(message);
1333 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1334 pNotification->ShowNotification();
1339 String title=__pWindowInfo->pageTitle;
1340 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1341 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1343 pBookmark->SetBookmarkTitle(title);
1344 pBookmark->SetUrl(url);
1345 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1347 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1349 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1350 pBookmark->SetFaviconId(id);
1351 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1352 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1355 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1356 if (pNotification != null)
1358 pNotification->SetText(message);
1359 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1360 pNotification->ShowNotification();
1361 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1364 if (pBitmap != null)
1366 r = __pMenu->SetItemAt(0,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1370 __pMenu->Invalidate(true);
1374 case IDA_SHARE_CLICKED:
1376 if(__pPopUp != null)
1381 __pPopUp = new(std::nothrow) SharePopup();
1382 __pPopUp->Initialize();
1383 if (__pWindowInfo != null)
1385 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1386 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1387 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1388 pShareInfo->SetImageAttached(false);
1389 __pPopUp->RemoveAllShareInfo();
1390 __pPopUp->AddShareInfo(pShareInfo);
1392 __pPopUp->SetShowState(true);
1396 case IDA_BOOKMARKBTN_CLICKED:
1398 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1399 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1402 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1407 case IDA_MOREBTN_CLICKED:
1409 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1410 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1411 AppLog("Anchot pos: %d %d", p.x, p.y);
1413 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1415 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1416 int bookmarkCount=0;
1419 url=__pWindowInfo->pageUrl;
1420 result r = E_SUCCESS;
1421 Bitmap* pBitmap = null;
1423 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1426 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1431 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1435 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1437 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1439 if (__pMenu->GetItemCount() == 8)
1441 r = __pMenu->SetItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1445 r = __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1450 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1454 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1455 if (__pMenu->GetItemCount() != 8)
1457 __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADDTOBOOKMARK_CLICKED);
1459 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1460 __pMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1461 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1462 __pMenu->SetMaxVisibleItemsCount(6);
1464 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1466 AppLog(" Orientation landscape");
1467 __pMenu->SetMaxVisibleItemsCount(5);
1471 AppLog(" Orientation potrait");
1472 __pMenu->SetMaxVisibleItemsCount(6);
1475 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1478 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1479 __pMenu->SetShowState(true);
1480 __pMenu->Invalidate(true);
1484 case IDA_HISTORY_CLICKED:
1486 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1487 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1490 case IDA_SAVED_PAGES_CLICKED:
1495 case IDA_DESKTOP_VIEW_CLICKED:
1500 case IDA_SAVE_CLICKED:
1505 case IDA_MULTIWINDOWBTN_CLICKED:
1507 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1508 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1512 case IDA_NEWWINDOWBTN_CLICKED:
1514 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1516 if (pNewWindowInfo == null)
1520 result r = E_SUCCESS;
1521 SceneManager* pSceneManager = SceneManager::GetInstance();
1523 if (pSceneManager == NULL)
1527 ArrayList* pArgList = new(std::nothrow) ArrayList();
1528 if (pArgList == NULL)
1532 r = pArgList->Construct();
1535 pArgList->Add(*pNewWindowInfo);
1536 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1542 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1547 case IDA_SMALLFONT_BTN_CLICKED:
1549 WebSetting setting = __pWebReader->GetSetting();
1550 setting.SetFontSize(15);
1551 __pWebReader->SetSetting(setting);
1554 case IDA_LARGEFONT_BTN_CLICKED:
1556 WebSetting setting = __pWebReader->GetSetting();
1557 setting.SetFontSize(25);
1558 __pWebReader->SetSetting(setting);
1561 case IDA_READER_CLOSE_CLICKED:
1563 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1565 //__pArticleReaderPanel->SetShowState(false);
1566 //__pArticleReaderPanel->Show();
1567 RemoveControl(*__pBlankPanel);
1568 //RemoveControl(*__pArticleReaderPanel);
1569 __pArticleReaderPanel = null;
1570 __pBlankPanel = null;
1571 __pArticleReaderLabel = null;
1573 //if (__pAddressbar)
1574 // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1575 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1578 case IDA_FINDWORD_CANCEL_CLICKED:
1580 __currentSearchStr = L"";
1581 __currentWordIndex = 0;
1582 __maxOccurrances = 0;
1583 __pFindWordEditField->SetText(L"");
1584 __pFindWordNext->SetEnabled(false);
1585 __pFindWordPrev->SetEnabled(false);
1586 __pFindWordCountLabel->SetText(L"0/0");
1587 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1588 ShowFindWordPanel(false);
1591 case IDA_FINDWORD_SEARCH_CLICKED:
1593 __currentSearchStr = __pFindWordEditField->GetText();
1594 if (__currentSearchStr.GetLength() > 0)
1600 AppLogDebug("Enter something");
1604 case IDA_FINDWORD_CLEAR_CLICKED:
1606 __pFindWordCountLabel->SetText(L"0/0");
1607 __pFindWordEditField->SetText(L"");
1608 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1610 __currentSearchStr = L"";
1611 __pFindWordNext->SetEnabled(false);
1612 __pFindWordPrev->SetEnabled(false);
1613 __pFindWordPanel->Invalidate(true);
1616 case IDA_FINDWORD_NEXT_CLICKED:
1621 case IDA_FINDWORD_PREV_CLICKED:
1623 FindNextWord(false);
1626 case IDA_BRIGHTNESS_BTN_CLICKED:
1628 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1629 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1632 case IDA_COPY_IMAGE_CLICKED:
1634 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1635 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1637 const Bitmap* pBitmap = null;
1638 if (__pHitElementResult != null)
1640 pBitmap = __pHitElementResult->GetImage();
1643 String resourcePath = App::GetInstance()->GetAppResourcePath();
1644 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1646 // copying the item to clipboard
1647 Clipboard* pClipboard = Clipboard::GetInstance();
1648 if (pClipboard != null)
1650 pClipboard->CopyItem(item);
1654 case IDA_VIEW_IMAGE_CLICKED:
1656 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1657 WindowInfo* pNewWindowInfo = null;
1658 if (__pHitElementResult != null)
1660 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1661 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1667 case IDA_SAVE_IMAGE_CLICKED:
1669 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1670 const Bitmap* pSaveBitmap = null;
1671 String imageName = GetImagePath();
1672 AppLog("Content manager image name %ls",imageName.GetPointer());
1675 imagePath.Append(imageName);
1676 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1677 AppLog("Content manager image path %ls",imagePath.GetPointer());
1678 if (__pHitElementResult != null)
1680 pSaveBitmap = __pHitElementResult->GetImage();
1682 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1686 UpdateImageContent(pBuffer, imageName);
1688 NotificationPanel *pNotification = new NotificationPanel(*this);
1690 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1691 msg.Append(imagePath);
1692 if (pNotification != null)
1694 pNotification->SetText(msg);
1695 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1696 pNotification->ShowNotification();
1701 int __modalMsgBoxResult;
1702 MessageBox* pMsgBox = new MessageBox();
1703 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1704 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1707 __modalMsgBoxResult = 0;
1711 case IDA_SHARE_IMAGE_CLICKED:
1713 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1714 if (__pPopUp != null)
1719 __pPopUp = new(std::nothrow) SharePopup();
1720 __pPopUp->Initialize();
1721 if (__pHitElementResult != null)
1723 const Bitmap* pSaveBitmap = null;
1724 String imageName = GetImagePath();
1725 AppLog("Content manager image name %ls",imageName.GetPointer());
1728 imagePath.Append(imageName);
1729 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1730 AppLog("Content manager image path %ls",imagePath.GetPointer());
1731 if (__pHitElementResult != null)
1733 pSaveBitmap = __pHitElementResult->GetImage();
1735 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1737 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1738 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1740 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1741 pShareInfo->SetPageTitle(L"");
1742 pShareInfo->SetPageUrl(srcUrl);
1743 pShareInfo->SetImageAttached(true);
1744 pShareInfo->SetImagePath(imagePath);
1745 __pPopUp->RemoveAllShareInfo();
1746 __pPopUp->AddShareInfo(pShareInfo);
1747 __pPopUp->SetShowState(true);
1752 case IDA_FIND_TEXT__CLICKED:
1754 AppLogDebug("MainForm::OnActionPerformed find word clicked");
1755 __currentSearchStr.Clear();
1756 __currentSearchStr.Append(__currentSelectedStr);
1757 InitFindWordPanel();
1760 __pMenu->SetShowState(false);
1761 __pMenu->Invalidate(false);
1764 __adressPanelPosition.y = 0;
1766 if (__pAddressbar != null && __pWebViewer != NULL)
1768 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
1769 //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
1770 //__pAddressbar->Invalidate(true);
1771 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
1773 if (__pFooterPanel->GetShowState() == false)
1774 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
1776 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
1777 // __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
1778 __pWebViewer->Invalidate(true);
1781 ShowFindWordPanel(true);
1782 if (__currentSearchStr.GetLength() > 0)
1788 AppLogDebug("Enter something");
1791 if (__pWebViewer != null)
1793 // releasing the set block
1794 __pWebViewer->ReleaseBlock();
1799 case IDA_SHARE_TEXT_CLICKED:
1801 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
1802 if(__pPopUp != null)
1807 __pPopUp = new(std::nothrow) SharePopup();
1808 __pPopUp->Initialize();
1809 if (__pHitElementResult != null)
1811 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1812 pShareInfo->SetPageTitle(L"");
1813 pShareInfo->SetPageUrl(__currentSelectedStr);
1814 pShareInfo->SetImageAttached(false);
1815 __pPopUp->RemoveAllShareInfo();
1816 __pPopUp->AddShareInfo(pShareInfo);
1817 __pPopUp->SetShowState(true);
1822 case IDA_COPY_TEXT_CLICKED:
1824 // need to implement
1825 //__currentSelectedStr
1826 // Sets data to a clip board item
1828 String resourcePath = App::GetInstance()->GetAppResourcePath();
1829 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
1831 // copying the item to clipboard
1832 Clipboard* pClipboard = Clipboard::GetInstance();
1833 if (pClipboard != null)
1835 pClipboard->CopyItem(item);
1839 case IDA_PASTE_TEXT_CLICKED:
1841 Clipboard* pClipboard = Clipboard::GetInstance();
1843 if(pClipboard == null)
1847 // Retrieves a latest item
1848 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
1854 //Gets data from the clipboard item
1855 String* pString = dynamic_cast<String*>(pItem->GetData());
1857 if (pString != null)
1859 String idElement = __pHitElementResult->GetAttributeValue(L"id");
1860 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
1861 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
1862 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; } } ";
1863 if(idElement.GetLength() != 0)
1865 script.Append("insertAtCursor(");
1866 script.Append(idElement);
1868 script.Append("\"");
1869 script.Append(*pString);
1870 script.Append("\");");
1872 else if (nameElement.GetLength() != 0)
1874 script.Append("insertAtCursor(document.getElementsByName('");
1875 script.Append(nameElement);
1876 script.Append("')[0],");
1877 script.Append("\"");
1878 script.Append(*pString);
1879 script.Append("\");");
1881 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
1882 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
1893 case IDA_GO_FORWARD:
1898 case IDA_REFRESH_BTN_CLICKED:
1900 __isLoadingCompleted = false;
1901 __isLoadingData = true;
1902 __progressPercentage = 0;
1903 __displayUrl = __pFooterUrlField->GetText();
1905 String url = __pFooterUrlField->GetText();
1906 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
1910 UpdateProgressBitmap();
1913 case IDA_STOP_BTN_CLICKED:
1915 __isLoadingCompleted = false;
1916 __isLoadingData = false;
1917 __progressPercentage = 0;
1918 __pFooterUrlField->HideKeypad();
1919 __displayUrl = __pFooterUrlField->GetText();
1923 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1924 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1925 __pWebViewer->StopLoading();
1926 RequestRedraw(true);
1929 UpdateProgressBitmap();
1934 if (__pFooterUrlField->GetText().IsEmpty() == false)
1936 //__displayUrl = __pUrlField->GetText();
1937 __pFooterUrlField->Clear();
1947 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
1950 UiApp* pApp = UiApp::GetInstance();
1959 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
1960 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
1962 String* pSelectedScene = NULL;
1963 Object* pValue = NULL;
1964 String* pUrl = null;
1965 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
1966 pSelectedScene = (String*) pValue;
1968 if (pSelectedScene != null)
1970 delete pSelectedScene;
1972 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
1973 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
1974 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
1975 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
1977 // setting the current scene ID
1978 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
1980 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
1982 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
1984 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
1985 if(__pWindowInfo == null)
1987 // if(__pWindowInfo == null)
1989 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
1992 else if ( pArgs != null && pArgs->GetCount() == 1)
1994 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2000 // hiding the address bar
2001 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2002 __pAddressbar->SetShowState(false);
2003 if(__pWebViewer != null)
2005 __pWebViewer->Resume();
2008 if(pUrl != null && pUrl->GetLength() > 0)
2012 else if(__pWindowInfo != null)
2014 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)
2016 LoadUrl(__pWindowInfo->pageUrl);
2018 else if (__pWindowInfo->isJavascriptInitiated == true)
2022 __pWindowInfo->pCurrentWeb = __pWebViewer;
2026 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2027 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2028 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2030 InitMostVisitedSitesView(GetOrientationStatus());
2033 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2035 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2037 if (pBookmarkUrl == null)
2039 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2040 //__pAddressbar->SetUrl(*pBookmarkUrl);
2041 SetUrl(*pBookmarkUrl);
2043 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2044 __pWebViewer->LoadUrl(*pBookmarkUrl);
2045 delete pBookmarkUrl;
2048 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2049 Bitmap* pBitmap = null;
2050 if (isPrivateBrowsing == true)
2052 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2054 if (__pWebViewer != null)
2056 __pWebViewer->SetPrivateBrowsingEnabled(true);
2059 if (__pAddressbar != null)
2061 // __pAddressbar->UpdateFaviconBitmap(true);
2067 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2069 if (__pWebViewer != null)
2071 __pWebViewer->SetPrivateBrowsingEnabled(false);
2074 if (__pAddressbar != null)
2076 // __pAddressbar->UpdateFaviconBitmap(false);
2080 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2082 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2084 else if (__pMenu != null )
2086 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2089 if (pBitmap != null)
2094 AppLog("ABC: OnSceneActivatedN started exit");
2099 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2100 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2102 Canvas* pWebCanvas = null;
2103 if (__pWebViewer != null)
2105 pWebCanvas = __pWebViewer->GetCanvasN();
2106 __pWebViewer->Pause();
2109 if (pWebCanvas == null)
2113 if (__pWindowInfo != null)
2115 if (__pWindowInfo->pWebCanvasBitmap != null)
2117 delete __pWindowInfo->pWebCanvasBitmap;
2119 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2120 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2121 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2123 Bitmap* pBitmap = GetCapturedBitmapN();
2124 AppLog("Coming here");
2125 Canvas* pCanvas = new(std::nothrow) Canvas();
2126 pCanvas->Construct(GetClientAreaBounds());
2129 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2132 if(__pWebViewer != null && __pWindowInfo != null)
2133 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2135 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2136 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2138 AppLog("Coming here");
2142 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2143 const Tizen::Base::String& realm,
2144 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2150 MainForm::OnHttpAuthenticationCanceled(void)
2155 MainForm::OnLoadingStarted(void)
2157 AppLogDebug("MainForm::OnLoadingStarted entered");
2159 if(__pAddressbar == NULL || __pWebViewer == null)
2163 String url = __pWebViewer->GetUrl();
2164 if(url.Contains(IDS_TIZEN_SERVICE))
2167 String delim(L":;");
2169 // Creates a StringTokenizer instance
2170 StringTokenizer strTok(url, delim);
2172 int count = strTok.GetTokenCount(); // count == 4
2174 HashMap *pMap = new HashMap();
2179 while (strTok.HasMoreTokens())
2181 AppLog("Token: %ls", token.GetPointer());
2182 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2183 if(token.Contains(IDS_APPID))
2185 token.SubString(6, appId);
2186 AppLog("AppID:%ls", appId.GetPointer());
2188 else if(token.Contains("="))
2190 String *pKey = new String();
2191 String *pValue = new String();
2193 token.IndexOf("=", 0, index);
2196 token.SubString(0, index, *pKey);
2197 token.SubString(index + 1, *pValue);
2198 pMap->Add(pKey, pValue);
2204 AppControl *pAppControl = null;
2205 String operationId = L"http://tizen.org/appcontrol/operation/main";
2206 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2209 AppLog("Starting AppControl");
2210 result r = pAppControl->Start(null, null, pMap, null);
2211 AppLog("Result of Start %s", GetErrorMessage(r));
2215 AppLogException("AppControl not found");
2220 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2223 __pAddressbar->SetFaviconBitmap(*pBitmap);
2226 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2228 // updating the address bar position with respect to web control
2229 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2230 __distanceMoved = 0;
2234 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2235 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2236 if (__pWebViewer != null)
2238 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2239 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2240 SetUrl(__pWebViewer->GetUrl());
2241 if (__pWindowInfo != NULL)
2243 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2245 __pAddressbar->Invalidate(true);
2251 MainForm::OnLoadingCanceled(void)
2258 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2260 AppLog("MainForm::OnKeypadWillOpen");
2261 if (__pAddressbar != null)
2263 OnAddressBarKeypadWillOpen(*__pAddressbar);
2269 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2271 if(__pAddressbar != null)
2273 OnAddressBarKeypadOpened(*__pAddressbar);
2279 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2281 if (__pAddressbar != null)
2283 OnAddressBarKeypadClosed(*__pAddressbar);
2288 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2290 AppLog("KeypadBoundsChanged");
2291 RelayoutControls(false);
2295 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2296 const Tizen::Base::String& reason)
2298 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2302 MainForm::OnLoadingCompleted(void)
2304 AppLog("MainForm::OnLoadingCompleted start");
2306 result r = E_SUCCESS;
2308 if (__pWebViewer == null)
2313 if (__pAddressbar == null)
2317 if (__pWebViewer->CanGoForward())
2319 //__pAddressbar->SetForwardButtonEnabled(true);
2320 SetForwardButtonEnabled(true);
2324 //__pAddressbar->SetForwardButtonEnabled(false);
2325 SetForwardButtonEnabled(false);
2328 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2330 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2332 //__pAddressbar->UpdateProgress(0);
2336 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2338 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2342 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2343 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2344 if (isPrivateBrowsing == false)
2346 History* pHistory = new(std::nothrow) History;
2348 HistoryPresentationModel::GetCurrentDateTime(date);
2351 pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2352 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2354 pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2355 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2357 pHistory->SetVisitedTime(date);
2360 id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2361 pHistory->SetFaviconId(id);*/
2363 if (__pWebViewer != null)
2365 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2367 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2368 if (pTempBitmap != null)
2370 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2371 pHistory->SetFavIconBitmap(*pTempBitmap);
2374 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2377 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2378 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2379 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2381 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2382 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2383 pHistory->SetThumbnail(pBitmap);
2385 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2388 pHistory->SetFavIconBitmap(*pFavIcon);
2392 HistoryPresentationModel::GetInstance()->SaveTempHistory(*pHistory);
2399 if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2401 // temperary fixed (webpage can be not loaded)
2404 AppLog("MainForm::OnLoadingCompleted done");
2408 MainForm::OnEstimatedProgress(int progress)
2410 AppLogDebug("MainForm::OnEstimatedProgress entered");
2411 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2412 progress = DEFAULT_PROGRESS_PERCENTAGE;
2414 // __pAddressbar->UpdateProgress(progress);
2415 UpdateProgress(progress);
2418 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2420 AppLog("MainForm::OnFaviconReceived");
2421 Bitmap* pFavIconBitmap = __pWebViewer->GetFaviconN();
2423 if (pFavIconBitmap != null)
2425 pFavIconBitmap->GetWidth();
2426 pFavIconBitmap->GetHeight();
2431 MainForm::OnUrlValueChanged(Addressbar&)
2437 MainForm::OnUrlSubmitted(Addressbar& addBar)
2439 AppLog("MainForm::OnUrlSubmitted");
2440 String url = addBar.GetUrl();
2441 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2443 // __pFooterPanel->SetShowState(true);
2444 OnAddressCancelledClicked(*__pAddressbar);
2445 // __pAddressbar->SetShowState(false);
2446 // RelayoutControls(false);
2451 MainForm::LoadUrl(String& url)
2454 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2455 AppLogDebug("MainForm::LoadUrl enter");
2457 if (__pWebViewer != null)
2459 __pWebViewer->SetShowState(true);
2460 __pWebViewer->Invalidate(true);
2463 if (url.CompareTo(L"") == 0)
2467 if(__pFooterPanel != null)
2469 __pFooterPanel->SetShowState(true);
2470 __pFooterPanel->Invalidate(true);
2477 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2478 String secondPattern(L"^[A-Za-z0-9\.\+-:#@%/;$~?]+\\.[A-Za-z0-9!\+-=:#@%/;$~()_?\\\.&]{2,}$"); // URL of type abc.com (i.e without protocol in front of it)
2480 RegularExpression firstRegex;
2481 RegularExpression secondRegex;
2483 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2484 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2487 ret = firstRegex.Match(url, false); // This returns true value
2488 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2490 if (ret == true && __pWebViewer != null)
2492 __pWebViewer->LoadUrl(url);
2494 else if(__pWebViewer != null)
2496 String tempUrl = L"http://";
2497 tempUrl.Append(url);
2501 __pWebViewer->LoadUrl(tempUrl);
2505 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2506 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2509 if (__pAddressbar != null)
2511 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2512 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2515 AppLogDebug("MainForm::LoadUrl exit");
2522 MainForm::OnStopClicked(Addressbar& addBar)
2524 AppLogDebug("MainForm::OnStopClicked called");
2527 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2528 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2529 __pWebViewer->StopLoading();
2530 RequestRedraw(true);
2535 MainForm::OnReaderClicked(const Addressbar& addBar)
2537 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2539 CreateReaderPanel();
2540 AppLogDebug("MainScene::OnReaderClicked entered");
2543 /*if (__pArticleReaderPanel)
2545 AppLogDebug("showstate true for reader panel");
2546 __pArticleReaderPanel->SetShowState(true);
2547 __pArticleReaderPanel->Show();
2549 int xPos = __pArticleReaderPanel->GetX();
2550 int yPos = __pArticleReaderPanel->GetY();
2551 AppLog("OnReaderClicked() xPos = %d",xPos);
2552 AppLog("OnReaderClicked() yPos = %d",yPos);
2554 if (__pReaderData == null)
2559 String loadData = L"<html>\
2561 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2566 background-color: transparent;\
2585 <body style='width:'";
2586 loadData.Append(bodyWidth);
2587 loadData.Append(L"px'>");
2588 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2589 loadData.Append(*__pReaderData);
2590 loadData.Append(L"</body></html>");
2593 buf.Construct(loadData.GetLength());
2594 AppLogDebug("data->GetLength %d",loadData.GetLength());
2595 for (int z=0;z<loadData.GetLength();z++)
2598 loadData.GetCharAt(z,b);
2599 buf.SetByte((byte)b);
2603 if (__pWebReader != null)
2605 __pWebReader->LoadData(L"",buf,L"text/html");
2606 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2610 AppLogDebug("cannot LoadData __pWebReader is null");
2616 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2618 AppLog("MainForm::OnBackClicked");
2619 result r = E_FAILURE;
2621 if (__pWebViewer != null && __pWebViewer->CanGoBack())
2623 __pWebViewer->GoBack();
2628 pApp = UiApp::GetInstance();
2631 r = pApp->Terminate();
2641 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
2643 AppLog("MainForm::OnForwardClicked");
2644 if (__pWebViewer == null)
2647 if (__pWebViewer->CanGoForward())
2649 __pWebViewer->GoForward();
2654 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
2656 result r = E_SUCCESS;
2657 // hiding the address bar
2658 __pAddressbar->SetShowState(false);
2659 __pFooterPanel->SetShowState(true);
2661 __pWebViewer->SetFocus();
2663 __pMostVisitedListView->SetFocus();
2664 __pFooterUrlField->SetFocusable(true);
2665 __pMoreButton->SetFocus();
2667 RelayoutControls(false);
2671 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
2673 __prevAddressBarMode = __curAddressBarMode;
2675 if (__pAddressbar != null)
2677 __curAddressBarMode = GetAddressbarMode();
2680 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
2682 __adressPanelPosition.y = 0;
2683 if (__pAddressbar != null)
2685 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2686 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2687 __pAddressbar->Invalidate(true);
2689 if (__pWebViewer != null)
2691 __pWebViewer->StopLoading();
2694 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
2696 __adressPanelPosition.y = 0;
2697 if (__pAddressbar != null)
2699 __webControlPosition.y = 0;
2700 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
2701 __pAddressbar->Invalidate(true);
2707 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
2710 __pAddressbar->SetShowState(false);
2712 __pFooterPanel->SetShowState(true);
2714 __pWebViewer->SetFocus();
2715 if(__pFooterUrlField)
2716 __pFooterUrlField->SetFocusable(true);
2717 RelayoutControls(false);
2721 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
2723 if (__pFindWordControl && __pFindWordControl->GetShowState() == true)
2725 __pAddressbar->SetShowState(false);
2729 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
2731 __pAddressbar->SetShowState(true);
2732 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2733 // __pAddressbar->SetAddressbarURLFocus();
2737 RelayoutControls(false);
2741 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
2743 __pFooterPanel->SetShowState(false);
2747 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
2749 AppLog("KeypadBoundsChanged");
2750 RelayoutControls(false);
2754 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
2758 __pWindowInfo->pageTitle = title;
2759 if (__pWebViewer != null)
2761 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2764 if (__pAddressbar != null && __pWebViewer != null)
2766 SetUrl(__pWebViewer->GetUrl());
2767 __pAddressbar->Invalidate(true);
2772 MainForm::UpdateFavicon(void)
2774 bool urlImageType = false;
2775 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();");
2776 Bitmap* pBitmap = null;
2778 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
2780 if (__pWindowInfo != null)
2783 url.SetUri(*tempPath);
2784 if (url.GetHost().GetLength() == 0)
2787 webUrl.SetUri(__pWebViewer->GetUrl());
2788 result r = url.SetHost(webUrl.GetHost());
2795 if (url.GetScheme().GetLength() == 0)
2798 webUrl.SetUri(__pWebViewer->GetUrl());
2799 url.SetScheme(webUrl.GetScheme());
2801 __pWindowInfo->faviconUrl = url.ToString();
2803 pBitmap = __pWebViewer->GetFaviconN();
2805 if (pBitmap != null)
2807 if (__pWindowInfo->pFavicon != NULL)
2809 __pWindowInfo->pFavicon = null;
2811 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
2812 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
2814 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2816 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2818 else if(__pWindowInfo->pFavicon != null)
2820 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2824 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
2825 if(pDefaultBmp != null)
2827 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
2836 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
2843 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
2844 Tizen::Web::Controls::WebNavigationType type)
2846 // when load new page if find word panel is open its show state is false
2847 ShowFindWordPanel(false);
2849 __pFooterPanel->Invalidate(true);
2852 uriInfo.SetUri(url);
2854 if(url.Contains(IDS_TIZEN_SERVICE))
2857 String delim(L":;");
2859 // Creates a StringTokenizer instance
2860 StringTokenizer strTok(url, delim);
2862 int count = strTok.GetTokenCount(); // count == 4
2864 HashMap *pMap = new HashMap();
2870 while (strTok.HasMoreTokens())
2872 AppLog("Token: %ls", token.GetPointer());
2873 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2874 if(token.Contains(IDS_APPID))
2876 token.SubString(6, appId);
2877 AppLog("AppID:%ls", appId.GetPointer());
2879 else if(token.Contains("="))
2881 String *pKey = new String();
2882 String *pValue = new String();
2884 token.IndexOf("=", 0, index);
2887 token.SubString(0, index, *pKey);
2888 token.SubString(index + 1, *pValue);
2889 pMap->Add(pKey, pValue);
2895 AppControl *pAppControl = null;
2896 String operationId = L"http://tizen.org/appcontrol/operation/main";
2897 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2900 result r = pAppControl->Start(null, null, pMap, null);
2904 AppLogException("AppControl not found");
2910 if ( __pAddressbar != null)
2912 __pAddressbar->SetShowState(false);
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;
3038 AppLog("Client area height: %d", __webControlHeight);
3040 AppLog("Client area height: %d", __webControlHeight);
3041 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3043 __webControlPosition.y += __pAddressbar->GetHeight();
3044 __webControlHeight -= __pAddressbar->GetHeight();
3045 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3047 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3049 __webControlPosition.y += __pFindWordControl->GetHeight();
3050 __webControlHeight -= __pFindWordControl->GetHeight();
3051 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3054 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true)
3056 __webControlHeight -= __pFooterPanel->GetHeight();
3057 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3059 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3061 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight);
3062 __pWebViewer->Invalidate(false);
3064 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3066 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3073 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3075 if (__pFindWordControl == null)
3081 InitFindWordPanel();
3082 __pFindWordEditField->SetText(__currentSearchStr);
3083 //__pFindWordCountLabel->SetText(L"");
3084 __pFindWordCountLabel->SetText(L"0/0");
3085 __pFindWordPanel->SetShowState(true);
3089 if(__pFindWordControl != null)
3091 __pFindWordControl->SetShowState(false);
3095 AppLog("MainForm::ShowFindWordPanel %d",show);
3096 if (show && !isTouchPressed)
3098 if (__pFindWordEditField)
3100 __pFindWordEditField->SetFocus();
3101 __pFindWordEditField->ShowKeypad();
3106 if (__pFindWordEditField)
3107 __pFindWordEditField->HideKeypad();
3110 RelayoutControls(false);
3114 MainForm::StartWordSearch()
3116 //Get the count of occurances of the word in the current page
3117 __maxOccurrances = 0;
3118 __currentWordIndex = 0;
3120 __pFindWordPrev->SetEnabled(false);
3121 String *pCountStr = null;
3122 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3123 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3124 if (pCountStr != null)
3126 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3130 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3135 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3137 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3138 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3140 if(totalCount == -1 || totalCount == 0)
3142 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),64,__pFindWordCountLabel->GetHeight());
3143 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3146 else if(totalCount > 100)
3148 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3149 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3153 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3154 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3157 __maxOccurrances = totalCount;
3158 __currentWordIndex = currentOrdinal;
3160 //Reset the UI controls as per the maxOccurrance value
3161 if (totalCount <= 0)
3163 AppLog("Word not found");
3164 //Show error notification to user
3165 __pFindWordNext->SetEnabled(false);
3166 __pFindWordCountLabel->SetText(L"0/0");
3167 __pFindWordNext->Invalidate(false);
3168 __pFindWordPrev->Invalidate(false);
3169 __pFindWordCountLabel->Invalidate(false);
3173 if (totalCount == 1)
3175 __pFindWordNext->SetEnabled(false);
3179 __pFindWordNext->SetEnabled(true);
3182 String countStr = L"";
3183 countStr.Append(__currentWordIndex);
3184 countStr.Append(L"/");
3185 countStr.Append(__maxOccurrances);
3186 __pFindWordCountLabel->SetText(countStr);
3187 // __pFindWordCountLabel->SetShowState(true);
3188 __pFindWordCountLabel->Invalidate(false);
3190 //FindNextWord(true);
3191 //Update the controls
3192 __pFindWordNext->Invalidate(false);
3193 __pFindWordPrev->Invalidate(false);
3194 __pFindWordCountLabel->Invalidate(false);
3198 MainForm::FindNextWord(bool next)
3202 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3204 if(__currentWordIndex < __maxOccurrances)
3206 __currentWordIndex++;
3212 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3214 if(__currentWordIndex > 1)
3216 __currentWordIndex--;
3221 String countStr = L"";
3222 countStr.Append(__currentWordIndex);
3223 countStr.Append(L"/");
3224 countStr.Append(__maxOccurrances);
3225 __pFindWordCountLabel->SetText(countStr);
3226 // __pFindWordCountLabel->SetShowState(true);
3227 __pFindWordCountLabel->Invalidate(false);
3228 if (__currentWordIndex >= __maxOccurrances)
3230 __pFindWordNext->SetEnabled(false);
3234 __pFindWordNext->SetEnabled(true);
3236 if (__currentWordIndex <= 1)
3238 __pFindWordPrev->SetEnabled(false);
3242 __pFindWordPrev->SetEnabled(true);
3244 __pFindWordPrev->Invalidate(false);
3245 __pFindWordNext->Invalidate(false);
3246 __pFindWordCountLabel->Invalidate(false);
3247 __pFindWordPanel->Invalidate(true);
3250 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3252 AppLog("MainForm::OnWebKeypadWillOpen");
3253 __isWebKeypadOpened = true;
3254 // OnAddressBarKeypadOpened(*__pAddressbar);
3258 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3261 if (__pWebViewer != null && __pFooterPanel != null)
3263 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3264 if(__pAddressbar != null)
3266 __pAddressbar->SetShowState(false);
3268 if(__pFindWordControl != null)
3270 __pFindWordControl->SetShowState(false);
3272 __pFooterPanel->SetShowState(false);
3273 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
3279 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3281 __pFooterPanel->SetShowState(true);
3282 OnAddressBarKeypadClosed(*__pAddressbar);
3283 __isWebKeypadOpened = false;
3287 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3289 Control* temp = const_cast< Control* >(&source);
3290 Header* pHeader = dynamic_cast< Header* >(temp);
3291 if (pHeader != null)
3293 //Header double - clicked
3294 AppLog("Header double clicked");
3296 if(__pFindWordPanel)
3298 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3299 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3303 AppLog("MainScene::OnTouchDoublePressed");
3304 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3305 if (isReaderEnabled == true)
3309 delete __pReaderData;
3310 __pReaderData = null;
3312 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3313 filePath.Append(L"data/reader.js");
3319 result r = E_SUCCESS;
3320 FileAttributes attr;
3322 File::GetAttributes(filePath,attr);
3324 r = file.Construct(filePath, L"r+");
3327 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3330 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3333 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3336 file.Read(pScript,attr.GetFileSize());
3338 AppLogDebug("scipt length %d",strlen(pScript));
3339 String strScript = L"";
3340 strScript.Append(pScript);
3341 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3344 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3347 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3348 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3350 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3351 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3357 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3359 AppLog("MainForm::OnTouchLongPressed");
3361 if (__pHitElementResult != null)
3363 delete __pHitElementResult;
3364 __pHitElementResult = null;
3367 if (__pWebViewer != null)
3369 AppLog("MainForm::OnTouchLongPressed web not null");
3370 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3373 if (__pHitElementResult == null)
3378 if (__pHitElementResult->HasImage() == true)
3380 InitImageContextMenu(currentPosition);
3381 __pImageMenu->SetShowState(true);
3382 __pImageMenu->Show();
3383 __pImageMenu->Invalidate(true);
3387 String tagName = __pHitElementResult->GetTagName();
3388 String type = __pHitElementResult->GetAttributeValue("type");
3389 String value = __pHitElementResult->GetAttributeValue(L"value");
3390 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3392 __currentSelectedStr.Clear();
3393 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3395 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0 && __isWebKeypadOpened == true)
3397 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3399 InitSelectTextContextMenu(currentPosition,true, true);
3400 __pImageMenu->SetShowState(true);
3401 __pImageMenu->Show();
3402 __pImageMenu->Invalidate(true);
3404 __isLongPressedDone = true;
3405 __pWebViewer->SetBlockSelectionPosition(currentPosition);
3408 __inputEventToBeSupressed = true;
3412 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3414 AppLog("MainForm::OnTouchReleased");
3416 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3417 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3419 __pWebViewer->ConsumeInputEvent();
3421 if(pHitElement != null)
3425 __inputEventToBeSupressed = false;
3429 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
3431 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
3432 int widthContextItem = 0;
3433 if(__pFindWordPanel != null)
3434 ShowFindWordPanel(__pFindWordPanel->GetShowState(), false);
3435 if ( __pFooterLabel != null)
3437 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
3440 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
3445 if (__pFindWordBgLabel != null)
3447 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
3448 if (pBitmap != null)
3450 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
3456 __pMenu->SetShowState(false);
3457 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
3459 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
3463 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
3468 AppLog("__pFooterPanel->GetShowState() is true");
3470 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3471 __pFooterPanel->Invalidate(true);
3475 if(__pMoreButton && __pMenu)
3477 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
3478 __pMenu->SetAnchorPosition(p);
3479 __pMenu->Invalidate(true);
3482 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
3483 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
3485 InitMostVisitedSitesView(orientationStatus);
3488 RelayoutControls(false);
3489 if (__pArticleReaderPanel != null)
3491 if (__pArticleReaderPanel->GetShowState() == true)
3493 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
3495 if (__pBlankPanel != null)
3496 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
3498 if (__pWebReader != null)
3500 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
3502 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3503 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3505 if ( pBitmap != null && pSrcBitmap != null)
3507 AppLog("CreateReaderPanel ninepatchbitmap found");
3508 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
3511 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
3512 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
3513 if (pBitmap != null)
3518 if (pSrcBitmap != null)
3527 if (__pAddressbar != null)
3529 int width = GetClientAreaBounds().width;
3530 __pAddressbar->OrientationChanged(width);
3535 MainForm::OnSettingsChange(int settingvalue)
3537 AppLogDebug("MainForm::OnSettingsChange entered");
3538 if (__pWebViewer == null)
3540 AppLogDebug("Webviewer is not initialized yet.");
3543 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
3545 WebSetting settings = __pWebViewer->GetSetting();
3546 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
3548 settings.SetAutoFittingEnabled(true);
3550 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
3552 settings.SetAutoFittingEnabled(false);
3554 __pWebViewer->SetSetting(settings);
3556 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
3558 WebSetting settings = __pWebViewer->GetSetting();
3559 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
3560 __pWebViewer->SetSetting(settings);
3562 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
3564 WebSetting settings = __pWebViewer->GetSetting();
3565 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
3566 __pWebViewer->SetSetting(settings);
3568 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
3570 WebSetting settings = __pWebViewer->GetSetting();
3571 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
3572 __pWebViewer->SetSetting(settings);
3574 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
3578 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3582 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
3584 WebSetting settings = __pWebViewer->GetSetting();
3585 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
3587 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
3591 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
3593 __pWebViewer->SetSetting(settings);
3595 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
3599 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
3600 WebSetting settings = __pWebReader->GetSetting();
3601 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
3602 __pWebReader->SetSetting(settings);
3608 MainForm::OnSettingsReset()
3612 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3613 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
3618 MainForm::OnClearCache()
3620 result r = E_SUCCESS;
3622 if (__pWebViewer != NULL)
3624 r = __pWebViewer->ClearCache();
3627 AppLogDebug("Cache cleared success");
3631 AppLogDebug("Cache cleared fail");
3637 MainForm::OnClearCookie()
3639 result r = E_SUCCESS;
3641 if (__pWebViewer != NULL)
3643 __pWebViewer->ClearCookie();
3647 AppLogDebug("Cookie cleared success");
3651 AppLogDebug("Cache cleared fail");
3656 MainForm::findDistance(int x1,int y1,int x2, int y2)
3658 int deltaX = Math::Abs(x2 - x1);
3659 int deltaY = Math::Abs(y2 - y1);
3660 double num = deltaX*deltaX + deltaY*deltaY;
3666 for (i = 0; i < 20; i++)
3668 x = (((x*x)+ num)/(2*x));
3679 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3681 if(__pFindWordPanel)
3683 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3684 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3686 __isLongPressedDone = false;
3689 IList* pList = null;
3690 pList = touch.GetTouchInfoListN(source);
3694 int count = pList->GetCount();
3697 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3698 __touchPoint1 = pTouchInfo->position;
3700 /*if (__pAddressbar != null)
3702 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3704 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3706 __pAddressbar->SaveAddressbarEditText();
3708 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3711 __pAddressbar->Invalidate(true);
3713 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3715 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3717 //__pAddressbar->SaveAddressbarEditText();
3719 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3722 else if (count == 2)
3724 AppLogDebug("MainForm::OnTouchPressed count is two");
3725 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3726 __touchPoint1 = pTouchInfo->position;
3728 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
3729 __touchPoint2 = pTouchInfo->position;
3735 pList->RemoveAll(true);
3742 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3744 __currentWordIndex = 0;
3745 __isLongPressedDone = false;
3750 MainForm::MoveUiControls()
3755 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
3757 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
3759 if(__pFooterUrlField->GetTextLength() == 0)
3761 __pFooterUrlField->SetKeypadActionEnabled(false);
3765 __pFooterUrlField->SetKeypadActionEnabled(true);
3768 if (__pFindWordEditField != null)
3770 __currentSearchStr = __pFindWordEditField->GetText();
3771 __pFindWordNext->SetEnabled(false);
3772 __pFindWordPrev->SetEnabled(false);
3773 __pFindWordNext->Invalidate(true);
3774 __pFindWordPrev->Invalidate(true);
3775 __pFindWordCountLabel->SetText(L"0/0");
3776 __pFindWordCountLabel->Invalidate(true);
3778 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
3779 if (__currentSearchStr.GetLength() > 0)
3785 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
3787 __currentSearchStr = L"";
3788 AppLogDebug("Enter something");
3793 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
3800 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
3802 if(__pWebViewer != null)
3805 AppLog("MainForm::InitMostVisitedSitesView");
3806 result r = E_SUCCESS;
3809 if (__pWebViewer != null && __pMostVisitedListView != null)
3814 if (__pMostVisitedListView != null)
3816 RemoveControl(*__pMostVisitedListView);
3818 if(__pMostVisitedSites != null)
3820 __pMostVisitedSites->RemoveAll(true);
3823 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
3825 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
3826 __pMostVisitedListView = new(std::nothrow) ListView();
3828 int height = GetClientAreaBounds().height;
3830 if(__pFooterPanel->GetShowState() == true)
3832 height = height - __pFooterPanel->GetHeight();
3834 if(__pAddressbar->GetShowState() == true)
3836 height -= __pAddressbar->GetHeight();
3839 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
3843 delete __pMostVisitedListView;
3844 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
3847 __pMostVisitedListView->SetItemProvider(*this);
3848 __pMostVisitedListView->AddListViewItemEventListener(*this);
3849 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
3850 AddControl(*__pMostVisitedListView);
3851 __pMostVisitedListView->UpdateList();
3858 MainForm::GetImagePath(void)
3862 String formattedTime;
3863 DateTime currentTime;
3864 LocaleManager localManager;
3865 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
3867 localManager.Construct();
3868 Locale locale = localManager.GetSystemLocale();
3869 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
3871 // Get date formatter
3872 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
3876 pTimeFormatter->Format(currentTime, formattedTime);
3879 AppLog("current time stamp is %ls", formattedTime.GetPointer());
3880 String delim(L" :");
3881 StringTokenizer strTok(formattedTime, delim);
3884 String str1("GMT+00");
3885 while (strTok.HasMoreTokens())
3887 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
3888 if(token.Equals(str1))
3890 AppLog("token is %ls", token.GetPointer());
3891 imageName.Append(token);
3897 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
3899 result r = E_FAILURE;
3900 AppLog("Content manager 1");
3901 ContentId contentId;
3902 ContentManager contentManager;
3903 r = contentManager.Construct();
3906 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
3909 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
3910 contentPath.Append(imageName);
3911 contentPath.Append(".jpg");
3912 contentId = contentManager.CreateContent(*aBuffer, contentPath);
3913 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
3917 MainForm::SetForwardButtonEnabled(bool isEnabled)
3919 __pGoForwardBtn->SetEnabled(isEnabled);
3920 __pGoBackBtn->Invalidate(true);
3924 MainForm::SetBackButtonEnabled(bool isEnabled)
3926 __pGoBackBtn->SetEnabled(isEnabled);
3927 __pGoBackBtn->Invalidate(true);
3931 MainForm::UpdateProgress(int percentage)
3933 __progressPercentage = percentage;
3934 if (percentage == 0 || percentage == 100)
3936 __isLoadingData = false;
3937 if (percentage == 100)
3939 __isLoadingCompleted = true;
3940 __progressPercentage = 0;
3944 __isLoadingCompleted = false;
3949 __isLoadingData = true;
3951 UpdateProgressBitmap();
3955 MainForm::GetProgress(void)
3957 return __progressPercentage;
3961 MainForm::UpdateProgressBitmap(void)
3963 result r = E_SUCCESS;
3964 if (__pProgressbarLabel == null)
3966 int w = __pProgressbarLabel->GetWidth();
3967 int h = __pProgressbarLabel->GetHeight();
3969 int progressWidth = 0;
3970 Bitmap* pRetBitmap = null;
3972 if (__progressPercentage == 0 || __progressPercentage == 100)
3974 __pProgressbarLabel->SetShowState(false);
3975 __pProgressbarLabel->Invalidate(false);
3980 __pProgressbarLabel->SetShowState(true);
3981 __pProgressbarLabel->Invalidate(false);
3984 r = canvas.Construct(Rectangle(0, 0, w, h));
3988 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
3993 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
3997 pBgBmp->Scale(Dimension(w, h));
3998 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4002 progressWidth = (double) (w) * __progressPercentage / 100;
4003 AppLogDebug("progressWidth: %d", progressWidth);
4004 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4006 if (pProgressBmp != null)
4008 pProgressBmp->Scale(Dimension(progressWidth, h));
4009 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4010 delete pProgressBmp;
4013 pRetBitmap = new (std::nothrow) Bitmap();
4015 if (pRetBitmap == null)
4017 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4021 pRetBitmap->Construct(canvas, canvas.GetBounds());
4023 if (__pProgressbarLabel != null && pRetBitmap != null)
4025 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4026 __pProgressbarLabel->Invalidate(false);
4029 if (pRetBitmap != null)
4037 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4039 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4041 __currentAddMode = addMode;
4045 case ADDRESSBAR_MODE_INVALID:
4050 case ADDRESSBAR_MODE_READER:
4052 __pStopBtn->SetShowState(false);
4053 __pClearBtn->SetShowState(false);
4056 case ADDRESSBAR_MODE_LOADING:
4058 __pRefreshBtn->SetShowState(false);
4059 __pStopBtn->SetShowState(true);
4060 __pClearBtn->SetShowState(false);
4063 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4065 // SetUrl(__pAddressbar->GetUrl());
4067 __pRefreshBtn->SetShowState(true);
4068 __pStopBtn->SetShowState(false);
4069 __pClearBtn->SetShowState(false);
4072 case ADDRESSBAR_MODE_EDIT:
4074 __pRefreshBtn->SetShowState(false);
4075 __pStopBtn->SetShowState(false);
4076 __pClearBtn->SetShowState(true);
4083 OnAddressBarModeChanged();
4086 AddressBarMode MainForm::GetAddressbarMode(void)
4088 return __currentAddMode;
4091 void MainForm::SetUrl(const String& url)
4095 if (__pFooterUrlField != NULL)
4097 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4098 if (removedHttpUrl.IsEmpty() == false)
4100 __pFooterUrlField->SetText(removedHttpUrl);
4101 __pAddressbar->SetUrl(__displayUrl);
4105 __pFooterUrlField->SetText(__displayUrl);
4106 __pAddressbar->SetUrl(__displayUrl);
4109 __pFooterUrlField->Invalidate(false);
4110 __pAddressbar->Invalidate(true);
4111 __pFooterUrlField->SetCursorPosition(0);
4116 MainForm::RemoveHttpTextFromDisplayURL(void)
4118 bool isHttpText = __displayUrl.Contains(L"http://");
4119 String updatedDisplayUrl;
4120 updatedDisplayUrl.Clear();
4122 if (isHttpText == true)
4124 __displayUrl.SubString(7,updatedDisplayUrl);
4126 return updatedDisplayUrl;