browserui/browser/BrowserAppSrc/BrowserAppUi.cpp
changeset 51 48e827313edd
parent 37 481242ead638
child 53 f427d27b98d8
equal deleted inserted replaced
37:481242ead638 51:48e827313edd
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *      Implementation of CBrowserAppUi
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 // INCLUDES
       
    21 #include <browser_platform_variant.hrh>
       
    22 #include <BrowserNG.rsg>
       
    23 #include <uri16.h>
       
    24 #include <uri8.h>
       
    25 #include <uriutils.h>
       
    26 #include <ApUtils.h>
       
    27 #include <StringLoader.h>
       
    28 #include <e32def.h>
       
    29 #include <aplistitemlist.h>
       
    30 #include <aplistitem.h>
       
    31 #include <apparc.h>
       
    32 #include <favouritesfile.h>
       
    33 #include <aknmessagequerydialog.h>
       
    34 #include <FeatMgr.h>
       
    35 #include <internetconnectionmanager.h>
       
    36 #include <APSettingsHandlerUi.h>
       
    37 #include <UriUtilsCommon.h>
       
    38 #include <aknnavi.h>
       
    39 #include <AiwGenericParam.h>
       
    40 #include <AknDef.h>
       
    41 #include <DocumentHandler.h>
       
    42 
       
    43 #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
       
    44 #include <MGXFileManagerFactory.h>
       
    45 #include <CMGXFileManager.h>
       
    46 #endif
       
    47 
       
    48 #include <browserplugininterface.h>
       
    49 #include <oommonitorplugin.h>
       
    50 
       
    51 #include <browseroverriddensettings.h>
       
    52 #include "BrowserLauncherService.h"
       
    53 
       
    54 #include "cookiemanagerclient.h"
       
    55 
       
    56 #ifdef __SERIES60_HELP
       
    57 #include <hlplch.h>
       
    58 #endif //__SERIES60_HELP
       
    59 
       
    60 #include "BrowserAppDocument.h"
       
    61 #include <downloadedcontenthandler.h>
       
    62 #include "BrowserBmOTABinSender.h"
       
    63 #include "BrowserCommandLineParser.h"
       
    64 #include "BrowserApplication.h"
       
    65 #include "BrowserContentView.h"
       
    66 #include "BrowserContentViewContainer.h"
       
    67 #include "BrowserContentViewToolbar.h"
       
    68 #include "BrowserBookmarksView.h"
       
    69 #include "SettingsView.h"
       
    70 #include "BrowserWindowSelectionView.h"
       
    71 #include "BrowserInitialView.h"
       
    72 #include "CommonConstants.h"
       
    73 #include "BrowserDialogs.h"
       
    74 #include "BrowserDisplay.h"
       
    75 #include "BrowserCommsModel.h"
       
    76 #include "BrowserUtil.h"
       
    77 #include "BrowserPreferences.h"
       
    78 #include "SessionAndSecurity.h"
       
    79 #include "BrowserUIVariant.hrh"
       
    80 #include "BrowserWindowQueue.h"
       
    81 #include "Logger.h"
       
    82 #include <data_caging_path_literals.hrh>
       
    83 
       
    84 #include <brctldefs.h>
       
    85 #include <browserdialogsprovider.h>
       
    86 #include "BrowserSoftkeysObserver.h"
       
    87 #include "BrowserLoadObserver.h"
       
    88 #include "BrowserSpecialLoadObserver.h"
       
    89 #include "BrowserAsyncExit.h"
       
    90 #include "CommonConstants.h"
       
    91 
       
    92 
       
    93 // Dialogs Provider
       
    94 #include <browserdialogsproviderobserver.h>
       
    95 #include <brctlinterface.h>
       
    96 #include <browserdialogsprovider.h>
       
    97 
       
    98 // Multiple Windows
       
    99 #include "BrowserPopupEngine.h"
       
   100 #include "BrowserDialogsProviderProxy.h"
       
   101 #include "BrowserWindow.h"
       
   102 #include "BrowserWindowManager.h"
       
   103 #include "AknInfoPopupNoteController.h"
       
   104 
       
   105 #include "BrowserAppUi.h"
       
   106 
       
   107 #include "BrowserPushMtmObserver.h"
       
   108 
       
   109 //CONSTANTS
       
   110 const TUint KBookmarkId = 1;
       
   111 const TUint KUrlId = 4;
       
   112 _LIT8 ( KLongZeroIdString, "5" );
       
   113 const TUint KFolderId = 6;
       
   114 const TUint KLaunchFeeds = 7;
       
   115 
       
   116 const TInt KMaxNumOfOpenedWindows = 5;
       
   117 const TInt KMinNumOfOpenedWindows = 2; // must allow at least 2 windows for most use cases
       
   118 
       
   119 const TUint KDot('.');
       
   120 const TUint KSlash('/');
       
   121 _LIT( KDefaultSchema, "http://" );
       
   122 const TInt KDefaultSchemaLength = 7;
       
   123 
       
   124 // ================= MEMBER FUNCTIONS =======================
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 // CBrowserAppUi::CBrowserAppUi()
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 CBrowserAppUi::CBrowserAppUi():
       
   131 iCalledFromAnotherApp( EFalse ),
       
   132 iIsForeground( EFalse ),
       
   133 iLastViewId( KUidBrowserNullViewId ),
       
   134 iExitInProgress( EFalse ),
       
   135 iShutdownRequested( EFalse ),
       
   136 iParametrizedLaunchInProgress( 0 ),
       
   137 iExitFromEmbeddedMode( EFalse ),
       
   138 iLongZeroPressed( EFalse ),
       
   139 iStartedUp( EFalse ),
       
   140 iFeatureManager( EFalse ),
       
   141 iUserExit( EFalse ),
       
   142 iPgNotFound( EFalse ),
       
   143 iOverriddenLaunchContextId( EBrowserContextIdNormal ),
       
   144 iBrowserAlreadyRunning (EFalse)
       
   145     {
       
   146     iViewToBeActivatedIfNeeded.iUid = 0;
       
   147     iViewToReturnOnClose.iUid = 0;
       
   148 	}
       
   149 
       
   150 // -----------------------------------------------------------------------------
       
   151 // CBrowserAppUi::~CBrowserAppUi()
       
   152 // -----------------------------------------------------------------------------
       
   153 //
       
   154 CBrowserAppUi::~CBrowserAppUi()
       
   155     {
       
   156     LOG_ENTERFN("CBrowserAppUi::~CBrowserAppUi");
       
   157 
       
   158     SetExitInProgress( ETrue );
       
   159     if(iBrowserAsyncExit)
       
   160     	{
       
   161     	iBrowserAsyncExit->Cancel();
       
   162     	}
       
   163     if(iIdle)
       
   164     	{
       
   165     	iIdle->Cancel();
       
   166     	}
       
   167 
       
   168 
       
   169     if( iFeatureManager )
       
   170         {
       
   171         FeatureManager::UnInitializeLib();
       
   172         iFeatureManager = EFalse;
       
   173         }
       
   174 
       
   175     //
       
   176     delete iPushMtmObserver;
       
   177 
       
   178 #ifdef __RSS_FEEDS
       
   179     delete iFeedsClientUtilities;
       
   180     LOG_WRITE( "iFeedsClientUtilities deleted" );
       
   181 #endif //__RSS_FEEDS
       
   182 
       
   183     delete iPopupEngine;
       
   184     LOG_WRITE(" iPopupEngine deleted.");
       
   185 
       
   186     // set user exit for 'save launch param' command handling
       
   187     if ( iWindowManager )
       
   188         {
       
   189         iWindowManager->SetUserExit( iUserExit );
       
   190         }
       
   191     delete iWindowManager;
       
   192     LOG_WRITE( " iWindowManager deleted" );
       
   193 
       
   194     // Delete the inetconman after deleting window manager
       
   195     CInternetConnectionManager* inetconman = (CInternetConnectionManager*)iConnection;
       
   196     delete inetconman;
       
   197     LOG_WRITE( " inetconman deleted" );
       
   198     delete iConnStageNotifier;
       
   199     LOG_WRITE( " iConnStageNotifier deleted" );
       
   200 
       
   201     delete iPreferences;
       
   202     LOG_WRITE( " iPreferences deleted" );
       
   203     delete iCommsModel;
       
   204     LOG_WRITE( " iCommsModel deleted" );
       
   205 
       
   206     delete iLateSendUi;
       
   207 	LOG_WRITE( " iLateSendUi deleted" );
       
   208 
       
   209     delete iSender;
       
   210     LOG_WRITE( " iSender deleted" );
       
   211 
       
   212     delete iIdle;
       
   213     LOG_WRITE( " iIdle deleted" );
       
   214 
       
   215 	delete iRecentUrlStore;
       
   216 	LOG_WRITE( " iRecentUrlStore deleted" );
       
   217 
       
   218     if ( iDoorObserver )
       
   219       {
       
   220         iDoorObserver->NotifyExit(MApaEmbeddedDocObserver::ENoChanges);
       
   221         LOG_WRITE( " NotifyExit deleted" );
       
   222       }
       
   223     delete iDialogsProvider;
       
   224     LOG_WRITE( " iDialogsProvider deleted" );
       
   225 
       
   226 	TBool isStandAlone = !IsEmbeddedModeOn();
       
   227 	LOG_WRITE_FORMAT( " isStandAlone: %d", isStandAlone );
       
   228 
       
   229     delete iBrowserAsyncExit;
       
   230     LOG_WRITE( " iBrowserAsyncExit deleted" );
       
   231 
       
   232     iFavouritesSess.Close();
       
   233     LOG_WRITE( " iFavouritesSess.Close() deleted" );
       
   234     }
       
   235 
       
   236 // -----------------------------------------------------------------------------
       
   237 // CBrowserAppUi::ConstructL()
       
   238 // -----------------------------------------------------------------------------
       
   239 //
       
   240 void CBrowserAppUi::ConstructL()
       
   241     {
       
   242     LOG_CREATE;
       
   243     LOG_ENTERFN( "CBrowserAppUi::ConstructL" );
       
   244 PERFLOG_CREATE;
       
   245 PERFLOG_LOCAL_INIT;
       
   246 PERFLOG_STOPWATCH_START;
       
   247 
       
   248 
       
   249 #ifdef BRDO_SINGLE_CLICK_ENABLED_FF
       
   250     BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible);
       
   251 #else 
       
   252     BaseConstructL( EAknEnableSkin | EAknEnableMSK );
       
   253 #endif
       
   254     if ( !IsEmbeddedModeOn( ) )
       
   255     	{
       
   256     	InitBrowserL();
       
   257     	LOG_WRITE( "Browser started standalone" );
       
   258     	}
       
   259 	else
       
   260 		{
       
   261 		iStartedUp = EFalse;
       
   262 		LOG_WRITE( "Browser started embedded" );
       
   263 		}
       
   264 
       
   265 PERFLOG_STOP_WRITE("BrowserUI::ConstructL");
       
   266 
       
   267     }
       
   268 
       
   269 // -----------------------------------------------------------------------------
       
   270 // CBrowserAppUi::InitBrowser()
       
   271 // -----------------------------------------------------------------------------
       
   272 //
       
   273 void CBrowserAppUi::InitBrowserL()
       
   274     {
       
   275     if (!iStartedUp)
       
   276         {
       
   277         LOG_ENTERFN( "CBrowserAppUi::InitBrowser" );
       
   278 
       
   279         User::LeaveIfError( iFavouritesSess.Connect() );
       
   280 
       
   281         PERFLOG_LOCAL_INIT;
       
   282 
       
   283         PERFLOG_STOPWATCH_START;
       
   284 
       
   285         // Replace the original synchronous creation with this async
       
   286         // creation. A new method was added to the interface stub that was
       
   287         // not added to the MAHLEClientAPI (it is owned by another group).
       
   288         //  // Init AHLE Interface
       
   289         //  TAHLEScore adaptationSpeed;
       
   290         //  TUint      primarySize;
       
   291         //  TUint      secondarySize;
       
   292         //  iAHLEClient=CAHLEInterface::NewL();
       
   293         //  iAHLEClient->GetConfigurationL( primarySize, secondarySize, adaptationSpeed  );
       
   294         //  iAHLEClient->ReconfigureL( KAhlePrimaryStorage, secondarySize, adaptationSpeed  );
       
   295 /*
       
   296     // Write to the file only if we are not below critical disk level
       
   297     if (SysUtil::DiskSpaceBelowCriticalLevelL (&rfs, aData.Length(), EDriveC))
       
   298         {
       
   299         User::Leave(KErrDiskFull);
       
   300         }
       
   301 
       
   302     TMemoryInfoV1Buf info;
       
   303     UserHal::MemoryInfo( info );
       
   304     TInt freeRamInBytes = 10*1024*1024;
       
   305     TInt dataSize = iContext->iDataPtr.Length();
       
   306     if( UserHal::MemoryInfo( info ) == KErrNone )
       
   307         freeRamInBytes = info().iFreeRamInBytes;
       
   308 
       
   309 */
       
   310         //New constructor that just replaces the default primary storage size with this one.
       
   311         iRecentUrlStore = CRecentUrlStore::NewL();
       
   312 
       
   313         iFlashPresent = CheckFlashPresent();
       
   314         PERFLOG_STOP_WRITE("\t AhleInterface Creation + Configuration");
       
   315         BROWSER_LOG( ( _L( "AHLE Interface inited" ) ) );
       
   316 
       
   317         // Init FeatureManager
       
   318         FeatureManager::InitializeLibL();
       
   319         iFeatureManager = ETrue;
       
   320 
       
   321         // Init CommsModel
       
   322 
       
   323         PERFLOG_STOPWATCH_START;
       
   324         iCommsModel = CBrowserCommsModel::NewL();
       
   325         PERFLOG_STOP_WRITE("\t CommsModel NewL");
       
   326         BROWSER_LOG( ( _L( "CommsModel up" ) ) );
       
   327 
       
   328         CBrowserAppDocument* doc = STATIC_CAST(CBrowserAppDocument*, Document());
       
   329 
       
   330         // Creating object to hold application settings
       
   331         PERFLOG_STOPWATCH_START;
       
   332         iPreferences = CBrowserPreferences::NewL( *iCommsModel, *this, doc->GetOverriddenSettings());
       
   333         PERFLOG_STOP_WRITE("\t Preferences NewL");
       
   334         BROWSER_LOG( ( _L( "Preferences up" ) ) );
       
   335 
       
   336         PERFLOG_STOPWATCH_START;
       
   337         #ifdef BRDO_OCC_ENABLED_FF
       
   338           iConnection = CInternetConnectionManager::NewL( &iCommsModel->CommsDb(), ETrue );
       
   339         #else
       
   340           iConnection = CInternetConnectionManager::NewL( &iCommsModel->CommsDb(), EFalse );
       
   341         #endif
       
   342         	
       
   343         PERFLOG_STOP_WRITE("\t ConnMan NewL");
       
   344         BROWSER_LOG( ( _L( "ConnectionManager up" ) ) );
       
   345 
       
   346 
       
   347         PERFLOG_STOPWATCH_START;
       
   348         iConnStageNotifier = CConnectionStageNotifierWCB::NewL();
       
   349         PERFLOG_STOP_WRITE("\t StageNotif NewL");
       
   350         BROWSER_LOG( ( _L( "StageNofier up" ) ) );
       
   351 
       
   352         // Starts a background processing, so it must be started early, to get
       
   353         // finished before the first send operation! Or it must be synchronized!
       
   354         PERFLOG_STOPWATCH_START;
       
   355         iLateSendUi  = CIdle::NewL( CActive::EPriorityIdle );
       
   356         iLateSendUi ->Start( TCallBack( DelayedSendUiConstructL, this ) );
       
   357         PERFLOG_STOP_WRITE("\t OtaSender NewL");
       
   358 
       
   359         iHTTPSecurityIndicatorSupressed = iPreferences->HttpSecurityWarningsStatSupressed();
       
   360 
       
   361         // set AP to be a default one (for Push messages)
       
   362         SetRequestedAP( Preferences().DefaultAccessPoint() );
       
   363         // get client rect before hiding CBAs
       
   364         TRect rect = ClientRect();
       
   365         Cba()->MakeVisible( EFalse );
       
   366         //-------------------------------------------------------------------------
       
   367         // Create bookmarkview
       
   368         PERFLOG_STOPWATCH_START;
       
   369         CBrowserBookmarksView* bookmarksView = NULL;
       
   370         TInt folderUid = doc->GetFolderToOpen();
       
   371         if ( IsEmbeddedModeOn() && folderUid!= KFavouritesRootUid)
       
   372             {
       
   373             bookmarksView = CBrowserBookmarksView::NewLC( *this, *iRecentUrlStore, folderUid );
       
   374             }
       
   375         else
       
   376             {
       
   377             bookmarksView = CBrowserBookmarksView::NewLC( *this, *iRecentUrlStore );
       
   378             }
       
   379         PERFLOG_STOP_WRITE("\t BMView NewL")
       
   380 
       
   381         iBookmarksView = bookmarksView;
       
   382 
       
   383         AddViewL( bookmarksView );  // transfer ownership to CAknViewAppUi
       
   384         CleanupStack::Pop(); // bookmarksView
       
   385         BROWSER_LOG( ( _L( "Bookmarksview up" ) ) );
       
   386 
       
   387         //-------------------------------------------------------------------------
       
   388         // Create ContentView
       
   389 
       
   390         PERFLOG_STOPWATCH_START;
       
   391         CBrowserContentView* contentView =
       
   392             CBrowserContentView::NewLC( *this, rect );
       
   393         AddViewL( contentView ); // transfer ownership to CAknViewAppUi
       
   394         CleanupStack::Pop(); // contentView
       
   395         PERFLOG_STOP_WRITE("\t ContentView NewL");
       
   396         BROWSER_LOG( ( _L( "ContentView up" ) ) );
       
   397 
       
   398         //-------------------------------------------------------------------------
       
   399         // Create the Plugin Browser Engine
       
   400 
       
   401         // proxy will handle dialog events through load observer
       
   402         iDialogsProvider = CBrowserDialogsProvider::NewL( NULL);
       
   403         BROWSER_LOG( ( _L( "CBrowserDialogsProvider UP" ) ) );
       
   404 
       
   405 #ifdef __RSS_FEEDS
       
   406         iFeedsClientUtilities = CFeedsClientUtilities::NewL( *this, *this );
       
   407 
       
   408         BROWSER_LOG( ( _L("Feeds up.") ) );
       
   409 #endif //__RSS_FEEDS
       
   410 
       
   411         PERFLOG_STOPWATCH_START;
       
   412         // Is Multiple Window feature suported?
       
   413         if ( Preferences().UiLocalFeatureSupported( KBrowserMultipleWindows ) )
       
   414             {
       
   415             if (Preferences().UiLocalFeatureSupported( KBrowserMinimalMultipleWindows ))//midrange
       
   416                 {
       
   417                 iWindowManager = CBrowserWindowManager::NewL( *this, *contentView,
       
   418                     KMinNumOfOpenedWindows );
       
   419                 }
       
   420             else
       
   421                 {
       
   422                 iWindowManager = CBrowserWindowManager::NewL( *this, *contentView,
       
   423                     KMaxNumOfOpenedWindows );
       
   424                 }
       
   425             LOG_WRITE_FORMAT("WindowManager Up. Max windows number. %d",
       
   426                 KMaxNumOfOpenedWindows );
       
   427 
       
   428             // bug fix for: EMBI-6NBAYM
       
   429             // Be very careful of the location to initialize the iPopupEngine before
       
   430             // PopupEngine is improved.
       
   431             iPopupEngine = CBrowserPopupEngine::NewL();
       
   432             BROWSER_LOG( ( _L( "PopupEngine up" ) ) );
       
   433             }
       
   434         else
       
   435             {
       
   436             iWindowManager = CBrowserWindowManager::NewL( *this, *contentView,
       
   437                 KMinNumOfOpenedWindows );
       
   438             BROWSER_LOG( ( _L( "WindowManager Up. MWs not supported." ) ) );
       
   439             }
       
   440 
       
   441         PERFLOG_STOP_WRITE("\t WindowMgr + PopUp Engine");
       
   442         contentView->SetZoomLevelL();
       
   443         contentView->Container()->FindKeywordPane()->SetOrdinalPosition( 0 );
       
   444         contentView->Container()->GotoPane()->SetOrdinalPosition( 0 );
       
   445 
       
   446         //-------------------------------------------------------------------------
       
   447 
       
   448 
       
   449         CBrowserSettingsView* settingsView = CBrowserSettingsView::NewLC( *this );
       
   450         AddViewL( settingsView );   // transfer ownership to CAknViewAppUi
       
   451         CleanupStack::Pop(); // settingsView
       
   452         BROWSER_LOG( ( _L( "SettingsView up" ) ) );
       
   453 
       
   454         CBrowserWindowSelectionView* windowSelectionView = CBrowserWindowSelectionView::NewLC( *this );
       
   455         AddViewL( windowSelectionView );   // transfer ownership to CAknViewAppUi
       
   456         CleanupStack::Pop(); // windowSelectionView
       
   457         BROWSER_LOG( ( _L( "windowSelectionView up" ) ) );
       
   458 
       
   459         //-------------------------------------------------------------------------
       
   460 
       
   461         iIdle = CIdle::NewL( CActive::EPriorityIdle );
       
   462 
       
   463         // Create asyncronous object to call when exit requires it.
       
   464         iBrowserAsyncExit = CBrowserAsyncExit::NewL( this );
       
   465         iStartedUp = ETrue;
       
   466         iSecureSiteVisited = EFalse;
       
   467 
       
   468 	    iPushMtmObserver = CBrowserPushMtmObserver::NewL( this );
       
   469 	    iPushMtmObserver->StartObserver();
       
   470         } //if (iStartedUp)
       
   471     }
       
   472 
       
   473 // -----------------------------------------------------------------------------
       
   474 // CBrowserAppUi::ProcessCommandL(TInt aCommand)
       
   475 // -----------------------------------------------------------------------------
       
   476 //
       
   477 void CBrowserAppUi::ProcessCommandL(TInt aCommand)
       
   478     {
       
   479     MEikAppUiFactory* appUiFactory = (iEikonEnv)->AppUiFactory();
       
   480     if (appUiFactory->MenuBar())
       
   481         {
       
   482         StopDisplayingMenuBar();
       
   483         }
       
   484     CAknViewAppUi::ProcessCommandL(aCommand);
       
   485     }
       
   486 
       
   487 // -----------------------------------------------------------------------------
       
   488 // CBrowserAppUi::HandleCommandL()
       
   489 // -----------------------------------------------------------------------------
       
   490 //
       
   491 void CBrowserAppUi::HandleCommandL(TInt aCommand)
       
   492     {
       
   493     // Default handling for all the thingies.
       
   494     switch (aCommand)
       
   495         {
       
   496         case EEikCmdExit:
       
   497 			{
       
   498 			ExitBrowser ( IsAppShutterActive() );
       
   499 			break;
       
   500 			}
       
   501     case EAknSoftkeyExit://  closes the whole application chain if embedded browser
       
   502     case EAknCmdExit:
       
   503 			{
       
   504 			if ( IsEmbeddedModeOn() )
       
   505 				{
       
   506 				CAknEnv::RunAppShutter();
       
   507 				break;
       
   508 				}
       
   509 			else
       
   510 				{
       
   511 				ExitBrowser ( ETrue ) ;
       
   512 				break;
       
   513 				}
       
   514 			}
       
   515 		//Fix for TSW error ICHV-75UFKZ	
       
   516 		case EWmlCmdUserExit://closes the current browser instance only
       
   517 		case EWmlCmdCloseBrowser: 
       
   518 			{
       
   519 			ExitBrowser ( ETrue );
       
   520 			break;
       
   521 			}
       
   522         case EWmlCmdChangeConnection :
       
   523             {
       
   524             ChangeConnectionL();
       
   525             break;
       
   526             }
       
   527         case EWmlCmdPreferences:
       
   528             {
       
   529             SetViewToBeActivatedIfNeededL( KUidBrowserSettingsViewId );
       
   530             break;
       
   531             }
       
   532         case EWmlCmdPreferencesToolbar:
       
   533             {
       
   534             SetViewToBeActivatedIfNeededL( KUidBrowserSettingsViewId, KUidSettingsGotoToolbarGroup.iUid );
       
   535             break;
       
   536             }            
       
   537         case EWmlCmdFavourites:
       
   538             {
       
   539             SetViewToBeActivatedIfNeededL( KUidBrowserBookmarksViewId );
       
   540             break;
       
   541             }
       
   542         case EWmlCmdSearchWeb:
       
   543             {
       
   544             LoadSearchPageL();
       
   545             break;
       
   546             }
       
   547         case EWmlCmdReload:
       
   548             {
       
   549 			BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandReload +
       
   550 												(TInt)TBrCtlDefs::ECommandIdBase );
       
   551             break;
       
   552             }
       
   553 #ifdef BRDO_SINGLE_CLICK_ENABLED_FF			
       
   554         case EWmlCmdSetAsHomePage:
       
   555             {
       
   556             ContentView()->HandleCommandL(EWmlCmdSetAsHomePage);
       
   557             break;
       
   558             }
       
   559 #endif			
       
   560         case EAknSoftkeyBack:
       
   561         case EWmlCmdBack:
       
   562             {
       
   563             HistoryLoadPrevious();
       
   564             break;
       
   565             }
       
   566         case EWmlCmdBackToFeedsView:
       
   567             {
       
   568    			//Note: iPreviousView in this case will always be one of the Feeds view.
       
   569    			//In general iPreviousView holds the UID of the previous view.
       
   570    			SetViewToBeActivatedIfNeededL( iPreviousView );
       
   571             break;
       
   572             }
       
   573         case EWmlCmdClearTheCache:
       
   574             {
       
   575             ClearTheCacheL(ETrue, ETrue);
       
   576             break;
       
   577             }
       
   578         case EWmlCmdDeleteCookies:
       
   579             {
       
   580             DeleteCookiesL();
       
   581             TBrowserDialogs::InfoNoteL(
       
   582                 R_BROWSER_OK_NOTE, R_QTN_BROWSER_NOTE_COOKIES_DELETED );
       
   583             break;
       
   584             }
       
   585 
       
   586         case EWmlCmdClearAllPrivacy:
       
   587             {
       
   588             ClearAllPrivacyL();
       
   589             break;
       
   590             }
       
   591 
       
   592         case EWmlCmdClearHistory:
       
   593             {
       
   594             ClearHistoryWithPromptL();
       
   595             break;
       
   596             }
       
   597 
       
   598         case EWmlCmdClearFormAndPasswd:
       
   599             {
       
   600             ClearFormAndPasswdDataL(ETrue);
       
   601             break;
       
   602             }
       
   603 
       
   604         case EWmlCmdLaunchHomePage:
       
   605             {
       
   606             if (!IsLaunchHomePageDimmedL())
       
   607                 {
       
   608                 LaunchHomePageL( /* EFalse */ );
       
   609                 }
       
   610             break;
       
   611             }
       
   612         case EWmlCmdDisconnect :
       
   613             {
       
   614             DisconnectL();
       
   615             TBrowserDialogs::InfoNoteL(
       
   616 									R_BROWSER_INFO_NOTE, R_WML_DISCONNECT );
       
   617             break;
       
   618             }
       
   619         case EWmlCmdCancelFetch:
       
   620             {
       
   621             if (SpecialLoadObserver().IsConnectionStarted()) // If Connection request is in processing 
       
   622             {                                                // try to Cancel.
       
   623                 SpecialLoadObserver().CancelConnection();
       
   624                 Connection().Disconnect();
       
   625             }
       
   626             else
       
   627             {
       
   628                 CancelFetch( ETrue );
       
   629             }
       
   630             break;
       
   631             }
       
   632         case EWmlCmdPageInfo:
       
   633             {
       
   634             CSessionAndSecurity* security = CSessionAndSecurity::NewLC(*this);
       
   635             security->ShowPageInfoL();
       
   636             CleanupStack::PopAndDestroy(); // security
       
   637             break;
       
   638             }
       
   639         case EWmlCmdInfoSession:
       
   640             {
       
   641             CSessionAndSecurity* session = CSessionAndSecurity::NewLC(*this);
       
   642             session->ShowSessionInfoL();
       
   643             CleanupStack::PopAndDestroy();  // session
       
   644             break;
       
   645             }
       
   646         case EWmlCmdInfoSecurity:
       
   647             {
       
   648             CSessionAndSecurity* security = CSessionAndSecurity::NewLC(*this);
       
   649             security->ShowSecurityInfoL();
       
   650             CleanupStack::PopAndDestroy();  // security
       
   651             break;
       
   652             }
       
   653         // browser engine specific command
       
   654 #ifdef __SERIES60_HELP
       
   655 
       
   656         case EAknCmdHelp:
       
   657             {
       
   658             HlpLauncher::LaunchHelpApplicationL
       
   659                 ( iEikonEnv->WsSession(), AppHelpContextL() );
       
   660             break;
       
   661             }
       
   662 
       
   663 #endif //__SERIES60_HELP
       
   664 
       
   665 		case EWmlCmdForward:
       
   666 			{
       
   667             HistoryLoadNext();
       
   668 			break;
       
   669 			}
       
   670 
       
   671         case EWmlCmdRotateDisplay:
       
   672             {
       
   673             if ( Orientation() == EAppUiOrientationPortrait )
       
   674                 {
       
   675                 SetOrientationL(EAppUiOrientationLandscape);
       
   676                 }
       
   677             else if (Orientation() == EAppUiOrientationLandscape)
       
   678                 {
       
   679                 SetOrientationL(EAppUiOrientationPortrait);
       
   680                 }
       
   681             else // EAppUiOrientationUnspecified
       
   682                 {
       
   683                 TRect rect = ApplicationRect();
       
   684                 TInt width = rect.Width();
       
   685                 TInt height = rect.Height();
       
   686 
       
   687                 if (width > height)
       
   688                     {
       
   689                     SetOrientationL(EAppUiOrientationPortrait);
       
   690                     }
       
   691                 else
       
   692                     {
       
   693                     SetOrientationL(EAppUiOrientationLandscape);
       
   694                     }
       
   695                 }
       
   696              if(ContentView()->KeymapIsUp())
       
   697              	{             	          
       
   698              	ContentView()->RedrawKeymap();
       
   699              	}
       
   700             break;
       
   701             }
       
   702 
       
   703         case EWmlCmdAboutProduct:
       
   704             {
       
   705             // get version info from browser control and display it
       
   706             ShowNameAndVersionL();
       
   707             break;
       
   708             }
       
   709 		case EWmlCmdProductUpdate:
       
   710             {
       
   711     			/*if(!iAppUpdate)
       
   712 				    {
       
   713 				    iAppUpdate = CBrowserAppUpdate::NewL();
       
   714 				    }
       
   715 			    iAppUpdate->CheckUpdates();*/            
       
   716             break;
       
   717             }
       
   718 
       
   719         //=====================================================================
       
   720         // Multiple Windows Support
       
   721         //
       
   722     	case EWmlCmdSwitchWindow:
       
   723             {
       
   724             if(WindowMgr().WindowCount() > 1)
       
   725 	            {
       
   726 	            // use switch window tab view if pageoverview bitmaps are available
       
   727 	            if (Preferences().UiLocalFeatureSupported( KBrowserGraphicalPage ))
       
   728 	            	{
       
   729 	            	SetViewToBeActivatedIfNeededL( KUidBrowserWindowSelectionViewId );
       
   730 	            	}
       
   731 	            else
       
   732 	            	{
       
   733 	            	SwitchWindowL();
       
   734 		            }            	
       
   735             	}
       
   736             break;
       
   737             }
       
   738     	case EWmlCmdCloseWindow:
       
   739     		{
       
   740     		if ( IsEmbeddedInOperatorMenu() )
       
   741     			{
       
   742     			ExitBrowser( ETrue );
       
   743     			}
       
   744     		else
       
   745 				{
       
   746     			CloseWindowL();
       
   747 				}
       
   748     		break;
       
   749     		}
       
   750     	case EWmlCmdAllowPopups:
       
   751         	{
       
   752         	// Add url to whitelist
       
   753         	HBufC* url( WindowMgr().CurrentWindow()->BrCtlInterface().
       
   754                 PageInfoLC( TBrCtlDefs::EPageInfoUrl ) );
       
   755             PopupEngine().AddUrlToWhiteListL( *url );
       
   756             CleanupStack::PopAndDestroy( url );
       
   757     		break;
       
   758 	    	}
       
   759     	case EWmlCmdBlockPopups:
       
   760         	{
       
   761         	// Remove from whitelist
       
   762         	HBufC* url( WindowMgr().CurrentWindow()->BrCtlInterface().
       
   763                 PageInfoLC( TBrCtlDefs::EPageInfoUrl ) );
       
   764         	PopupEngine().RemoveUrlFromWhiteListL( *url );
       
   765             CleanupStack::PopAndDestroy( url );
       
   766         	break;
       
   767         	}
       
   768         case EWmlCmdShowAnchorHref:
       
   769             {
       
   770 			BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandIdBase + (TInt)TBrCtlDefs::ECommandShowAnchorHref );
       
   771             break;
       
   772             }
       
   773         case EWmlCmdSaveToGallery:
       
   774             {
       
   775             SaveFocusedImageToGalleryL();
       
   776             break;
       
   777             }
       
   778         case EWmlCmdOpenToViewer:
       
   779             {
       
   780             TBrCtlImageCarrier* imageCarrier = BrCtlInterface().FocusedImageLC();
       
   781             if (imageCarrier)
       
   782                 {
       
   783                 CArrayFixFlat<TBrCtlImageCarrier>* imageArray = new( ELeave ) CArrayFixFlat<TBrCtlImageCarrier>(1);
       
   784                 CleanupStack::PushL(imageArray);
       
   785                 imageArray->AppendL(*imageCarrier);
       
   786                 iDialogsProvider->DialogDisplayPageImagesL( *imageArray );
       
   787                 CleanupStack::PopAndDestroy(2); // imageArray, imageCarrier
       
   788                 }
       
   789             break;
       
   790             }
       
   791         case EWmlCmdSaveUrlAsBookmark:
       
   792             {
       
   793             HBufC* url = BrCtlInterface().PageInfoLC(TBrCtlDefs::EPageInfoFocusedNodeUrl);
       
   794             ContentView()->AddNewBookmarkL(EFalse, url);
       
   795             CleanupStack::PopAndDestroy(); // url
       
   796             break;
       
   797             }
       
   798         case EWmlCmdSmartLinkMakeCall:
       
   799             {
       
   800 			BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandIdBase + (TInt)TBrCtlDefs::ECommandSmartLinkMakeCall );
       
   801             break;
       
   802             }
       
   803         case EWmlCmdSmartLinkSendEmail:
       
   804             {
       
   805 			BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandIdBase + (TInt)TBrCtlDefs::ECommandSmartLinkSendEmail );
       
   806             break;
       
   807             }
       
   808         case EWmlCmdSmartLinkSendSms:
       
   809             {
       
   810 			BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandIdBase + (TInt)TBrCtlDefs::ECommandSmartLinkSendMessage );
       
   811             break;
       
   812             }
       
   813         case EWmlCmdSmartLinkAddToContacts:
       
   814             {
       
   815 			BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandIdBase + (TInt)TBrCtlDefs::ECommandSmartLinkAddToPhoneBook );
       
   816             break;
       
   817             }
       
   818         case EWmlCmdLoadFocusedImage:
       
   819             {
       
   820 			BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandIdBase + (TInt)TBrCtlDefs::ECommandLoadFocusedImage );
       
   821             break;
       
   822             }
       
   823         case EWmlCmdLoadImagesOnly:
       
   824             {
       
   825             iPreferences->SetAutoLoadContentL(EWmlSettingsAutoloadImagesNoFlash);
       
   826             break;
       
   827             }
       
   828         case EWmlCmdLoadImagesAndFlash:
       
   829             {
       
   830             iPreferences->SetAutoLoadContentL(EWmlSettingsAutoloadAll);
       
   831             break;
       
   832             }
       
   833         case EWmlCmdOneStepBack:
       
   834             {
       
   835 			BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandIdBase + (TInt)TBrCtlDefs::ECommandOneStepBack );
       
   836             break;
       
   837             }
       
   838         case EEikCmdEditPaste:
       
   839             {
       
   840             TKeyEvent keyEvent;
       
   841             keyEvent.iCode = EKeyF18;  //member of TKeyCode	
       
   842             keyEvent.iScanCode = EEikCmdEditPaste;	
       
   843             keyEvent.iModifiers = EModifierCtrl;
       
   844             keyEvent.iRepeats = 0;
       
   845             TRAP_IGNORE( BrCtlInterface().OfferKeyEventL(keyEvent, EEventKey));
       
   846             }
       
   847             break;
       
   848 	    //=====================================================================
       
   849         default:
       
   850             {
       
   851             if( iStartedUp )
       
   852                 {
       
   853                 // pass to Browser Control
       
   854                 BrCtlInterface().HandleCommandL( aCommand );
       
   855                 }
       
   856             break;
       
   857             }
       
   858         }
       
   859     }
       
   860 
       
   861 // -----------------------------------------------------------------------------
       
   862 // CBrowserAppUi::ActiveView()
       
   863 // -----------------------------------------------------------------------------
       
   864 //
       
   865 CBrowserViewBase* CBrowserAppUi::ActiveView()
       
   866     {
       
   867     TVwsViewId activeViewId;
       
   868     TInt err = GetActiveViewId( activeViewId );
       
   869 
       
   870     if ( !err )
       
   871         {
       
   872         return STATIC_CAST( CBrowserViewBase*, View(activeViewId.iViewUid) );
       
   873         }
       
   874     else
       
   875         {
       
   876         //We should not panic
       
   877         //On 3.0 wk40 it was observed that GetActiveViewId returned with KErrNotFound
       
   878         //in case Browser was in the background
       
   879         //Symbian error?
       
   880         return NULL;
       
   881         }
       
   882     }
       
   883 
       
   884 // -----------------------------------------------------------------------------
       
   885 // CBrowserAppUi::SetRequestedAP()
       
   886 // -----------------------------------------------------------------------------
       
   887 //
       
   888 void CBrowserAppUi::SetRequestedAP( TInt aAp )
       
   889     {
       
   890     iRequestedAp = aAp;
       
   891     }
       
   892 
       
   893 // -----------------------------------------------------------------------------
       
   894 // CBrowserAppUi::IsPageLoaded()
       
   895 // -----------------------------------------------------------------------------
       
   896 //
       
   897 TBool CBrowserAppUi::IsPageLoaded()
       
   898     {
       
   899     TBool ret( EFalse );
       
   900     TInt winCount( WindowMgr().WindowCount() );
       
   901 
       
   902     // at least 2 window -> there is a page loaded
       
   903     if( winCount > 1 )
       
   904         {
       
   905         ret = ETrue;
       
   906         }
       
   907     // 1 window with a loaded content
       
   908     else if( winCount == 1 )
       
   909         {
       
   910         // This checks to see if a dialog is launched and if that is the case, then
       
   911         // the current window is being used, hence returning true.
       
   912         if( iDialogsProvider->IsDialogLaunched() )
       
   913             {
       
   914             ret = ETrue;
       
   915             }
       
   916         else
       
   917             {
       
   918             ret = WindowMgr().IsContentExist();
       
   919             }
       
   920         }
       
   921     // else (winCount == 0), no content view -> no page loaded
       
   922     return ret;
       
   923     }
       
   924 
       
   925 // -----------------------------------------------------------------------------
       
   926 // CBrowserAppUi::Fetching()
       
   927 // -----------------------------------------------------------------------------
       
   928 //
       
   929 TBool CBrowserAppUi::Fetching() const
       
   930     {
       
   931 	// TO DO:
       
   932 	// use load obs., remove ifetchstate from this class and use from loadobs.
       
   933 	// iLoadState
       
   934     //return ( iFetchState == MFetchObserver::ELoadStart );
       
   935 	return ( LoadObserver().LoadState() != CBrowserLoadObserver::ELoadStateIdle );
       
   936     }
       
   937 // -----------------------------------------------------------------------------
       
   938 // CBrowserAppUi::ContentDisplayed()
       
   939 // -----------------------------------------------------------------------------
       
   940 //
       
   941 TBool CBrowserAppUi::ContentDisplayed() const
       
   942     {
       
   943     return ( LoadObserver().ContentDisplayed() );
       
   944     }
       
   945 
       
   946 // -----------------------------------------------------------------------------
       
   947 // CBrowserAppUi::SetContentDisplayed()
       
   948 // -----------------------------------------------------------------------------
       
   949 //
       
   950 void CBrowserAppUi::SetContentDisplayed(TBool aValue) 
       
   951     {
       
   952         LoadObserver().SetContentDisplayed( aValue );
       
   953     }
       
   954 // -----------------------------------------------------------------------------
       
   955 // CBrowserAppUi::FetchBookmarkL
       
   956 // -----------------------------------------------------------------------------
       
   957 //
       
   958 void CBrowserAppUi::FetchBookmarkL( TInt aBookmarkUid )
       
   959     {
       
   960     SetViewToReturnOnClose( KUidBrowserBookmarksViewId );
       
   961     if ( aBookmarkUid == KFavouritesStartPageUid )
       
   962         {
       
   963         TUint defaultAp = Preferences().DefaultAccessPoint();
       
   964         if ( defaultAp != KWmlNoDefaultAccessPoint ) // There is no access point defined
       
   965             {
       
   966             CApAccessPointItem* apItem = Preferences().AllPreferencesL().iDefaultAPDetails;
       
   967             if ( apItem )
       
   968                 {
       
   969                 const HBufC* currentHP = apItem->ReadConstLongTextL( EApWapStartPage );
       
   970                 //TPtrC currentHP(apItem->StartPage()); // Get the start page of the access point.
       
   971                 TFavouritesWapAp accessPoint;
       
   972 
       
   973                 FetchL( *currentHP, KNullDesC, KNullDesC, accessPoint,
       
   974                     CBrowserLoadObserver::ELoadUrlTypeStartPage ); // Fetch the start page.
       
   975 				}
       
   976             }
       
   977         }
       
   978     else
       
   979         {
       
   980         RFavouritesDb db;
       
   981         User::LeaveIfError( db.Open( iFavouritesSess, KBrowserBookmarks ) );
       
   982         CleanupClosePushL<RFavouritesDb>( db );
       
   983 
       
   984         CFavouritesItem* item = CFavouritesItem::NewLC();
       
   985         User::LeaveIfError( db.Get( aBookmarkUid, *item ) );
       
   986 
       
   987         FetchBookmarkL( *item );
       
   988         CleanupStack::PopAndDestroy( 2 );  // item, db
       
   989         }
       
   990     }
       
   991 
       
   992 // -----------------------------------------------------------------------------
       
   993 // CBrowserAppUi::FetchBookmarkL
       
   994 // -----------------------------------------------------------------------------
       
   995 //
       
   996 void CBrowserAppUi::FetchBookmarkL( const CFavouritesItem& aBookmarkItem )
       
   997     {
       
   998     SetViewToReturnOnClose( KUidBrowserBookmarksViewId );
       
   999     if ( Util::CheckBookmarkApL( *this, aBookmarkItem.WapAp()) )
       
  1000         FetchL
       
  1001             (
       
  1002             aBookmarkItem.Url() ,
       
  1003             aBookmarkItem.UserName(),
       
  1004             aBookmarkItem.Password(),
       
  1005             aBookmarkItem.WapAp(),
       
  1006             CBrowserLoadObserver::ELoadUrlTypeOther
       
  1007             );
       
  1008     else
       
  1009         TBrowserDialogs::ErrorNoteL( R_WML_INVALID_AP );
       
  1010     }
       
  1011 
       
  1012 // -----------------------------------------------------------------------------
       
  1013 // CBrowserAppUi::SetViewToBeActivatedIfNeededL
       
  1014 // -----------------------------------------------------------------------------
       
  1015 //
       
  1016 void CBrowserAppUi::SetViewToBeActivatedIfNeededL( TUid aUid, TInt aMessageId )
       
  1017     {
       
  1018 	CBrowserAppDocument* doc = STATIC_CAST(CBrowserAppDocument*, Document());
       
  1019 
       
  1020 	if((iCurrentView != aUid) && (aUid != KUidBrowserSettingsViewId))
       
  1021 	{
       
  1022 		iPreviousView = iCurrentView;
       
  1023 		iCurrentView = aUid;
       
  1024 	}
       
  1025 
       
  1026 	//Check view id validity first
       
  1027 	if ( aUid == KUidBrowserNullViewId )
       
  1028 		{
       
  1029 		SetLastActiveViewId( KUidBrowserBookmarksViewId );
       
  1030 		SetViewToBeActivatedIfNeededL( LastActiveViewId() );
       
  1031            return;
       
  1032 		}
       
  1033 
       
  1034 	if ( ( aUid != KUidBrowserContentViewId ) && 
       
  1035 	   ( LastActiveViewId() == KUidBrowserContentViewId ) )
       
  1036 		{
       
  1037 		ContentView()->SetFullScreenOffL();
       
  1038 		}
       
  1039 	
       
  1040 	if ( iWindowManager->ContentView()->FullScreenMode() )
       
  1041 	    {
       
  1042     	if ( aUid == KUidBrowserFeedsFeedViewId )
       
  1043     	    {
       
  1044     	    BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandIdBase + 
       
  1045     	        (TInt)TBrCtlDefs::ECommandLeaveFullscreenBrowsing );
       
  1046     	    }
       
  1047     	
       
  1048     	else  if ( aUid != KUidBrowserFeedsTopicViewId && 
       
  1049             aUid != KUidBrowserFeedsFolderViewId && 
       
  1050             aUid != KUidBrowserBookmarksViewId )
       
  1051             {
       
  1052             BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandIdBase + 
       
  1053                 (TInt)TBrCtlDefs::ECommandEnterFullscreenBrowsing );
       
  1054             }
       
  1055     	}
       
  1056 
       
  1057 
       
  1058 	if ( iIsForeground )
       
  1059 		{
       
  1060         if ( aUid == KUidBrowserSettingsViewId )
       
  1061 	        {
       
  1062             CEikStatusPane* sp = STATIC_CAST( CAknAppUi*,
       
  1063 						  CEikonEnv::Static()->EikAppUi() )
       
  1064 			                ->StatusPane();
       
  1065             sp->DrawNow();
       
  1066             }
       
  1067 
       
  1068 		ActivateLocalViewL(  aUid, TUid::Uid( aMessageId ), KNullDesC8 );
       
  1069 		}
       
  1070 	else
       
  1071 		{
       
  1072 		iViewToBeActivatedIfNeeded = aUid;
       
  1073 		}
       
  1074     }
       
  1075 
       
  1076 // -----------------------------------------------------------------------------
       
  1077 // CBrowserAppUi::LastActiveViewId
       
  1078 // -----------------------------------------------------------------------------
       
  1079 //
       
  1080 TUid CBrowserAppUi::LastActiveViewId() const
       
  1081     {
       
  1082     return iLastViewId;
       
  1083     }
       
  1084 
       
  1085 // -----------------------------------------------------------------------------
       
  1086 // CBrowserAppUi::SetLastActiveViewId
       
  1087 // -----------------------------------------------------------------------------
       
  1088 //
       
  1089 void CBrowserAppUi::SetLastActiveViewId( TUid aUid )
       
  1090     {
       
  1091 LOG_ENTERFN("CBrowserAppUi::SetLastActiveViewId");
       
  1092     LOG_WRITE_FORMAT(" SetLastActiveViewId: %d", aUid);
       
  1093     iLastViewId = aUid;
       
  1094     }
       
  1095 
       
  1096 // -----------------------------------------------------------------------------
       
  1097 // CBrowserAppUi::ExitInProgress
       
  1098 // -----------------------------------------------------------------------------
       
  1099 //
       
  1100 TBool CBrowserAppUi::ExitInProgress() const
       
  1101     {
       
  1102     return iExitInProgress;
       
  1103     }
       
  1104 
       
  1105 // -----------------------------------------------------------------------------
       
  1106 // CBrowserAppUi::ExitInProgress
       
  1107 // -----------------------------------------------------------------------------
       
  1108 //
       
  1109 void CBrowserAppUi::SetExitInProgress( TBool aValue )
       
  1110     {
       
  1111     iExitInProgress = aValue;
       
  1112     }
       
  1113 
       
  1114 // -----------------------------------------------------------------------------
       
  1115 // CBrowserAppUi::IsConnecting
       
  1116 // -----------------------------------------------------------------------------
       
  1117 //
       
  1118 TBool CBrowserAppUi::IsConnecting() const
       
  1119     {
       
  1120     return ( LoadObserver().LoadState() != CBrowserLoadObserver::ELoadStateIdle );
       
  1121     }
       
  1122 
       
  1123 // -----------------------------------------------------------------------------
       
  1124 // CBrowserAppUi::HandleForegroundEventL
       
  1125 // -----------------------------------------------------------------------------
       
  1126 //
       
  1127 void CBrowserAppUi::HandleForegroundEventL( TBool aForeground )
       
  1128     {
       
  1129     // Handle this event only if the browser is started up
       
  1130     if ( !StartedUp() )
       
  1131     	{
       
  1132     	return;
       
  1133     	}
       
  1134     iIsForeground = IsForeground();
       
  1135     if( iIsForeground )
       
  1136     	{
       
  1137  	    if (iViewToBeActivatedIfNeeded.iUid)
       
  1138 	        {
       
  1139 	        ActivateLocalViewL( iViewToBeActivatedIfNeeded );
       
  1140 	        }
       
  1141 	    else
       
  1142 	        {
       
  1143 	        TVwsViewId activeViewId;
       
  1144 	        if( ( GetActiveViewId( activeViewId ) == KErrNone ) &&	        		
       
  1145 	            (  LastActiveViewId()  != activeViewId.iViewUid ) )
       
  1146 	             {
       
  1147 	             // LastActiveViewId() might return with 0!
       
  1148 	             TRAP_IGNORE( ActivateLocalViewL( LastActiveViewId() ) );
       
  1149 	             }
       
  1150 	        }
       
  1151     	}
       
  1152 	iViewToBeActivatedIfNeeded.iUid = 0;    
       
  1153     CAknViewAppUi::HandleForegroundEventL( aForeground );
       
  1154             
       
  1155     if( iIsForeground )
       
  1156         {	               
       
  1157         // We need to refresh the softkeys
       
  1158         UpdateCbaL();
       
  1159         if ( Preferences().FullScreen() == EWmlSettingsFullScreenFullScreen )
       
  1160             {
       
  1161             ContentView()->UpdateFullScreenL();
       
  1162             }
       
  1163 
       
  1164         if( !Fetching() )
       
  1165             {
       
  1166             Display().StopProgressAnimationL();
       
  1167             }
       
  1168         }
       
  1169 
       
  1170     if (iWindowManager)
       
  1171         {
       
  1172         iWindowManager->SendCommandToAllWindowsL( iIsForeground
       
  1173             ? (TInt)TBrCtlDefs::ECommandAppForeground + (TInt)TBrCtlDefs::ECommandIdBase
       
  1174             : (TInt)TBrCtlDefs::ECommandAppBackground + (TInt)TBrCtlDefs::ECommandIdBase);
       
  1175         }
       
  1176 
       
  1177     // if browser comes to foreground and exit is requested,
       
  1178     // asyncronous exit is started
       
  1179     if( iIsForeground && iExitFromEmbeddedMode && !IsEmbeddedInOperatorMenu() )
       
  1180         {
       
  1181         iBrowserAsyncExit->Start();
       
  1182         } 
       
  1183     }
       
  1184 
       
  1185 // -----------------------------------------------------------------------------
       
  1186 // CBrowserAppUi::FetchL
       
  1187 // -----------------------------------------------------------------------------
       
  1188 //
       
  1189 void CBrowserAppUi::FetchL(
       
  1190 						   const TDesC& aUrl,
       
  1191                            const TDesC& aUsername,
       
  1192                            const TDesC& aPassword,
       
  1193                            const TFavouritesWapAp& aAccessPoint,
       
  1194                            CBrowserLoadObserver::TBrowserLoadUrlType aUrlType )
       
  1195     {
       
  1196 LOG_ENTERFN("CBrowserAppUi::FetchL");
       
  1197     // Let's cancel the previous fetch if any
       
  1198     if ( Fetching() )
       
  1199 		{
       
  1200         CancelFetch();
       
  1201 		}
       
  1202 
       
  1203     // iDoNotRestoreContentFlag = EFalse;
       
  1204 
       
  1205     TInt toPop = 0;
       
  1206     TUriParser uriParser;
       
  1207     TInt err = uriParser.Parse(aUrl);
       
  1208     if ( !err && aUrl.Length() )
       
  1209         {
       
  1210         // check url for missing scheme and add default scheme if needed
       
  1211         HBufC* url = NULL;
       
  1212         HBufC* resultUrlBuf = NULL;
       
  1213         //find ://
       
  1214         TPtrC scheme = uriParser.Extract( EUriScheme );
       
  1215         // add http:// scheme as default if it is missing
       
  1216         if( scheme.Length() == 0 )
       
  1217             { 
       
  1218             //put the "http://" schema before the string
       
  1219             url = HBufC::NewLC( aUrl.Length() + KDefaultSchemaLength );
       
  1220             url->Des().Copy( KDefaultSchema );
       
  1221             url->Des().Append( aUrl );
       
  1222             ++toPop;  // url
       
  1223             resultUrlBuf = CreateFullUrlLC( url->Des(), aUsername, aPassword );
       
  1224 		    LogRequestedPageToRecentUrlL(  url->Des() );
       
  1225             }
       
  1226         else
       
  1227             {
       
  1228             resultUrlBuf = CreateFullUrlLC( aUrl, aUsername, aPassword );
       
  1229 		    LogRequestedPageToRecentUrlL(  aUrl );
       
  1230             }
       
  1231         ++toPop;  // resultUrlBuf
       
  1232     
       
  1233     
       
  1234         if ( aAccessPoint.IsNull() || aAccessPoint.IsDefault() || (!Util::IsValidAPFromParamL( *this, aAccessPoint.ApId() )) )
       
  1235 			{
       
  1236             if ( (Preferences().AccessPointSelectionMode() == EConnectionMethod) || 
       
  1237                  (Preferences().AccessPointSelectionMode() == EAlwaysAsk) )
       
  1238                 {
       
  1239     			iRequestedAp = Preferences().DefaultAccessPoint();
       
  1240                 }
       
  1241             else if ( Preferences().AccessPointSelectionMode() == EDestination ) 
       
  1242                 {
       
  1243                 // for bug fix MLAN-7EKFV4
       
  1244     			iRequestedAp = KWmlNoDefaultAccessPoint;
       
  1245                 }
       
  1246             }
       
  1247 		else
       
  1248 			{
       
  1249 			iRequestedAp = aAccessPoint.ApId();
       
  1250 			}
       
  1251 #ifndef __WINSCW__ //On WINS we don't want this dlg to come up
       
  1252 					//as the ConnMan will present us with a selection
       
  1253         BROWSER_LOG( ( _L( "requestedAp: %d" ), iRequestedAp ) );
       
  1254         // it's ok to assign in the case of EDest, since CBrCtl doesn't use the apId passed in LoadUrlL()
       
  1255         TUint32 IAPid = iRequestedAp;
       
  1256         TUint32 defaultSnap =  iPreferences->DefaultSnapId();
       
  1257         // if no AP or SNAP is defined, define it
       
  1258         if( (iRequestedAp == KWmlNoDefaultAccessPoint && iPreferences->AccessPointSelectionMode() == EConnectionMethod) || 
       
  1259             (defaultSnap == KWmlNoDefaultSnapId && iPreferences->AccessPointSelectionMode() == EDestination) )
       
  1260             {
       
  1261             StartPreferencesViewL( EShowAlwaysAsk | EShowDestinations | EShowConnectionMethods );
       
  1262             }
       
  1263         //Check AP and snap if it is still not defined, set always ask mode this case
       
  1264         if ( (iRequestedAp == KWmlNoDefaultAccessPoint && iPreferences->AccessPointSelectionMode() == EConnectionMethod) ||
       
  1265              (defaultSnap == KWmlNoDefaultSnapId && iPreferences->AccessPointSelectionMode() == EDestination) )
       
  1266             {
       
  1267             BROWSER_LOG( ( _L( "AP or SNAP was not added set to Always ask mode" ) ) );
       
  1268             iPreferences->SetAccessPointSelectionModeL(EAlwaysAsk );
       
  1269             }
       
  1270         if ( iRequestedAp == KWmlNoDefaultAccessPoint )
       
  1271             {
       
  1272             // For all cases just set dummy id to IAPid not to let Ap engine or Ap util to leave
       
  1273             // In the cases of EDest, EAA, since ap will not be used, it's ok to do so as well
       
  1274             // In the case of EDest, need to preserve KWmlNoDefaultAccessPoint as the value
       
  1275             // it'll be used in BrowserSpecialLoadObserver.cpp for for bug fix MLAN-7EKFV4
       
  1276             if ( Preferences().AccessPointSelectionMode() != EDestination )
       
  1277                 {
       
  1278     		    iRequestedAp = 2;
       
  1279                 }
       
  1280             IAPid = 2;
       
  1281             }
       
  1282         else
       
  1283             {
       
  1284     		BROWSER_LOG( ( _L( "AP added" ) ) );
       
  1285     		IAPid = Util::IapIdFromWapIdL( *this, iRequestedAp );  // Get currently active ap
       
  1286     		BROWSER_LOG( ( _L( "No AP 2" ) ) );
       
  1287             }
       
  1288 
       
  1289 #else	//we can use any numbers here
       
  1290         // alr: snap on emulator should not exist; use cm mode instead?
       
  1291 		iRequestedAp = 2;
       
  1292 		TUint32 IAPid = 2;
       
  1293 #endif //__WINSCW__
       
  1294 
       
  1295 		err = KErrNone;
       
  1296 		BROWSER_LOG( ( _L( "Load the URL" ) ) );
       
  1297 		
       
  1298 		if ( iPreferences->SearchFeature() || iPreferences->ServiceFeature())
       
  1299 		    {
       
  1300     		iSpecialSchemeinAddress = EFalse;
       
  1301             
       
  1302             HBufC* searchScheme = HBufC::NewLC( KMaxHomePgUrlLength );  // cleanupstack
       
  1303             TPtr searchSchemePtr( searchScheme->Des() );
       
  1304             ++toPop;
       
  1305             
       
  1306             HBufC* serviceScheme = HBufC::NewLC( KMaxHomePgUrlLength );  // cleanupstack
       
  1307             TPtr serviceSchemePtr( serviceScheme->Des() );
       
  1308             ++toPop;
       
  1309             
       
  1310             iPreferences->GetStringValueL( KBrowserSearchProviderUrl, KMaxHomePgUrlLength, searchSchemePtr );
       
  1311             iPreferences->GetStringValueL( KBrowserServiceUrl, KMaxHomePgUrlLength, serviceSchemePtr );
       
  1312                     
       
  1313             TInt err = uriParser.Parse(searchSchemePtr);
       
  1314             if (!err)
       
  1315                 searchSchemePtr = uriParser.Extract( EUriScheme );
       
  1316             
       
  1317             err = uriParser.Parse(serviceSchemePtr);
       
  1318             if (!err)
       
  1319                 serviceSchemePtr = uriParser.Extract( EUriScheme );
       
  1320             
       
  1321             if( scheme.Length() != 0 )
       
  1322                 {
       
  1323                 if( !scheme.Compare(serviceSchemePtr) || !scheme.Compare(searchSchemePtr) )
       
  1324                 	{
       
  1325                 	iSpecialSchemeinAddress = ETrue;
       
  1326                 	TRAP( err, BrCtlInterface().LoadUrlL( resultUrlBuf->Des(), IAPid ) );
       
  1327                 	}
       
  1328                 else
       
  1329                 	{
       
  1330                 	LoadObserver().DoStartLoad( aUrlType );
       
  1331                     TRAP( err, BrCtlInterface().LoadUrlL( resultUrlBuf->Des(), IAPid ) );
       
  1332                 	}            
       
  1333                 }
       
  1334 	        }
       
  1335 	    else
       
  1336 	        {
       
  1337 	        LoadObserver().DoStartLoad( aUrlType );
       
  1338             TRAP( err, BrCtlInterface().LoadUrlL( resultUrlBuf->Des(), IAPid ) );
       
  1339 	        }
       
  1340         
       
  1341 		CleanupStack::PopAndDestroy(toPop); //resultUrlBuf and url if needed
       
  1342 		BROWSER_LOG( ( _L( "No AP 4 %d" ), err  ) );
       
  1343 		if ( err != KErrNone )
       
  1344     		{
       
  1345 		    CancelFetch();
       
  1346 	    	}
       
  1347         }
       
  1348 
       
  1349     BROWSER_LOG( ( _L( "Check the result" ) ) );
       
  1350 	switch ( err )
       
  1351 		{
       
  1352 		case KErrNotFound:
       
  1353 			{
       
  1354 			(*(CBrowserBookmarksView*)View( KUidBrowserBookmarksViewId )).UpdateGotoPaneL();
       
  1355 			iCoeEnv->HandleError( KBrsrMalformedUrl );
       
  1356 			BROWSER_LOG( ( _L( "KErrNotFound" ) ) );
       
  1357 			break;
       
  1358 			}
       
  1359 		case KUriUtilsErrInvalidUri: // return value of TUriParser::Parse
       
  1360 			{
       
  1361 			(*(CBrowserBookmarksView*)View( KUidBrowserBookmarksViewId )).UpdateGotoPaneL();
       
  1362 			iCoeEnv->HandleError( KBrsrUnknownScheme );
       
  1363 			BROWSER_LOG( ( _L( "KUriUtilsErrInvalidUri" ) ) );
       
  1364 			break;
       
  1365 			}
       
  1366 		case KErrNone:
       
  1367 		    {
       
  1368 		    BROWSER_LOG( ( _L( "KErrNone" ) ) );
       
  1369             ContentView()->ResetPreviousViewFlag();
       
  1370 		    break;
       
  1371 		    }
       
  1372         case KErrCancel:
       
  1373             {
       
  1374             BROWSER_LOG( ( _L( "KErrCancel" ) ) );
       
  1375             // do nothing, it is already cancelled by CancelFetch().
       
  1376             break;
       
  1377             }
       
  1378         default:
       
  1379 			{
       
  1380 			BROWSER_LOG( ( _L( "default" ) ) );
       
  1381 			User::Leave( err );  // pass error code to caller
       
  1382 			break;
       
  1383 			}
       
  1384 		}
       
  1385 	}
       
  1386 
       
  1387 // -----------------------------------------------------------------------------
       
  1388 // CBrowserAppUi::ExitBrowser()
       
  1389 // -----------------------------------------------------------------------------
       
  1390 //
       
  1391 void CBrowserAppUi::ExitBrowser( TBool aUserInitiated )
       
  1392     {
       
  1393     LOG_ENTERFN("CBrowserAppUi::ExitBrowser");
       
  1394 
       
  1395     TInt err( KErrNone );
       
  1396 	TBool isStandAlone = !IsEmbeddedModeOn();
       
  1397 	BROWSER_LOG( ( _L( " isStandAlone: %d" ), isStandAlone ) );
       
  1398 
       
  1399 	if( isStandAlone && aUserInitiated )
       
  1400 	    {
       
  1401 		if( !BrCtlInterface().OkToExit() )
       
  1402 		    {
       
  1403 		    return;
       
  1404 		    }
       
  1405 	    }
       
  1406 
       
  1407 	//If launch with parameters is in progress, do not exit now
       
  1408 	//as it can lead to synchronisation problems in embedded mode
       
  1409 	if ( iParametrizedLaunchInProgress == 1 )
       
  1410 		{
       
  1411 		BROWSER_LOG( ( _L( " iParametrizedLaunchInProgress" ) ) );
       
  1412 		return;
       
  1413 		}
       
  1414 
       
  1415     // Operator feature - Display confirmation note on exit only if exit is initiated by user.
       
  1416     // Skip displaying exit confirmation if exit is initiated from fast swap window.
       
  1417     BROWSER_LOG(  ( _L( " iPreferences:  %d" ), iPreferences ) );
       
  1418     if ( iPreferences->QueryOnExit() && aUserInitiated )
       
  1419         {
       
  1420         BROWSER_LOG( ( _L( " iPreferences->QueryOnExit()" ) ) );
       
  1421         TBool confirmdialog( EFalse );
       
  1422         TRAP( err, confirmdialog = TBrowserDialogs::ConfirmQueryYesNoL( R_TEXT_WML_EXIT_CONFIRM ) );
       
  1423         if ( !confirmdialog )
       
  1424         	{
       
  1425             return;
       
  1426         	}
       
  1427 		}
       
  1428 
       
  1429     //delete attacment from mailer if existing
       
  1430 	CCoeEnv::Static()->FsSession().Delete( KAttachment() );
       
  1431 	
       
  1432     BROWSER_LOG( ( _L(" iConnection:  %d"), iConnection ) );
       
  1433     BROWSER_LOG( ( _L(" iExitFromEmbeddedMode:  %d"), iExitFromEmbeddedMode ) );
       
  1434     // if browser is embedded, should not call Exit(),
       
  1435     // just delete the object, otherwise leave occurs.
       
  1436     if( ( IsEmbeddedInOperatorMenu() || IsEmbeddedModeOn() ) &&
       
  1437             !ExitInProgress() &&
       
  1438              ((LoadObserver().LoadUrlType() == CBrowserLoadObserver::ELoadUrlTypeEmbeddedBrowserWithUrl) ||
       
  1439               (LoadObserver().LoadUrlType() == CBrowserLoadObserver::ELoadUrlTypeOther)   ) )
       
  1440                // ELoadUrlTypeEmbeddedBrowserWithUrl is typical for load via Phonebook, MMS, OperatorMenu
       
  1441                // ELoadUrlTypeOther is typical via Media download since those are via GotoPane entered urls
       
  1442         {
       
  1443         // Simulate an escape key event in order to close any open resources (for example an open dialog)
       
  1444         TKeyEvent keyEvent;
       
  1445         keyEvent.iModifiers = 0;
       
  1446         keyEvent.iRepeats = 0;
       
  1447         keyEvent.iCode = EKeyEscape;
       
  1448         keyEvent.iScanCode = EStdKeyEscape;
       
  1449         TRAP_IGNORE(iCoeEnv->SimulateKeyEventL( keyEvent, EEventKey ));
       
  1450 
       
  1451         // force not to load Exit() when next time call this function,
       
  1452         // just delete the object
       
  1453         SetExitFromEmbeddedMode( ETrue );
       
  1454         SetExitInProgress( ETrue );
       
  1455         BROWSER_LOG( ( _L( " iBrowserAsyncExit->Start()" ) ) );
       
  1456         iBrowserAsyncExit->Start();
       
  1457         }
       
  1458     else if( iExitFromEmbeddedMode )
       
  1459     	{
       
  1460     	BROWSER_LOG( ( _L( " delete this;" ) ) );
       
  1461     	if ( iConnection )
       
  1462     		{
       
  1463             TRAP_IGNORE( SendDisconnectEventL() );
       
  1464     		iConnection->Disconnect();
       
  1465 #ifdef __RSS_FEEDS
       
  1466             BROWSER_LOG( ( _L( " iFeedsClientUtilities->DisconnectFeedsViewL()" ) ) );
       
  1467             TRAP_IGNORE( iFeedsClientUtilities->DisconnectFeedsViewL() );
       
  1468             //notify feeds engine to close the connection
       
  1469             TRAP_IGNORE( iFeedsClientUtilities->DisconnectManualUpdateConnectionL() );
       
  1470 #endif
       
  1471     		}
       
  1472         PrepareToExit();
       
  1473         Exit();
       
  1474     	}
       
  1475     else
       
  1476     	{
       
  1477     	BROWSER_LOG( ( _L( " Exit()" ) ) );
       
  1478     	if ( iConnection )
       
  1479     		{
       
  1480             TRAP_IGNORE( SendDisconnectEventL() );
       
  1481     		iConnection->Disconnect();
       
  1482 #ifdef __RSS_FEEDS
       
  1483     		BROWSER_LOG( ( _L( " iFeedsClientUtilities->DisconnectFeedsViewL()" ) ) );
       
  1484     		TRAP_IGNORE( iFeedsClientUtilities->DisconnectFeedsViewL() );
       
  1485     		//notify feeds engine to close the connection
       
  1486 			TRAP_IGNORE( iFeedsClientUtilities->DisconnectManualUpdateConnectionL() );
       
  1487 #endif
       
  1488     		}
       
  1489         Exit();
       
  1490     	}
       
  1491     }
       
  1492 
       
  1493 // -----------------------------------------------------------------------------
       
  1494 // CBrowserAppUi::Display
       
  1495 // -----------------------------------------------------------------------------
       
  1496 //
       
  1497 MDisplay& CBrowserAppUi::Display() const
       
  1498     {
       
  1499     CBrowserWindow *window = iWindowManager->CurrentWindow();
       
  1500     __ASSERT_DEBUG( window, Util::Panic( Util::EUninitializedData ) );
       
  1501     return window->Display();
       
  1502     }
       
  1503 
       
  1504 // -----------------------------------------------------------------------------
       
  1505 // CBrowserAppUi::SoftkeysObserver()
       
  1506 // -----------------------------------------------------------------------------
       
  1507 //
       
  1508 CBrowserSoftkeysObserver& CBrowserAppUi::SoftkeysObserver() const
       
  1509     {
       
  1510     CBrowserWindow *window = iWindowManager->CurrentWindow();
       
  1511     __ASSERT_DEBUG( window, Util::Panic( Util::EUninitializedData ) );
       
  1512     return window->SoftkeysObserver();
       
  1513     }
       
  1514 
       
  1515 // -----------------------------------------------------------------------------
       
  1516 // CBrowserAppUi::CommsModel
       
  1517 // -----------------------------------------------------------------------------
       
  1518 //
       
  1519 MCommsModel& CBrowserAppUi::CommsModel() const
       
  1520     {
       
  1521     __ASSERT_DEBUG( iCommsModel,
       
  1522         Util::Panic( Util::EUninitializedData ) );
       
  1523     return *iCommsModel;
       
  1524     }
       
  1525 
       
  1526 // -----------------------------------------------------------------------------
       
  1527 // CBrowserAppUi::Preferences
       
  1528 // -----------------------------------------------------------------------------
       
  1529 //
       
  1530 MPreferences& CBrowserAppUi::Preferences() const
       
  1531     {
       
  1532     __ASSERT_DEBUG( iPreferences,
       
  1533         Util::Panic( Util::EUninitializedData ) );
       
  1534     return *iPreferences;
       
  1535     }
       
  1536 
       
  1537 // -----------------------------------------------------------------------------
       
  1538 // CBrowserAppUi::Connection
       
  1539 // -----------------------------------------------------------------------------
       
  1540 //
       
  1541 MConnection& CBrowserAppUi::Connection() const
       
  1542     {
       
  1543     __ASSERT_DEBUG( iConnection,
       
  1544         Util::Panic( Util::EUninitializedData ) );
       
  1545     return *iConnection;
       
  1546     }
       
  1547 
       
  1548 // -----------------------------------------------------------------------------
       
  1549 // CBrowserAppUi::BrCtlInterface
       
  1550 // -----------------------------------------------------------------------------
       
  1551 CBrCtlInterface& CBrowserAppUi::BrCtlInterface() const
       
  1552     {
       
  1553     CBrowserWindow *window = iWindowManager->CurrentWindow();
       
  1554     __ASSERT_DEBUG( window, Util::Panic( Util::EUninitializedData ) );
       
  1555     return window->BrCtlInterface();
       
  1556     }
       
  1557 
       
  1558 // -----------------------------------------------------------------------------
       
  1559 // CBrowserAppUi::LoadObserver
       
  1560 // -----------------------------------------------------------------------------
       
  1561 //
       
  1562 CBrowserLoadObserver& CBrowserAppUi::LoadObserver() const
       
  1563     {
       
  1564     CBrowserWindow *window = iWindowManager->CurrentWindow();
       
  1565     __ASSERT_DEBUG( window, Util::Panic( Util::EUninitializedData ) );
       
  1566     return window->LoadObserver();
       
  1567     }
       
  1568 
       
  1569 // -----------------------------------------------------------------------------
       
  1570 // CBrowserAppUi::SpecialLoadObserver
       
  1571 // -----------------------------------------------------------------------------
       
  1572 //
       
  1573 CBrowserSpecialLoadObserver& CBrowserAppUi::SpecialLoadObserver() const
       
  1574     {
       
  1575     CBrowserWindow *window = iWindowManager->CurrentWindow();
       
  1576     __ASSERT_DEBUG( window, Util::Panic( Util::EUninitializedData ) );
       
  1577     return window->SpecialLoadObserver();
       
  1578     }
       
  1579 
       
  1580 // -----------------------------------------------------------------------------
       
  1581 // CBrowserAppUi::DialogsProvider
       
  1582 // -----------------------------------------------------------------------------
       
  1583 //
       
  1584 CBrowserDialogsProvider& CBrowserAppUi::DialogsProvider() const
       
  1585 	{
       
  1586 	return *iDialogsProvider;
       
  1587 	}
       
  1588 
       
  1589 // -----------------------------------------------------------------------------
       
  1590 // CBrowserAppUi::PopupEngine
       
  1591 // -----------------------------------------------------------------------------
       
  1592 //
       
  1593 CBrowserPopupEngine& CBrowserAppUi::PopupEngine() const
       
  1594     {
       
  1595     return *iPopupEngine;
       
  1596     }
       
  1597 
       
  1598 // -----------------------------------------------------------------------------
       
  1599 // CBrowserAppUi::WindowMgr()
       
  1600 // -----------------------------------------------------------------------------
       
  1601 //
       
  1602 CBrowserWindowManager& CBrowserAppUi::WindowMgr() const
       
  1603     {
       
  1604     return *iWindowManager;
       
  1605     }
       
  1606 
       
  1607 // -----------------------------------------------------------------------------
       
  1608 // CBrowserAppUi::IsCancelFetchAllowed
       
  1609 // -----------------------------------------------------------------------------
       
  1610 //
       
  1611 TBool CBrowserAppUi::IsCancelFetchAllowed() const
       
  1612     {
       
  1613     return ETrue;
       
  1614     }
       
  1615 
       
  1616 // -----------------------------------------------------------------------------
       
  1617 // CBrowserAppUi::UpdateCbaL()
       
  1618 // -----------------------------------------------------------------------------
       
  1619 //
       
  1620 void CBrowserAppUi::UpdateCbaL()
       
  1621     {
       
  1622     if( ActiveView() )
       
  1623         {
       
  1624         ActiveView()->UpdateCbaL();
       
  1625         }
       
  1626     }
       
  1627 
       
  1628 void CBrowserAppUi::LogAccessToRecentUrlL( CBrCtlInterface& aBrCtlInterface )
       
  1629     {
       
  1630     if ((ADAPTIVEBOOKMARKS)&&(!(Preferences().AdaptiveBookmarks()==EWmlSettingsAdaptiveBookmarksOff )))
       
  1631         {
       
  1632         HBufC* url = aBrCtlInterface.PageInfoLC( TBrCtlDefs::EPageInfoUrl );
       
  1633         HBufC* name = aBrCtlInterface.PageInfoLC( TBrCtlDefs::EPageInfoTitle );
       
  1634         if( url && url->Length() )
       
  1635             {
       
  1636             // If url is same as the one in the store delete it because the url will be rewritten 
       
  1637             // along with the name 
       
  1638             iRecentUrlStore->DeleteData(*url);
       
  1639             
       
  1640             TInt index;
       
  1641             index = url->Des().LocateReverse(KSlash);
       
  1642             // If the only difference between the url in the store and the one we are writing is a "/" 
       
  1643             // at the end of the url, delete the one in the store because it will be rewritten along 
       
  1644             // with the name
       
  1645             if (index == url->Length()-1)
       
  1646             	{
       
  1647 	            HBufC* urlwoslash = HBufC::NewLC( url->Length() );
       
  1648 				urlwoslash->Des().Copy( *url );
       
  1649 				urlwoslash->Des().Delete(url->Length() -1, 2);         
       
  1650 	            
       
  1651 	            iRecentUrlStore->DeleteData(*urlwoslash);
       
  1652 
       
  1653 	            CleanupStack::PopAndDestroy(); //urlwoslash            	
       
  1654             	}
       
  1655                         
       
  1656             if (name && name->Length())
       
  1657             	{
       
  1658             	iRecentUrlStore->SaveDataL(*url,*name);
       
  1659             	}
       
  1660             else
       
  1661             	{
       
  1662             	if (url->Length() > KFavouritesMaxName)
       
  1663                 	{
       
  1664                 	// name will be the url but it needs to be compressed to fit max name length
       
  1665                 	HBufC* cname = HBufC::NewLC(KFavouritesMaxName);
       
  1666                 	TInt edgeStringLen = ((KFavouritesMaxName / 2) - 3);
       
  1667                 	TPtrC cnameRight( url->Right( edgeStringLen ) );
       
  1668                 	TPtrC cnameLeft( url->Left( edgeStringLen ));
       
  1669                 	TPtr cnameDes = cname->Des();
       
  1670 
       
  1671                   	cnameDes.Append( cnameLeft );
       
  1672                    	cnameDes.AppendFill( TChar(KDot),5 );   // '.....'
       
  1673                    	cnameDes.Append( cnameRight );
       
  1674                 	iRecentUrlStore->SaveDataL(*url,*cname);
       
  1675                     CleanupStack::PopAndDestroy();//cname
       
  1676                 	}
       
  1677                 else
       
  1678             	    {
       
  1679             	    iRecentUrlStore->SaveDataL(*url,*url);
       
  1680             	    }
       
  1681             	}
       
  1682             }
       
  1683         CleanupStack().PopAndDestroy(2); // url, name
       
  1684         }
       
  1685     }
       
  1686 
       
  1687 void CBrowserAppUi::LogRequestedPageToRecentUrlL( const TDesC& aUrl )
       
  1688     {
       
  1689     if ((ADAPTIVEBOOKMARKS)&&(!(Preferences().AdaptiveBookmarks()==EWmlSettingsAdaptiveBookmarksOff )))
       
  1690         {
       
  1691         HBufC *url = HBufC::NewLC( aUrl.Length() );
       
  1692 		url->Des().Copy( aUrl );
       
  1693 
       
  1694         if( url && url->Length() )
       
  1695             {
       
  1696            	if (url->Length() > KFavouritesMaxName)
       
  1697             	{
       
  1698             	// name will be the url but it needs to be compressed to fit max name length
       
  1699             	HBufC* cname = HBufC::NewLC(KFavouritesMaxName);
       
  1700             	TInt edgeStringLen = ((KFavouritesMaxName / 2) - 3);
       
  1701             	TPtrC cnameRight( url->Right( edgeStringLen ) );
       
  1702             	TPtrC cnameLeft( url->Left( edgeStringLen ));
       
  1703             	TPtr cnameDes = cname->Des();
       
  1704 
       
  1705               	cnameDes.Append( cnameLeft );
       
  1706                	cnameDes.AppendFill( TChar(KDot),5 );   // '.....'
       
  1707                	cnameDes.Append( cnameRight );
       
  1708             	iRecentUrlStore->SaveDataL(*url,*cname);
       
  1709                 CleanupStack::PopAndDestroy();//cname
       
  1710             	}
       
  1711             else
       
  1712         	    {
       
  1713         	    iRecentUrlStore->SaveDataL(*url,*url);
       
  1714         	    }
       
  1715             }
       
  1716         CleanupStack().PopAndDestroy(); // url
       
  1717         }
       
  1718     }
       
  1719 
       
  1720 // -----------------------------------------------------------------------------
       
  1721 // CBrowserAppUi::SwitchWindowL()
       
  1722 // -----------------------------------------------------------------------------
       
  1723 //
       
  1724 void CBrowserAppUi::SwitchWindowL()
       
  1725     {
       
  1726 LOG_ENTERFN("CBrowserAppUi::SwitchWindowL");
       
  1727     CArrayFixFlat<CWindowInfo*>* windowBuf = iWindowManager->GetWindowInfoL( this );
       
  1728     CleanupStack::PushL( windowBuf );
       
  1729 
       
  1730     // Open 'Switch Window' selection dialog
       
  1731     HBufC* title = StringLoader::LoadLC( R_BROWSER_SWITCH_WINDOW_HEADER );
       
  1732 
       
  1733     CArrayFixFlat<TBrCtlSelectOptionData>* optDataArray = new ( ELeave )
       
  1734         CArrayFixFlat<TBrCtlSelectOptionData>( KGranularityMedium );
       
  1735     CleanupStack::PushL( optDataArray );
       
  1736 
       
  1737     TInt i( 0 );
       
  1738     TInt numWindows = windowBuf->Count();
       
  1739 
       
  1740 LOG_WRITE_FORMAT("Window's count: %d", numWindows );
       
  1741     for ( i = 0; i < numWindows; ++i )
       
  1742         {
       
  1743         TBrCtlSelectOptionData optData( *((*windowBuf)[i]->iWindowText),
       
  1744                                         (*windowBuf)[i]->iCurrent,
       
  1745                                         EFalse,
       
  1746                                         EFalse );
       
  1747         optDataArray->AppendL( optData );
       
  1748         }
       
  1749 
       
  1750     TBool ret = DialogsProvider().DialogSelectOptionL( *title,
       
  1751                                                         ESelectTypeSingle,
       
  1752                                                         *optDataArray );
       
  1753     if ( ret )
       
  1754         {
       
  1755         for( i = 0; i < numWindows; ++i)
       
  1756             {
       
  1757             if( (*optDataArray)[i].IsSelected() )
       
  1758                 {
       
  1759                 LOG_WRITE_FORMAT("Selected window: %d", (*windowBuf)[i]->iWindowId );
       
  1760                 iWindowManager->SwitchWindowL( (*windowBuf)[i]->iWindowId );
       
  1761                 break;
       
  1762                 }
       
  1763             }
       
  1764         }
       
  1765     CleanupStack::PopAndDestroy( 3 );           // optDataArray, title, windowBuf
       
  1766     }
       
  1767 
       
  1768 // -----------------------------------------------------------------------------
       
  1769 // CBrowserAppUi::SetCalledFromAnotherApp
       
  1770 // -----------------------------------------------------------------------------
       
  1771 //
       
  1772 void CBrowserAppUi::SetCalledFromAnotherApp( TBool aValue )
       
  1773     {
       
  1774     iCalledFromAnotherApp = aValue;
       
  1775     }
       
  1776 
       
  1777 // -----------------------------------------------------------------------------
       
  1778 // CBrowserAppUi::CalledFromAnotherApp
       
  1779 // -----------------------------------------------------------------------------
       
  1780 //
       
  1781 TBool CBrowserAppUi::CalledFromAnotherApp()
       
  1782     {
       
  1783     return iCalledFromAnotherApp;
       
  1784     }
       
  1785     
       
  1786 // -----------------------------------------------------------------------------
       
  1787 // CBrowserAppUi::NoHomePageToBeLaunchedL
       
  1788 // -----------------------------------------------------------------------------
       
  1789 //
       
  1790 TBool CBrowserAppUi::NoHomePageToBeLaunchedL()
       
  1791     {
       
  1792     LOG_ENTERFN("CBrowserAppUi::NoHomePageToBeLaunchedL");
       
  1793     TWmlSettingsHomePage pgtype = iPreferences->HomePageType();
       
  1794     TBool alwaysAskCase = (( Preferences().AccessPointSelectionMode() == EAlwaysAsk ) &&
       
  1795                            ( EWmlSettingsHomePageAccessPoint == pgtype ));
       
  1796     BROWSER_LOG( ( _L( "pgtype: %d, alwaysAsk: %d" ), pgtype, alwaysAskCase ) );
       
  1797 
       
  1798     if( ( pgtype == EWmlSettingsHomePageBookmarks ) || alwaysAskCase )
       
  1799         {   // Can't load home page since set to Bookmarks or (AlwaysAsk AP and homepage set to AP homepage)
       
  1800         return ETrue;
       
  1801         }
       
  1802     else
       
  1803         {
       
  1804         // now check for other cases where homepage string might be defined and will be used    
       
  1805         HBufC* buf = HBufC::NewLC( KMaxHomePgUrlLength );  // cleanupstack
       
  1806         TPtr ptr( buf->Des() );
       
  1807         TInt pgFound = Preferences().HomePageUrlL( ptr );
       
  1808         CleanupStack::PopAndDestroy( buf );
       
  1809         if (pgFound != KErrNone)
       
  1810             {   // no homepage string found
       
  1811             return ETrue;
       
  1812             }
       
  1813         else
       
  1814             {   // homepage string was found 
       
  1815             return EFalse;
       
  1816             }
       
  1817         }        
       
  1818     }
       
  1819 
       
  1820 // CBrowserAppUi::ProcessCommandParametersL()
       
  1821 // -----------------------------------------------------------------------------
       
  1822 //
       
  1823 TBool CBrowserAppUi::ProcessCommandParametersL( TApaCommand aCommand,
       
  1824                                                TFileName& /*aDocumentName*/ ,
       
  1825                                                const TDesC8& /*aTail*/ )
       
  1826     {
       
  1827     LOG_ENTERFN("CBrowserAppUi::ProcessCommandParametersL");
       
  1828     LOG_WRITE_FORMAT(" aCommand: %d", aCommand);
       
  1829 
       
  1830     // The browser is in embedded mode and it is not initialized yet
       
  1831     if ( !StartedUp() )
       
  1832     	{
       
  1833     	return EFalse;
       
  1834     	}
       
  1835 
       
  1836     if ( aCommand == EApaCommandOpen )
       
  1837         {
       
  1838 		//Startup parameters are given to browser at CBrowserAppDocument::OpenFileL().
       
  1839 		//- a part of shell starting (ConstructAppFromCommandLineL calls OpenFileL)
       
  1840         }
       
  1841 
       
  1842     else if ( aCommand == EApaCommandRun )
       
  1843         {
       
  1844 
       
  1845    	    if ( LastActiveViewId() == KUidBrowserNullViewId )
       
  1846 	        {
       
  1847 	        TBool specialSchemeInHomePageAddress = EFalse;
       
  1848 	        
       
  1849 	        if (NoHomePageToBeLaunchedL())
       
  1850 	            {
       
  1851 	            // No homepage to be launched so start browser in bookmarks view
       
  1852     	        SetLastActiveViewId(KUidBrowserBookmarksViewId);
       
  1853 	            }
       
  1854     	    else if ( iPreferences->SearchFeature() || iPreferences->ServiceFeature())
       
  1855     	        {
       
  1856     	        
       
  1857     	        HBufC* buf = HBufC::NewLC( KMaxHomePgUrlLength );  // cleanupstack
       
  1858     	        TPtr ptr( buf->Des() );
       
  1859     	        TInt pgFound( KErrNotFound );
       
  1860     	        pgFound = Preferences().HomePageUrlL( ptr );
       
  1861     	        
       
  1862     			HBufC* searchScheme = HBufC::NewLC( KMaxHomePgUrlLength );  // cleanupstack
       
  1863     			TPtr searchSchemePtr( searchScheme->Des() );
       
  1864     			
       
  1865     			HBufC* serviceScheme = HBufC::NewLC( KMaxHomePgUrlLength );  // cleanupstack
       
  1866     			TPtr serviceSchemePtr( serviceScheme->Des() );
       
  1867     			
       
  1868     	        iPreferences->GetStringValueL( KBrowserSearchProviderUrl, KMaxHomePgUrlLength, searchSchemePtr );
       
  1869     	        iPreferences->GetStringValueL( KBrowserServiceUrl, KMaxHomePgUrlLength, serviceSchemePtr );
       
  1870 
       
  1871     			
       
  1872 	            if( !ptr.Compare(serviceSchemePtr) || !ptr.Compare(searchSchemePtr) )
       
  1873 	            	{    
       
  1874 	            	specialSchemeInHomePageAddress = ETrue;
       
  1875 	            	SetLastActiveViewId(KUidBrowserBookmarksViewId);
       
  1876 	            	TRAPD( err, FetchL( ptr, CBrowserLoadObserver::ELoadUrlTypeOther ) );
       
  1877 	            	}
       
  1878 	            else
       
  1879 	                {
       
  1880                     StartFetchHomePageL();
       
  1881 	            	}
       
  1882     	        CleanupStack::PopAndDestroy( 3,buf );
       
  1883     	        }
       
  1884             else
       
  1885             	{
       
  1886                 StartFetchHomePageL();
       
  1887             	}
       
  1888            
       
  1889 	        if( !specialSchemeInHomePageAddress )
       
  1890 	            {
       
  1891 	        	ActivateLocalViewL( LastActiveViewId() );
       
  1892 	            }
       
  1893         	}        	   	  
       
  1894         }
       
  1895     else if ( aCommand == EApaCommandViewActivate )
       
  1896     // Get when activated from soft notification (Downloads List).
       
  1897     // Must behave as in case of EApaCommandOpen, but no OpenFileL() is called.
       
  1898         {
       
  1899         ParseAndProcessParametersL( KNullDesC8 );
       
  1900         }
       
  1901     return EFalse;
       
  1902     }
       
  1903 
       
  1904 // -----------------------------------------------------------------------------
       
  1905 // CBrowserAppUi::Static()
       
  1906 // -----------------------------------------------------------------------------
       
  1907 //
       
  1908 CBrowserAppUi* CBrowserAppUi::Static()
       
  1909     {
       
  1910     return REINTERPRET_CAST( CBrowserAppUi*, CEikonEnv::Static()->EikAppUi() );
       
  1911     }
       
  1912 
       
  1913 // -----------------------------------------------------------------------------
       
  1914 // CBrowserAppUi::ParseAndProcessParametersL
       
  1915 // -----------------------------------------------------------------------------
       
  1916 //
       
  1917 void CBrowserAppUi::ParseAndProcessParametersL( const TDesC8& aDocumentName, TBool aDoFetch )
       
  1918     {
       
  1919     LOG_ENTERFN("CBrowserAppUi::ParseAndProcessParametersL");
       
  1920     TInt err = KErrNone;
       
  1921 
       
  1922     TUid ViewToActivate = { 0 };
       
  1923 
       
  1924     HBufC8* params = NULL;
       
  1925     TLex8 parameter(aDocumentName);
       
  1926 
       
  1927     // Here we check if the url contains control characters.
       
  1928     TBool urlError( EFalse );  // If there is a Control caracter in the url.
       
  1929     parameter.Mark(); // Save the start position in the string.
       
  1930     while ( !parameter.Eos() && !urlError )
       
  1931         {
       
  1932         if ( parameter.Get().IsControl() )
       
  1933             {
       
  1934             urlError = ETrue;
       
  1935             }
       
  1936         }
       
  1937     parameter.UnGetToMark(); // Now go back to the beginning of the string.
       
  1938 
       
  1939     //Check for parameter validity
       
  1940     if(	!parameter.Peek().IsDigit() || urlError )    //First char of aDocumentName is NOT a digit
       
  1941         {
       
  1942         if( ( aDocumentName.Locate( ':' ) > 0) && (!urlError) )    //There is a ":" character in aDocumentName (->probably a valid url)
       
  1943             {
       
  1944             //Add "4" + <space> before the given parameter to make the parameter legal for url launch
       
  1945             _LIT8(KUrlId, "4 ");
       
  1946             params = HBufC8::NewL(aDocumentName.Length() + 2 + 1);
       
  1947             params->Des().Copy( KUrlId );
       
  1948             params->Des().Append(aDocumentName);
       
  1949             params->Des().ZeroTerminate();
       
  1950             ViewToActivate = KUidBrowserContentViewId;
       
  1951             }
       
  1952         else
       
  1953             {
       
  1954             //Activate bookmarks view if parameters are invalid and browser is not embedded.
       
  1955             // In embedded mode bookmarks are not shown, so if there is an
       
  1956             // error in the url, we make the browser to pop up a
       
  1957             // "Page not found" note, by defining a not existing url.
       
  1958             if ( IsEmbeddedModeOn() )
       
  1959                 {
       
  1960                 params = HBufC8::NewL( 10 );
       
  1961                 params->Des().Copy(_L8("4 http://") );
       
  1962                 }
       
  1963             else
       
  1964                 {
       
  1965                 params = HBufC8::NewL(aDocumentName.Length() + 1 );
       
  1966                 params->Des().Copy(aDocumentName);
       
  1967                 }
       
  1968             params->Des().ZeroTerminate();
       
  1969             ViewToActivate = KUidBrowserBookmarksViewId;
       
  1970             }
       
  1971         }
       
  1972     else
       
  1973         {
       
  1974         params = HBufC8::NewL(aDocumentName.Length() + 1);
       
  1975         params->Des().Copy(aDocumentName);
       
  1976         params->Des().ZeroTerminate();
       
  1977         ViewToActivate = KUidBrowserContentViewId;
       
  1978         }
       
  1979     CleanupStack::PushL( params );
       
  1980 
       
  1981     //Set view to activate if no view yet activated
       
  1982     if ( LastActiveViewId() == KUidBrowserNullViewId )
       
  1983         {
       
  1984         SetLastActiveViewId(ViewToActivate);
       
  1985         }
       
  1986 
       
  1987     CBrowserCommandLineParser8* command = CBrowserCommandLineParser8::NewL( *params );
       
  1988     CleanupStack::PopAndDestroy( params );
       
  1989     CleanupStack::PushL( command );
       
  1990 
       
  1991 	//wait a while, contentview initializing itself
       
  1992     WaitCVInit();
       
  1993     switch ( command->Count() )
       
  1994         {
       
  1995         case 0:
       
  1996             {
       
  1997             SetViewToBeActivatedIfNeededL( LastActiveViewId() );
       
  1998             break;
       
  1999             }
       
  2000         case 1:
       
  2001             {
       
  2002             if ( !aDocumentName.Compare( KLongZeroIdString ) )
       
  2003                 {
       
  2004                 // Long 0 is pressed and Browser is started up for the first time...
       
  2005                 // if no AP or SNAP is defined, define it
       
  2006                 TUint32 defaultAp = iPreferences->DefaultAccessPoint();
       
  2007                 TUint32 defaultSnap =  iPreferences->DefaultSnapId();
       
  2008                 // AP or SNAP is not defined
       
  2009                 if( (defaultAp == KWmlNoDefaultAccessPoint && iPreferences->AccessPointSelectionMode() == EConnectionMethod) || 
       
  2010                     (defaultSnap == KWmlNoDefaultSnapId && iPreferences->AccessPointSelectionMode() == EDestination) )
       
  2011                     {
       
  2012                     StartPreferencesViewL( EShowAlwaysAsk | EShowDestinations | EShowConnectionMethods );
       
  2013                     }
       
  2014                 // If there is a homepage url then try to fetch it
       
  2015                 if ( !NoHomePageToBeLaunchedL() )
       
  2016                     {
       
  2017                     iLongZeroPressed = ETrue;
       
  2018                     FetchHomePageL();
       
  2019                     }
       
  2020                 else  
       
  2021                     {
       
  2022                     ContentView()->SetFullScreenOffL();
       
  2023                     if ( !IsEmbeddedModeOn() )
       
  2024                         {
       
  2025                         SetLastActiveViewId( KUidBrowserBookmarksViewId );
       
  2026                         }
       
  2027                     }
       
  2028                 }
       
  2029             SetViewToBeActivatedIfNeededL( LastActiveViewId() );
       
  2030             break;
       
  2031             }
       
  2032         case 2:
       
  2033         case 3:
       
  2034             {
       
  2035             // UID and wml adress and optional access point UID
       
  2036 
       
  2037             TUint typeId;
       
  2038             TInt dataId;
       
  2039             TLex8 param0( command->Param( 0 ) );
       
  2040             TLex8 param1( command->Param( 1 ) );
       
  2041             err = param0.Val( typeId );
       
  2042             if ( !err )
       
  2043                 {
       
  2044                 BROWSER_LOG( ( _L( " typeId: %d" ), typeId ) );
       
  2045 
       
  2046                 if ( typeId == KUrlId )
       
  2047                     {  // FIX THIS!
       
  2048                     TUriParser8 uri8;
       
  2049                     err = uri8.Parse(command->Param(1));      // what if parsing fails?
       
  2050                     User::LeaveIfError(err);
       
  2051                     // Url decoding section was removed from here.
       
  2052                     HBufC* url = HBufC::NewL(command->Param(1).Length()+1);
       
  2053                     url->Des().Copy( command->Param(1) );
       
  2054                     CleanupStack::PushL(url);
       
  2055                     BROWSER_LOG( ( _L( " url: %S" ), url ) );
       
  2056 
       
  2057                     TFavouritesWapAp accessPoint;   // Initially "default".
       
  2058                     BROWSER_LOG( ( _L( " Count: %d" ), command->Count() ) );
       
  2059                     if ( command->Count() == 3 )
       
  2060                         {
       
  2061                         // URL Typeid, url, ap
       
  2062                         TUint ap;
       
  2063                         TLex8 param2( command->Param( 2 ) );
       
  2064                         err = param2.Val( ap );
       
  2065                         if ( !err )
       
  2066                             {
       
  2067                             BROWSER_LOG( ( _L( " ap: %d" ), ap ) );
       
  2068                             if (iSuppressAlwaysAsk)
       
  2069                                 {
       
  2070                                 // Always ask was temporarily disabled, enable it again
       
  2071                                 iPreferences->SetAccessPointSelectionModeL(EAlwaysAsk);
       
  2072                                 
       
  2073                                 iSuppressAlwaysAsk = EFalse;
       
  2074                                 }
       
  2075 
       
  2076                             // Note: OTA Provisioning application requires the 
       
  2077                             // KBrowserAccessPointSelectionMode key value to be
       
  2078                             // read directly from cenrep, rather than use the
       
  2079                             // cached cenrep value taken at browser initialization 
       
  2080                             // time. 
       
  2081                             TInt selectionMode;
       
  2082 
       
  2083                             CRepository* repository = CRepository::NewLC( KCRUidBrowser );
       
  2084                             User::LeaveIfError( repository->Get( KBrowserAccessPointSelectionMode, selectionMode ) );
       
  2085                             CleanupStack::PopAndDestroy( repository );
       
  2086 
       
  2087                             // If selectionMode cenrep value is always ask, then 
       
  2088                             // temporarily change selection mode
       
  2089                             if ( EBrowserCenRepApSelModeAlwaysAsk == selectionMode )
       
  2090                                 {
       
  2091                                 iSuppressAlwaysAsk = ETrue;
       
  2092                                 iPreferences->SetAccessPointSelectionModeL(EConnectionMethod);
       
  2093                                 }
       
  2094                             accessPoint.SetApId( ap );
       
  2095                             SetCalledFromAnotherApp( ETrue );
       
  2096                             CBrowserLoadObserver::TBrowserLoadUrlType urlType =
       
  2097                                 IsEmbeddedModeOn() ?
       
  2098                                     CBrowserLoadObserver::ELoadUrlTypeEmbeddedBrowserWithUrl :
       
  2099                                     CBrowserLoadObserver::ELoadUrlTypeOther;
       
  2100                             if( IsPageLoaded() &&
       
  2101                             	!(WindowMgr().CurrentWindow()->HasWMLContent(EFalse)) &&
       
  2102             		            Preferences().UiLocalFeatureSupported( KBrowserMultipleWindows ) &&
       
  2103             	                !Preferences().UiLocalFeatureSupported( KBrowserMinimalMultipleWindows ))
       
  2104                                 {
       
  2105                                 // Cancel history view, mini map, toolbar or any other active control on the current window 
       
  2106                                 BrCtlInterface().HandleCommandL( TBrCtlDefs::ECommandCancel + TBrCtlDefs::ECommandIdBase );
       
  2107                                 // there is already a window, so create a new one
       
  2108                                 CBrowserWindow *win = WindowMgr().CreateWindowL( 0, &KNullDesC );
       
  2109                                 if (win != NULL)
       
  2110                                     {
       
  2111                                         
       
  2112                                     CleanupStack::PushL( win );
       
  2113                                     WindowMgr().SwitchWindowL( win->WindowId() );
       
  2114                                     TRAP( err, FetchL(  *url,
       
  2115                                                                 KNullDesC,
       
  2116                                                                 KNullDesC,
       
  2117                                                                 accessPoint,
       
  2118                                                                 urlType ) );
       
  2119                                     CleanupStack::Pop();  // win
       
  2120                                     SetLastActiveViewId( KUidBrowserContentViewId );
       
  2121                                     }
       
  2122                                 }                          
       
  2123                             else
       
  2124                                 {
       
  2125                                 // Cancel history view, mini map, toolbar or any other active control on the current window 
       
  2126                                 BrCtlInterface().HandleCommandL( TBrCtlDefs::ECommandCancel + TBrCtlDefs::ECommandIdBase );
       
  2127                                 TRAP( err, FetchL(  *url,
       
  2128                                                             KNullDesC,
       
  2129                                                             KNullDesC,
       
  2130                                                             accessPoint,
       
  2131                                                             urlType ) );                                
       
  2132                                 SetLastActiveViewId( KUidBrowserContentViewId );                                
       
  2133                                 }                        
       
  2134                             }
       
  2135                         }
       
  2136                     else
       
  2137                         {
       
  2138                         // URL Typeid, url
       
  2139                         SetCalledFromAnotherApp( ETrue );
       
  2140 
       
  2141                         if ( aDoFetch )
       
  2142                             {
       
  2143                             CBrowserLoadObserver::TBrowserLoadUrlType urlType =
       
  2144                                 IsEmbeddedModeOn() ?
       
  2145                                     CBrowserLoadObserver::ELoadUrlTypeEmbeddedBrowserWithUrl :
       
  2146                                     CBrowserLoadObserver::ELoadUrlTypeOther;
       
  2147                             if( IsPageLoaded() &&
       
  2148                             	!(WindowMgr().CurrentWindow()->HasWMLContent(EFalse)) &&                            
       
  2149                         		Preferences().UiLocalFeatureSupported( KBrowserMultipleWindows ) &&
       
  2150                             	!Preferences().UiLocalFeatureSupported( KBrowserMinimalMultipleWindows ))
       
  2151                                 {
       
  2152                                 // Cancel history view, mini map, toolbar or any other active control on the current window 
       
  2153                                 BrCtlInterface().HandleCommandL( TBrCtlDefs::ECommandCancel + TBrCtlDefs::ECommandIdBase );
       
  2154                                 // there is already a window, so create a new one
       
  2155                                 CBrowserWindow *win = WindowMgr().CreateWindowL( 0, &KNullDesC );
       
  2156                                 if (win != NULL)
       
  2157                                     {
       
  2158                                         
       
  2159                                     CleanupStack::PushL( win );
       
  2160                                     WindowMgr().SwitchWindowL( win->WindowId() );
       
  2161                                     TRAP( err, FetchL(  *url,
       
  2162                                                                 KNullDesC,
       
  2163                                                                 KNullDesC,
       
  2164                                                                 accessPoint,
       
  2165                                                                 urlType ) );
       
  2166                                     CleanupStack::Pop();  // win
       
  2167                                     }
       
  2168                             }
       
  2169                             else
       
  2170                                 {
       
  2171                                 // Cancel history view, mini map, toolbar or any other active control on the current window 
       
  2172                                 BrCtlInterface().HandleCommandL( TBrCtlDefs::ECommandCancel + TBrCtlDefs::ECommandIdBase );
       
  2173                                 TRAP( err, FetchL(  *url,
       
  2174                                                             KNullDesC,
       
  2175                                                             KNullDesC,
       
  2176                                                             accessPoint,
       
  2177                                                             urlType ) );
       
  2178                                 }
       
  2179                             }          
       
  2180                     if (err==KErrNone)
       
  2181                         {
       
  2182                         SetLastActiveViewId(ViewToActivate);
       
  2183                         }
       
  2184                         }
       
  2185                     CleanupStack::PopAndDestroy();  // url
       
  2186                     }
       
  2187                 else if( typeId == KLaunchFeeds )
       
  2188                     {
       
  2189                     // Special facility to launch non-embedded into the feeds view
       
  2190                     if( !iBrowserAlreadyRunning )
       
  2191                     	{
       
  2192                     	SetOverriddenLaunchContextId(EBrowserContextIdFeeds);
       
  2193                     	SetLastActiveViewId( KUidBrowserFeedsFolderViewId );                    	
       
  2194                     	}	
       
  2195                     LaunchIntoFeedsL();          	
       
  2196                     }         
       
  2197                 else
       
  2198                     {
       
  2199                     err = param1.Val( dataId );
       
  2200                     if ( !err )
       
  2201                         {
       
  2202                         switch ( typeId )
       
  2203                             {
       
  2204                             case KBookmarkId:
       
  2205                                 {
       
  2206                                 // Bookmark typeid, uid
       
  2207                                 SetCalledFromAnotherApp( ETrue );
       
  2208 								
       
  2209 	                            if( IsPageLoaded() &&
       
  2210                                	!(WindowMgr().CurrentWindow()->HasWMLContent(EFalse)) &&
       
  2211                         		Preferences().UiLocalFeatureSupported( KBrowserMultipleWindows ) &&
       
  2212                             	!Preferences().UiLocalFeatureSupported( KBrowserMinimalMultipleWindows ))
       
  2213 	                                {
       
  2214 	   	                            // Cancel history view, mini map, toolbar or any other active control on the current window 
       
  2215 	                                BrCtlInterface().HandleCommandL( TBrCtlDefs::ECommandCancel + TBrCtlDefs::ECommandIdBase );
       
  2216 	                                // there is already a window, so create a new one
       
  2217 	                                CBrowserWindow *win = WindowMgr().CreateWindowL( 0, &KNullDesC );
       
  2218 	                                if (win != NULL)
       
  2219     	                                {
       
  2220     	                                CleanupStack::PushL( win );
       
  2221     	                                WindowMgr().SwitchWindowL( win->WindowId() );
       
  2222     	                            	TRAP( err, FetchBookmarkL( dataId ) );
       
  2223     	                                CleanupStack::Pop();  // win                                
       
  2224     	                                }
       
  2225 	                                }
       
  2226 	                            else
       
  2227 	                            	{
       
  2228     	                            // Cancel history view, mini map, toolbar or any other active control on the current window 
       
  2229 	                                BrCtlInterface().HandleCommandL( TBrCtlDefs::ECommandCancel + TBrCtlDefs::ECommandIdBase );
       
  2230 	                            	TRAP( err, FetchBookmarkL( dataId ) );
       
  2231 	                            	}    
       
  2232 
       
  2233                                 if ( err )
       
  2234                                     {
       
  2235                                     // Unable to fetch bookmark
       
  2236                                     TBrowserDialogs::InfoNoteL(
       
  2237                                         R_BROWSER_INFO_NOTE, R_WML_UNABLE_TO_FETCH_BOOKMARK );
       
  2238                                     }
       
  2239 	                            if (err==KErrNone)
       
  2240     			                    {
       
  2241                 			        SetLastActiveViewId(ViewToActivate);
       
  2242                         			}
       
  2243 
       
  2244                                 break;
       
  2245                                 }
       
  2246                             case KFolderId:
       
  2247                                 {
       
  2248                                 SetCalledFromAnotherApp( EFalse );
       
  2249                                 iIsForeground = IsForeground();
       
  2250                                 CloseContentViewL();
       
  2251                                 SetLastActiveViewId( KUidBrowserBookmarksViewId );
       
  2252                                 break;
       
  2253                                 }
       
  2254                             default:
       
  2255                                 {
       
  2256                                 // Typeid was not readable
       
  2257                                 // TBD: error message!
       
  2258                                 break;
       
  2259                                 }
       
  2260                             }
       
  2261                         }
       
  2262                     else
       
  2263                         {
       
  2264                         // Dataid was not readable
       
  2265                         User::Leave( err );
       
  2266                         }
       
  2267                     }
       
  2268                 }
       
  2269             else
       
  2270                 {
       
  2271                 // Sender Uid was not readable
       
  2272                 User::Leave( err );
       
  2273                 }
       
  2274             if( !iSpecialSchemeinAddress )
       
  2275             	{              
       
  2276             	SetViewToBeActivatedIfNeededL( LastActiveViewId() );
       
  2277             	}
       
  2278             break;
       
  2279             }
       
  2280 
       
  2281         default:
       
  2282             {
       
  2283             SendBrowserToBackground();
       
  2284             break;
       
  2285             }
       
  2286         }
       
  2287         CleanupStack::PopAndDestroy();  // command
       
  2288     }
       
  2289 
       
  2290 // -----------------------------------------------------------------------------
       
  2291 // CBrowserAppUi::WaitCVInit
       
  2292 // -----------------------------------------------------------------------------
       
  2293 //
       
  2294 void CBrowserAppUi::WaitCVInit()
       
  2295     {
       
  2296     if( iParametrizedLaunchInProgress == 0 )
       
  2297         {
       
  2298         iParametrizedLaunchInProgress = 1;
       
  2299         iIdle->Cancel();
       
  2300         iIdle->Start( TCallBack( StopDelay, this ) );
       
  2301         iWait.Start();
       
  2302         iParametrizedLaunchInProgress = 2;
       
  2303         }
       
  2304     }
       
  2305 
       
  2306 // -----------------------------------------------------------------------------
       
  2307 // CBrowserAppUi::ConnNeededStatusL
       
  2308 // -----------------------------------------------------------------------------
       
  2309 //
       
  2310 void CBrowserAppUi::ConnNeededStatusL( TInt aErr )
       
  2311     {
       
  2312     UpdateSoftKeys();
       
  2313     if (iSuppressAlwaysAsk)
       
  2314         {
       
  2315         // Always ask was temporarily disabled, after creating the network connection, enable it again
       
  2316         iPreferences->SetAccessPointSelectionModeL(EAlwaysAsk);
       
  2317         iSuppressAlwaysAsk = EFalse;
       
  2318         }
       
  2319     if ( aErr != KErrNone )
       
  2320         {
       
  2321         if( iCalledFromAnotherApp )
       
  2322             {
       
  2323             // This function call should be replaced by ExitBrowser(ETrue)
       
  2324             // so that the blank content view is not displayed.
       
  2325             // SendBrowserToBackground();
       
  2326             }
       
  2327         // if any error, return Cancel to Kimono.
       
  2328         return;
       
  2329         }
       
  2330 
       
  2331 
       
  2332 
       
  2333     if ( !iConnStageNotifier->IsActive() )
       
  2334         {
       
  2335         TName* connectionName = Connection().ConnectionNameL();
       
  2336         CleanupStack::PushL( connectionName );
       
  2337         iConnStageNotifier->StartNotificationL(
       
  2338             connectionName, KConnectionUninitialised, this);
       
  2339         CleanupStack::PopAndDestroy();  //connectionName
       
  2340         }
       
  2341     }
       
  2342 
       
  2343 
       
  2344 // -----------------------------------------------------------------------------
       
  2345 // CBrowserAppUi::SendBrowserToBackground
       
  2346 // -----------------------------------------------------------------------------
       
  2347 //
       
  2348 void CBrowserAppUi::SendBrowserToBackground()
       
  2349     {
       
  2350     TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
       
  2351 
       
  2352     // Browser might be embedded. 
       
  2353     TUid appUid;
       
  2354     if ( iEmbeddingApplicationUid != KNullUid )
       
  2355         {
       
  2356         appUid = iEmbeddingApplicationUid;
       
  2357         }
       
  2358     else 
       
  2359         {
       
  2360         appUid = KUidBrowserApplication;
       
  2361         }
       
  2362     TApaTask task = taskList.FindApp( appUid );
       
  2363     task.SendToBackground();
       
  2364     }
       
  2365 
       
  2366 
       
  2367 // -----------------------------------------------------------------------------
       
  2368 // CBrowserAppUi::CreateWindowInfoLC()
       
  2369 // -----------------------------------------------------------------------------
       
  2370 //
       
  2371 HBufC* CBrowserAppUi::CreateWindowInfoLC( const CBrowserWindow& aWindow )
       
  2372     {
       
  2373     HBufC* buf = aWindow.BrCtlInterface().PageInfoLC( TBrCtlDefs::EPageInfoTitle );
       
  2374     if( !buf || !buf->Length() )
       
  2375         {
       
  2376         CleanupStack::PopAndDestroy( buf );
       
  2377         buf = aWindow.BrCtlInterface().PageInfoLC( TBrCtlDefs::EPageInfoUrl );
       
  2378         if( !buf )
       
  2379             {
       
  2380 
       
  2381             CleanupStack::PopAndDestroy( buf );
       
  2382             buf = KNullDesC().AllocLC();
       
  2383             }
       
  2384         }
       
  2385     return buf;
       
  2386     }
       
  2387 
       
  2388 
       
  2389 // -----------------------------------------------------------------------------
       
  2390 // CBrowserAppUi::ConnectionStageAchievedL()
       
  2391 // -----------------------------------------------------------------------------
       
  2392 //
       
  2393 void CBrowserAppUi::ConnectionStageAchievedL()
       
  2394     {
       
  2395     // this function is called only when network is lost
       
  2396     // because we set notifier for KAgentUnconnected only
       
  2397     Display().StopProgressAnimationL();
       
  2398 	if ( Fetching() )
       
  2399 		{
       
  2400                  CancelFetch();
       
  2401 		}
       
  2402     //Close the uploading dialog.
       
  2403     iDialogsProvider->UploadProgressNoteL(
       
  2404 	                0, 0, ETrue, (MBrowserDialogsProviderObserver *)this );
       
  2405     //connection has been lost, so cancel the authentication dialog.
       
  2406     iDialogsProvider->CancelAll();
       
  2407     // SendDisconnectEventL();
       
  2408     // not needed as by that point HTTPSession was already shutdown by executing disconnect menu option
       
  2409     // will cause a crash when user tries to quickly reconnect right after disconnecting, as HTTP session
       
  2410     // is starting to initialize, while this call is trying to close it.
       
  2411     }
       
  2412 
       
  2413 
       
  2414 // -----------------------------------------------------------------------------
       
  2415 // CBrowserAppUi::UpdateSoftKeys
       
  2416 // -----------------------------------------------------------------------------
       
  2417 //
       
  2418 void CBrowserAppUi::UpdateSoftKeys()
       
  2419     {
       
  2420 	TRAP_IGNORE( UpdateCbaL() );
       
  2421     }
       
  2422 
       
  2423 // -----------------------------------------------------------------------------
       
  2424 // CBrowserAppUi::DeleteCookiesL
       
  2425 // -----------------------------------------------------------------------------
       
  2426 //
       
  2427 void CBrowserAppUi::DeleteCookiesL()
       
  2428     {
       
  2429     // stringPool is not needed to initialize
       
  2430     RStringPool stringPool;
       
  2431     RCookieManager cookieManager( stringPool );
       
  2432     TInt num(0);
       
  2433 
       
  2434     User::LeaveIfError( cookieManager.Connect() );
       
  2435     CleanupClosePushL( cookieManager );
       
  2436     User::LeaveIfError( cookieManager.ClearCookies( num ) );
       
  2437     CleanupStack::PopAndDestroy( &cookieManager );
       
  2438 
       
  2439     stringPool.Close();
       
  2440     }
       
  2441 
       
  2442 // -----------------------------------------------------------------------------
       
  2443 // CBrowserAppUi::LaunchHomePageL
       
  2444 // -----------------------------------------------------------------------------
       
  2445 //
       
  2446 void CBrowserAppUi::LaunchHomePageL()
       
  2447     {
       
  2448     LOG_ENTERFN( "CBrowserAppUi::LaunchHomePageL" );
       
  2449     TWmlSettingsHomePage pgtype = iPreferences->HomePageType();
       
  2450     TBool alwaysAskCase = (( Preferences().AccessPointSelectionMode() == EAlwaysAsk ) &&
       
  2451                            ( EWmlSettingsHomePageAccessPoint == pgtype ));
       
  2452     BROWSER_LOG( ( _L( "pgtype: %d, alwaysAsk: %d" ), pgtype, alwaysAskCase ) );
       
  2453 
       
  2454     if( ( pgtype == EWmlSettingsHomePageBookmarks ) || alwaysAskCase )
       
  2455         // Bookmarks is selected as HomePage
       
  2456         // has effect only for startup, otherwise 'Home' command is not shown
       
  2457         {
       
  2458         ContentView()->SetFullScreenOffL();
       
  2459         // view change will be done somewhere else
       
  2460         SetLastActiveViewId( KUidBrowserBookmarksViewId );
       
  2461         SetViewToBeActivatedIfNeededL( LastActiveViewId() );
       
  2462         return;
       
  2463         }
       
  2464 
       
  2465     HBufC* buf = HBufC::NewLC( KMaxHomePgUrlLength );  // cleanupstack
       
  2466     TPtr ptr( buf->Des() );
       
  2467     TInt pgFound( KErrNotFound );
       
  2468 
       
  2469     pgFound = Preferences().HomePageUrlL( ptr );
       
  2470     BROWSER_LOG( ( _L( "pgFound 1: %d" ), pgFound ) );
       
  2471 
       
  2472 
       
  2473     if( pgFound == KErrNone )     // Home page url found, fetch the url
       
  2474         {
       
  2475         SetLastActiveViewId( KUidBrowserContentViewId );
       
  2476         FetchL( ptr );
       
  2477         }
       
  2478     else  // Home page not found, or not defined, go to BookMarksView
       
  2479         {
       
  2480         TVwsViewId activeViewId;
       
  2481         if( ( GetActiveViewId( activeViewId ) != KErrNone ) ||
       
  2482             ( activeViewId.iViewUid == KUidBrowserContentViewId ) )
       
  2483             {
       
  2484             ContentView()->SetFullScreenOffL();
       
  2485             }
       
  2486         SetLastActiveViewId( KUidBrowserBookmarksViewId );
       
  2487         SetViewToBeActivatedIfNeededL( LastActiveViewId() );
       
  2488         }
       
  2489     CleanupStack::PopAndDestroy( buf );
       
  2490     }
       
  2491 
       
  2492 // -----------------------------------------------------------------------------
       
  2493 // CBrowserAppUi::ClearTheCacheL
       
  2494 // -----------------------------------------------------------------------------
       
  2495 //
       
  2496 void CBrowserAppUi::ClearTheCacheL(TBool afterQuery, TBool aShowDoneNote)
       
  2497     {
       
  2498     TUint32 totalBytesFlushed = BrCtlInterface().ClearCache();
       
  2499         if(afterQuery || totalBytesFlushed)
       
  2500     	{
       
  2501 
       
  2502     	HBufC* resultText = NULL;
       
  2503     	HBufC* tempText = NULL;
       
  2504     	TBuf<12> totalText;
       
  2505 
       
  2506     	totalText.Num ((TInt)totalBytesFlushed);
       
  2507 
       
  2508     	resultText = StringLoader::LoadLC( R_TEXT_WML_CACHE_EMPTIED_NOTE);
       
  2509     	//CleanupStack::PushL(resultText);
       
  2510     	tempText = HBufC::NewLC( resultText->Length() + totalText.Length() );
       
  2511     	//CleanupStack::PushL(tempText);
       
  2512 
       
  2513     	tempText->Des().AppendFormat( resultText->Des(), totalBytesFlushed );
       
  2514 
       
  2515 
       
  2516 
       
  2517     	if(aShowDoneNote)
       
  2518     	    {
       
  2519     	    TBrowserDialogs::InfoNoteL ( R_BROWSER_OK_NOTE, tempText->Des() );
       
  2520     	    }
       
  2521      	CleanupStack::PopAndDestroy(2); //resultText, tempText
       
  2522     	}
       
  2523     }
       
  2524 
       
  2525 // ---------------------------------------------------------
       
  2526 // CBrowserAppUi::ClearFormAndPasswdDataL
       
  2527 // ---------------------------------------------------------
       
  2528 //
       
  2529 void CBrowserAppUi::ClearFormAndPasswdDataL(TBool aShowPromptAndComplete)
       
  2530     {
       
  2531     if (aShowPromptAndComplete)
       
  2532         {
       
  2533         CAknQueryDialog* query = CAknQueryDialog::NewL();
       
  2534 	    if ( query->ExecuteLD( R_BROWSER_CLEARFORMPASSWDDATA_QUERY ) )
       
  2535             {
       
  2536             // call brctl to clear form and password data
       
  2537             BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandClearAutoFormFillData +
       
  2538     		       						     (TInt)TBrCtlDefs::ECommandIdBase );
       
  2539 
       
  2540             BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandClearAutoFormFillPasswordData +
       
  2541      		 								 (TInt)TBrCtlDefs::ECommandIdBase );
       
  2542 
       
  2543             TBrowserDialogs::InfoNoteL(
       
  2544                 R_BROWSER_OK_NOTE, R_QTN_BROWSER_NOTE_FORM_AND_PASSWD_DATA_CLEARED );
       
  2545             }
       
  2546 
       
  2547         }
       
  2548     else
       
  2549         {
       
  2550             // call brctl to clear form and password data
       
  2551             BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandClearAutoFormFillData +
       
  2552     		       						     (TInt)TBrCtlDefs::ECommandIdBase );
       
  2553 
       
  2554             BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandClearAutoFormFillPasswordData +
       
  2555      		 								 (TInt)TBrCtlDefs::ECommandIdBase );
       
  2556 
       
  2557         }
       
  2558     }
       
  2559 
       
  2560 
       
  2561 // ---------------------------------------------------------
       
  2562 // CBrowserAppUi::ClearHistoryWithPromptL
       
  2563 // ---------------------------------------------------------
       
  2564 //
       
  2565 void CBrowserAppUi::ClearHistoryWithPromptL()
       
  2566     {
       
  2567     CAknQueryDialog* query = CAknQueryDialog::NewL();
       
  2568 
       
  2569     if ( query->ExecuteLD( R_BROWSER_CLEARHISTORYDATA_QUERY ) )
       
  2570         {
       
  2571         ClearHistoryL();
       
  2572         TBrowserDialogs::InfoNoteL( R_BROWSER_OK_NOTE,
       
  2573                     R_QTN_BROWSER_NOTE_HISTORY_CLEARED );
       
  2574         }
       
  2575     }
       
  2576 
       
  2577 // ---------------------------------------------------------
       
  2578 // CBrowserAppUi::ClearHistoryL
       
  2579 // ---------------------------------------------------------
       
  2580 //
       
  2581 void CBrowserAppUi::ClearHistoryL()
       
  2582     {
       
  2583 	if (iWindowManager)
       
  2584         {
       
  2585         iWindowManager->SendCommandToAllWindowsL(
       
  2586         (TInt)TBrCtlDefs::ECommandClearHistory + (TInt)TBrCtlDefs::ECommandIdBase);
       
  2587         }
       
  2588     else
       
  2589         {
       
  2590         BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandClearHistory +
       
  2591                                          (TInt)TBrCtlDefs::ECommandIdBase );
       
  2592 
       
  2593         }
       
  2594 
       
  2595     if (!(Preferences().AdaptiveBookmarks()==EWmlSettingsAdaptiveBookmarksOff ))
       
  2596         {
       
  2597         // This call will ensure that the bookmarks are cleared when we are
       
  2598         // outside the bookmarksview since the next call doesn't do anything in
       
  2599         // that case due to the unset Container pointer.
       
  2600 		iRecentUrlStore->ClearData();
       
  2601 
       
  2602         // Below will serve for when we are called from BookmarksView to ensure
       
  2603         // thorough clearing and view refresh after clearing adapt bookmarks
       
  2604         iBookmarksView->HandleCommandL(EWmlCmdClearAdaptiveBookmarksNoPrompt);
       
  2605         }
       
  2606 
       
  2607     UpdateCbaL();
       
  2608 
       
  2609     }
       
  2610 
       
  2611 // ---------------------------------------------------------
       
  2612 // CBrowserAppUi::ClearAllPrivacyL
       
  2613 // ---------------------------------------------------------
       
  2614 //
       
  2615 void CBrowserAppUi::ClearAllPrivacyL()
       
  2616     {
       
  2617 
       
  2618     CAknQueryDialog* query = CAknQueryDialog::NewL();
       
  2619 	if ( query->ExecuteLD( R_BROWSER_CLEARPRIVACYDATA_QUERY ) )
       
  2620         {
       
  2621         ClearTheCacheL(EFalse, EFalse);     // false -> no prompt or info note after op
       
  2622         DeleteCookiesL();
       
  2623         ClearHistoryL();
       
  2624         ClearFormAndPasswdDataL(EFalse);    // no prompt or completed info note
       
  2625 
       
  2626         TBrowserDialogs::InfoNoteL(
       
  2627             R_BROWSER_OK_NOTE, R_QTN_BROWSER_NOTE_CLEAR_ALL_PRIVACY_DONE );
       
  2628         }
       
  2629     }
       
  2630 
       
  2631 
       
  2632 // -----------------------------------------------------------------------------
       
  2633 // CBrowserAppUi::DisconnectL
       
  2634 // -----------------------------------------------------------------------------
       
  2635 //
       
  2636 void CBrowserAppUi::DisconnectL()
       
  2637     {
       
  2638 //#pragma message("TODO: inform LoadObserver?")
       
  2639     SendDisconnectEventL();
       
  2640     Connection().Disconnect();
       
  2641 
       
  2642 #ifdef __RSS_FEEDS
       
  2643     iFeedsClientUtilities->DisconnectFeedsViewL();
       
  2644     //notify feeds engine to close the connection
       
  2645 	iFeedsClientUtilities->DisconnectManualUpdateConnectionL();
       
  2646 #endif
       
  2647     }
       
  2648 
       
  2649 
       
  2650 // -----------------------------------------------------------------------------
       
  2651 // CBrowserAppUi::BmOTABinSenderL()
       
  2652 // -----------------------------------------------------------------------------
       
  2653 //
       
  2654 MBmOTABinSender& CBrowserAppUi::BmOTABinSenderL()
       
  2655     {
       
  2656     if (!iSender)
       
  2657     	{
       
  2658 		iLateSendUi->Cancel();
       
  2659     	DoConstructSendUiL();
       
  2660     	}
       
  2661     return *iSender;
       
  2662     }
       
  2663 
       
  2664 
       
  2665 // -----------------------------------------------------------------------------
       
  2666 // CBrowserAppUi::ContentView()
       
  2667 // -----------------------------------------------------------------------------
       
  2668 //
       
  2669 CBrowserContentView* CBrowserAppUi::ContentView() const
       
  2670     {
       
  2671     return (CBrowserContentView*)View( KUidBrowserContentViewId );
       
  2672     }
       
  2673 
       
  2674 
       
  2675 // -----------------------------------------------------------------------------
       
  2676 // CBrowserAppUi::FetchL
       
  2677 // -----------------------------------------------------------------------------
       
  2678 //
       
  2679 void CBrowserAppUi::FetchL( const TDesC& aUrl, CBrowserLoadObserver::TBrowserLoadUrlType aUrlType )
       
  2680     {
       
  2681     TFavouritesWapAp ap;
       
  2682     ap.SetDefault();
       
  2683     FetchL( aUrl, KNullDesC, KNullDesC, ap, aUrlType );
       
  2684     }
       
  2685 
       
  2686 // TO DO: done by BaP
       
  2687 // -----------------------------------------------------------------------------
       
  2688 // CBrowserAppUi::CancelFetch
       
  2689 // -----------------------------------------------------------------------------
       
  2690 //
       
  2691 void CBrowserAppUi::CancelFetch( TBool aIsUserInitiated /*= EFalse*/ )
       
  2692     {
       
  2693     LoadObserver().DoEndLoad( aIsUserInitiated );
       
  2694     TRAP_IGNORE( BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandCancelFetch + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  2695     SetContentDisplayed(ETrue);
       
  2696     }
       
  2697 
       
  2698 
       
  2699 // ----------------------------------------------------------------------------------------
       
  2700 // CBrowserAppUi::HandleMessageL
       
  2701 //
       
  2702 // Changes the URL to another if WAP is running before Wap Url
       
  2703 // is started from Desk
       
  2704 // ----------------------------------------------------------------------------------------
       
  2705 //
       
  2706 MCoeMessageObserver::TMessageResponse CBrowserAppUi::HandleMessageL(
       
  2707 																	TUint32 aClientHandleOfTargetWindowGroup,
       
  2708 																	TUid aMessageUid,
       
  2709 																	const TDesC8& aMessageParameters )
       
  2710     {
       
  2711     iBrowserAlreadyRunning = ETrue;
       
  2712     TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
       
  2713     TUid wapUid = KUidBrowserApplication;
       
  2714     TApaTask task = taskList.FindApp( wapUid );
       
  2715     task.BringToForeground();
       
  2716     if ( aMessageParameters.Compare( KLongZeroIdString ) )
       
  2717         {
       
  2718         ParseAndProcessParametersL( aMessageParameters );
       
  2719         }
       
  2720     return CAknViewAppUi::HandleMessageL(
       
  2721 		aClientHandleOfTargetWindowGroup,
       
  2722         aMessageUid,
       
  2723 		aMessageParameters);
       
  2724     }
       
  2725 
       
  2726 // ----------------------------------------------------------------------------------
       
  2727 // CBrowserAppUi::UpdateNaviPaneL
       
  2728 // ----------------------------------------------------------------------------------
       
  2729 //
       
  2730 void CBrowserAppUi::UpdateNaviPaneL( TDesC& aStatusMsg )
       
  2731     {
       
  2732     ContentView()->UpdateNaviPaneL( aStatusMsg );
       
  2733     }
       
  2734 
       
  2735 // ----------------------------------------------------------------------------------
       
  2736 // CBrowserAppUi::StopDelay
       
  2737 // ----------------------------------------------------------------------------------
       
  2738 //
       
  2739 TInt CBrowserAppUi::StopDelay( TAny* aCBrowserAppUi )
       
  2740     {
       
  2741 	__ASSERT_DEBUG(aCBrowserAppUi, Util::Panic( Util::EUninitializedData ));
       
  2742 
       
  2743     ((CBrowserAppUi*)aCBrowserAppUi)->DoStopDelay();
       
  2744     return 0;
       
  2745     }
       
  2746 
       
  2747 
       
  2748 // ----------------------------------------------------------------------------------
       
  2749 // CBrowserAppUi::DoStopDelay
       
  2750 // ----------------------------------------------------------------------------------
       
  2751 //
       
  2752 void CBrowserAppUi::DoStopDelay()
       
  2753     {
       
  2754     iWait.AsyncStop();
       
  2755     }
       
  2756 
       
  2757 // ----------------------------------------------------------------------------------
       
  2758 // CBrowserAppUi::DelayedSendUiConstructL
       
  2759 // ----------------------------------------------------------------------------------
       
  2760 //
       
  2761 /*static*/ TInt CBrowserAppUi::DelayedSendUiConstructL( TAny* aCBrowserAppUi )
       
  2762 	{
       
  2763 	__ASSERT_DEBUG(aCBrowserAppUi, Util::Panic( Util::EUninitializedData ));
       
  2764 	TRAP_IGNORE(
       
  2765 				((CBrowserAppUi*)aCBrowserAppUi)->DoConstructSendUiL();
       
  2766 				);
       
  2767 	return KErrNone;
       
  2768 	}
       
  2769 
       
  2770 
       
  2771 // ----------------------------------------------------------------------------------
       
  2772 // CBrowserAppUi::DoConstructSendUiL
       
  2773 // ----------------------------------------------------------------------------------
       
  2774 //
       
  2775 void CBrowserAppUi::DoConstructSendUiL()
       
  2776 	{
       
  2777 	__ASSERT_DEBUG(!iSender, Util::Panic( Util::EUnExpected ));
       
  2778 	iSender = CWmlBrowserBmOTABinSender::NewL();
       
  2779 	}
       
  2780 
       
  2781 // -----------------------------------------------------------------------------------
       
  2782 // CBrowserAppUi::SetViewToReturnOnClose
       
  2783 // -----------------------------------------------------------------------------------
       
  2784 //
       
  2785 void CBrowserAppUi::SetViewToReturnOnClose( TUid const &aUid )
       
  2786     {
       
  2787     iViewToReturnOnClose.iUid = aUid.iUid;
       
  2788     }
       
  2789 
       
  2790 // -----------------------------------------------------------------------------------
       
  2791 // CBrowserAppUi::CloseContentViewL
       
  2792 // -----------------------------------------------------------------------------------
       
  2793 //
       
  2794 void CBrowserAppUi::CloseContentViewL()
       
  2795     {
       
  2796 LOG_ENTERFN("CBrowserAppUi::CloseContentViewL");
       
  2797 	CBrowserAppDocument* doc = STATIC_CAST(CBrowserAppDocument*, Document());
       
  2798 
       
  2799     // Close should Exit asynchronously if called from another application 
       
  2800     // & if not in feeds view
       
  2801 #ifdef __RSS_FEEDS
       
  2802 	if(CalledFromAnotherApp() && (!IsEmbeddedModeOn()) 
       
  2803     	&& (GetPreviousViewFromViewHistory() != KUidBrowserFeedsFolderViewId)
       
  2804     	&& (GetPreviousViewFromViewHistory() != KUidBrowserFeedsTopicViewId)
       
  2805     	&& (GetPreviousViewFromViewHistory() != KUidBrowserFeedsFeedViewId ))
       
  2806 	    {
       
  2807         SetExitInProgress( ETrue );
       
  2808         BROWSER_LOG( ( _L( " iBrowserAsyncExit->Start()" ) ) );
       
  2809         iBrowserAsyncExit->Start();
       
  2810 	    }
       
  2811 #else
       
  2812 	if(CalledFromAnotherApp() && !IsEmbeddedModeOn()) 
       
  2813 	    {
       
  2814         SetExitInProgress( ETrue );
       
  2815         BROWSER_LOG( ( _L( " iBrowserAsyncExit->Start()" ) ) );
       
  2816         iBrowserAsyncExit->Start();
       
  2817 	    }
       
  2818 #endif // __RSS_FEEDS
       
  2819    	    
       
  2820 	else
       
  2821 	    {	    
       
  2822 	if ( IsEmbeddedModeOn() &&
       
  2823         doc->GetFolderToOpen() == KFavouritesRootUid )
       
  2824 		{
       
  2825 		ExitBrowser(ETrue);
       
  2826 		}
       
  2827 	else
       
  2828 		{
       
  2829         if ( ContentView()->GetPreviousViewID() == KUidBrowserBookmarksViewId )
       
  2830             {
       
  2831             if ( GetBookmarksView()->GetAdaptiveBookmarksFolderWasActive() )
       
  2832                 {
       
  2833                 GetBookmarksView()->OpenAdaptiveBookmarksWhenActivated();
       
  2834                 }
       
  2835             SetViewToBeActivatedIfNeededL( KUidBrowserBookmarksViewId );
       
  2836             }
       
  2837         else if ( IsEmbeddedModeOn())
       
  2838         {
       
  2839          if( !iExitInProgress )
       
  2840           {
       
  2841            ExitBrowser( ETrue );
       
  2842           }
       
  2843         }
       
  2844         else
       
  2845             {
       
  2846                	if(CalledFromAnotherApp() && (!IsEmbeddedModeOn()))
       
  2847                	    {
       
  2848                     SetViewToBeActivatedIfNeededL( GetPreviousViewFromViewHistory());
       
  2849   	       	        SetCalledFromAnotherApp(EFalse);
       
  2850                	    SendBrowserToBackground();
       
  2851                	    }                	
       
  2852                 else
       
  2853                     {                  
       
  2854                     SetViewToBeActivatedIfNeededL( iViewToReturnOnClose );
       
  2855                     }
       
  2856                 }
       
  2857             }
       
  2858 		}
       
  2859 	}
       
  2860 
       
  2861 // -----------------------------------------------------------------------------------
       
  2862 // CBrowserAppUi::IsEmbeddedModeOn
       
  2863 // -----------------------------------------------------------------------------------
       
  2864 //
       
  2865 TBool CBrowserAppUi::IsEmbeddedModeOn() const
       
  2866 	{
       
  2867 	return iEikonEnv->StartedAsServerApp();
       
  2868 	}
       
  2869 
       
  2870 // -----------------------------------------------------------------------------------
       
  2871 // CBrowserAppUi::HistoryLoadPrevious
       
  2872 // -----------------------------------------------------------------------------------
       
  2873 //
       
  2874 void CBrowserAppUi::HistoryLoadPrevious()
       
  2875     {
       
  2876     if( BrCtlInterface().NavigationAvailable( TBrCtlDefs::ENavigationBack ) )
       
  2877         {
       
  2878 	    TRAP_IGNORE( BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandBack +
       
  2879 										    (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  2880         }
       
  2881     }
       
  2882 
       
  2883 // -----------------------------------------------------------------------------------
       
  2884 // CBrowserAppUi::HistoryLoadNext
       
  2885 // -----------------------------------------------------------------------------------
       
  2886 //
       
  2887 void CBrowserAppUi::HistoryLoadNext()
       
  2888     {
       
  2889     if( BrCtlInterface().NavigationAvailable( TBrCtlDefs::ENavigationForward ) )
       
  2890         {
       
  2891         LoadObserver().DoStartLoad( CBrowserLoadObserver::ELoadUrlTypeOther );
       
  2892         BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandForward +
       
  2893                                                 (TInt)TBrCtlDefs::ECommandIdBase );
       
  2894         }
       
  2895     }
       
  2896 
       
  2897 
       
  2898 // ---------------------------------------------------------------------------
       
  2899 // CBrowserAppUi::IsShutdownRequested
       
  2900 // ---------------------------------------------------------------------------
       
  2901 //
       
  2902 TBool CBrowserAppUi::IsShutdownRequested() const
       
  2903 	{
       
  2904     return iShutdownRequested;
       
  2905 	}
       
  2906 
       
  2907 // ---------------------------------------------------------------------------
       
  2908 // CBrowserAppUi::IsEmbeddedInOperatorMenu
       
  2909 // ---------------------------------------------------------------------------
       
  2910 //
       
  2911 TBool CBrowserAppUi::IsEmbeddedInOperatorMenu() const
       
  2912 	{
       
  2913 	const TUid KUidOperatorMenuApp = { 0x10008D5E };
       
  2914 	const TUid KUidVideoServicesApp = { 0x10281893 }; 
       
  2915 
       
  2916 	// If the embedding application is the Operator Menu or Video Services
       
  2917 	if ( iEmbeddingApplicationUid == KUidOperatorMenuApp || iEmbeddingApplicationUid == KUidVideoServicesApp )
       
  2918 		{
       
  2919 		return ETrue;
       
  2920 		}
       
  2921 	else
       
  2922 		{
       
  2923 		return EFalse;
       
  2924 		}
       
  2925 	}
       
  2926 
       
  2927 // ---------------------------------------------------------------------------
       
  2928 // CBrowserAppUi::IsAppShutterActive
       
  2929 // ---------------------------------------------------------------------------
       
  2930 //
       
  2931 TBool CBrowserAppUi::IsAppShutterActive() const
       
  2932 	{
       
  2933 	CAknAppUi* shuttingApp = CAknEnv::AppWithShutterRunning();
       
  2934 
       
  2935 	if ( shuttingApp )
       
  2936 		{
       
  2937 		return ETrue;
       
  2938 		}
       
  2939 	else
       
  2940 		{
       
  2941 		return EFalse;
       
  2942 		}
       
  2943 	}
       
  2944 
       
  2945 // ---------------------------------------------------------------------------
       
  2946 // CBrowserAppUi::FetchHomePage
       
  2947 // --------------------------------------------------------------------------
       
  2948 //
       
  2949 void CBrowserAppUi::FetchHomePageL()
       
  2950     {
       
  2951 LOG_ENTERFN( "CBrowserAppUi::FetchHomePageL" );
       
  2952     if ( !Fetching() )
       
  2953         {
       
  2954         UpdateSoftKeys();
       
  2955 
       
  2956         // If the last active view is content view, return to the bookmark view on close.
       
  2957         // Otherwise if the last active view is bookmark view and we return to the appropriate view on close.
       
  2958         TUid lastViewId = LastActiveViewId();
       
  2959         if( lastViewId == KUidBrowserContentViewId ||
       
  2960             lastViewId == KUidBrowserNullViewId )
       
  2961             {
       
  2962             lastViewId = KUidBrowserBookmarksViewId;
       
  2963             }
       
  2964         SetViewToReturnOnClose( lastViewId );
       
  2965 
       
  2966         if( iLongZeroPressed )
       
  2967             {
       
  2968 			BROWSER_LOG( ( _L( " LongZeroPressed." ) ) );
       
  2969 
       
  2970             // There should only be one special load observer at startup
       
  2971             SpecialLoadObserver().SetLongZeroStartup( iLongZeroPressed );
       
  2972             iLongZeroPressed = EFalse;
       
  2973             HBufC* buf = HBufC::NewLC( KMaxHomePgUrlLength );
       
  2974             TPtr ptr( buf->Des() );
       
  2975             TBool homePgFound( KErrNotFound );
       
  2976 
       
  2977             // try to read Access Points homepage
       
  2978             TUint defaultAp( KWmlNoDefaultAccessPoint );
       
  2979             // 'always ask' feature doesn't let to read the AP
       
  2980             if( Preferences().AccessPointSelectionMode() == EConnectionMethod )
       
  2981                 {
       
  2982                 defaultAp = Preferences().DefaultAccessPoint();
       
  2983                 }
       
  2984             if ( defaultAp != KWmlNoDefaultAccessPoint ) // There is an access point defined
       
  2985                 {
       
  2986                 CApAccessPointItem* apItem = Preferences().AllPreferencesL().iDefaultAPDetails;
       
  2987                 if ( apItem )
       
  2988                     {
       
  2989                     const HBufC* defaultHP = apItem->ReadConstLongTextL( EApWapStartPage );
       
  2990                     if ( defaultHP->Length() )
       
  2991                         {
       
  2992                         ptr.Zero();
       
  2993                         ptr.Append( *defaultHP );
       
  2994                         homePgFound = KErrNone;
       
  2995                         }
       
  2996                     }
       
  2997                 }
       
  2998             // in case of error, read user defined home page from SD
       
  2999             TInt err( KErrNone );
       
  3000             if( homePgFound == KErrNotFound ) 
       
  3001                 {
       
  3002                 // do not let leaving
       
  3003                 if ((Preferences().HomePageType() == EWmlSettingsHomePageAddress)
       
  3004                    ||(Preferences().HomePageType() == EWmlSettingsHomePageUseCurrent))
       
  3005                 	{                         
       
  3006                 	TRAP( err, homePgFound = Preferences().HomePageUrlL( ptr, ETrue ) );
       
  3007                 	}
       
  3008                 }
       
  3009             // we have a url to load
       
  3010             if( err == KErrNone &&
       
  3011                 homePgFound == KErrNone &&
       
  3012                 ptr.Length() > 0 )
       
  3013                 {
       
  3014                 TRAP( err, FetchL( ptr, CBrowserLoadObserver::ELoadUrlTypeOther ) );
       
  3015                 // in case of any error switch back to BookmarksView
       
  3016                 if( err != KErrNone )
       
  3017                     {
       
  3018                     ContentView()->SetFullScreenOffL();
       
  3019                     SetLastActiveViewId( KUidBrowserBookmarksViewId );
       
  3020                     }
       
  3021                 }
       
  3022             else
       
  3023                 {
       
  3024                 // we already switched to ContentView, so change the layout back
       
  3025                 ContentView()->SetFullScreenOffL();
       
  3026                 SetLastActiveViewId( KUidBrowserBookmarksViewId );
       
  3027                 }
       
  3028             CleanupStack::PopAndDestroy( buf );
       
  3029             }
       
  3030         else
       
  3031             {
       
  3032             // it checks HomePageSettings
       
  3033             LaunchHomePageL( /* EFalse */ );
       
  3034             }
       
  3035         }
       
  3036     }
       
  3037 
       
  3038 // ---------------------------------------------------------------------------
       
  3039 // CBrowserAppUi::StartPreferencesViewL
       
  3040 // ---------------------------------------------------------------------------
       
  3041 //
       
  3042 TBool CBrowserAppUi::StartPreferencesViewL( TUint aListItems )
       
  3043     {
       
  3044     TBool retVal( EFalse );
       
  3045 	TInt retUi( KErrNone );
       
  3046     TInt err(KErrNone);
       
  3047 
       
  3048 	//start the connection  dialog
       
  3049 	CCmApplicationSettingsUi* settings = CCmApplicationSettingsUi::NewL();
       
  3050 	CleanupStack::PushL( settings );
       
  3051 	TCmSettingSelection selection;
       
  3052     // empty filter array because no filtering is wanted
       
  3053     TBearerFilterArray filterArray;
       
  3054 	TRAP ( err, retUi = settings->RunApplicationSettingsL( selection, aListItems, filterArray ) );
       
  3055 	CleanupStack::PopAndDestroy(); // settings
       
  3056     
       
  3057 	//if something has been selected
       
  3058 	if (retUi)	
       
  3059 	    {
       
  3060 	    //set the selection mode
       
  3061         iPreferences->SetAccessPointSelectionModeL( 
       
  3062                 STATIC_CAST( TCmSettingSelectionMode, selection.iResult ) );
       
  3063 
       
  3064 	    //based on the chosen connection type, store the connection identifier(iapid, snap id, always ask)
       
  3065 	    //in the preferences list
       
  3066 	    switch ( iPreferences->AccessPointSelectionMode() )
       
  3067 		    {			
       
  3068 		    case EConnectionMethod:
       
  3069 			    {
       
  3070 			    TUint32 id = iPreferences->DefaultAccessPoint();
       
  3071                 // CMManager gives us IAPid, need to translate to WAPid
       
  3072 			    if (selection.iId != 0)
       
  3073 			        {                   		
       
  3074 			        id = Util::WapIdFromIapIdL( *this, selection.iId ); 
       
  3075 			        }			    			    
       
  3076 			    iPreferences->SetDefaultAccessPointL( id );
       
  3077                 // Requested AP is preset for PushMtm
       
  3078 			    id = iPreferences->DefaultAccessPoint();
       
  3079                 if( id != KWmlNoDefaultAccessPoint )
       
  3080                     {
       
  3081     			    SetRequestedAP( id );
       
  3082                     retVal = ETrue;
       
  3083                     }
       
  3084 			    break;	
       
  3085 			    }
       
  3086 
       
  3087 		    case EDestination:
       
  3088 			    {
       
  3089 			    TUint32 snapId = iPreferences->DefaultSnapId();
       
  3090 			    if (selection.iId != 0)
       
  3091 			        {                   		
       
  3092 			        snapId = selection.iId;
       
  3093 			        }			        
       
  3094 			    iPreferences->SetDefaultSnapId( snapId );
       
  3095                 if( snapId != KWmlNoDefaultSnapId )
       
  3096                     {
       
  3097                     retVal = ETrue;
       
  3098                     }
       
  3099 			    break;	
       
  3100 			    }
       
  3101 
       
  3102 		    case EAlwaysAsk:
       
  3103 		    default:
       
  3104 			    {
       
  3105 			    break;	
       
  3106 			    }
       
  3107 		    }			
       
  3108 	    }
       
  3109 
       
  3110     // alr: is return val needed?  should it be true or false in EAA and default?  check how it's used
       
  3111     return retVal;
       
  3112     }
       
  3113 // ---------------------------------------------------------------------------
       
  3114 // CBrowserAppUi::AhleConnection
       
  3115 // ---------------------------------------------------------------------------
       
  3116 //
       
  3117 CRecentUrlStore* CBrowserAppUi::RecentUrlStore()
       
  3118     {
       
  3119     return iRecentUrlStore;
       
  3120     }
       
  3121 
       
  3122 // ---------------------------------------------------------------------------
       
  3123 // CBrowserAppUi::SomeItemsNotSecure
       
  3124 // ---------------------------------------------------------------------------
       
  3125 //
       
  3126 TBool CBrowserAppUi::SomeItemsNotSecure() const
       
  3127     {
       
  3128     return !( LoadObserver().LoadStatus( CBrowserLoadObserver::ELoadStatusAllItemIsSecure ) );
       
  3129     }
       
  3130 
       
  3131 // ----------------------------------------------------
       
  3132 // CBrowserAppUi::IsProgressShown
       
  3133 // ----------------------------------------------------
       
  3134 //
       
  3135 TBool CBrowserAppUi::IsProgressShown() const
       
  3136     {
       
  3137     return iShowProgress;
       
  3138     }
       
  3139 
       
  3140 // ----------------------------------------------------
       
  3141 // CBrowserAppUi::SetProgressShown
       
  3142 // ----------------------------------------------------
       
  3143 //
       
  3144 void CBrowserAppUi::SetProgressShown( TBool aProgressShown )
       
  3145     {
       
  3146     iShowProgress = aProgressShown;
       
  3147     }
       
  3148 
       
  3149 // ----------------------------------------------------
       
  3150 // CBrowserAppUi::RecognizeUiFileL
       
  3151 // ----------------------------------------------------
       
  3152 //
       
  3153 TBool CBrowserAppUi::RecognizeUiFileL( RFile& aFile, TBuf<KMaxDataTypeLength>& aDataTypeDes  )
       
  3154 	{
       
  3155 	TBool recognized = EFalse;
       
  3156 	HBufC8* buffer = NULL;
       
  3157 
       
  3158 	TFileName fileName;
       
  3159 	User::LeaveIfError(aFile.FullName(fileName));
       
  3160 
       
  3161     TInt fileSize;
       
  3162 
       
  3163 	// Read the file from the beginning into a buffer
       
  3164 	User::LeaveIfError(aFile.Size(fileSize));
       
  3165 	buffer = HBufC8::NewLC(fileSize);
       
  3166     TPtr8 bufferPtr(buffer->Des());
       
  3167     TInt startPos = 0;
       
  3168     User::LeaveIfError(aFile.Read(startPos, bufferPtr, fileSize));
       
  3169     // move the seek position back to start
       
  3170     User::LeaveIfError(aFile.Seek(ESeekStart, startPos));
       
  3171 
       
  3172     _LIT( KDotOPML, ".opml");
       
  3173     _LIT( KDotXML, ".xml");
       
  3174 
       
  3175     // First try the name extension
       
  3176     if ( fileName.Length() >= 3 )
       
  3177         {
       
  3178         TInt dotPos = fileName.LocateReverse( '.' );
       
  3179         if ( dotPos != KErrNotFound )
       
  3180             {
       
  3181             TInt extLength = fileName.Length() - dotPos;
       
  3182             HBufC* ext = fileName.Right( extLength ).AllocL();
       
  3183             CleanupStack::PushL( ext );
       
  3184 
       
  3185             // if .opml return true
       
  3186             if ( ext->CompareF( KDotOPML )  == 0)
       
  3187             	{
       
  3188 				aDataTypeDes = KOPMLMimeType;
       
  3189             	recognized = ETrue;
       
  3190             	}
       
  3191             else if (ext->CompareF( KDotXML ) == 0 )
       
  3192                 {
       
  3193                 _LIT8( dtd, "<opml" );
       
  3194 				if( bufferPtr.FindF( dtd ) != KErrNotFound )
       
  3195 					{
       
  3196 					aDataTypeDes =  KOPMLMimeType;
       
  3197 					recognized = ETrue;
       
  3198 					}
       
  3199                	}
       
  3200             CleanupStack::PopAndDestroy();	// ext
       
  3201             }
       
  3202         }
       
  3203 
       
  3204 		if (!recognized)
       
  3205 			{
       
  3206 			// just check content of buffer
       
  3207         	_LIT8( dtd, "<opml" );
       
  3208 			if( (bufferPtr.Length() > 5) &&
       
  3209 			    (bufferPtr.FindF( dtd ) != KErrNotFound ))
       
  3210 				{
       
  3211 				aDataTypeDes = KOPMLMimeType;
       
  3212 				recognized = ETrue;
       
  3213 				}
       
  3214         	}
       
  3215 
       
  3216 	CleanupStack::PopAndDestroy(); //buffer
       
  3217 
       
  3218 	return recognized;
       
  3219 	}
       
  3220 
       
  3221 
       
  3222 // ---------------------------------------------------------
       
  3223 // CBrowserAppUi::ConfirmUiHandlingL
       
  3224 // ---------------------------------------------------------
       
  3225 //
       
  3226 TBool CBrowserAppUi::ConfirmUiHandlingL( TFileName& aFilename, TBuf<KMaxDataTypeLength>& aDataTypeDes  )
       
  3227 	{
       
  3228 	// switch on data type desc and handle file accordingly
       
  3229 	if(aDataTypeDes.Compare( KOPMLMimeType ) == 0)
       
  3230 		{
       
  3231 		// Display confirmation dialog before activating feeds view
       
  3232 		HBufC* message = StringLoader::LoadLC(R_FEEDS_QUERY_IMPORT_NOW, aFilename);
       
  3233 		HBufC* lsc_yes = StringLoader::LoadLC(R_FEEDS_IMPORT_NOW_YES);
       
  3234 		HBufC* rsc_no = StringLoader::LoadLC(R_FEEDS_IMPORT_NOW_NO);
       
  3235 
       
  3236 		TBool ret(iDialogsProvider->DialogConfirmL( _L(""), *message, *lsc_yes, *rsc_no ));
       
  3237 
       
  3238 		CleanupStack::PopAndDestroy(3); //message, lsc_yes, rsc_no
       
  3239 
       
  3240 		if(ret)
       
  3241 			{
       
  3242 			return ETrue;
       
  3243 			}
       
  3244 		}
       
  3245 
       
  3246 	return EFalse;
       
  3247 	}
       
  3248 
       
  3249 // ---------------------------------------------------------
       
  3250 // CBrowserAppUi::CopyUiRFileToFileL
       
  3251 // ---------------------------------------------------------
       
  3252 //
       
  3253 
       
  3254 void CBrowserAppUi::CopyUiRFileToFileL( RFile& aFile, const TDesC& aFilepath )
       
  3255 	{
       
  3256 	//
       
  3257 	// copy r-file to a temporary file
       
  3258 	//
       
  3259 	RFs tempRFs;
       
  3260 	RFile tempRFile;
       
  3261 	TInt fileSize;
       
  3262 	HBufC8* buffer = NULL;
       
  3263 
       
  3264 	// Connect to file server
       
  3265 	User::LeaveIfError(tempRFs.Connect());
       
  3266     CleanupClosePushL(tempRFs);
       
  3267 
       
  3268 	// Create the filepath to copy to
       
  3269 	// Replace the file if it already exists
       
  3270 	User::LeaveIfError(tempRFile.Replace(tempRFs, aFilepath, EFileWrite));
       
  3271 	CleanupClosePushL(tempRFile);
       
  3272 
       
  3273 	// Copy the file
       
  3274 	User::LeaveIfError(aFile.Size(fileSize));
       
  3275 	buffer = HBufC8::NewLC(fileSize);
       
  3276     TPtr8 bufferPtr(buffer->Des());
       
  3277 
       
  3278 	// Read from the start of the file
       
  3279     User::LeaveIfError(aFile.Read(0, bufferPtr, fileSize));
       
  3280 	User::LeaveIfError(tempRFile.Write(bufferPtr, fileSize));
       
  3281 
       
  3282 	tempRFile.Close();
       
  3283 	tempRFs.Close();
       
  3284 
       
  3285 	// Cleanup Buffer and file copy stuff
       
  3286 	CleanupStack::PopAndDestroy(3); //buffer, tempRFile, tempRFs
       
  3287 	}
       
  3288 
       
  3289 // ---------------------------------------------------------
       
  3290 // CBrowserAppUi::HandleUiFileL
       
  3291 // ---------------------------------------------------------
       
  3292 //
       
  3293 void CBrowserAppUi::HandleUiFileL( TFileName& aFilepath, TBuf<KMaxDataTypeLength>& aDataTypeDes )
       
  3294 	{
       
  3295 	// switch on data type desc and handle file accordingly
       
  3296 	if(aDataTypeDes.Compare(KOPMLMimeType) == 0)
       
  3297 		{
       
  3298 		// Activate Content view first in order to
       
  3299 		// get it's BrowserControl instance ready to go
       
  3300 		// (as opposed to Feeds' BC instance) to be used to render
       
  3301 		// feeds content in case the user wants to read
       
  3302 		// the feed in-page.
       
  3303 		SetLastActiveViewId( KUidBrowserContentViewId );
       
  3304 		SetViewToBeActivatedIfNeededL( LastActiveViewId() );
       
  3305 		ActivateLocalViewL( LastActiveViewId() );
       
  3306 
       
  3307 		// Now activate bookmarks view
       
  3308 		SetLastActiveViewId( KUidBrowserBookmarksViewId );
       
  3309 		SetViewToBeActivatedIfNeededL( LastActiveViewId() );
       
  3310 		ActivateLocalViewL( LastActiveViewId() );
       
  3311 		HandleForegroundEventL( ETrue );
       
  3312 
       
  3313 		// wait until the content view is completely ready
       
  3314 		WaitCVInit();
       
  3315 
       
  3316 		// begin import, pass to feeds view
       
  3317 		iFeedsClientUtilities->BeginImportOPMLFeedsFileL(aFilepath);
       
  3318 		}
       
  3319 	}
       
  3320 
       
  3321 // ---------------------------------------------------------
       
  3322 // CBrowserAppUi::HandleUiDownloadL
       
  3323 // ---------------------------------------------------------
       
  3324 //
       
  3325 void CBrowserAppUi::HandleUiDownloadL( TFileName& aFilepath, TBuf<KMaxDataTypeLength>& aDataTypeDes )
       
  3326 	{
       
  3327 	// switch on data type desc and handle file accordingly
       
  3328 	if(aDataTypeDes.Compare(KOPMLMimeType) == 0)
       
  3329 		{
       
  3330 		SetLastActiveViewId( KUidBrowserFeedsFolderViewId );
       
  3331 		// begin import
       
  3332 		iFeedsClientUtilities->BeginImportOPMLFeedsFileL(aFilepath);
       
  3333         // switch back to FeedsView, so change layout
       
  3334         ContentView()->SetFullScreenOffL();
       
  3335 		}
       
  3336 	}
       
  3337 	
       
  3338 // ---------------------------------------------------------
       
  3339 // CBrowserAppUi::LaunchIntoFeedsL
       
  3340 // ---------------------------------------------------------
       
  3341 //
       
  3342 void CBrowserAppUi::LaunchIntoFeedsL()
       
  3343 {
       
  3344     if(iBrowserAlreadyRunning && (LastActiveViewId() == KUidBrowserContentViewId))
       
  3345 		{
       
  3346 		iFeedsClientUtilities->ShowFolderViewL(KUidBrowserContentViewId);         	
       
  3347 		}
       
  3348 	else
       
  3349 		{
       
  3350 		iFeedsClientUtilities->ShowFolderViewL();
       
  3351 		}
       
  3352 }
       
  3353 	
       
  3354 // ----------------------------------------------------
       
  3355 // CBrowserAppUi::CreateFullUrlLC
       
  3356 // ----------------------------------------------------
       
  3357 //
       
  3358 HBufC* CBrowserAppUi::CreateFullUrlLC(
       
  3359         const TDesC& aUrl,
       
  3360         const TDesC& aUsername,
       
  3361         const TDesC& aPassword )
       
  3362     {
       
  3363     // username[:password]@server/document
       
  3364     TInt lPw = aPassword.Length();
       
  3365     TInt lUn = aUsername.Length();
       
  3366     _LIT( KBrowserScheme, "://" );
       
  3367     TInt index = aUrl.Find( KBrowserScheme );
       
  3368     if( index == KErrNotFound )
       
  3369     	{
       
  3370         index = 0;  // insert at first position
       
  3371     	}
       
  3372     else
       
  3373     	{
       
  3374     	index += 3;  // insert after scheme
       
  3375     	}
       
  3376 
       
  3377     HBufC *fullUrl = HBufC::NewLC( aUrl.Length() + lUn + lPw + 3 );
       
  3378     fullUrl->Des().Copy( aUrl );
       
  3379     if( lPw + lUn )
       
  3380         {
       
  3381         fullUrl->Des().Insert( index, _L( "@" ) );
       
  3382         }
       
  3383     if( lPw )
       
  3384         {
       
  3385         fullUrl->Des().Insert( index, aPassword );
       
  3386         fullUrl->Des().Insert( index, _L( ":" ) );
       
  3387         }
       
  3388     if( lUn )
       
  3389         {
       
  3390         fullUrl->Des().Insert( index, aUsername );
       
  3391         }
       
  3392     // insert scheme???
       
  3393     fullUrl->Des().ZeroTerminate();
       
  3394 
       
  3395     return fullUrl;
       
  3396     }
       
  3397 
       
  3398 // ---------------------------------------------------------
       
  3399 // CBrowserAppUi::HandleResourceChangeL( TInt aType )
       
  3400 // ---------------------------------------------------------
       
  3401 //
       
  3402 void CBrowserAppUi::HandleResourceChangeL( TInt aType )
       
  3403     {
       
  3404     LOG_ENTERFN("CBrowserAppUi::HandleResourceChangeL");
       
  3405     LOG_WRITE_FORMAT(" aType: %d", aType);
       
  3406     if( iExitInProgress )
       
  3407         {
       
  3408         BROWSER_LOG( ( _L(" iExitInProgress ETrue ") ) );
       
  3409         return;
       
  3410         }
       
  3411 
       
  3412     CAknViewAppUi::HandleResourceChangeL( aType );
       
  3413     if ( aType == KEikDynamicLayoutVariantSwitch )
       
  3414         {
       
  3415         CBrowserViewBase* activeView = ActiveView( );
       
  3416         if( activeView != NULL )
       
  3417             {
       
  3418             activeView->HandleClientRectChange();
       
  3419             if (activeView != ContentView())
       
  3420                 {
       
  3421                 ContentView()->HandleClientRectChange();
       
  3422                 }
       
  3423             }
       
  3424         }
       
  3425     if (aType == KEikMessageFadeAllWindows)
       
  3426         {
       
  3427         if (ContentView() && ContentView()->PenEnabled())
       
  3428             {
       
  3429             if (iCurrentView == KUidBrowserContentViewId)
       
  3430                 {
       
  3431                 ContentView()->Toolbar()->DisableToolbarL(ETrue);
       
  3432                 }
       
  3433             }
       
  3434         }
       
  3435 
       
  3436     if (aType == KEikMessageUnfadeWindows)
       
  3437         {
       
  3438         if (ContentView()&& ContentView()->PenEnabled() && !ExitInProgress())
       
  3439             {
       
  3440             if (iCurrentView == KUidBrowserContentViewId)
       
  3441                 {
       
  3442                 ContentView()->MakeZoomSliderVisibleL(EFalse);
       
  3443                 ContentView()->Toolbar()->DisableToolbarL(EFalse);
       
  3444                 }
       
  3445             }
       
  3446         }
       
  3447     }
       
  3448 
       
  3449 // ---------------------------------------------------------
       
  3450 // CBrowserAppUi::ChangeConnectionL()
       
  3451 // ---------------------------------------------------------
       
  3452 //
       
  3453 void CBrowserAppUi::ChangeConnectionL()
       
  3454     {
       
  3455     TConManChangeConn change;
       
  3456     // This will contain the new IAP as well, but it needs to pass the old one
       
  3457     TUint32 newAp = Util::IapIdFromWapIdL( *this, RequestedAp() );
       
  3458     iConnection->ChangeIapL( change, newAp );
       
  3459     if( EConManDoNothing == change )
       
  3460         {
       
  3461         // Do nothing
       
  3462         }
       
  3463     else
       
  3464         {
       
  3465         //cancel transaction
       
  3466         SendDisconnectEventL();
       
  3467         /* start all */
       
  3468         if( EConManCloseAndStart == change )
       
  3469             {
       
  3470             //close connection
       
  3471             iConnection->Disconnect();
       
  3472 
       
  3473 #ifdef __RSS_FEEDS
       
  3474             //notify feeds engine to close the connection
       
  3475         	iFeedsClientUtilities->DisconnectManualUpdateConnectionL();
       
  3476 #endif
       
  3477             }
       
  3478         iConnection->SetRequestedAP( newAp );
       
  3479         TInt err = iConnection->StartConnectionL( ETrue );
       
  3480         if( err == KErrNone )
       
  3481             {
       
  3482             iConnection->ShowConnectionChangedDlg();
       
  3483             }
       
  3484         }
       
  3485     }
       
  3486 
       
  3487 // ---------------------------------------------------------
       
  3488 // CBrowserAppUi::HandleContentL()
       
  3489 // ---------------------------------------------------------
       
  3490 //
       
  3491 TBool CBrowserAppUi::HandleContentL( const TDesC& aFileName,
       
  3492                                       const CAiwGenericParamList& aParamList,
       
  3493                                       TBool& aContinue )
       
  3494     {
       
  3495     // Put the file name to the generic parameter list, if it is not there yet
       
  3496     TInt index(0);
       
  3497     aParamList.FindFirst( index, EGenericParamFile, EVariantTypeDesC );
       
  3498     if ( index == KErrNotFound )
       
  3499     	{
       
  3500         TAiwVariant paramVariant( aFileName );
       
  3501         TAiwGenericParam genericParam( EGenericParamFile, paramVariant );
       
  3502         CAiwGenericParamList* paramList = (CAiwGenericParamList*)&aParamList;
       
  3503         paramList->AppendL( genericParam );
       
  3504     	}
       
  3505 
       
  3506 	// Set EGenericParamAllowMove - we allow handlers to apply move instead
       
  3507 	// of copy for the file.
       
  3508     aParamList.FindFirst( index, EGenericParamAllowMove, EVariantTypeAny );
       
  3509     if ( index == KErrNotFound )
       
  3510     	{
       
  3511     	TBool allowMove( ETrue );
       
  3512         TAiwVariant allowMoveVariant( allowMove );
       
  3513         TAiwGenericParam genericParamAllowMove( EGenericParamAllowMove, allowMoveVariant );
       
  3514         CAiwGenericParamList* paramList = (CAiwGenericParamList*)&aParamList;
       
  3515         paramList->AppendL( genericParamAllowMove );
       
  3516     	}
       
  3517 
       
  3518     BrowserLauncherService()->DownloadFinishedL( KErrNone, aParamList );
       
  3519 
       
  3520     // Wait until the client sends two TBools (contentHandled & continueBrowsing).
       
  3521     iClientWantsToContinue = EFalse;
       
  3522     iWasContentHandled = EFalse;
       
  3523 
       
  3524     iLauncherServiceWait.Start();
       
  3525 
       
  3526     // iClientWantsToContinue and iWasContentHandled contains the results
       
  3527     aContinue = iClientWantsToContinue;
       
  3528     return iWasContentHandled;
       
  3529     }
       
  3530 
       
  3531 // ---------------------------------------------------------
       
  3532 // CBrowserAppUi::DownloadedContentHandlerReserved1()
       
  3533 // ---------------------------------------------------------
       
  3534 //
       
  3535 TAny* CBrowserAppUi::DownloadedContentHandlerReserved1( TAny* /*aAnyParam*/ )
       
  3536     {
       
  3537     return 0;
       
  3538     }
       
  3539 
       
  3540 // ---------------------------------------------------------
       
  3541 // CBrowserAppUi::SetContentHandlingResult()
       
  3542 // ---------------------------------------------------------
       
  3543 //
       
  3544 void CBrowserAppUi::SetContentHandlingResult
       
  3545     ( TBool aClientWantsToContinue, TBool aWasContentHandled )
       
  3546     {
       
  3547     iClientWantsToContinue = aClientWantsToContinue;
       
  3548     iWasContentHandled = aWasContentHandled;
       
  3549 
       
  3550     // continue handling the content
       
  3551     iLauncherServiceWait.AsyncStop();
       
  3552     }
       
  3553 
       
  3554 // ---------------------------------------------------------
       
  3555 // CBrowserAppUi::LoadSearchPageL()
       
  3556 // ---------------------------------------------------------
       
  3557 //
       
  3558 void CBrowserAppUi::LoadSearchPageL()
       
  3559 	{
       
  3560     TPtrC url = iPreferences->SearchPageUrlL();
       
  3561 
       
  3562     // url undefined
       
  3563     if ( !url.Length() )
       
  3564         {
       
  3565         HBufC* query = StringLoader::LoadLC(
       
  3566                                     R_BROWSER_QUERY_DEF_SEARCHPAGE );
       
  3567         // Ask if user want to define the search web setting now
       
  3568         if (
       
  3569             TBrowserDialogs::DialogQueryReqL( query->Des(),
       
  3570                                                 KNullDesC,
       
  3571                                                 KNullDesC )
       
  3572             )
       
  3573             {
       
  3574             HBufC* prompt = StringLoader::LoadLC(
       
  3575                                         R_BROWSER_PROMPT_SEARCH_URL );
       
  3576             HBufC* retBuf = HBufC::NewLC( KMaxSearchPgUrlLength );
       
  3577             TPtr retString = retBuf->Des();
       
  3578             retString.Copy( KNullDesC );
       
  3579 
       
  3580             TInt result = TBrowserDialogs::DialogPromptReqL(
       
  3581                                              prompt->Des(),
       
  3582                                              &retString,
       
  3583                                              ETrue,
       
  3584                                              KMaxSearchPgUrlLength
       
  3585                                              );
       
  3586 
       
  3587             if( result )  // URL was accepted
       
  3588                 {
       
  3589                 Preferences().SetSearchPageUrlL( retString );
       
  3590                 url.Set( iPreferences->SearchPageUrlL() );
       
  3591                 }
       
  3592             CleanupStack::PopAndDestroy( 2 ); // retBuf, prompt
       
  3593             }
       
  3594         CleanupStack::PopAndDestroy( query );
       
  3595         }
       
  3596 
       
  3597     FetchL( url );
       
  3598 	}
       
  3599 
       
  3600 // ---------------------------------------------------------
       
  3601 // CBrowserAppUi::CloseWindowL()
       
  3602 // ---------------------------------------------------------
       
  3603 //
       
  3604 void CBrowserAppUi::CloseWindowL( TInt aWindowId )
       
  3605     {
       
  3606 LOG_ENTERFN("AppUi::CloseWindowL");
       
  3607 
       
  3608 	//There are only two cases for closing window. One is user initialized and the
       
  3609 	//other is script initialized. For both cases, the window should be deleted.
       
  3610     TBool forceDelete( ETrue );
       
  3611     // this variable is useful to know if the window has a parent window which needs to be activated on closing current window
       
  3612     TBool parentPresent(EFalse);
       
  3613     if ( WindowMgr().CurrentWindowQue() && WindowMgr().CurrentWindowQue()->iParent )
       
  3614         {
       
  3615         parentPresent = ETrue;
       
  3616         }
       
  3617     // delete the current window by default
       
  3618     if( aWindowId == 0 )
       
  3619         {
       
  3620         aWindowId = WindowMgr().CurrentWindow()->WindowId();
       
  3621         // scripts directly pass a real windowId,
       
  3622         // so if user initiated the process, we really delete the window
       
  3623         forceDelete = ETrue;
       
  3624         }
       
  3625 
       
  3626 #ifdef __RSS_FEEDS
       
  3627 	// If we are closing a Feeds Full Story then go back to feeds
       
  3628 	TBool feedsWindow(EFalse);
       
  3629 	CBrowserWindow* win;
       
  3630 	TInt err = WindowMgr().Window(aWindowId, win);
       
  3631 	if (err == KErrNone)
       
  3632 		{
       
  3633 		feedsWindow = win->HasFeedsContent();
       
  3634 		win->SetHasFeedsContent(EFalse);
       
  3635 		}
       
  3636 #endif
       
  3637 
       
  3638 	TInt winId = WindowMgr().DeleteWindowL( aWindowId, forceDelete );
       
  3639 
       
  3640 #ifdef __RSS_FEEDS
       
  3641 	if (feedsWindow)
       
  3642 		{
       
  3643 		SetViewToBeActivatedIfNeededL( KUidBrowserFeedsFeedViewId );
       
  3644 		return;
       
  3645 		}
       
  3646 #endif
       
  3647 
       
  3648     if( winId > 0 )  // still remain a window to be activated
       
  3649         {
       
  3650    	    WindowMgr().SwitchWindowL( winId );
       
  3651         if(CalledFromAnotherApp() && (!IsEmbeddedModeOn()) && !parentPresent)
       
  3652    	        {
       
  3653    	        SetCalledFromAnotherApp(EFalse);
       
  3654    	        SendBrowserToBackground();
       
  3655    	        }
       
  3656    	    }
       
  3657    	else  if( winId == 0) // last window was closed
       
  3658 	    {
       
  3659         if(CalledFromAnotherApp() && (!IsEmbeddedModeOn()))
       
  3660    	        {
       
  3661 #ifdef __RSS_FEEDS
       
  3662    	        if ((GetPreviousViewFromViewHistory() == KUidBrowserFeedsFolderViewId) || 
       
  3663    	            (GetPreviousViewFromViewHistory() == KUidBrowserFeedsTopicViewId) ||
       
  3664    	            (GetPreviousViewFromViewHistory() == KUidBrowserFeedsFeedViewId))
       
  3665    	            {
       
  3666    	            SetViewToBeActivatedIfNeededL( GetPreviousViewFromViewHistory() );
       
  3667    	            SetCalledFromAnotherApp(EFalse);
       
  3668    	            SendBrowserToBackground();
       
  3669    	            }
       
  3670    	        else
       
  3671                 {
       
  3672                	ExitBrowser(ETrue);
       
  3673                 }
       
  3674 #else
       
  3675             ExitBrowser(ETrue);
       
  3676 #endif // __RSS_FEEDS
       
  3677    	        }
       
  3678         else
       
  3679             {
       
  3680         	ExitBrowser(ETrue);        
       
  3681             }
       
  3682     	}
       
  3683     // else a background window was closed
       
  3684 
       
  3685     }
       
  3686 
       
  3687 // ---------------------------------------------------------
       
  3688 // CBrowserAppUi::StartProgressAnimationL
       
  3689 // ---------------------------------------------------------
       
  3690 //
       
  3691 void CBrowserAppUi::StartProgressAnimationL()
       
  3692     {
       
  3693 LOG_ENTERFN("AppUi::StartProgressAnimationL");
       
  3694     }
       
  3695 
       
  3696 // ---------------------------------------------------------
       
  3697 // CBrowserAppUi::StopProgressAnimationL
       
  3698 // ---------------------------------------------------------
       
  3699 //
       
  3700 void CBrowserAppUi::StopProgressAnimationL()
       
  3701     {
       
  3702 LOG_ENTERFN("AppUi::StopProgressAnimationL");
       
  3703     }
       
  3704 
       
  3705 #ifdef __RSS_FEEDS
       
  3706 // ---------------------------------------------------------
       
  3707 // CBrowserAppUi::FeedsClientUtilities
       
  3708 // ---------------------------------------------------------
       
  3709 //
       
  3710 CFeedsClientUtilities& CBrowserAppUi::FeedsClientUtilities() const
       
  3711 	{
       
  3712 	return *iFeedsClientUtilities;
       
  3713 	}
       
  3714 #endif  // __RSS_FEEDS
       
  3715 
       
  3716 // ---------------------------------------------------------
       
  3717 // CBrowserAppUi::OpenLinkInNewWindowL()
       
  3718 // ---------------------------------------------------------
       
  3719 //
       
  3720 void CBrowserAppUi::OpenLinkInNewWindowL( const CFavouritesItem& aBookmarkItem )
       
  3721     {
       
  3722     if( ( aBookmarkItem.IsItem() ) &&
       
  3723         ( aBookmarkItem.Uid() != KFavouritesRSSItemUid ) )
       
  3724         {
       
  3725         // Check if we should/can create a new window
       
  3726         // In most cases when the feature is not allowed option menu items have been dimmed.
       
  3727         // In the case where a long key press on a bookmark happens we fall through to this function
       
  3728         // and check the feature here.  If a new window is not allowed we can open in the current window
       
  3729         if( IsPageLoaded() &&
       
  3730         		Preferences().UiLocalFeatureSupported( KBrowserMultipleWindows ) &&
       
  3731             	!Preferences().UiLocalFeatureSupported( KBrowserMinimalMultipleWindows ))
       
  3732             {
       
  3733             // there is already a window, so create a new one
       
  3734             CBrowserWindow *win = WindowMgr().CreateWindowL( 0, &KNullDesC );
       
  3735             if (win != NULL)
       
  3736                 {
       
  3737                 CleanupStack::PushL( win );
       
  3738                 WindowMgr().SwitchWindowL( win->WindowId() );
       
  3739                 FetchBookmarkL( aBookmarkItem );
       
  3740                 CleanupStack::Pop();  // win
       
  3741                 }
       
  3742             }
       
  3743         else
       
  3744             {
       
  3745             // no page is loaded yet, so do not create new window
       
  3746             FetchBookmarkL( aBookmarkItem );
       
  3747             }
       
  3748         }
       
  3749     }
       
  3750 
       
  3751 // ---------------------------------------------------------
       
  3752 // CBrowserAppUi::SendDisconnectEventL
       
  3753 // ---------------------------------------------------------
       
  3754 //
       
  3755 void CBrowserAppUi::SendDisconnectEventL()
       
  3756     {
       
  3757     LOG_ENTERFN("CBrowserAppUi::SendDisconnectEventL");
       
  3758     SpecialLoadObserver().CancelConnection();
       
  3759     CArrayFixFlat<CWindowInfo*>* windows = iWindowManager->GetWindowInfoL( this );
       
  3760     if( windows )
       
  3761         {
       
  3762         TInt i;
       
  3763 
       
  3764         for ( i = 0; i < windows->Count(); i++ )
       
  3765             {
       
  3766             CBrowserWindow* window = NULL;
       
  3767             iWindowManager->Window( windows->At( i )->iWindowId, window );
       
  3768             if( window )
       
  3769                 {
       
  3770                 TInt err;
       
  3771            //     BROWSER_LOG( ( _L( " iConnection Connected" ) ) );
       
  3772                 TRAP( err, window->BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandCancelFetch + (TInt)TBrCtlDefs::ECommandIdBase ) );
       
  3773            //     BROWSER_LOG( ( _L( " HandleCommandL:  %d"), err ) );
       
  3774                 }
       
  3775             }
       
  3776         
       
  3777         CBrowserWindow* window = NULL;
       
  3778         iWindowManager->Window( windows->At( 0 )->iWindowId, window );
       
  3779         
       
  3780         // Close session only once
       
  3781         if (window)
       
  3782             {
       
  3783             window->BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandDisconnect + (TInt)TBrCtlDefs::ECommandIdBase );
       
  3784             }
       
  3785         
       
  3786         // delete the window items before deleting the array
       
  3787         for( i=0; i<windows->Count(); ++i )
       
  3788             delete windows->At( i );
       
  3789 
       
  3790         delete windows;
       
  3791         }
       
  3792     }
       
  3793     /*
       
  3794 
       
  3795 // ----------------------------------------------------
       
  3796 // CBrowserAppUi::IsPgNotFound
       
  3797 // ----------------------------------------------------
       
  3798 //
       
  3799 TBool CBrowserAppUi::IsPgNotFound() const
       
  3800     {
       
  3801     return iPgNotFound;
       
  3802     }
       
  3803 */
       
  3804 // ----------------------------------------------------
       
  3805 // CBrowserAppUi::HandleApplicationSpecificEventL
       
  3806 // ----------------------------------------------------
       
  3807 //
       
  3808 void CBrowserAppUi::HandleApplicationSpecificEventL(TInt aEventType, const TWsEvent& aWsEvent)
       
  3809     {
       
  3810     CAknAppUi::HandleApplicationSpecificEventL(aEventType, aWsEvent);
       
  3811 
       
  3812     /*
       
  3813      * Note:  Even though we get these memory events from the system for handling OOM, and we pass them off
       
  3814      * to the command handler, there is no code further down the line that actually handles them (it would 
       
  3815      * normally be in BrCtl).  We totally ignore these events.  This is because the system has too high of an OOM threshold.
       
  3816      * I.e. the system may only have 6m left and think it's out of memory, however, the browser can still render
       
  3817      * many pages in only 6m.  So, these system events are ignored and the browser handles OOM with its own mechanism.
       
  3818      * (See OOMStopper and OOMHandler)
       
  3819      */
       
  3820 	if(aEventType == KAppOomMonitor_FreeRam )
       
  3821 		{
       
  3822 		iWindowManager->CloseAllWindowsExceptCurrent();
       
  3823 		// If we were really doing anything about this event, why do we not want to do it to the foreground?
       
  3824 		if(!iIsForeground)
       
  3825 		    {
       
  3826             BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandFreeMemory + (TInt)TBrCtlDefs::ECommandIdBase);
       
  3827 		    }
       
  3828 		}
       
  3829 	else if(aEventType == KAppOomMonitor_MemoryGood)
       
  3830 		{
       
  3831         BrCtlInterface().HandleCommandL( (TInt)TBrCtlDefs::ECommandMemoryGood + (TInt)TBrCtlDefs::ECommandIdBase);
       
  3832 		}
       
  3833     else if ( KAknFullOrPartialForegroundGained == aEventType )
       
  3834         {
       
  3835         if ( iViewToBeActivatedIfNeeded.iUid )
       
  3836             {
       
  3837             ActivateLocalViewL( iViewToBeActivatedIfNeeded );
       
  3838             }
       
  3839         else
       
  3840             {
       
  3841             // LastActiveViewId() might return with 0!
       
  3842             TRAP_IGNORE( ActivateLocalViewL( LastActiveViewId() ) );
       
  3843             }
       
  3844         iViewToBeActivatedIfNeeded.iUid = 0;
       
  3845         }
       
  3846     }
       
  3847 
       
  3848 // ----------------------------------------------------
       
  3849 // CBrowserAppUi::OfferApplicationSpecificKeyEventL
       
  3850 //
       
  3851 // Use this function to handle key events that are application wide and not specific to any view
       
  3852 // All views (containers) call this first and should return if key was consumed
       
  3853 // As a note for future reference the red end key shows up as iCode = EKeyNo...though you would
       
  3854 // think it would be EKeyEnd...
       
  3855 // ----------------------------------------------------
       
  3856 //
       
  3857 TKeyResponse CBrowserAppUi::OfferApplicationSpecificKeyEventL(const TKeyEvent& /*aKeyEvent*/,
       
  3858 															  TEventCode /*aType*/)
       
  3859     {
       
  3860     TKeyResponse result( EKeyWasNotConsumed );
       
  3861 
       
  3862     return result;
       
  3863     }
       
  3864 
       
  3865 // -----------------------------------------------------------------------------
       
  3866 // CBrowserAppUi::GetPreviousViewFromViewHistory
       
  3867 // -----------------------------------------------------------------------------
       
  3868 //
       
  3869 TUid CBrowserAppUi::GetPreviousViewFromViewHistory()
       
  3870 {
       
  3871 	return iPreviousView;
       
  3872 }
       
  3873 
       
  3874 // -----------------------------------------------------------------------------
       
  3875 // CBrowserAppUi::SaveFocusedImageToGalleryL
       
  3876 // -----------------------------------------------------------------------------
       
  3877 //
       
  3878 void CBrowserAppUi::SaveFocusedImageToGalleryL()
       
  3879     {
       
  3880     TBrCtlImageCarrier* imageCarrier = BrCtlInterface().FocusedImageLC();
       
  3881     CDocumentHandler* docHandler = CDocumentHandler::NewLC();
       
  3882     TUriParser uriParser;
       
  3883     User::LeaveIfError(uriParser.Parse(imageCarrier->Url()));
       
  3884     TPtrC path;
       
  3885     path.Set( uriParser.Extract( EUriPath ) );
       
  3886     HBufC* fileName = NULL;
       
  3887     if( path.Length() )
       
  3888         {
       
  3889         TInt slash = path.LocateReverse( '/' );
       
  3890         if( slash != KErrNotFound && slash != path.Length() )
       
  3891             {
       
  3892             TPtrC temp( path.Right( path.Length() - slash - 1 ) );
       
  3893             if( temp.Length() )
       
  3894                 {
       
  3895                 fileName = HBufC::NewLC(temp.Length() + 4); // leave room for edding extenstion if needed
       
  3896                 fileName->Des().Copy(temp);
       
  3897                 }
       
  3898             }
       
  3899         }
       
  3900     HBufC8* dataType8 = NULL;
       
  3901     dataType8 = HBufC8::NewLC(imageCarrier->ContentType().Length());
       
  3902     dataType8->Des().Copy(imageCarrier->ContentType());
       
  3903     TDataType dataType(*dataType8);
       
  3904     if (fileName)
       
  3905         {
       
  3906         TPtr fileNamePtr(fileName->Des());
       
  3907         docHandler->CheckFileNameExtension(fileNamePtr, dataType);
       
  3908         docHandler->SaveL(imageCarrier->RawData(), dataType, *fileName, KEntryAttNormal);
       
  3909         }
       
  3910     else
       
  3911         {
       
  3912         docHandler->SaveL(imageCarrier->RawData(), dataType, KEntryAttNormal);
       
  3913         }
       
  3914     if (fileName)
       
  3915         {
       
  3916         CleanupStack::PopAndDestroy(2); // fileName, dataType8
       
  3917         }
       
  3918     else
       
  3919         {
       
  3920         CleanupStack::PopAndDestroy(dataType8); // dataType8
       
  3921         }
       
  3922 
       
  3923     TFileName fName;
       
  3924     User::LeaveIfError(docHandler->GetPath(fName));
       
  3925     
       
  3926     #ifdef BRDO_APP_GALLERY_SUPPORTED_FF
       
  3927     
       
  3928     CMGXFileManager* mgFileManager = MGXFileManagerFactory::NewFileManagerL(CEikonEnv::Static()->FsSession());
       
  3929     CleanupStack::PushL(mgFileManager);
       
  3930     if( fName.Length() > 0 )
       
  3931         {
       
  3932         TRAP_IGNORE( mgFileManager->UpdateL( fName ) );
       
  3933         }
       
  3934     else
       
  3935         {
       
  3936         TRAP_IGNORE( mgFileManager->UpdateL() );
       
  3937         }
       
  3938     CleanupStack::PopAndDestroy(1); // mgFileManager
       
  3939     
       
  3940     #endif
       
  3941     
       
  3942     CleanupStack::PopAndDestroy(1); // imageCarrier
       
  3943     }
       
  3944 
       
  3945 // ---------------------------------------------------------
       
  3946 // CBrowserAppUi::CheckFlashPresent
       
  3947 // ---------------------------------------------------------
       
  3948 //
       
  3949 TBool CBrowserAppUi::CheckFlashPresent()
       
  3950     {
       
  3951     RImplInfoPtrArray animPluginList;
       
  3952 
       
  3953     TRAP_IGNORE( REComSession::ListImplementationsL( KBrowserPluginInterfaceUid,
       
  3954                                         animPluginList ) );
       
  3955 
       
  3956 
       
  3957 	_LIT8(KFlashMimeType,     "application/x-shockwave-flash");
       
  3958 
       
  3959     const TInt count = animPluginList.Count();
       
  3960     TBool found = EFalse;
       
  3961     for ( TInt i = 0; i < count; i++ )
       
  3962         {
       
  3963         CImplementationInformation* implInfo = animPluginList[i];
       
  3964         if (( implInfo->DataType( ) ).Find( KFlashMimeType) != KErrNotFound)
       
  3965             {
       
  3966             found = ETrue;  //flash plugin is present
       
  3967             break;
       
  3968             }
       
  3969         }
       
  3970     animPluginList.ResetAndDestroy();
       
  3971 
       
  3972     return found;
       
  3973 
       
  3974     }
       
  3975 
       
  3976 // ---------------------------------------------------------
       
  3977 // CBrowserAppUi::FlashPresent
       
  3978 // ---------------------------------------------------------
       
  3979 //
       
  3980 TBool CBrowserAppUi::FlashPresent()
       
  3981     {
       
  3982     return iFlashPresent;
       
  3983     }
       
  3984 
       
  3985 // ---------------------------------------------------------
       
  3986 // CBrowserAppUi::ShowNameAndVersionL
       
  3987 // ---------------------------------------------------------
       
  3988 //
       
  3989 void CBrowserAppUi::ShowNameAndVersionL()
       
  3990 {
       
  3991     HBufC* header = StringLoader::LoadLC( R_BROWSER_QUERY_BROWSER_VERSION );
       
  3992     HBufC* browserVersion = BrCtlInterface().VersionInfoLC(TBrCtlDefs::EBrowserVersion);
       
  3993 
       
  3994     // output browser version to dialog
       
  3995     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( *browserVersion );
       
  3996     CleanupStack::PushL(dlg);
       
  3997     dlg->PrepareLC( R_BROWSER_PAGE_VERSION );
       
  3998     CleanupStack::Pop(dlg);
       
  3999     CAknPopupHeadingPane* hPane = dlg->QueryHeading();
       
  4000     if ( hPane )
       
  4001         {
       
  4002         CleanupStack::PushL(hPane);
       
  4003         hPane->SetTextL( *header );
       
  4004 	    CleanupStack::Pop(hPane);
       
  4005         }
       
  4006     dlg->RunLD();
       
  4007 	CleanupStack::PopAndDestroy(2); // browserVersion, header
       
  4008 }
       
  4009 
       
  4010 
       
  4011 // ---------------------------------------------------------
       
  4012 // CBrowserAppUi::IsLaunchHomePageDimmedL
       
  4013 // ---------------------------------------------------------
       
  4014 //
       
  4015 TBool CBrowserAppUi::IsLaunchHomePageDimmedL()
       
  4016 {
       
  4017     
       
  4018     // Set dimmed flag if shortcut key for launch home page is dimmed and was selected
       
  4019     TBool dimmed = EFalse;
       
  4020     TBool homepage = Preferences().UiLocalFeatureSupported( KBrowserUiHomePageSetting );
       
  4021     if( homepage )
       
  4022         {
       
  4023         TWmlSettingsHomePage pgtype = Preferences().HomePageType();
       
  4024         TBool alwaysAskCase = ((Preferences().AccessPointSelectionMode() == EAlwaysAsk ) &&
       
  4025             ( EWmlSettingsHomePageAccessPoint == pgtype ));
       
  4026         
       
  4027         if (alwaysAskCase || (pgtype == EWmlSettingsHomePageBookmarks))
       
  4028             {
       
  4029             dimmed = ETrue;
       
  4030             }
       
  4031         else if (pgtype == EWmlSettingsHomePageAccessPoint)
       
  4032         	{
       
  4033         	// check to see if no home page defined on the access point
       
  4034         	HBufC* buf = HBufC::NewLC( KMaxHomePgUrlLength );  // cleanupstack
       
  4035     		TPtr ptr( buf->Des() );
       
  4036     		TInt pgFound = Preferences().HomePageUrlL( ptr );
       
  4037     		if( pgFound != KErrNone )
       
  4038     			{
       
  4039     			dimmed = ETrue;
       
  4040     			}
       
  4041     		CleanupStack::PopAndDestroy( buf );
       
  4042         	}
       
  4043         }
       
  4044     else
       
  4045         {
       
  4046         dimmed = ETrue;
       
  4047         }
       
  4048         
       
  4049     return(dimmed);
       
  4050 }
       
  4051 
       
  4052 // ---------------------------------------------------------
       
  4053 // CBrowserAppUi::IsDisplayingMenuOrDialog
       
  4054 // ---------------------------------------------------------
       
  4055 //
       
  4056 TBool CBrowserAppUi::IsDisplayingMenuOrDialog()
       
  4057 {
       
  4058 	return CCoeAppUi::IsDisplayingMenuOrDialog();
       
  4059 }
       
  4060 // ---------------------------------------------------------
       
  4061 // CBrowserAppUi::HandleWsEventL
       
  4062 // ---------------------------------------------------------
       
  4063 void CBrowserAppUi::HandleWsEventL(const TWsEvent& aEvent, 
       
  4064                                    CCoeControl* aDestination)
       
  4065 {
       
  4066   /**
       
  4067    * We need a special handling for pointer events to handle the situation 
       
  4068    * when the pointer is crossing the boundaries of plugin window. Browser
       
  4069    * scrolling id done using PointerMove events not a Drag. 
       
  4070    * When PointerMoveBuffer is ready HandlePointerBufferReadyL() is called by
       
  4071    * Symbian framework. By default if Pointer Down event wasn't issued on the 
       
  4072    * current CoeControl Pointer Move events are not sent to this control.
       
  4073    * The code below makes sure that when we entering the Content View window 
       
  4074    * from pluging window we are still getting move events.
       
  4075    * When we are leaving Content window we are generating fake Pointer Up 
       
  4076    * event in order to on-demand scrollbars disapear properly. The later is a
       
  4077    * hack and needs to be re-designed in such way that pluging will pass 
       
  4078    * pointer event back to the browser.
       
  4079    */
       
  4080    if (aDestination != NULL)
       
  4081        {
       
  4082        TInt type=aEvent.Type();
       
  4083        
       
  4084        switch (type)
       
  4085            {
       
  4086            case EEventPointerExit:
       
  4087                {
       
  4088 
       
  4089                break;
       
  4090                }
       
  4091                
       
  4092            case EEventPointerEnter:
       
  4093                {
       
  4094                if (iCurrentView == KUidBrowserContentViewId)
       
  4095                    {
       
  4096                    CCoeControl* ctrl = &(BrCtlInterface());
       
  4097                    ctrl->DrawableWindow()->DiscardPointerMoveBuffer(); 
       
  4098                    const TInt count = ctrl->CountComponentControls();
       
  4099                    for (TInt i = 0; i < count; i++) 
       
  4100                        {
       
  4101                        CCoeControl* c = ctrl->ComponentControl(i);
       
  4102                        if (c) 
       
  4103                           {
       
  4104                           c->ClaimPointerGrab(EFalse);
       
  4105                           }
       
  4106                        }
       
  4107                    ctrl->ClaimPointerGrab(EFalse);
       
  4108                    }
       
  4109                break;
       
  4110                }
       
  4111            
       
  4112            }
       
  4113        }
       
  4114    CAknViewAppUi::HandleWsEventL(aEvent, aDestination);
       
  4115 }
       
  4116 
       
  4117 // ---------------------------------------------------------
       
  4118 // CBrowserAppUi::HandleSystemEventL
       
  4119 // ---------------------------------------------------------
       
  4120 #if defined(__S60_50__)
       
  4121 void CBrowserAppUi::HandleSystemEventL(const TWsEvent& aEvent)
       
  4122    {
       
  4123    
       
  4124    /**
       
  4125     * We need a special handling for System events to handle the situation 
       
  4126     * like when the shut down is done while download is going on.
       
  4127     */
       
  4128    
       
  4129    switch (*(TApaSystemEvent*)(aEvent.EventData()))
       
  4130      {
       
  4131      case EApaSystemEventShutdown:    
       
  4132        // do things here
       
  4133         ExitBrowser ( IsAppShutterActive() );  
       
  4134        break;
       
  4135      default:
       
  4136        break;
       
  4137      }
       
  4138    // call base class implementation
       
  4139    CAknAppUi::HandleSystemEventL(aEvent);
       
  4140    }
       
  4141 #endif  
       
  4142 // ---------------------------------------------------------
       
  4143 // CBrowserAppUi::StartFetchHomePageL
       
  4144 // ---------------------------------------------------------
       
  4145 void CBrowserAppUi::StartFetchHomePageL(void)
       
  4146     {
       
  4147     
       
  4148     // There's a homepage to be launched so start in content view
       
  4149     SetLastActiveViewId(KUidBrowserContentViewId);      	    	          
       
  4150    	//wait for contentview to initialize itself
       
  4151     WaitCVInit();
       
  4152     
       
  4153     TInt error( KErrNone );
       
  4154     TRAP( error, FetchHomePageL() );
       
  4155     if( error != KErrNone )
       
  4156         {
       
  4157         CloseContentViewL();
       
  4158         }                
       
  4159     }
       
  4160 
       
  4161 // End of File