browserui/browser/BrowserAppInc/BrowserLoadObserver.h
branchRCL_3
changeset 64 6385c4c93049
parent 63 4baee4f15982
child 65 8e6fa1719340
equal deleted inserted replaced
63:4baee4f15982 64:6385c4c93049
     1 /*
       
     2 * Copyright (c) 2004 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:  Handle special load events such as network connection,
       
    15 *                deal with non-http or non-html requests
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef BROWSERLOADOBSERVER_H
       
    22 #define BROWSERLOADOBSERVER_H
       
    23 
       
    24 //  INCLUDES
       
    25 #include <brctlinterface.h>
       
    26 #include <browserdialogsproviderobserver.h>
       
    27 
       
    28 //  FORWARD DECLARATIONS
       
    29 class MApiProvider;
       
    30 class CBrowserContentView;
       
    31 class CBrowserWindow;
       
    32 
       
    33 // define this macro to log event time, temporary
       
    34 // #define I__LOG_EVENT_TIME
       
    35 
       
    36 //  CLASS DECLARATION
       
    37 
       
    38 /**
       
    39 *  This observer registers for load events
       
    40 */
       
    41 class CBrowserLoadObserver : public CBase,
       
    42                              public MBrCtlLoadEventObserver,
       
    43                              public MBrowserDialogsProviderObserver
       
    44     {
       
    45     public: // Constructors and destructors
       
    46 
       
    47         /**
       
    48         * Constructor.
       
    49         */
       
    50         static CBrowserLoadObserver* NewL( MApiProvider& aApiProvider,
       
    51                                            CBrowserContentView& aContentView,
       
    52                                            CBrowserWindow& aWindow );
       
    53 
       
    54         /**
       
    55         * Destructor.
       
    56         */
       
    57         virtual ~CBrowserLoadObserver();
       
    58 
       
    59     public:
       
    60 
       
    61         enum TBrowserLoadState
       
    62             {
       
    63             ELoadStateIdle = 0x01,
       
    64             // ELoadStateContentStart is not used.
       
    65             // If you want to set it from BrowserUi, please note
       
    66             // that it's not guarantued that Kimono will send
       
    67             // any load event in case the content is already moved to 
       
    68             // Download Manager!
       
    69             ELoadStateContentStart = 0x02,
       
    70             ELoadStateResponseInProgress = 0x04,
       
    71             ELoadStateLoadDone = 0x08,
       
    72             ELoadStateContentAvailable = 0x10
       
    73             };
       
    74 
       
    75         enum TBrowserLoadUrlType
       
    76             {
       
    77             ELoadUrlTypeSavedDeck = 0x01,
       
    78             ELoadUrlTypeStartPage,
       
    79             ELoadUrlTypeEmbeddedBrowserWithUrl,
       
    80             ELoadUrlTypeOther  // for example GotoPane's url, Bookmark
       
    81             };
       
    82 
       
    83         enum TBrowserLoadStatus
       
    84             {
       
    85             // these flags are the status of loading a page,
       
    86             // can be OR'd for querying, setting
       
    87             ELoadStatusFirstChunkArrived = 0x0001 ,
       
    88             ELoadStatusContentDisplayed = 0x0002 ,
       
    89             ELoadStatusMainError = 0x0004 ,
       
    90             ELoadStatusSubError = 0x0008 ,
       
    91             ELoadStatusError = ELoadStatusMainError | ELoadStatusSubError,
       
    92                 // 0x000C , // MainError or SubError
       
    93             ELoadStatusTitleAvailable = 0x0010,
       
    94             ELoadStatusFirstChunkDisplayed = 0x0020,
       
    95             ELoadStatusDone = 0x0040,
       
    96             ELoadStatusSecurePage = 0x0080,
       
    97             ELoadStatusSecureItemNonSecurePage = 0x0100,
       
    98             ELoadStatusAllItemIsSecure = 0x0200,  // !SomeItemsNotSecure
       
    99             ELoadStatusSecurePageVisited = 0x0400
       
   100             };
       
   101 
       
   102     public: // Functions from MBrCtlLoadEventObserver
       
   103 
       
   104         /**
       
   105         * A load events notification
       
   106         * @since 2.8
       
   107         * @param aLoadEvent The load event
       
   108         * @param aSize Size depends on the event
       
   109         * @param aTransactionId The transaction that had this event
       
   110         * @return void
       
   111         */
       
   112         virtual void HandleBrowserLoadEventL(
       
   113             TBrCtlDefs::TBrCtlLoadEvent aLoadEvent,
       
   114             TUint aSize,
       
   115             TUint16 aTransactionId );
       
   116 
       
   117     public: // Functions from MBrowserDialogsProviderObserver
       
   118 
       
   119         /**
       
   120         * Callback function for dialog events.
       
   121         */
       
   122         void ReportDialogEventL( TInt aType, TInt aFlags = 0 );
       
   123 
       
   124     public:  // new functions
       
   125 
       
   126         /**
       
   127         * Loading must be started with this function by the owner.
       
   128         * @since 3.0
       
   129         * @param aLoadUrlType What is the url's type?
       
   130         *   if url doesn't need to be handled a special way, use ELoadUrlTypeOther
       
   131         *   otherwise implement special handling for all the events.
       
   132         * @return void
       
   133         */
       
   134         void DoStartLoad( TBrowserLoadUrlType aLoadUrlType );
       
   135 
       
   136         /**
       
   137         * Loading must be terminated with this function by the owner.
       
   138         * @since 3.0
       
   139         * @param aIsCancelled Is user cancelled the fetching operation?
       
   140         */
       
   141         void DoEndLoad( TBool aIsUserInitiated = EFalse );
       
   142 
       
   143         /**
       
   144         * Checks loading status against some flags.
       
   145         * @param aFlags 
       
   146         * @return ETrue only if ALL the aFlags are set
       
   147         */
       
   148         inline TBool LoadStatus( TUint32 aFlag ) const
       
   149             { return ( ( aFlag ) && (( iStatus & ( aFlag )) == ( aFlag ))); }
       
   150 
       
   151     protected: // new functions
       
   152 
       
   153         /**
       
   154         * Default C++ constructor.
       
   155         */
       
   156         CBrowserLoadObserver( MApiProvider& aApiProvider,
       
   157                               CBrowserContentView& aContentView,
       
   158                               CBrowserWindow& aWindow );
       
   159 
       
   160         /**
       
   161         * 2nd phase constructor. Leaves on failure.
       
   162         */
       
   163         void ConstructL();
       
   164 
       
   165     private:  // new functions
       
   166 
       
   167         void HandleLoadEventOtherL(
       
   168             TBrCtlDefs::TBrCtlLoadEvent aLoadEvent,
       
   169             TUint aSize,
       
   170             TUint16 aTransactionId );
       
   171 
       
   172         inline void SetStatus( TUint32 aFlag )   { iStatus |= aFlag; }
       
   173         inline void ClearStatus( TUint32 aFlag ) { iStatus &= ~aFlag; }
       
   174         inline void ClearStatus( )               { iStatus = 0; }
       
   175 
       
   176         void UpdateSecureIndicatorL();
       
   177 
       
   178     private:
       
   179         void StateChange( TBrowserLoadState aNextState );
       
   180         void NewTitleAvailableL();
       
   181         TBool InBrowserContentView();
       
   182         void ContentArrivedL();
       
   183         inline void SetRestoreContentFlag( TBool aFlag )
       
   184             { iRestoreContentFlag = aFlag; }
       
   185 
       
   186     public:
       
   187         // Get functions
       
   188         TBrowserLoadUrlType LoadUrlType() const;
       
   189         TBrowserLoadState   LoadState()   const;
       
   190         inline TBool ContentDisplayed(){return  iNewContentDisplayed;}
       
   191         void SetContentDisplayed( TBool aValue );
       
   192 
       
   193     private:  // data members
       
   194         MApiProvider        *iApiProvider;  // owner app, not owned
       
   195         CBrowserContentView *iContentView;  // contentView, not owned
       
   196         CBrowserWindow      *iWindow;
       
   197         TBrowserLoadState   iLoadState;
       
   198         TBrowserLoadUrlType iLoadUrlType;
       
   199         TUint32             iStatus;
       
   200 
       
   201         TBool               iRestoreContentFlag;
       
   202         TBool               iBrowserInitLoad;
       
   203         TBool               iNewContentDisplayed;
       
   204         // Large file upload max content
       
   205         TUint32             iMaxUploadContent;
       
   206         
       
   207 #ifdef I__LOG_EVENT_TIME
       
   208         TTime               iStartDownloadTime;
       
   209         TInt64              iTotalUpdateTime;
       
   210         TInt64              iNumberOfUpdates;
       
   211 #endif
       
   212 
       
   213     };
       
   214 
       
   215 #endif      // BROWSERLOADOBSERVER_H
       
   216 
       
   217 // End of File