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;
193 MainForm::~MainForm(void)
195 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
199 __pAddressbar->SetAddressbarEventListener(null);
201 if (__pReaderData != null)
203 delete __pReaderData;
204 __pReaderData = null;
207 if (__pPopUp != null)
213 if (__pHitElementResult != null)
215 delete __pHitElementResult;
216 __pHitElementResult = null;
218 String* pSelectedScene = NULL;
219 Object* pValue = NULL;
220 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
221 pSelectedScene = (String*) pValue;
223 /*if (pSelectedScene != null)
225 delete pSelectedScene;
227 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
231 MainForm::Initialize(void)
233 Construct(L"IDL_FORM");
238 MainForm::OnInitializing(void)
240 AppLog("get client area width = %d",GetClientAreaBounds().width);
241 AppLog("get client area height = %d",GetClientAreaBounds().height);
242 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
243 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
245 Panel* pFooterPanel = null;
247 __pSaveImage = new Image();
248 __pSaveImage->Construct();
250 // Setup back event listener
251 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
252 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
253 AddOrientationEventListener(*this);
254 AppLogDebug(" MainForm::OnInitializing ended");
255 if (__pMostVisitedSites == null)
257 __pMostVisitedSites = new(std::nothrow) ArrayList();
258 __pMostVisitedSites->Construct();
260 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
262 __pItemContext= new(std::nothrow) ListContextItem();
263 __pItemContext->Construct();
264 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
265 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
267 if (pBitmapNormal != null && pBitmapPressed != null)
269 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
272 if (pBitmapNormal != null)
274 delete pBitmapNormal;
277 if (pBitmapPressed != null)
279 delete pBitmapPressed;
282 __pItemContextLandscape= new(std::nothrow) ListContextItem();
283 __pItemContextLandscape->Construct();
284 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
285 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
287 if (pBitmapNormal != null && pBitmapPressed != null)
289 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
292 if (pBitmapNormal != null)
294 delete pBitmapNormal;
297 if (pBitmapPressed != null)
299 delete pBitmapPressed;
306 MainForm::InitAddressbar(void)
308 AppLogDebug("MainForm::InitAddressbar entered");
310 result r = E_SUCCESS;
312 if (__pAddressbar != null)
316 __pAddressbar = new(std::nothrow) Addressbar();
317 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
318 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
321 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
324 __pAddressbar->SetAddressbarEventListener(this);
325 AddControl(*__pAddressbar);
326 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
327 SetControlAlwaysOnTop(*__pAddressbar, true);
328 __adressPanelPosition = __pAddressbar->GetPosition();
330 AppLogDebug("MainForm::InitAddressbar exit");
336 MainForm::CreateReaderPanel(void)
338 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
339 result r = E_FAILURE;
341 Button *pSmallFontBtn = null;
342 Button *pLargeFontBtn = null;
344 __pBlankPanel = new (std::nothrow) Panel();
345 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
347 __pArticleReaderPanel = new (std::nothrow) Panel();
348 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
350 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
351 if (__pReaderCloseBtn)
353 AppLogDebug("CreateReaderPanel() 6");
354 __pReaderCloseBtn->AddActionEventListener(*this);
355 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
358 __pWebReader = new (std::nothrow) Web();
359 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
361 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
362 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
364 r = __pWebReader->SetSetting(settings);
366 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
369 __pArticleReaderLabel = new Label();
370 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
372 __pBlankPanel->AddControl(*__pArticleReaderLabel);
373 __pBlankPanel->AddControl(*__pArticleReaderPanel);
374 AddControl(*__pBlankPanel);
376 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
377 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
378 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
380 __pArticleReaderPanel->AddControl(*__pWebReader);
381 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
382 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
383 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
385 if (pBitmap != null && pSrcBitmap != null)
387 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
389 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
391 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
394 pSmallFontBtn->AddActionEventListener(*this);
395 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
398 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
401 pLargeFontBtn->AddActionEventListener(*this);
402 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
411 if (pSrcBitmap != null)
417 SetControlAlwaysOnTop(*__pBlankPanel, true);
418 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
425 MainForm::InitWebControl()
427 AppLogDebug("MainForm::InitWebControl enter");
428 result r = E_SUCCESS;
429 AppLogDebug("InitWebControl");
431 if (__pAddressbar == null || __pFooterPanel == null)
434 const int Y_WEBCONTROL_POSITION = 0;
435 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
436 if (__pMostVisitedListView)
438 __pMostVisitedListView->SetShowState(false);
440 if (__pWebViewer != null)
442 AppLogDebug("Already initialized");
445 __pWebViewer = new(std::nothrow) Web();
446 if(__pWebViewer == NULL)
448 AppLogDebug("Initialization failed");
451 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight));
455 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
460 r = AddControl(*__pWebViewer);
464 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
467 __webControlPosition = __pWebViewer->GetPosition();
468 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
471 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
475 __pWebViewer->SetLoadingListener(this);
476 __pWebViewer->SetWebUiEventListener(this);
477 __pWebViewer->SetWebKeypadEventListener(this);
478 __pWebViewer->SetFocus();
479 __pWebViewer->AddTouchEventListener(*this);
481 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
482 __pWebViewer->SetTextSearchListener(this);
485 AppLogDebug("MainForm :before return");
487 AppLogDebug("MainForm::InitWebControl Exit");
493 MainForm::SetJavascriptEnabled()
495 WebSetting settings = __pWebViewer->GetSetting();
496 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
497 __pWebViewer->SetSetting(settings);
501 MainForm::SetImageLoadEnabled()
503 WebSetting settings = __pWebViewer->GetSetting();
504 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
505 __pWebViewer->SetSetting(settings);
509 MainForm::InitFooter(void)
511 AppLogDebug("MainForm::InitFooter entered");
512 Button* pBackButton = null;
513 Button* pBookmarkButton = null;
514 Button* pMultiWindowButton = null;
515 Bitmap *pIconBitmap = null;
516 Bitmap *pBGBitmap = null;
517 Label *pBGLabel = null;
519 if (__pFooterPanel == null)
521 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
524 if (__pFooterPanel == null)
529 SetControlAlwaysOnTop(*__pFooterPanel, true);
531 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
532 if ( __pFooterLabel == NULL )
536 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
537 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
540 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
544 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
546 if ( __pMultiWindowButton == NULL )
551 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
553 if ( __pMoreButton == NULL )
558 if (__pMultiWindowButton != null)
560 Bitmap* pBitmap = null;
561 Bitmap* pPressedBitmap = null;
562 String imagePath = "I01_toolbar_icon_windows_manager_0";
563 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
564 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
565 imagePath.Append(totalCount);
566 imagePath.Append(".png");
568 pressedImagePath.Append(totalCount);
569 pressedImagePath.Append("_press.png");
571 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
572 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
573 if ( pBitmap == null )
578 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
581 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
582 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
587 __pMultiWindowButton->AddActionEventListener(*this);
588 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
593 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
594 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
597 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
598 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
599 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
603 __pMoreButton->AddActionEventListener(*this);
604 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
607 //Add the editfield for url
608 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
609 if (__pFooterUrlField == NULL)
611 return E_INVALID_KEY;
614 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
615 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
616 //__pFooterUrlField->AddFocusEventListener(*this);
617 __pFooterUrlField->AddKeypadEventListener(*this);
619 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
621 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
623 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
625 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
629 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
630 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
633 //Add the go Back Button
634 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
635 if (__pGoBackBtn == NULL)
637 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
638 return E_INVALID_KEY;
640 __pGoBackBtn->SetActionId(IDA_GO_BACK);
641 __pGoBackBtn->AddActionEventListener(*this);
643 //Add the go forward Button
644 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
645 if (__pGoForwardBtn == NULL)
647 AppLogDebug("Control not found returning E_INVALID_KEY");
648 return E_INVALID_KEY;
650 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
651 __pGoForwardBtn->AddActionEventListener(*this);
652 __pGoForwardBtn->SetEnabled(false);
654 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
655 if (__pRefreshBtn == NULL)
657 AppLogDebug("Control not found returning E_INVALID_KEY");
658 return E_INVALID_KEY;
661 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
662 __pRefreshBtn->AddActionEventListener(*this);
663 __pRefreshBtn->SetShowState(true);
665 //Add the backround label for displaying progressbar
666 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
667 if (__pProgressbarLabel == NULL)
669 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
670 return E_INVALID_KEY;
672 __pProgressbarLabel->SetShowState(false);
674 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
675 if (__pStopBtn == NULL)
677 AppLogDebug("Control not found returning E_INVALID_KEY");
678 return E_INVALID_KEY;
680 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
681 __pStopBtn->AddActionEventListener(*this);
682 __pStopBtn->SetShowState(false);
684 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
685 if (__pClearBtn == NULL)
687 AppLogDebug("Control not found returning E_INVALID_KEY");
688 return E_INVALID_KEY;
690 __pClearBtn->SetActionId(IDA_CLEAR_URL);
691 __pClearBtn->AddActionEventListener(*this);
692 __pClearBtn->SetShowState(false);
694 // __pFooterPanel->Invalidate(true);
695 AppLogDebug("MainForm::InitFooter exit");
701 MainForm::InitContextMenu(Point& p)
703 result r = E_SUCCESS;
704 bool isPrivateBrowsing = false;
705 Bitmap* pBitmap = null;
709 __pMenu->SetAnchorPosition(p);
710 __pMenu->Invalidate(true);
714 __pMenu = new(std::nothrow) ContextMenu();
715 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST);
716 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
718 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
721 if (isPrivateBrowsing == true)
723 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
727 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
730 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
732 if ( pBitmap != NULL)
734 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"), IDA_PRIVATEON_CLICKED,*pBitmap);
737 r = __pMenu->AddItem(L"History"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_HISTORY_CLICKED);
738 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
739 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
742 __pMenu->SetMaxVisibleItemsCount(6);
743 __pMenu->SetShowState(false);
744 __pMenu->AddActionEventListener(*this);
745 SetControlAlwaysOnTop(*__pMenu, true);
751 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
753 result r = E_SUCCESS;
754 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
756 AppLog("MainForm::InitImageContextMenu clicked on image");
757 if (__pImageMenu != null)
763 p.y = p.y + __pAddressbar->GetHeight() + 12;
766 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
770 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
772 __pImageMenu = new (std::nothrow) ContextMenu();
773 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
774 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
776 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
777 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
778 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
779 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_IMAGE_CLICKED);
780 __pImageMenu->SetMaxVisibleItemsCount(4);
781 __pImageMenu->AddActionEventListener(*this);
782 SetControlAlwaysOnTop(*__pImageMenu, true);
787 result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
789 result r = E_SUCCESS;
790 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
792 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
793 if (__pImageMenu != null)
798 p.y = p.y + __pAddressbar->GetHeight() + 12;
801 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
805 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
807 __pImageMenu = new (std::nothrow) ContextMenu();
808 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
809 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
811 if(onlyPasteOption == false)
813 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
815 if (pasteOption || onlyPasteOption)
817 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
819 if(onlyPasteOption == false)
821 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
822 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
825 __pImageMenu->SetMaxVisibleItemsCount(3);
826 __pImageMenu->AddActionEventListener(*this);
827 SetControlAlwaysOnTop(*__pImageMenu, true);
834 MainForm::InitFindWordPanel(void)
836 result r = E_SUCCESS;
837 Bitmap *pIconBitmap = null;
839 if (__pFindWordPanel != null)
841 AppLogDebug("Findword panel already initialized");
842 if (__pFindWordBgLabel != null)
844 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
847 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
854 __pFindWordPanel = static_cast<Panel*>(GetControl(L"IDC_FIND_ON_PAGE_PANEL"));
855 if (__pFindWordPanel == null)
857 AppLogException("There is some problem in the xml file. Please check.");
861 __pFindWordControl = new (std::nothrow) Panel();
862 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
865 AppLogException("There is some problem in the xml file. Please check.");
868 AddControl(*__pFindWordControl);
869 __pFindWordControl->SetBounds(0,0, __pFindWordPanel->GetWidth(), __pFindWordPanel->GetHeight());
870 SetControlAlwaysOnTop(*__pFindWordControl,true);
871 __pFindWordPanel->SetShowState(false);
872 __pFindWordPanel->Invalidate(false);
874 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
875 if (__pFindWordBgLabel != null)
877 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
878 Rectangle pRect = pPanel1->GetBounds();
879 pRect.x = pRect.y = 0;
880 __pFindWordBgLabel->SetBounds(pRect);
881 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
884 AppLogDebug("InitFindWordPanel: Coming here");
885 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
890 AppLogDebug("InitFindWordPanel: shouldn't Come here");
894 Button* pfindWordCancel = null;
895 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
896 if (pfindWordCancel == null)
898 AppLogException("There is some problem in the xml file. Please check.");
901 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
902 pfindWordCancel->AddActionEventListener(*this);
904 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
905 if (__pFindWordClear == null)
907 AppLogException("There is some problem in the xml file. Please check.");
911 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
912 __pFindWordClear->AddActionEventListener(*this);
914 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
915 if (__pFindWordNext == null)
917 AppLogException("There is some problem in the xml file. Please check.");
921 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
922 __pFindWordNext->AddActionEventListener(*this);
924 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
925 if (__pFindWordPrev == null)
927 AppLogException("There is some problem in the xml file. Please check.");
931 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
932 __pFindWordPrev->AddActionEventListener(*this);
934 __pFindWordNext->SetEnabled(false);
935 __pFindWordPrev->SetEnabled(false);
937 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
938 if (__pFindWordCountLabel == null)
940 AppLogException("There is some problem in the xml file. Please check.");
944 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
945 if (__pFindWordEditField == null)
947 AppLogException("There is some problem in the xml file. Please check.");
950 __pFindWordEditField->AddTextEventListener(*this);
951 __pFindWordEditField->AddKeypadEventListener(*this);
952 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
958 MainForm::CreateItem (int index, int itemWidth)
960 Rectangle listImageRect;
961 Rectangle pagetTitleRect;
962 Rectangle pageURLRect;
963 Rectangle deleteImageRect;
964 String pageTitle(L"");
966 result r = E_SUCCESS;
967 Bitmap* pListIconImage = null;
970 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
975 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
976 if ( pAppResource == NULL )
980 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
982 CustomItem* pItem = new(std::nothrow) CustomItem();
983 pageTitle = pHistory->GetHistoryTitle();
984 pageURL = pHistory->GetHistoryUrl();
986 if (pageURL.GetLength() == 0)
989 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
990 pageURL = L"<"+ nourl +">";
994 Rectangle screenBounds = GetBounds();
997 r = pItem->Construct(Dimension(itemWidth, 128), style);
1006 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1008 if ( pBitmap != NULL)
1010 pListIconImage = new Bitmap();
1011 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1015 if(pListIconImage == null)
1017 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1020 if ( pListIconImage != NULL)
1022 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1023 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1024 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1027 if (pItem != null && pListIconImage != NULL)
1029 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1033 if (pageTitle.CompareTo(L"") != 0)
1037 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1041 if (pageURL.CompareTo(L"") != 0)
1045 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1050 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1052 if ( __pItemContext!= NULL)
1056 pItem->SetContextItem(__pItemContext);
1062 if ( __pItemContextLandscape!= NULL)
1066 pItem->SetContextItem(__pItemContextLandscape);
1070 if( pListIconImage != NULL)
1072 delete pListIconImage;
1073 pListIconImage = null;
1080 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1087 MainForm::GetItemCount (void)
1089 if(__pMostVisitedSites != null)
1091 __pMostVisitedSites->RemoveAll(true);
1093 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1094 if(__pMostVisitedSites != null)
1096 return __pMostVisitedSites->GetCount();
1103 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1105 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1106 String url = pHistory->GetHistoryUrl();
1107 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1108 __pMostVisitedListView->UpdateList();
1112 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1114 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1115 String url = pHistory->GetHistoryUrl();
1123 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1129 MainForm::OnTerminating(void)
1131 result r = E_SUCCESS;
1134 delete __pItemContext;
1136 if(__pItemContextLandscape)
1138 delete __pItemContextLandscape;
1144 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1146 result r = E_SUCCESS;
1148 AppLogDebug("Clicked : %d", actionId);
1151 case IDA_BACKBTN_CLICKED:
1153 if (__pWebViewer && __pWebViewer->CanGoBack())
1155 __pWebViewer->GoBack();
1160 pApp = UiApp::GetInstance();
1163 r = pApp->Terminate();
1166 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1174 case IDA_FORWARD_CLICKED:
1175 if (__pWebViewer == null)
1178 if (__pWebViewer->CanGoForward())
1180 __pWebViewer->GoForward();
1182 __pMenu->SetShowState(false);
1183 __pMenu->Invalidate(false);
1186 case IDA_FINDONPAGE_CLICKED:
1188 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1189 __currentSearchStr.Clear();
1191 InitFindWordPanel();
1192 __pMenu->SetShowState(false);
1193 __pMenu->Invalidate(false);
1195 __pFindWordEditField->SetFocus();
1197 if (__pWebViewer != null)
1199 // releasing the set block
1200 __pWebViewer->ReleaseBlock();
1203 ShowFindWordPanel(true);
1206 case IDA_PRIVATEON_CLICKED:
1208 result r = E_SUCCESS;
1210 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1211 Bitmap* pBitmap = null;
1212 if (isPrivateBrowsing == true)
1214 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1217 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1221 if (__pWebViewer != NULL)
1223 __pWebViewer->SetPrivateBrowsingEnabled(false);
1226 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1228 if (__pAddressbar != null)
1230 __pAddressbar->UpdateFaviconBitmap(false);
1236 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1239 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1243 if (__pWebViewer != NULL)
1245 __pWebViewer->SetPrivateBrowsingEnabled(true);
1248 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1250 if (__pAddressbar != null)
1252 __pAddressbar->UpdateFaviconBitmap(true);
1257 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1258 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1259 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1260 __pMenu->Invalidate(true);
1262 if ( pBitmap != NULL )
1269 case IDA_SETTINGS_CLICKED:
1272 ArrayList* pArgList = new(std::nothrow) ArrayList();
1275 pArgList->Construct();
1276 pArgList->Add(*__pWindowInfo);
1277 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1279 __pMenu->SetShowState(false);
1280 __pMenu->Invalidate(false);
1281 if (pArgList != null)
1290 case IDA_ADDTOBOOKMARK_CLICKED:
1293 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1295 int bookmarkCount=0;
1298 url=__pWindowInfo->pageUrl;
1299 result r = E_SUCCESS;
1300 Bitmap* pBitmap = null;
1301 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1309 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1310 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1311 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1313 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1314 if (pNotification != null)
1316 pNotification->SetText(message);
1317 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1318 pNotification->ShowNotification();
1323 String title=__pWindowInfo->pageTitle;
1324 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1325 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1327 pBookmark->SetBookmarkTitle(title);
1328 pBookmark->SetUrl(url);
1329 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1331 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1333 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1334 pBookmark->SetFaviconId(id);
1335 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1336 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1339 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1340 if (pNotification != null)
1342 pNotification->SetText(message);
1343 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1344 pNotification->ShowNotification();
1345 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1348 if (pBitmap != null)
1350 r = __pMenu->SetItemAt(0,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1354 __pMenu->Invalidate(true);
1358 case IDA_SHARE_CLICKED:
1360 if(__pPopUp != null)
1365 __pPopUp = new(std::nothrow) SharePopup();
1366 __pPopUp->Initialize();
1367 if (__pWindowInfo != null)
1369 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1370 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1371 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1372 pShareInfo->SetImageAttached(false);
1373 __pPopUp->RemoveAllShareInfo();
1374 __pPopUp->AddShareInfo(pShareInfo);
1376 __pPopUp->SetShowState(true);
1380 case IDA_BOOKMARKBTN_CLICKED:
1382 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1383 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1386 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1391 case IDA_MOREBTN_CLICKED:
1393 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1394 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1395 AppLog("Anchot pos: %d %d", p.x, p.y);
1397 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1399 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1400 int bookmarkCount=0;
1403 url=__pWindowInfo->pageUrl;
1404 result r = E_SUCCESS;
1405 Bitmap* pBitmap = null;
1407 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1410 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1415 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1419 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1421 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1423 if (__pMenu->GetItemCount() == 9)
1425 r = __pMenu->SetItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1429 r = __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1434 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1438 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1439 if (__pMenu->GetItemCount() != 8)
1441 __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADDTOBOOKMARK_CLICKED);
1443 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1444 __pMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1445 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1446 __pMenu->SetMaxVisibleItemsCount(6);
1448 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1450 AppLog(" Orientation landscape");
1451 __pMenu->SetMaxVisibleItemsCount(5);
1455 AppLog(" Orientation potrait");
1456 __pMenu->SetMaxVisibleItemsCount(6);
1459 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1462 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1463 __pMenu->SetShowState(true);
1464 __pMenu->Invalidate(true);
1468 case IDA_HISTORY_CLICKED:
1470 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1471 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1474 case IDA_SAVED_PAGES_CLICKED:
1479 case IDA_DESKTOP_VIEW_CLICKED:
1484 case IDA_SAVE_CLICKED:
1489 case IDA_MULTIWINDOWBTN_CLICKED:
1491 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1492 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1496 case IDA_NEWWINDOWBTN_CLICKED:
1498 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1500 if (pNewWindowInfo == null)
1504 result r = E_SUCCESS;
1505 SceneManager* pSceneManager = SceneManager::GetInstance();
1507 if (pSceneManager == NULL)
1511 ArrayList* pArgList = new(std::nothrow) ArrayList();
1512 if (pArgList == NULL)
1516 r = pArgList->Construct();
1519 pArgList->Add(*pNewWindowInfo);
1520 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1526 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1531 case IDA_SMALLFONT_BTN_CLICKED:
1533 WebSetting setting = __pWebReader->GetSetting();
1534 setting.SetFontSize(15);
1535 __pWebReader->SetSetting(setting);
1538 case IDA_LARGEFONT_BTN_CLICKED:
1540 WebSetting setting = __pWebReader->GetSetting();
1541 setting.SetFontSize(25);
1542 __pWebReader->SetSetting(setting);
1545 case IDA_READER_CLOSE_CLICKED:
1547 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1549 //__pArticleReaderPanel->SetShowState(false);
1550 //__pArticleReaderPanel->Show();
1551 RemoveControl(*__pBlankPanel);
1552 //RemoveControl(*__pArticleReaderPanel);
1553 __pArticleReaderPanel = null;
1554 __pBlankPanel = null;
1555 __pArticleReaderLabel = null;
1557 //if (__pAddressbar)
1558 // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1559 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1562 case IDA_FINDWORD_CANCEL_CLICKED:
1564 __currentSearchStr = L"";
1565 __currentWordIndex = 0;
1566 __maxOccurrances = 0;
1567 __pFindWordEditField->SetText(L"");
1568 __pFindWordNext->SetEnabled(false);
1569 __pFindWordPrev->SetEnabled(false);
1570 __pFindWordCountLabel->SetText(L"0/0");
1571 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1572 ShowFindWordPanel(false);
1575 case IDA_FINDWORD_SEARCH_CLICKED:
1577 __currentSearchStr = __pFindWordEditField->GetText();
1578 if (__currentSearchStr.GetLength() > 0)
1584 AppLogDebug("Enter something");
1588 case IDA_FINDWORD_CLEAR_CLICKED:
1590 __pFindWordCountLabel->SetText(L"0/0");
1591 __pFindWordEditField->SetText(L"");
1592 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1594 __currentSearchStr = L"";
1595 __pFindWordNext->SetEnabled(false);
1596 __pFindWordPrev->SetEnabled(false);
1597 __pFindWordPanel->Invalidate(true);
1600 case IDA_FINDWORD_NEXT_CLICKED:
1605 case IDA_FINDWORD_PREV_CLICKED:
1607 FindNextWord(false);
1610 case IDA_BRIGHTNESS_BTN_CLICKED:
1612 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1613 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1616 case IDA_COPY_IMAGE_CLICKED:
1618 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1619 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1621 const Bitmap* pBitmap = null;
1622 if (__pHitElementResult != null)
1624 pBitmap = __pHitElementResult->GetImage();
1627 String resourcePath = App::GetInstance()->GetAppResourcePath();
1628 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1630 // copying the item to clipboard
1631 Clipboard* pClipboard = Clipboard::GetInstance();
1632 if (pClipboard != null)
1634 pClipboard->CopyItem(item);
1638 case IDA_VIEW_IMAGE_CLICKED:
1640 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1641 WindowInfo* pNewWindowInfo = null;
1642 if (__pHitElementResult != null)
1644 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1645 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1651 case IDA_SAVE_IMAGE_CLICKED:
1653 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1654 const Bitmap* pSaveBitmap = null;
1655 String imageName = GetImagePath();
1656 AppLog("Content manager image name %ls",imageName.GetPointer());
1659 imagePath.Append(imageName);
1660 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1661 AppLog("Content manager image path %ls",imagePath.GetPointer());
1662 if (__pHitElementResult != null)
1664 pSaveBitmap = __pHitElementResult->GetImage();
1666 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1670 UpdateImageContent(pBuffer, imageName);
1672 NotificationPanel *pNotification = new NotificationPanel(*this);
1674 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1675 msg.Append(imagePath);
1676 if (pNotification != null)
1678 pNotification->SetText(msg);
1679 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1680 pNotification->ShowNotification();
1685 int __modalMsgBoxResult;
1686 MessageBox* pMsgBox = new MessageBox();
1687 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1688 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1691 __modalMsgBoxResult = 0;
1695 case IDA_SHARE_IMAGE_CLICKED:
1697 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1698 if (__pPopUp != null)
1703 __pPopUp = new(std::nothrow) SharePopup();
1704 __pPopUp->Initialize();
1705 if (__pHitElementResult != null)
1707 const Bitmap* pSaveBitmap = null;
1708 String imageName = GetImagePath();
1709 AppLog("Content manager image name %ls",imageName.GetPointer());
1712 imagePath.Append(imageName);
1713 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1714 AppLog("Content manager image path %ls",imagePath.GetPointer());
1715 if (__pHitElementResult != null)
1717 pSaveBitmap = __pHitElementResult->GetImage();
1719 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1721 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1722 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1724 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1725 pShareInfo->SetPageTitle(L"");
1726 pShareInfo->SetPageUrl(srcUrl);
1727 pShareInfo->SetImageAttached(true);
1728 pShareInfo->SetImagePath(imagePath);
1729 __pPopUp->RemoveAllShareInfo();
1730 __pPopUp->AddShareInfo(pShareInfo);
1731 __pPopUp->SetShowState(true);
1736 case IDA_FIND_TEXT__CLICKED:
1738 AppLogDebug("MainForm::OnActionPerformed find word clicked");
1739 __currentSearchStr.Clear();
1740 __currentSearchStr.Append(__currentSelectedStr);
1741 InitFindWordPanel();
1744 __pMenu->SetShowState(false);
1745 __pMenu->Invalidate(false);
1748 __adressPanelPosition.y = 0;
1750 if (__pAddressbar != null && __pWebViewer != NULL)
1752 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
1753 //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
1754 //__pAddressbar->Invalidate(true);
1755 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
1757 if (__pFooterPanel->GetShowState() == false)
1758 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
1760 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
1761 // __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
1762 __pWebViewer->Invalidate(true);
1765 ShowFindWordPanel(true);
1766 if (__currentSearchStr.GetLength() > 0)
1772 AppLogDebug("Enter something");
1775 if (__pWebViewer != null)
1777 // releasing the set block
1778 __pWebViewer->ReleaseBlock();
1783 case IDA_SHARE_TEXT_CLICKED:
1785 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
1786 if(__pPopUp != null)
1791 __pPopUp = new(std::nothrow) SharePopup();
1792 __pPopUp->Initialize();
1793 if (__pHitElementResult != null)
1795 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1796 pShareInfo->SetPageTitle(L"");
1797 pShareInfo->SetPageUrl(__currentSelectedStr);
1798 pShareInfo->SetImageAttached(false);
1799 __pPopUp->RemoveAllShareInfo();
1800 __pPopUp->AddShareInfo(pShareInfo);
1801 __pPopUp->SetShowState(true);
1806 case IDA_COPY_TEXT_CLICKED:
1808 // need to implement
1809 //__currentSelectedStr
1810 // Sets data to a clip board item
1812 String resourcePath = App::GetInstance()->GetAppResourcePath();
1813 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
1815 // copying the item to clipboard
1816 Clipboard* pClipboard = Clipboard::GetInstance();
1817 if (pClipboard != null)
1819 pClipboard->CopyItem(item);
1823 case IDA_PASTE_TEXT_CLICKED:
1825 Clipboard* pClipboard = Clipboard::GetInstance();
1827 if(pClipboard == null)
1831 // Retrieves a latest item
1832 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
1838 //Gets data from the clipboard item
1839 String* pString = dynamic_cast<String*>(pItem->GetData());
1841 if (pString != null)
1843 String idElement = __pHitElementResult->GetAttributeValue(L"id");
1844 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
1845 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
1846 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; } } ";
1847 if(idElement.GetLength() != 0)
1849 script.Append("insertAtCursor(");
1850 script.Append(idElement);
1852 script.Append("\"");
1853 script.Append(*pString);
1854 script.Append("\");");
1856 else if (nameElement.GetLength() != 0)
1858 script.Append("insertAtCursor(document.getElementsByName('");
1859 script.Append(nameElement);
1860 script.Append("')[0],");
1861 script.Append("\"");
1862 script.Append(*pString);
1863 script.Append("\");");
1865 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
1866 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
1877 case IDA_GO_FORWARD:
1882 case IDA_REFRESH_BTN_CLICKED:
1884 __isLoadingCompleted = false;
1885 __isLoadingData = true;
1886 __progressPercentage = 0;
1887 __displayUrl = __pFooterUrlField->GetText();
1889 String url = __pFooterUrlField->GetText();
1890 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
1894 UpdateProgressBitmap();
1897 case IDA_STOP_BTN_CLICKED:
1899 __isLoadingCompleted = false;
1900 __isLoadingData = false;
1901 __progressPercentage = 0;
1902 __pFooterUrlField->HideKeypad();
1903 __displayUrl = __pFooterUrlField->GetText();
1907 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1908 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1909 __pWebViewer->StopLoading();
1910 RequestRedraw(true);
1913 UpdateProgressBitmap();
1918 if (__pFooterUrlField->GetText().IsEmpty() == false)
1920 //__displayUrl = __pUrlField->GetText();
1921 __pFooterUrlField->Clear();
1931 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
1934 UiApp* pApp = UiApp::GetInstance();
1943 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
1944 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
1946 String* pSelectedScene = NULL;
1947 Object* pValue = NULL;
1948 String* pUrl = null;
1949 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
1950 pSelectedScene = (String*) pValue;
1952 if (pSelectedScene != null)
1954 delete pSelectedScene;
1956 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
1957 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
1958 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
1959 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
1961 // setting the current scene ID
1962 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
1964 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
1966 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
1968 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
1969 if(__pWindowInfo == null)
1971 // if(__pWindowInfo == null)
1973 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
1976 else if ( pArgs != null && pArgs->GetCount() == 1)
1978 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
1984 // hiding the address bar
1985 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
1986 __pAddressbar->SetShowState(false);
1987 if(__pWebViewer != null)
1989 __pWebViewer->Resume();
1992 if(pUrl != null && pUrl->GetLength() > 0)
1996 else if(__pWindowInfo != null)
1998 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)
2000 LoadUrl(__pWindowInfo->pageUrl);
2002 else if (__pWindowInfo->isJavascriptInitiated == true)
2006 __pWindowInfo->pCurrentWeb = __pWebViewer;
2010 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2011 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2012 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2014 InitMostVisitedSitesView(GetOrientationStatus());
2017 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2019 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2021 if (pBookmarkUrl == null)
2023 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2024 //__pAddressbar->SetUrl(*pBookmarkUrl);
2025 SetUrl(*pBookmarkUrl);
2027 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2028 __pWebViewer->LoadUrl(*pBookmarkUrl);
2029 delete pBookmarkUrl;
2032 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2033 Bitmap* pBitmap = null;
2034 if (isPrivateBrowsing == true)
2036 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2038 if (__pWebViewer != null)
2040 __pWebViewer->SetPrivateBrowsingEnabled(true);
2043 if (__pAddressbar != null)
2045 // __pAddressbar->UpdateFaviconBitmap(true);
2051 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2053 if (__pWebViewer != null)
2055 __pWebViewer->SetPrivateBrowsingEnabled(false);
2058 if (__pAddressbar != null)
2060 // __pAddressbar->UpdateFaviconBitmap(false);
2064 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2066 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2068 else if (__pMenu != null )
2070 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2073 if (pBitmap != null)
2078 AppLog("ABC: OnSceneActivatedN started exit");
2083 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2084 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2086 Canvas* pWebCanvas = null;
2087 if (__pWebViewer != null)
2089 pWebCanvas = __pWebViewer->GetCanvasN();
2090 __pWebViewer->Pause();
2093 if (pWebCanvas == null)
2097 if (__pWindowInfo != null)
2099 if (__pWindowInfo->pWebCanvasBitmap != null)
2101 delete __pWindowInfo->pWebCanvasBitmap;
2103 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2104 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2105 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2107 Bitmap* pBitmap = GetCapturedBitmapN();
2108 AppLog("Coming here");
2109 Canvas* pCanvas = new(std::nothrow) Canvas();
2110 pCanvas->Construct(GetClientAreaBounds());
2113 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2116 if(__pWebViewer != null && __pWindowInfo != null)
2117 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2119 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2120 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2122 AppLog("Coming here");
2126 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2127 const Tizen::Base::String& realm,
2128 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2134 MainForm::OnHttpAuthenticationCanceled(void)
2139 MainForm::OnLoadingStarted(void)
2141 AppLogDebug("MainForm::OnLoadingStarted entered");
2143 if(__pAddressbar == NULL)
2147 String url = __pWebViewer->GetUrl();
2148 if(url.Contains(IDS_TIZEN_SERVICE))
2151 String delim(L":;");
2153 // Creates a StringTokenizer instance
2154 StringTokenizer strTok(url, delim);
2156 int count = strTok.GetTokenCount(); // count == 4
2158 HashMap *pMap = new HashMap();
2163 while (strTok.HasMoreTokens())
2165 AppLog("Token: %ls", token.GetPointer());
2166 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2167 if(token.Contains(IDS_APPID))
2169 token.SubString(6, appId);
2170 AppLog("AppID:%ls", appId.GetPointer());
2172 else if(token.Contains("="))
2174 String *pKey = new String();
2175 String *pValue = new String();
2177 token.IndexOf("=", 0, index);
2180 token.SubString(0, index, *pKey);
2181 token.SubString(index + 1, *pValue);
2182 pMap->Add(pKey, pValue);
2188 AppControl *pAppControl = null;
2189 String operationId = L"http://tizen.org/appcontrol/operation/main";
2190 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2193 AppLog("Starting AppControl");
2194 result r = pAppControl->Start(null, null, pMap, null);
2195 AppLog("Result of Start %s", GetErrorMessage(r));
2199 AppLogException("AppControl not found");
2204 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2207 __pAddressbar->SetFaviconBitmap(*pBitmap);
2210 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2212 // updating the address bar position with respect to web control
2213 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2214 __distanceMoved = 0;
2218 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2219 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2222 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2223 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2224 SetUrl(__pWebViewer->GetUrl());
2225 if (__pWindowInfo != NULL)
2227 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2229 __pAddressbar->Invalidate(true);
2235 MainForm::OnLoadingCanceled(void)
2242 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2244 AppLog("MainForm::OnKeypadWillOpen");
2245 if (__pAddressbar != null)
2247 OnAddressBarKeypadWillOpen(*__pAddressbar);
2253 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2255 if(__pAddressbar != null)
2257 OnAddressBarKeypadOpened(*__pAddressbar);
2263 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2265 if (__pAddressbar != null)
2267 OnAddressBarKeypadClosed(*__pAddressbar);
2272 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2274 AppLog("KeypadBoundsChanged");
2275 RelayoutControls(false);
2279 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2280 const Tizen::Base::String& reason)
2282 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2286 MainForm::OnLoadingCompleted(void)
2288 AppLog("MainForm::OnLoadingCompleted start");
2290 result r = E_SUCCESS;
2292 if (__pWebViewer == null)
2297 if (__pAddressbar == null)
2301 if (__pWebViewer->CanGoForward())
2303 //__pAddressbar->SetForwardButtonEnabled(true);
2304 SetForwardButtonEnabled(true);
2308 //__pAddressbar->SetForwardButtonEnabled(false);
2309 SetForwardButtonEnabled(false);
2312 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2314 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2316 //__pAddressbar->UpdateProgress(0);
2320 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2322 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2326 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2327 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2328 if (isPrivateBrowsing == false)
2330 History* pHistory = new(std::nothrow) History;
2332 HistoryPresentationModel::GetCurrentDateTime(date);
2335 pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2336 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2338 pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2339 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2341 pHistory->SetVisitedTime(date);
2344 id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2345 pHistory->SetFaviconId(id);*/
2347 if (__pWebViewer != null)
2349 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2351 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2352 if (pTempBitmap != null)
2354 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2355 pHistory->SetFavIconBitmap(*pTempBitmap);
2358 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2361 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2362 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2363 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2365 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2366 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2367 pHistory->SetThumbnail(pBitmap);
2369 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2372 pHistory->SetFavIconBitmap(*pFavIcon);
2376 HistoryPresentationModel::GetInstance()->SaveTempHistory(*pHistory);
2383 if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2385 // temperary fixed (webpage can be not loaded)
2388 AppLog("MainForm::OnLoadingCompleted done");
2392 MainForm::OnEstimatedProgress(int progress)
2394 AppLogDebug("MainForm::OnEstimatedProgress entered");
2395 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2396 progress = DEFAULT_PROGRESS_PERCENTAGE;
2398 // __pAddressbar->UpdateProgress(progress);
2399 UpdateProgress(progress);
2402 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2404 AppLog("MainForm::OnFaviconReceived");
2405 Bitmap* pFavIconBitmap = __pWebViewer->GetFaviconN();
2407 if (pFavIconBitmap != null)
2409 pFavIconBitmap->GetWidth();
2410 pFavIconBitmap->GetHeight();
2415 MainForm::OnUrlValueChanged(Addressbar&)
2421 MainForm::OnUrlSubmitted(Addressbar& addBar)
2423 AppLog("MainForm::OnUrlSubmitted");
2424 String url = addBar.GetUrl();
2425 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2427 __pFooterPanel->SetShowState(true);
2428 // __pAddressbar->SetShowState(false);
2429 // RelayoutControls(false);
2434 MainForm::LoadUrl(String& url)
2437 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2438 AppLogDebug("MainForm::LoadUrl enter");
2440 if (__pWebViewer != null)
2442 __pWebViewer->SetShowState(true);
2443 __pWebViewer->Invalidate(true);
2446 if (url.CompareTo(L"") == 0)
2450 if(__pFooterPanel != null)
2452 __pFooterPanel->SetShowState(true);
2453 __pFooterPanel->Invalidate(true);
2460 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2461 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)
2463 RegularExpression firstRegex;
2464 RegularExpression secondRegex;
2466 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2467 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2470 ret = firstRegex.Match(url, false); // This returns true value
2471 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2473 if (ret == true && __pWebViewer != null)
2475 __pWebViewer->LoadUrl(url);
2477 else if(__pWebViewer != null)
2479 String tempUrl = L"http://";
2480 tempUrl.Append(url);
2484 __pWebViewer->LoadUrl(tempUrl);
2488 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2489 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2492 if (__pAddressbar != null)
2494 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2495 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2498 AppLogDebug("MainForm::LoadUrl exit");
2505 MainForm::OnStopClicked(Addressbar& addBar)
2507 AppLogDebug("MainForm::OnStopClicked called");
2510 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2511 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2512 __pWebViewer->StopLoading();
2513 RequestRedraw(true);
2518 MainForm::OnReaderClicked(const Addressbar& addBar)
2520 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2522 CreateReaderPanel();
2523 AppLogDebug("MainScene::OnReaderClicked entered");
2526 /*if (__pArticleReaderPanel)
2528 AppLogDebug("showstate true for reader panel");
2529 __pArticleReaderPanel->SetShowState(true);
2530 __pArticleReaderPanel->Show();
2532 int xPos = __pArticleReaderPanel->GetX();
2533 int yPos = __pArticleReaderPanel->GetY();
2534 AppLog("OnReaderClicked() xPos = %d",xPos);
2535 AppLog("OnReaderClicked() yPos = %d",yPos);
2537 if (__pReaderData == null)
2542 String loadData = L"<html>\
2544 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2549 background-color: transparent;\
2568 <body style='width:'";
2569 loadData.Append(bodyWidth);
2570 loadData.Append(L"px'>");
2571 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2572 loadData.Append(*__pReaderData);
2573 loadData.Append(L"</body></html>");
2576 buf.Construct(loadData.GetLength());
2577 AppLogDebug("data->GetLength %d",loadData.GetLength());
2578 for (int z=0;z<loadData.GetLength();z++)
2581 loadData.GetCharAt(z,b);
2582 buf.SetByte((byte)b);
2586 if (__pWebReader != null)
2588 __pWebReader->LoadData(L"",buf,L"text/html");
2589 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2593 AppLogDebug("cannot LoadData __pWebReader is null");
2599 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2601 AppLog("MainForm::OnBackClicked");
2602 result r = E_FAILURE;
2604 if (__pWebViewer != null && __pWebViewer->CanGoBack())
2606 __pWebViewer->GoBack();
2611 pApp = UiApp::GetInstance();
2614 r = pApp->Terminate();
2624 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
2626 AppLog("MainForm::OnForwardClicked");
2627 if (__pWebViewer == null)
2630 if (__pWebViewer->CanGoForward())
2632 __pWebViewer->GoForward();
2637 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
2639 result r = E_SUCCESS;
2640 // hiding the address bar
2641 __pAddressbar->SetShowState(false);
2642 __pFooterPanel->SetShowState(true);
2643 RelayoutControls(false);
2647 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
2649 __prevAddressBarMode = __curAddressBarMode;
2651 if (__pAddressbar != null)
2653 __curAddressBarMode = GetAddressbarMode();
2656 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
2658 __adressPanelPosition.y = 0;
2659 if (__pAddressbar != null)
2661 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2662 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2663 __pAddressbar->Invalidate(true);
2665 if (__pWebViewer != null)
2667 __pWebViewer->StopLoading();
2670 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
2672 __adressPanelPosition.y = 0;
2673 if (__pAddressbar != null)
2675 __webControlPosition.y = 0;
2676 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
2677 __pAddressbar->Invalidate(true);
2683 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
2685 __pFooterPanel->SetShowState(true);
2686 RelayoutControls(false);
2690 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
2692 if (__pFindWordControl && __pFindWordControl->GetShowState() == true)
2694 __pAddressbar->SetShowState(false);
2698 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
2700 __pAddressbar->SetShowState(true);
2701 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2702 __pAddressbar->SetAddressbarURLFocus();
2706 RelayoutControls(false);
2710 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
2712 __pFooterPanel->SetShowState(false);
2716 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
2718 AppLog("KeypadBoundsChanged");
2719 RelayoutControls(false);
2723 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
2727 __pWindowInfo->pageTitle = title;
2728 if (__pWebViewer != null)
2730 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2733 if (__pAddressbar != null && __pWebViewer != null)
2735 SetUrl(__pWebViewer->GetUrl());
2736 __pAddressbar->Invalidate(true);
2741 MainForm::UpdateFavicon(void)
2743 bool urlImageType = false;
2744 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();");
2745 Bitmap* pBitmap = null;
2747 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
2749 if (__pWindowInfo != null)
2752 url.SetUri(*tempPath);
2753 if (url.GetHost().GetLength() == 0)
2756 webUrl.SetUri(__pWebViewer->GetUrl());
2757 result r = url.SetHost(webUrl.GetHost());
2764 if (url.GetScheme().GetLength() == 0)
2767 webUrl.SetUri(__pWebViewer->GetUrl());
2768 url.SetScheme(webUrl.GetScheme());
2770 __pWindowInfo->faviconUrl = url.ToString();
2772 pBitmap = __pWebViewer->GetFaviconN();
2774 if (pBitmap != null)
2776 if (__pWindowInfo->pFavicon != NULL)
2778 __pWindowInfo->pFavicon = null;
2780 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
2781 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
2783 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2785 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2787 else if(__pWindowInfo->pFavicon != null)
2789 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2793 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
2794 if(pDefaultBmp != null)
2796 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
2805 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
2812 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
2813 Tizen::Web::Controls::WebNavigationType type)
2815 // when load new page if find word panel is open its show state is false
2816 ShowFindWordPanel(false);
2817 AppLog("__pAddressbar->GetAddressbarURL() is %ls",__pAddressbar->GetAddressbarURL().GetPointer());
2819 __pFooterPanel->Invalidate(true);
2822 uriInfo.SetUri(url);
2824 if(url.Contains(IDS_TIZEN_SERVICE))
2827 String delim(L":;");
2829 // Creates a StringTokenizer instance
2830 StringTokenizer strTok(url, delim);
2832 int count = strTok.GetTokenCount(); // count == 4
2834 HashMap *pMap = new HashMap();
2840 while (strTok.HasMoreTokens())
2842 AppLog("Token: %ls", token.GetPointer());
2843 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2844 if(token.Contains(IDS_APPID))
2846 token.SubString(6, appId);
2847 AppLog("AppID:%ls", appId.GetPointer());
2849 else if(token.Contains("="))
2851 String *pKey = new String();
2852 String *pValue = new String();
2854 token.IndexOf("=", 0, index);
2857 token.SubString(0, index, *pKey);
2858 token.SubString(index + 1, *pValue);
2859 pMap->Add(pKey, pValue);
2865 AppControl *pAppControl = null;
2866 String operationId = L"http://tizen.org/appcontrol/operation/main";
2867 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2870 result r = pAppControl->Start(null, null, pMap, null);
2874 AppLogException("AppControl not found");
2880 if (__pWebViewer && __pAddressbar)
2882 __pAddressbar->SetShowState(false);
2883 /*AppLog("__pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2884 __pAddressbar->SetUrl(__pWebViewer->GetUrl());
2885 __pAddressbar->UpdateProgress(DEFAULT_PROGRESS_PERCENTAGE);
2889 __pWindowInfo->pageTitle = CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK");
2890 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2891 __pWindowInfo->faviconUrl = "";
2892 __pWindowInfo->faviconFilePath = "";
2894 if (__pWindowInfo->pFavicon != NULL)
2896 // delete __pWindowInfo->pFavicon;
2897 __pWindowInfo->pFavicon = null ;
2899 __pWindowInfo->pFavicon = FaviconManager::GetInstance()->GetDefaultFaviconN();
2903 __pAddressbar->Invalidate(true);
2909 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
2910 const Tizen::Net::Http::HttpHeader& httpHeader)
2912 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
2917 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
2919 AppLog("MainForm::OnWebPageBlockSelected");
2920 if (__pHitElementResult != null)
2922 delete __pHitElementResult;
2923 __pHitElementResult = null;
2926 if (__pWebViewer != null)
2928 AppLog("MainForm::OnWebPageBlockSelected web not null");
2929 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
2932 if (__pHitElementResult == null)
2937 if (__pHitElementResult->HasImage() != true)
2939 String tagName = __pHitElementResult->GetTagName();
2940 String type = __pHitElementResult->GetAttributeValue("type");
2942 __currentSelectedStr.Clear();
2943 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
2944 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
2945 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
2947 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && __isLongPressedDone == true)
2949 AppLog("MainForm::OnWebPageBlockSelected show paste option");
2951 InitSelectTextContextMenu(endPoint,true);
2952 __pImageMenu->SetShowState(true);
2953 __pImageMenu->Show();
2954 __pImageMenu->Invalidate(true);
2956 else if(__isLongPressedDone == true)
2958 AppLog("MainForm::OnWebPageBlockSelected no paste option");
2960 if(__pHitElementResult->GetUrl().GetLength() > 0)
2962 __currentSelectedStr.Clear();
2963 __currentSelectedStr = __pHitElementResult->GetUrl();
2965 InitSelectTextContextMenu(endPoint,false);
2966 __pImageMenu->SetShowState(true);
2967 __pImageMenu->Show();
2968 __pImageMenu->Invalidate(true);
2971 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
2972 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
2973 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
2979 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
2985 MainForm::OnWebWindowCreateRequested(void)
2987 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
2989 if (pNewWindowInfo == null)
2993 result r = E_SUCCESS;
2994 SceneManager* pSceneManager = SceneManager::GetInstance();
2995 if (pSceneManager == NULL)
2999 ArrayList* pArgList = new(std::nothrow) ArrayList();
3000 if (pArgList == NULL)
3004 r = pArgList->Construct();
3007 pNewWindowInfo->isJavascriptInitiated = true;
3008 pArgList->Add(*pNewWindowInfo);
3009 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3013 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3020 return pNewWindowInfo->pCurrentWeb;
3024 MainForm::RelayoutControls(bool showAddressbar)
3026 __webControlPosition.y = 0;
3027 __webControlHeight = GetClientAreaBounds().height;
3028 AppLog("Client area height: %d", __webControlHeight);
3030 AppLog("Client area height: %d", __webControlHeight);
3031 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3033 __webControlPosition.y += __pAddressbar->GetHeight();
3034 __webControlHeight -= __pAddressbar->GetHeight();
3035 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3037 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3039 __webControlPosition.y += __pFindWordControl->GetHeight();
3040 __webControlHeight -= __pFindWordControl->GetHeight();
3041 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3044 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true)
3046 __webControlHeight -= __pFooterPanel->GetHeight();
3047 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3049 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3051 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight);
3052 __pWebViewer->Invalidate(false);
3054 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3056 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3062 void MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3064 if (__pFindWordControl == null)
3070 InitFindWordPanel();
3071 __pFindWordEditField->SetText(__currentSearchStr);
3072 //__pFindWordCountLabel->SetText(L"");
3073 __pFindWordCountLabel->SetText(L"0/0");
3074 __pFindWordPanel->SetShowState(true);
3078 if(__pFindWordControl != null)
3080 __pFindWordControl->SetShowState(false);
3084 AppLog("MainForm::ShowFindWordPanel %d",show);
3085 if (show && !isTouchPressed)
3087 if (__pFindWordEditField)
3089 __pFindWordEditField->SetFocus();
3090 __pFindWordEditField->ShowKeypad();
3095 if (__pFindWordEditField)
3096 __pFindWordEditField->HideKeypad();
3099 RelayoutControls(false);
3103 MainForm::StartWordSearch()
3105 //Get the count of occurances of the word in the current page
3106 __maxOccurrances = 0;
3107 __currentWordIndex = 0;
3109 __pFindWordPrev->SetEnabled(false);
3110 String *pCountStr = null;
3111 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3112 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3113 if (pCountStr != null)
3115 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3119 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3124 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3126 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3127 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3129 if(totalCount == -1 || totalCount == 0)
3131 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),64,__pFindWordCountLabel->GetHeight());
3132 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3135 else if(totalCount > 100)
3137 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3138 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3141 __maxOccurrances = totalCount;
3142 __currentWordIndex = currentOrdinal;
3144 //Reset the UI controls as per the maxOccurrance value
3145 if (totalCount <= 0)
3147 AppLog("Word not found");
3148 //Show error notification to user
3149 __pFindWordNext->SetEnabled(false);
3150 __pFindWordCountLabel->SetText(L"0/0");
3151 __pFindWordNext->Invalidate(false);
3152 __pFindWordPrev->Invalidate(false);
3153 __pFindWordCountLabel->Invalidate(false);
3157 if (totalCount == 1)
3159 __pFindWordNext->SetEnabled(false);
3163 __pFindWordNext->SetEnabled(true);
3166 String countStr = L"";
3167 countStr.Append(__currentWordIndex);
3168 countStr.Append(L"/");
3169 countStr.Append(__maxOccurrances);
3170 __pFindWordCountLabel->SetText(countStr);
3171 // __pFindWordCountLabel->SetShowState(true);
3172 __pFindWordCountLabel->Invalidate(false);
3174 //FindNextWord(true);
3175 //Update the controls
3176 __pFindWordNext->Invalidate(false);
3177 __pFindWordPrev->Invalidate(false);
3178 __pFindWordCountLabel->Invalidate(false);
3182 MainForm::FindNextWord(bool next)
3186 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3188 if(__currentWordIndex < __maxOccurrances)
3190 __currentWordIndex++;
3196 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3198 if(__currentWordIndex > 1)
3200 __currentWordIndex--;
3205 String countStr = L"";
3206 countStr.Append(__currentWordIndex);
3207 countStr.Append(L"/");
3208 countStr.Append(__maxOccurrances);
3209 __pFindWordCountLabel->SetText(countStr);
3210 // __pFindWordCountLabel->SetShowState(true);
3211 __pFindWordCountLabel->Invalidate(false);
3212 if (__currentWordIndex >= __maxOccurrances)
3214 __pFindWordNext->SetEnabled(false);
3218 __pFindWordNext->SetEnabled(true);
3220 if (__currentWordIndex <= 1)
3222 __pFindWordPrev->SetEnabled(false);
3226 __pFindWordPrev->SetEnabled(true);
3228 __pFindWordPrev->Invalidate(false);
3229 __pFindWordNext->Invalidate(false);
3230 __pFindWordCountLabel->Invalidate(false);
3231 __pFindWordPanel->Invalidate(true);
3234 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3236 AppLog("MainForm::OnWebKeypadWillOpen");
3237 // OnAddressBarKeypadOpened(*__pAddressbar);
3241 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3244 if (__pWebViewer != null && __pFooterPanel != null)
3246 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3247 if(__pAddressbar != null)
3249 __pAddressbar->SetShowState(false);
3251 if(__pFindWordControl != null)
3253 __pFindWordControl->SetShowState(false);
3255 __pFooterPanel->SetShowState(false);
3256 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
3262 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3264 __pFooterPanel->SetShowState(true);
3265 OnAddressBarKeypadClosed(*__pAddressbar);
3269 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3271 Control* temp = const_cast< Control* >(&source);
3272 Header* pHeader = dynamic_cast< Header* >(temp);
3273 if (pHeader != null)
3275 //Header double - clicked
3276 AppLog("Header double clicked");
3278 if(__pFindWordPanel)
3280 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3281 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3285 AppLog("MainScene::OnTouchDoublePressed");
3286 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3287 if (isReaderEnabled == true)
3291 delete __pReaderData;
3292 __pReaderData = null;
3294 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3295 filePath.Append(L"data/reader.js");
3301 result r = E_SUCCESS;
3302 FileAttributes attr;
3304 File::GetAttributes(filePath,attr);
3306 r = file.Construct(filePath, L"r+");
3309 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3312 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3315 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3318 file.Read(pScript,attr.GetFileSize());
3320 AppLogDebug("scipt length %d",strlen(pScript));
3321 String strScript = L"";
3322 strScript.Append(pScript);
3323 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3326 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3329 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3330 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3332 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3333 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3339 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3341 AppLog("MainForm::OnTouchLongPressed");
3343 if (__pHitElementResult != null)
3345 delete __pHitElementResult;
3346 __pHitElementResult = null;
3349 if (__pWebViewer != null)
3351 AppLog("MainForm::OnTouchLongPressed web not null");
3352 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3355 if (__pHitElementResult == null)
3360 if (__pHitElementResult->HasImage() == true)
3362 InitImageContextMenu(currentPosition);
3363 __pImageMenu->SetShowState(true);
3364 __pImageMenu->Show();
3365 __pImageMenu->Invalidate(true);
3369 String tagName = __pHitElementResult->GetTagName();
3370 String type = __pHitElementResult->GetAttributeValue("type");
3371 String value = __pHitElementResult->GetAttributeValue(L"value");
3372 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3374 __currentSelectedStr.Clear();
3375 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3377 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0)
3379 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3381 InitSelectTextContextMenu(currentPosition,true, true);
3382 __pImageMenu->SetShowState(true);
3383 __pImageMenu->Show();
3384 __pImageMenu->Invalidate(true);
3386 __isLongPressedDone = true;
3387 __pWebViewer->SetBlockSelectionPosition(currentPosition);
3392 __inputEventToBeSupressed = true;
3396 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3398 AppLog("MainForm::OnTouchReleased");
3400 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3401 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3403 __pWebViewer->ConsumeInputEvent();
3405 if(pHitElement != null)
3409 __inputEventToBeSupressed = false;
3413 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
3415 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
3416 int widthContextItem = 0;
3418 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
3419 if (pBitmap != null && __pFooterLabel != null)
3421 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
3425 if (__pFindWordBgLabel != null)
3427 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
3428 if (pBitmap != null)
3430 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
3436 __pMenu->SetShowState(false);
3437 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
3439 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
3443 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
3448 AppLog("__pFooterPanel->GetShowState() is true");
3450 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3451 __pFooterPanel->Invalidate(true);
3455 if(__pMoreButton && __pMenu)
3457 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
3458 __pMenu->SetAnchorPosition(p);
3459 __pMenu->Invalidate(true);
3462 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
3463 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
3465 InitMostVisitedSitesView(orientationStatus);
3468 RelayoutControls(false);
3469 if (__pArticleReaderPanel != null)
3471 if (__pArticleReaderPanel->GetShowState() == true)
3473 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
3475 if (__pBlankPanel != null)
3476 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
3478 if (__pWebReader != null)
3480 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
3482 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3483 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3485 if ( pBitmap != null && pSrcBitmap != null)
3487 AppLog("CreateReaderPanel ninepatchbitmap found");
3488 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
3491 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
3492 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
3493 if (pBitmap != null)
3498 if (pSrcBitmap != null)
3507 if (__pAddressbar != null)
3509 int width = GetClientAreaBounds().width;
3510 __pAddressbar->OrientationChanged(width);
3515 MainForm::OnSettingsChange(int settingvalue)
3517 AppLogDebug("MainForm::OnSettingsChange entered");
3518 if (__pWebViewer == null)
3520 AppLogDebug("Webviewer is not initialized yet.");
3523 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
3525 WebSetting settings = __pWebViewer->GetSetting();
3526 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
3528 settings.SetAutoFittingEnabled(true);
3530 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
3532 settings.SetAutoFittingEnabled(false);
3534 __pWebViewer->SetSetting(settings);
3536 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
3538 WebSetting settings = __pWebViewer->GetSetting();
3539 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
3540 __pWebViewer->SetSetting(settings);
3542 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
3544 WebSetting settings = __pWebViewer->GetSetting();
3545 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
3546 __pWebViewer->SetSetting(settings);
3548 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
3550 WebSetting settings = __pWebViewer->GetSetting();
3551 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
3552 __pWebViewer->SetSetting(settings);
3554 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
3558 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3562 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
3564 WebSetting settings = __pWebViewer->GetSetting();
3565 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
3567 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
3571 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
3573 __pWebViewer->SetSetting(settings);
3575 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
3579 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
3580 WebSetting settings = __pWebReader->GetSetting();
3581 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
3582 __pWebReader->SetSetting(settings);
3588 MainForm::OnSettingsReset()
3592 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3593 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
3598 MainForm::OnClearCache()
3600 result r = E_SUCCESS;
3602 if (__pWebViewer != NULL)
3604 r = __pWebViewer->ClearCache();
3607 AppLogDebug("Cache cleared success");
3611 AppLogDebug("Cache cleared fail");
3617 MainForm::OnClearCookie()
3619 result r = E_SUCCESS;
3621 if (__pWebViewer != NULL)
3623 __pWebViewer->ClearCookie();
3627 AppLogDebug("Cookie cleared success");
3631 AppLogDebug("Cache cleared fail");
3636 MainForm::findDistance(int x1,int y1,int x2, int y2)
3638 int deltaX = Math::Abs(x2 - x1);
3639 int deltaY = Math::Abs(y2 - y1);
3640 double num = deltaX*deltaX + deltaY*deltaY;
3646 for (i = 0; i < 20; i++)
3648 x = (((x*x)+ num)/(2*x));
3659 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3661 if(__pFindWordPanel)
3663 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3664 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3666 __isLongPressedDone = false;
3669 IList* pList = null;
3670 pList = touch.GetTouchInfoListN(source);
3674 int count = pList->GetCount();
3677 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3678 __touchPoint1 = pTouchInfo->position;
3680 /*if (__pAddressbar != null)
3682 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3684 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3686 __pAddressbar->SaveAddressbarEditText();
3688 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3691 __pAddressbar->Invalidate(true);
3693 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3695 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3697 //__pAddressbar->SaveAddressbarEditText();
3699 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3702 else if (count == 2)
3704 AppLogDebug("MainForm::OnTouchPressed count is two");
3705 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3706 __touchPoint1 = pTouchInfo->position;
3708 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
3709 __touchPoint2 = pTouchInfo->position;
3715 pList->RemoveAll(true);
3722 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3724 __currentWordIndex = 0;
3725 __isLongPressedDone = false;
3730 MainForm::MoveUiControls()
3735 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
3737 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
3739 if(__pFooterUrlField->GetTextLength() == 0)
3741 __pFooterUrlField->SetKeypadActionEnabled(false);
3745 __pFooterUrlField->SetKeypadActionEnabled(true);
3748 if (__pFindWordEditField != null)
3750 __currentSearchStr = __pFindWordEditField->GetText();
3751 __pFindWordNext->SetEnabled(false);
3752 __pFindWordPrev->SetEnabled(false);
3753 __pFindWordNext->Invalidate(true);
3754 __pFindWordPrev->Invalidate(true);
3755 __pFindWordCountLabel->SetText(L"0/0");
3756 __pFindWordCountLabel->Invalidate(true);
3758 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
3759 if (__currentSearchStr.GetLength() > 0)
3765 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
3767 AppLogDebug("Enter something");
3772 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
3779 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
3781 if(__pWebViewer != null)
3784 AppLog("MainForm::InitMostVisitedSitesView");
3785 result r = E_SUCCESS;
3788 if (__pWebViewer != null && __pMostVisitedListView != null)
3793 if (__pMostVisitedListView != null)
3795 RemoveControl(*__pMostVisitedListView);
3797 if(__pMostVisitedSites != null)
3799 __pMostVisitedSites->RemoveAll(true);
3802 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
3804 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
3805 __pMostVisitedListView = new(std::nothrow) ListView();
3807 int height = GetClientAreaBounds().height;
3809 if(__pFooterPanel->GetShowState() == true)
3811 height = height - __pFooterPanel->GetHeight();
3813 if(__pAddressbar->GetShowState() == true)
3815 height -= __pAddressbar->GetHeight();
3818 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
3822 delete __pMostVisitedListView;
3823 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
3826 __pMostVisitedListView->SetItemProvider(*this);
3827 __pMostVisitedListView->AddListViewItemEventListener(*this);
3828 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
3829 AddControl(*__pMostVisitedListView);
3830 __pMostVisitedListView->UpdateList();
3837 MainForm::GetImagePath(void)
3841 String formattedTime;
3842 DateTime currentTime;
3843 LocaleManager localManager;
3844 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
3846 localManager.Construct();
3847 Locale locale = localManager.GetSystemLocale();
3848 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
3850 // Get date formatter
3851 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
3855 pTimeFormatter->Format(currentTime, formattedTime);
3858 AppLog("current time stamp is %ls", formattedTime.GetPointer());
3859 String delim(L" :");
3860 StringTokenizer strTok(formattedTime, delim);
3863 String str1("GMT+00");
3864 while (strTok.HasMoreTokens())
3866 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
3867 if(token.Equals(str1))
3869 AppLog("token is %ls", token.GetPointer());
3870 imageName.Append(token);
3876 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
3878 result r = E_FAILURE;
3879 AppLog("Content manager 1");
3880 ContentId contentId;
3881 ContentManager contentManager;
3882 r = contentManager.Construct();
3885 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
3888 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
3889 contentPath.Append(imageName);
3890 contentPath.Append(".jpg");
3891 contentId = contentManager.CreateContent(*aBuffer, contentPath);
3892 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
3896 MainForm::SetForwardButtonEnabled(bool isEnabled)
3898 __pGoForwardBtn->SetEnabled(isEnabled);
3899 __pGoBackBtn->Invalidate(true);
3903 MainForm::SetBackButtonEnabled(bool isEnabled)
3905 __pGoBackBtn->SetEnabled(isEnabled);
3906 __pGoBackBtn->Invalidate(true);
3910 MainForm::UpdateProgress(int percentage)
3912 __progressPercentage = percentage;
3913 if (percentage == 0 || percentage == 100)
3915 __isLoadingData = false;
3916 if (percentage == 100)
3918 __isLoadingCompleted = true;
3919 __progressPercentage = 0;
3923 __isLoadingCompleted = false;
3928 __isLoadingData = true;
3930 UpdateProgressBitmap();
3934 MainForm::GetProgress(void)
3936 return __progressPercentage;
3940 MainForm::UpdateProgressBitmap(void)
3942 result r = E_SUCCESS;
3943 if (__pProgressbarLabel == null)
3945 int w = __pProgressbarLabel->GetWidth();
3946 int h = __pProgressbarLabel->GetHeight();
3948 int progressWidth = 0;
3949 Bitmap* pRetBitmap = null;
3951 if (__progressPercentage == 0 || __progressPercentage == 100)
3953 __pProgressbarLabel->SetShowState(false);
3954 __pProgressbarLabel->Invalidate(false);
3959 __pProgressbarLabel->SetShowState(true);
3960 __pProgressbarLabel->Invalidate(false);
3963 r = canvas.Construct(Rectangle(0, 0, w, h));
3967 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
3972 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
3976 pBgBmp->Scale(Dimension(w, h));
3977 canvas.DrawBitmap(Point(0,0), *pBgBmp);
3981 progressWidth = (double) (w) * __progressPercentage / 100;
3982 AppLogDebug("progressWidth: %d", progressWidth);
3983 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
3985 if (pProgressBmp != null)
3987 pProgressBmp->Scale(Dimension(progressWidth, h));
3988 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
3989 delete pProgressBmp;
3992 pRetBitmap = new (std::nothrow) Bitmap();
3994 if (pRetBitmap == null)
3996 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4000 pRetBitmap->Construct(canvas, canvas.GetBounds());
4002 if (__pProgressbarLabel != null && pRetBitmap != null)
4004 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4005 __pProgressbarLabel->Invalidate(false);
4008 if (pRetBitmap != null)
4016 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4018 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4020 __currentAddMode = addMode;
4024 case ADDRESSBAR_MODE_INVALID:
4029 case ADDRESSBAR_MODE_READER:
4031 __pStopBtn->SetShowState(false);
4032 __pClearBtn->SetShowState(false);
4035 case ADDRESSBAR_MODE_LOADING:
4037 __pRefreshBtn->SetShowState(false);
4038 __pStopBtn->SetShowState(true);
4039 __pClearBtn->SetShowState(false);
4042 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4044 // SetUrl(__pAddressbar->GetUrl());
4046 __pRefreshBtn->SetShowState(true);
4047 __pStopBtn->SetShowState(false);
4048 __pClearBtn->SetShowState(false);
4051 case ADDRESSBAR_MODE_EDIT:
4053 __pRefreshBtn->SetShowState(false);
4054 __pStopBtn->SetShowState(false);
4055 __pClearBtn->SetShowState(true);
4062 OnAddressBarModeChanged();
4065 AddressBarMode MainForm::GetAddressbarMode(void)
4067 return __currentAddMode;
4070 void MainForm::SetUrl(const String& url)
4074 if (__pFooterUrlField != NULL)
4076 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4077 if (removedHttpUrl.IsEmpty() == false)
4079 __pFooterUrlField->SetText(removedHttpUrl);
4080 __pAddressbar->SetUrl(__displayUrl);
4084 __pFooterUrlField->SetText(__displayUrl);
4085 __pAddressbar->SetUrl(__displayUrl);
4088 __pFooterUrlField->Invalidate(false);
4089 __pAddressbar->Invalidate(true);
4090 __pFooterUrlField->SetCursorPosition(0);
4095 MainForm::RemoveHttpTextFromDisplayURL(void)
4097 bool isHttpText = __displayUrl.Contains(L"http://");
4098 String updatedDisplayUrl;
4099 updatedDisplayUrl.Clear();
4101 if (isHttpText == true)
4103 __displayUrl.SubString(7,updatedDisplayUrl);
4105 return updatedDisplayUrl;