Tizen 2.0 Release
[apps/osp/Internet.git] / src / IntAddressbar.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 //!Internet
18 /*@file:    IntAddressbar
19  *@brief:       This class defines common behaviour of Addressbar control.
20  *
21  */
22
23 #include "IntAddressbar.h"
24 #include "IntCommonLib.h"
25 #include "IntTypes.h"
26 #include "IntMultipleWindowPresentationModel.h"
27 #include "IntSettingPresentationModel.h"
28 #include "IntMultipleWindowPresentationModel.h"
29
30 using namespace Tizen::App;
31 using namespace Tizen::Base;
32 using namespace Tizen::Ui;
33 using namespace Tizen::Ui::Controls;
34 using namespace Tizen::Graphics;
35
36 static const wchar_t* IDB_SEARCH_INPUT_FIELD_BG = L"I01_toolbar_input_field.9.png";
37 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
38 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
39 static const wchar_t* IDB_ICON_PRIVATE = L"I01_icon_private.png";
40
41 //Action IDs
42 const int Addressbar::IDA_REFRESH_BTN_CLICKED = 101;
43 const int Addressbar::IDA_READER_BTN_CLICKED = 102;
44 const int Addressbar::IDA_STOP_BTN_CLICKED = 103;
45 const int Addressbar::IDA_GO_BACK = 104;
46 const int Addressbar::IDA_GO_FORWARD = 105;
47 const int Addressbar::IDA_CANCEL = 106;
48 const int Addressbar::IDA_CLEAR_URL = 107;
49
50 Addressbar::Addressbar(void)
51 {
52         __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
53         __displayUrl = L"";
54         __editTextUrl = L"";
55         __isLoadingData = false;
56         __isLoadingCompleted = false;
57         __progressPercentage = 0;
58         __pAddressbarBg = null;
59         __pBgPanel = null;
60         __pCancelBtn = null;
61         __pClearBtn = null;
62         __pFavIcon = FaviconManager::GetInstance()->GetDefaultFaviconN();
63         __pFaviconLabel = null;
64         __pGoBackBtn = null;
65         __pGoForwardBtn = null;
66         __pLabelPrivateOn = null;
67         __pListener = null;
68         __pPrivateIconLabel = null;
69         __pProgressbarLabel = null;
70         __pPrivateIconLabel = null ;
71         __pReaderBtn = null;
72         __pRefreshBtn = null;
73         __pStopBtn = null;
74         __pClearBtn = null ;
75         __pSearchLabel = null;
76         __pUrlField = null;
77 }
78
79 Addressbar::~Addressbar(void)
80 {
81         if (__pFavIcon != null)
82         {
83                 delete __pFavIcon;
84                 __pFavIcon = null;
85         }
86 }
87
88 result
89 Addressbar::Initialize(const Rectangle& rect)
90 {
91         result r = E_SUCCESS;
92
93         AppLogDebug("Addressbar::Initialize entered");
94         //Construct the base first
95         r = Construct(L"IDL_ADDRESSBAR");
96
97         //Add background label
98         Label* pBgLabel = static_cast<Label*> (GetControl(L"IDC_BG_LABEL",true));
99         if (pBgLabel == NULL)
100         {
101                 AppLogDebug("Control not found returning E_INVALID_KEY");
102                 return E_INVALID_KEY;
103         }
104
105         //Add inner panel for border
106         __pBgPanel = static_cast<Panel*> (GetControl(L"IDC_BG_PANEL",true));
107         if (__pBgPanel == NULL)
108         {
109                 AppLogDebug("Control not found returning E_INVALID_KEY");
110                 return E_INVALID_KEY;
111         }
112
113         __pLabelPrivateOn = static_cast<Label*> (GetControl(L"IDC_LABEL_PRIVATE_ON",true));
114
115         if (__pLabelPrivateOn == NULL)
116         {
117                 AppLogDebug("Control not found returning E_INVALID_KEY");
118                 return E_INVALID_KEY;
119         }
120         __pLabelPrivateOn->SetShowState(false);
121
122         __pAddressbarBg = static_cast<Label*> (GetControl(L"IDC_ADDRESSBAR_BG_LABEL",true));
123         if (__pAddressbarBg == NULL)
124         {
125                 AppLogDebug("Control not found returning E_INVALID_KEY");
126                 return E_INVALID_KEY;
127         }
128         __pBgPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
129         Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pAddressbarBg->GetWidth(), __pAddressbarBg->GetHeight());
130         if (pBitmap != null)
131         {
132                 __pAddressbarBg->SetBackgroundBitmap(*pBitmap);
133                 delete pBitmap;
134         }
135
136         //Add the backround label for displaying progressbar
137         __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
138         if (__pProgressbarLabel == NULL)
139         {
140                 AppLogDebug("Control not found returning E_INVALID_KEY");
141                 return E_INVALID_KEY;
142         }
143         __pProgressbarLabel->SetShowState(false);
144
145         //Add the go Back Button
146         __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_BACKWARD_BUTTON",true));
147         if (__pGoBackBtn == NULL)
148         {
149                 AppLogDebug("Control not found returning E_INVALID_KEY");
150                 return E_INVALID_KEY;
151         }
152         __pGoBackBtn->SetActionId(IDA_GO_BACK);
153         __pGoBackBtn->AddActionEventListener(*this);
154         __pGoBackBtn->SetEnabled(false);
155
156         //Add the go forward Button
157         __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_FORWARD_BUTTON",true));
158         if (__pGoForwardBtn == NULL)
159         {
160                 AppLogDebug("Control not found returning E_INVALID_KEY");
161                 return E_INVALID_KEY;
162         }
163         __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
164         __pGoForwardBtn->AddActionEventListener(*this);
165         __pGoForwardBtn->SetEnabled(false);
166
167
168         //Add the favicon
169         __pFaviconLabel = static_cast<Label*> (GetControl(L"IDC_FAVICON_BUTTON",true));
170         if (__pFaviconLabel == NULL)
171         {
172                 AppLogDebug("Control not found returning E_INVALID_KEY");
173                 return E_INVALID_KEY;
174         }
175
176         __pFaviconLabel->SetShowState(false);
177
178         //Add the search icon
179         __pSearchLabel = static_cast<Label*> (GetControl(L"IDC_SEARCH_BUTTON",true));
180         if (__pSearchLabel == NULL)
181         {
182                 AppLogDebug("Control not found returning E_INVALID_KEY");
183                 return E_INVALID_KEY;
184         }
185
186         __pSearchLabel->SetShowState(true);
187
188         //Add the refresh button
189         __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
190         if (__pRefreshBtn == NULL)
191         {
192                 AppLogDebug("Control not found returning E_INVALID_KEY");
193                 return E_INVALID_KEY;
194         }
195
196         __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
197         __pRefreshBtn->AddActionEventListener(*this);
198         __pRefreshBtn->SetShowState(true);
199
200
201         //Add the stop button
202         __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
203         if (__pStopBtn == NULL)
204         {
205                 AppLogDebug("Control not found returning E_INVALID_KEY");
206                 return E_INVALID_KEY;
207         }
208         __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
209         __pStopBtn->AddActionEventListener(*this);
210         __pStopBtn->SetShowState(false);
211
212
213         //Add the reader button
214         __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
215         if (__pReaderBtn == NULL)
216         {
217                 AppLogDebug("Control not found returning E_INVALID_KEY");
218                 return E_INVALID_KEY;
219         }
220
221         __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
222         __pReaderBtn->AddActionEventListener(*this);
223         __pReaderBtn->SetShowState(false);
224
225         __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
226         if (__pClearBtn == NULL)
227         {
228                 AppLogDebug("Control not found returning E_INVALID_KEY");
229                 return E_INVALID_KEY;
230         }
231         __pClearBtn->SetActionId(IDA_CLEAR_URL);
232         __pClearBtn->AddActionEventListener(*this);
233         __pClearBtn->SetShowState(false);
234
235         //Add the editfield for url
236         __pUrlField =  static_cast<EditField*> (GetControl(L"IDC_URL_EDITFIELD",true));
237         if (__pUrlField == NULL)
238         {
239                 AppLogDebug("Control not found returning E_INVALID_KEY");
240                 return E_INVALID_KEY;
241         }
242
243         __pUrlField->SetOverlayKeypadCommandButtonVisible(false);
244         __pUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
245
246         //Add the Cancel Button
247         __pCancelBtn = static_cast<Button*> (GetControl(L"IDC_CANCEL_BUTTON",true));
248         if (__pCancelBtn == NULL)
249         {
250                 AppLogDebug("Control not found returning E_INVALID_KEY");
251                 return E_INVALID_KEY;
252         }
253         __pCancelBtn->SetActionId(IDA_CANCEL);
254         __pCancelBtn->AddActionEventListener(*this);
255         __pCancelBtn->SetShowState(false);
256         // Added to get the favorite url if not set then address bar is about blank
257
258         if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
259         {
260                 __pUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
261         }
262         else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_BLANK_PAGE")) == 0)
263         {
264                 __pUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
265         }
266         else
267         {
268                 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
269                 __pUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
270         }
271         __pUrlField->AddKeypadEventListener(*this);
272
273         AppLogDebug("Addressbar::Initialize exit");
274         return r;
275 }
276
277 void
278 Addressbar::UpdateProgressBitmap(void)
279 {
280         result r = E_SUCCESS;
281         if (__pProgressbarLabel == null)
282                 return;
283         int w = __pProgressbarLabel->GetWidth();
284         int h = __pProgressbarLabel->GetHeight();
285         Canvas canvas;
286         int progressWidth = 0;
287         Bitmap* pRetBitmap = null;
288
289         if (__progressPercentage == 0 || __progressPercentage == 100)
290         {
291                 __pProgressbarLabel->SetShowState(false);
292                 __pProgressbarLabel->Invalidate(false);
293                 return;
294         }
295         else
296         {
297                 __pProgressbarLabel->SetShowState(true);
298                 __pProgressbarLabel->Invalidate(false);
299         }
300
301         r = canvas.Construct(Rectangle(0, 0, w, h));
302
303         if (r != E_SUCCESS)
304         {
305                 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
306                 return;
307         }
308
309         canvas.Clear();
310         Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
311
312         if (pBgBmp != null)
313         {
314                 pBgBmp->Scale(Dimension(w, h));
315                 canvas.DrawBitmap(Point(0,0), *pBgBmp);
316                 delete pBgBmp;
317         }
318
319         progressWidth = (double) (w) * __progressPercentage / 100;
320         AppLogDebug("progressWidth: %d", progressWidth);
321         Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
322
323         if (pProgressBmp != null)
324         {
325                 pProgressBmp->Scale(Dimension(progressWidth, h));
326                 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
327                 delete pProgressBmp;
328         }
329
330         pRetBitmap = new (std::nothrow) Bitmap();
331
332         if (pRetBitmap == null)
333         {
334                 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
335                 return;
336         }
337
338         pRetBitmap->Construct(canvas, canvas.GetBounds());
339
340         if (__pProgressbarLabel != null && pRetBitmap != null)
341         {
342                 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
343                 __pProgressbarLabel->Invalidate(false);
344         }
345
346
347         if (pRetBitmap != null)
348         {
349                 delete pRetBitmap;
350                 pRetBitmap = null;
351         }
352         return;
353 }
354
355 void
356 Addressbar::SetUrl(const String& url)
357 {
358         __displayUrl = url;
359         String updatedDisplayUrl;
360         updatedDisplayUrl.Clear();
361
362         if (__pUrlField != NULL)
363         {
364                 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
365                 if (removedHttpUrl.IsEmpty() == false)
366                 {
367                         __pUrlField->SetText(removedHttpUrl);
368                 }
369                 else
370                 {
371                         __pUrlField->SetText(__displayUrl);
372                 }
373
374                 __pUrlField->Invalidate(false);
375                 __pUrlField->SetCursorPosition(0);
376         }
377 }
378
379 String
380 Addressbar::GetUrl(void)
381 {
382         return __displayUrl;
383 }
384
385 AddressBarMode
386 Addressbar::GetAddressbarMode(void)
387 {
388         return __currentAddMode;
389 }
390
391 void
392 Addressbar::SetAddressbarMode(AddressBarMode addMode)
393 {
394         AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
395
396         __currentAddMode = addMode;
397
398         switch(addMode)
399         {
400         case ADDRESSBAR_MODE_INVALID:
401         {
402                 // do nothing
403         }
404         break;
405         case ADDRESSBAR_MODE_READER:
406         {
407                 __pBgPanel->SetPosition(__pGoBackBtn->GetPosition().x + 2* __pGoBackBtn->GetWidth() + 13,__pBgPanel->GetPosition().y);
408                 __pSearchLabel->SetShowState(false);
409                 __pFaviconLabel->SetShowState(true);
410                 __pCancelBtn->SetShowState(false);
411                 __pRefreshBtn->SetShowState(false);
412                 __pStopBtn->SetShowState(false);
413                 __pReaderBtn->SetShowState(true);
414                 __pReaderBtn->Invalidate(true);
415                 __pGoForwardBtn->SetShowState(true);
416                 __pGoBackBtn->SetShowState(true);
417                 __pClearBtn->SetShowState(false);
418
419         }
420         break;
421
422         case ADDRESSBAR_MODE_LOADING:
423         {
424                 __pBgPanel->SetPosition(__pGoBackBtn->GetPosition().x + 2* __pGoBackBtn->GetWidth() + 13,__pBgPanel->GetPosition().y);
425                 __pSearchLabel->SetShowState(false);
426                 __pFaviconLabel->SetShowState(true);
427                 __pCancelBtn->SetShowState(false);
428                 __pRefreshBtn->SetShowState(false);
429                 __pStopBtn->SetShowState(true);
430                 __pReaderBtn->SetShowState(false);
431                 __pGoForwardBtn->SetShowState(true);
432                 __pGoBackBtn->SetShowState(true);
433                 __pClearBtn->SetShowState(false);
434
435         }
436         break;
437
438         case ADDRESSBAR_MODE_LOADING_COMPLETE:
439         {
440                 __pBgPanel->SetPosition(__pGoBackBtn->GetPosition().x + 2* __pGoBackBtn->GetWidth() + 13,__pBgPanel->GetPosition().y);
441                 __pCancelBtn->SetShowState(false);
442
443                 if (__pUrlField && __pUrlField->GetText().IsEmpty() == false)
444                 {
445
446                         __pSearchLabel->SetShowState(false);
447                         __pFaviconLabel->SetShowState(true);
448                 }
449                 else
450                 {
451                         __pSearchLabel->SetShowState(true);
452                         __pFaviconLabel->SetShowState(false);
453                 }
454
455                 if (__pUrlField != NULL)
456                 {
457                         __pUrlField->SetText(__displayUrl);
458                         __pUrlField->HideKeypad();
459                 }
460
461                 __pRefreshBtn->SetShowState(true);
462                 __pStopBtn->SetShowState(false);
463                 __pReaderBtn->SetShowState(false);
464                 __pGoForwardBtn->SetShowState(true);
465                 __pGoBackBtn->SetShowState(true);
466                 __pClearBtn->SetShowState(false);
467         }
468         break;
469         case ADDRESSBAR_MODE_EDIT:
470         {
471                 __pBgPanel->SetPosition(__pGoBackBtn->GetPosition().x,__pBgPanel->GetPosition().y);
472                 __pCancelBtn->SetShowState(true);
473                 __pRefreshBtn->SetShowState(false);
474                 __pStopBtn->SetShowState(false);
475                 __pReaderBtn->SetShowState(false);
476                 __pGoForwardBtn->SetShowState(false);
477                 __pGoBackBtn->SetShowState(false);
478                 __pClearBtn->SetShowState(true);
479                 if (__pUrlField && __pUrlField->GetText().IsEmpty() == true)
480                 {
481                         __pSearchLabel->SetShowState(true);
482                         __pFaviconLabel->SetShowState(false);
483                 }
484                 else
485                 {
486                         __pSearchLabel->SetShowState(false);
487                         __pFaviconLabel->SetShowState(true);
488                 }
489                 if (__pUrlField != NULL)
490                 {
491                         __pUrlField->SetCursorPosition(__pUrlField->GetTextLength());
492                 }
493
494         }
495         break;
496         }
497
498         if (__pAddressbarBg->GetWidth() != __pBgPanel->GetWidth())
499         {
500                 __pAddressbarBg->SetBounds(Rectangle(0, 0, __pBgPanel->GetWidth(), __pBgPanel->GetHeight()));
501                 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pAddressbarBg->GetWidth(), __pAddressbarBg->GetHeight());
502                 if (pBitmap != null)
503                 {
504                         __pAddressbarBg->SetBackgroundBitmap(*pBitmap);
505                         delete pBitmap;
506                 }
507         }
508
509         Invalidate(true);
510
511         if (__pListener != null)
512         {
513                 __pListener->OnAddressBarModeChanged(*this);
514         }
515 }
516
517 void
518 Addressbar::SetFaviconBitmap(const Tizen::Graphics::Bitmap& favicon)
519 {
520
521         String url =__pUrlField->GetText();
522         String secureSiteText = "https://";
523         bool flag = false;
524         flag = url.StartsWith(secureSiteText,0);
525
526         if (__pFavIcon != null)
527         {
528                 delete __pFavIcon;
529         }
530
531         __pFavIcon = new(std::nothrow) Bitmap();
532         __pFavIcon->Construct(favicon,Rectangle(0,0,favicon.GetWidth(),favicon.GetHeight()));
533
534         if (flag == true)
535         {
536                 Bitmap* pButtonImage = GetLockedImageN();
537
538                 if (pButtonImage != null)
539                 {
540                         __pFaviconLabel->SetBackgroundBitmap(*pButtonImage);
541                         __pFaviconLabel->Invalidate(true);
542                         delete pButtonImage;
543                 }
544         }
545         else
546         {
547                 if (__pFaviconLabel != null)
548                 {
549                         __pFaviconLabel->SetBackgroundBitmap(*__pFavIcon);
550                         __pFaviconLabel->Invalidate(true);
551                 }
552         }
553 }
554
555 void Addressbar::SaveAddressbarEditText()
556 {
557         __editTextUrl = __pUrlField->GetText();
558 }
559
560 void
561 Addressbar::UpdateFaviconBitmap(bool isPrivateOn)
562 {
563
564         String url =__pUrlField->GetText();
565         String secureSiteText = "https://";
566         bool flag = false;
567         flag = url.StartsWith(secureSiteText,0);
568
569         if (isPrivateOn == true)
570         {
571                 __pUrlField->SetBounds(__pLabelPrivateOn->GetBounds().x + __pLabelPrivateOn->GetBounds().width,__pUrlField->GetBounds().y , __pAddressbarBg->GetBounds().width - __pLabelPrivateOn->GetBounds().width - __pRefreshBtn->GetBounds().width - __pSearchLabel->GetBounds().width,__pUrlField->GetBounds().height );
572                 __pLabelPrivateOn->SetShowState(true);
573
574         }
575         else
576         {
577                 __pUrlField->SetBounds(__pLabelPrivateOn->GetBounds().x ,__pUrlField->GetBounds().y , __pAddressbarBg->GetBounds().width - __pRefreshBtn->GetBounds().width - __pSearchLabel->GetBounds().width,__pUrlField->GetBounds().height );
578                 __pLabelPrivateOn->SetShowState(false);
579         }
580
581
582         if (flag == true)
583                 {
584                         Bitmap* pButtonImage = GetLockedImageN();
585
586                         if (pButtonImage != null)
587                         {
588                                 __pFaviconLabel->SetBackgroundBitmap(*pButtonImage);
589                                 __pFaviconLabel->Invalidate(true);
590                                 delete pButtonImage;
591                         }
592                 }
593                 else
594                 {
595                         if (__pFaviconLabel != null)
596                         {
597                                 __pFaviconLabel->SetBackgroundBitmap(*__pFavIcon);
598                                 __pFaviconLabel->Invalidate(true);
599                         }
600                 }
601
602
603         __pAddressbarBg->Invalidate(true);
604 }
605
606 void
607 Addressbar::SetForwardButtonEnabled(bool isEnabled)
608 {
609         __pGoForwardBtn->SetEnabled(isEnabled);
610         __pGoBackBtn->Invalidate(true);
611 }
612
613 void
614 Addressbar::SetBackButtonEnabled(bool isEnabled)
615 {
616         __pGoBackBtn->SetEnabled(isEnabled);
617         __pGoBackBtn->Invalidate(true);
618 }
619
620 void
621 Addressbar::SetAddressbarEventListener(IAddressbarEventListener* plistener)
622 {
623         __pListener = plistener;
624 }
625
626 void
627 Addressbar::UpdateProgress(int percentage)
628 {
629         __progressPercentage = percentage;
630         if (percentage == 0 || percentage == 100)
631         {
632                 __isLoadingData = false;
633                 if (percentage == 100)
634                 {
635                         __isLoadingCompleted = true;
636                         __progressPercentage = 0;
637                 }
638                 else
639                 {
640                         __isLoadingCompleted = false;
641                 }
642         }
643         else
644         {
645                 __isLoadingData = true;
646         }
647         UpdateProgressBitmap();
648 }
649
650 int
651 Addressbar::GetProgress(void)
652 {
653         return __progressPercentage;
654 }
655
656 void
657 Addressbar::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
658 {
659         AppLogDebug("Addressbar::OnActionPerformed action %d",actionId);
660
661         switch (actionId)
662         {
663         case IDA_REFRESH_BTN_CLICKED:
664                 __isLoadingCompleted = false;
665                 __isLoadingData = true;
666                 __progressPercentage = 0;
667                 __pUrlField->HideKeypad();
668                 __displayUrl = __pUrlField->GetText();
669
670                 if (__pListener != NULL)
671                 {
672                         __pListener->OnUrlSubmitted(*this);
673                 }
674
675                 UpdateProgressBitmap();
676                 break;
677
678         case IDA_STOP_BTN_CLICKED:
679                 __isLoadingCompleted = false;
680                 __isLoadingData = false;
681                 __progressPercentage = 0;
682                 __pUrlField->HideKeypad();
683                 __displayUrl = __pUrlField->GetText();
684
685                 if (__pListener != NULL)
686                 {
687                         __pListener->OnStopClicked(*this);
688                 }
689
690                 UpdateProgressBitmap();
691                 break;
692         case IDA_READER_BTN_CLICKED:
693                 __pUrlField->HideKeypad();
694                 __displayUrl = __pUrlField->GetText();
695
696                 if (__pListener != NULL)
697                 {
698                         __pListener->OnReaderClicked(*this);
699                 }
700
701                 break;
702
703         case IDA_GO_BACK:
704         {
705                 if (__pListener != NULL)
706                 {
707                         __pListener->OnBackClicked(*this);
708
709                 }
710         }
711         break;
712
713         case IDA_GO_FORWARD:
714         {
715                 if (__pListener != NULL )
716                         __pListener->OnForwardClicked(*this);
717         }
718         break;
719
720         case IDA_CANCEL:
721         {
722                 __pListener->OnAddressCancelledClicked(*this);
723                 __pUrlField->SetText(__displayUrl);
724                 __editTextUrl = L"";
725                 __pUrlField->HideKeypad();
726                 SetAddressbarMode(ADDRESSBAR_MODE_LOADING_COMPLETE);
727         }
728         break;
729
730         case IDA_CLEAR_URL:
731         {
732                 if (__pUrlField->GetText().IsEmpty() == false)
733                 {
734                         //__displayUrl = __pUrlField->GetText();
735                         __pUrlField->Clear();
736                         __pUrlField->Invalidate(true);
737                 }
738         }
739         break;
740         default:
741                 break;
742         }
743 }
744
745 void
746 Addressbar::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
747 {
748         AppLog("Addressbar::OnKeypadActionPerformed keypadAction %d",keypadAction);
749         switch (keypadAction)
750         {
751         case KEYPAD_ACTION_GO:
752         case KEYPAD_ACTION_ENTER:
753         case KEYPAD_ACTION_SEND:
754         {
755                 if (__pUrlField->GetText().IsEmpty() == false)
756                 {
757                         SetAddressbarMode(ADDRESSBAR_MODE_LOADING);
758                         __displayUrl = __pUrlField->GetText();
759
760                         __isLoadingCompleted = false;
761                         __isLoadingData = true;
762                         __progressPercentage = 0;
763                         __pUrlField->HideKeypad();
764
765                         if (__pListener != NULL)
766                         {
767                                 __pListener->OnUrlSubmitted(*this);
768                         }
769                         UpdateProgressBitmap();
770
771                 }
772         }
773         break;
774
775         default:
776                 break;
777         }
778 }
779
780 void
781 Addressbar::OnKeypadClosed(Tizen::Ui::Control& source)
782 {
783         __pListener->OnAddressBarKeypadClosed(*this);
784 }
785
786 void
787 Addressbar::OnKeypadOpened(Tizen::Ui::Control& source)
788 {
789 //      __pListener->OnAddressBarKeypadOpened(*this);
790         __pListener->OnAddressBarKeypadOpened(*this);
791 }
792
793 void
794 Addressbar::OnKeypadWillOpen(Tizen::Ui::Control& source)
795 {
796         SetAddressbarMode(ADDRESSBAR_MODE_EDIT);
797         //      SetAddressbarMode(__prevAddMode);
798         if(__pListener != null)
799         {
800                 __pListener->OnAddressBarKeypadWillOpen(*this);
801         }
802 }
803 void
804 Addressbar::OrientationChanged(void)
805 {
806         Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pAddressbarBg->GetWidth(), __pAddressbarBg->GetHeight());
807         if (pBitmap != null)
808         {
809                 __pAddressbarBg->SetBackgroundBitmap(*pBitmap);
810                 delete pBitmap;
811         }
812         Invalidate(true);
813 }
814
815 String
816 Addressbar::RemoveHttpTextFromDisplayURL(void)
817 {
818         bool isHttpText = __displayUrl.Contains(L"http://");
819         String updatedDisplayUrl;
820         updatedDisplayUrl.Clear();
821
822         if (isHttpText == true)
823         {
824                 __displayUrl.SubString(7,updatedDisplayUrl);
825         }
826         return updatedDisplayUrl;
827 }
828
829 Bitmap*
830 Addressbar::GetLockedImageN(void)
831 {
832         Bitmap* pIconImage = null;
833
834         AppResource* pAppResource = Application::GetInstance()->GetAppResource();
835         if (pAppResource)
836         {
837                 pIconImage = pAppResource->GetBitmapN(IDB_ICON_PRIVATE);
838         }
839
840         Bitmap* pLockImage = new (std::nothrow) Bitmap();
841
842         Canvas* pCanvas = new (std::nothrow) Canvas();
843         pCanvas->Construct(Rectangle(0,0,__pFaviconLabel->GetWidth(),__pFaviconLabel->GetHeight()));
844         pCanvas->Clear();
845         pCanvas->DrawBitmap(Rectangle(0,0,__pFaviconLabel->GetWidth(),__pFaviconLabel->GetHeight()),*__pFavIcon);
846         pCanvas->DrawBitmap(Rectangle(__pFaviconLabel->GetWidth()/2,__pFaviconLabel->GetHeight()/2,__pFaviconLabel->GetWidth()/2,__pFaviconLabel->GetHeight()/2),*pIconImage);
847         pLockImage->Construct(*pCanvas,Rectangle(0,0,__pFaviconLabel->GetWidth(),__pFaviconLabel->GetHeight()));
848
849         delete pCanvas;
850         return pLockImage;
851 }
852
853