Back to index

lightning-sunbird  0.9+nobinonly
EmbedPrivate.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is mozilla.org code.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Christopher Blizzard. Portions created by Christopher Blizzard are Copyright (C) Christopher Blizzard.  All Rights Reserved.
00018  * Portions created by the Initial Developer are Copyright (C) 2001
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *   Christopher Blizzard <blizzard@mozilla.org>
00023  *   Brian Edmond <briane@qnx.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #ifndef __EmbedPrivate_h
00040 #define __EmbedPrivate_h
00041 
00042 #include <nsCOMPtr.h>
00043 #include <nsString.h>
00044 #include <nsIWebNavigation.h>
00045 #include <nsIURIFixup.h>
00046 #include <nsISHistory.h>
00047 #include "nsIExternalHelperAppService.h"
00048 // for our one function that gets the EmbedPrivate via the chrome
00049 // object.
00050 #include <nsIWebBrowserChrome.h>
00051 #include <nsIPrintSettings.h>
00052 #include <nsIAppShell.h>
00053 #include <nsIDOMEventReceiver.h>
00054 #include <nsVoidArray.h>
00055 #include <nsClipboard.h>
00056 // for profiles
00057 #include <nsIPref.h>
00058 
00059 #include <Pt.h>
00060 
00061 class EmbedProgress;
00062 class EmbedWindow;
00063 class EmbedContentListener;
00064 class EmbedEventListener;
00065 class EmbedStream;
00066 class EmbedPrintListener;
00067 
00068 class nsPIDOMWindow;
00069 
00070 class EmbedPrivate {
00071 
00072  public:
00073 
00074   EmbedPrivate();
00075   ~EmbedPrivate();
00076 
00077   nsresult    Init            (PtWidget_t *aOwningWidget);
00078   nsresult    Setup           ();
00079   void        Unrealize       (void);
00080   void        Show            (void);
00081   void        Hide            (void);
00082   void        Position        (PRUint32 aX, PRUint32 aY);
00083   void        Size            (PRUint32 aWidth, PRUint32 aHeight);
00084   void        Destroy         (void);
00085   void        SetURI          (const char *aURI);
00086   void        LoadCurrentURI  (void);
00087   void        Stop  (void);
00088   void        Reload(int32_t flags);
00089   void        Back  (void);
00090   void        Forward  (void);
00091   void                 ScrollUp(int amount);
00092   void                 ScrollDown(int amount);
00093   void                 ScrollLeft(int amount);
00094   void                 ScrollRight(int amount);
00095   void                 ScrollTo(int x, int y);
00096   void        Cut  (int ig);
00097   void        Copy  (int ig);
00098   void        Paste  (int ig);
00099   void        SelectAll  (void);
00100   void        Clear  (void);
00101   int           SaveAs(char *fname,char *dirname);
00102   void                 Print(PpPrintContext_t *pc);
00103   PRBool        CanGoBack();
00104   PRBool        CanGoForward();
00105   nsIPref       *GetPrefs();
00106 
00107   nsresult OpenStream         (const char *aBaseURI, const char *aContentType);
00108   nsresult AppendToStream     (const char *aData, PRInt32 aLen);
00109   nsresult CloseStream        (void);
00110 
00111   // This function will find the specific EmbedPrivate object for a
00112   // given nsIWebBrowserChrome.
00113   static EmbedPrivate *FindPrivateForBrowser(nsIWebBrowserChrome *aBrowser);
00114 
00115   // This is an upcall that will come from the progress listener
00116   // whenever there is a content state change.  We need this so we can
00117   // attach event listeners.
00118   void        ContentStateChange    (void);
00119 
00120   // This is an upcall from the progress listener when content is
00121   // finished loading.  We have this so that if it's chrome content
00122   // that we can size to content properly and show ourselves if
00123   // visibility is set.
00124   void        ContentFinishedLoading(void);
00125 
00126 
00127 #if 0
00128 /*
00129   not used - we handle focus in/out activate/deactivate in
00130   child_getting_focus/child_losing_focus methods
00131   of the PtMozilla widget class
00132 */
00133 
00134   // these let the widget code know when the toplevel window gets and
00135   // looses focus.
00136   void        TopLevelFocusIn (void);
00137   void        TopLevelFocusOut(void);
00138 
00139   // these are when the widget itself gets focus in and focus out
00140   // events
00141   void        ChildFocusIn (void);
00142   void        ChildFocusOut(void);
00143 #endif
00144 
00145 
00146   PtWidget_t                   *mOwningWidget;
00147 
00148   // all of the objects that we own
00149   EmbedWindow                   *mWindow;
00150   nsCOMPtr<nsISupports>          mWindowGuard;
00151   EmbedProgress                 *mProgress;
00152   nsCOMPtr<nsISupports>          mProgressGuard;
00153   EmbedContentListener          *mContentListener;
00154   nsCOMPtr<nsISupports>          mContentListenerGuard;
00155   EmbedEventListener            *mEventListener;
00156   nsCOMPtr<nsISupports>          mEventListenerGuard;
00157   EmbedStream                   *mStream;
00158   nsCOMPtr<nsISupports>          mStreamGuard;
00159   EmbedPrintListener             *mPrint;
00160   nsCOMPtr<nsISupports>          mPrintGuard;
00161 
00162   nsCOMPtr<nsIWebNavigation>     mNavigation;
00163   nsCOMPtr<nsISHistory>          mSessionHistory;
00164 
00165   // our event receiver
00166   nsCOMPtr<nsIDOMEventReceiver>  mEventReceiver;
00167 
00168   // the currently loaded uri
00169   nsString                       mURI;
00170 
00171   nsCOMPtr<nsIPrintSettings> m_PrintSettings;
00172 
00173   // the number of widgets that have been created
00174   static PRUint32                sWidgetCount;
00175   // the path to components
00176   static char                   *sCompPath;
00177   // the appshell we have created
00178   static nsIAppShell            *sAppShell;
00179   // for profiles
00180   static nsIPref                *sPrefs;
00181        static nsVoidArray            *sWindowList;
00182   // for clipboard input group setting
00183   static nsClipboard *sClipboard;
00184 
00185   // chrome mask
00186   PRUint32                       mChromeMask;
00187   // is this a chrome window?
00188   PRBool                         mIsChrome;
00189   // has the chrome finished loading?
00190   PRBool                         mChromeLoaded;
00191   // saved window ID for reparenting later
00192   PtWidget_t                     *mMozWindowWidget;
00193 
00194   // this will get the PIDOMWindow for this widget
00195   nsresult        GetPIDOMWindow   (nsPIDOMWindow **aPIWin);
00196  private:
00197 
00198   // is the chrome listener attached yet?
00199   PRBool                         mListenersAttached;
00200 
00201   void GetListener    (void);
00202   void AttachListeners(void);
00203   void DetachListeners(void);
00204        void PrintHeaderFooter_FormatSpecialCodes(const char *original, nsString& aNewStr);
00205 
00206 };
00207 
00208 #endif /* __EmbedPrivate_h */