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  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef __EmbedPrivate_h
00039 #define __EmbedPrivate_h
00040 
00041 #include <nsCOMPtr.h>
00042 #include <nsString.h>
00043 #include <nsIWebNavigation.h>
00044 #include <nsISHistory.h>
00045 // for our one function that gets the EmbedPrivate via the chrome
00046 // object.
00047 #include <nsIWebBrowserChrome.h>
00048 #include <nsIAppShell.h>
00049 #include <nsIDOMEventReceiver.h>
00050 #include <nsVoidArray.h>
00051 // for profiles
00052 #include <nsIPref.h>
00053 // app component registration
00054 #include <nsIGenericFactory.h>
00055 #include <nsIComponentRegistrar.h>
00056 
00057 #include "gtkmozembedprivate.h"
00058 
00059 class EmbedProgress;
00060 class EmbedWindow;
00061 class EmbedContentListener;
00062 class EmbedEventListener;
00063 
00064 class nsPIDOMWindow;
00065 class nsIDirectoryServiceProvider;
00066 class nsProfileDirServiceProvider;
00067 
00068 class EmbedPrivate {
00069 
00070  public:
00071 
00072   EmbedPrivate();
00073   ~EmbedPrivate();
00074 
00075   nsresult    Init            (GtkMozEmbed *aOwningWidget);
00076   nsresult    Realize         (PRBool *aAlreadRealized);
00077   void        Unrealize       (void);
00078   void        Show            (void);
00079   void        Hide            (void);
00080   void        Resize          (PRUint32 aWidth, PRUint32 aHeight);
00081   void        Destroy         (void);
00082   void        SetURI          (const char *aURI);
00083   void        LoadCurrentURI  (void);
00084   void        Reload          (PRUint32 reloadFlags);
00085 
00086   void        SetChromeMask   (PRUint32 chromeMask);
00087   void        ApplyChromeMask ();
00088 
00089   static void PushStartup     (void);
00090   static void PopStartup      (void);
00091   static void SetCompPath     (const char *aPath);
00092   static void SetAppComponents (const nsModuleComponentInfo* aComps,
00093                                 int aNumComponents);
00094   static void SetProfilePath  (const char *aDir, const char *aName);
00095   static void SetDirectoryServiceProvider (nsIDirectoryServiceProvider * appFileLocProvider);
00096 
00097   nsresult OpenStream         (const char *aBaseURI, const char *aContentType);
00098   nsresult AppendToStream     (const PRUint8 *aData, PRUint32 aLen);
00099   nsresult CloseStream        (void);
00100 
00101   // This function will find the specific EmbedPrivate object for a
00102   // given nsIWebBrowserChrome.
00103   static EmbedPrivate *FindPrivateForBrowser(nsIWebBrowserChrome *aBrowser);
00104 
00105   // This is an upcall that will come from the progress listener
00106   // whenever there is a content state change.  We need this so we can
00107   // attach event listeners.
00108   void        ContentStateChange    (void);
00109 
00110   // This is an upcall from the progress listener when content is
00111   // finished loading.  We have this so that if it's chrome content
00112   // that we can size to content properly and show ourselves if
00113   // visibility is set.
00114   void        ContentFinishedLoading(void);
00115 
00116 #ifdef MOZ_WIDGET_GTK
00117   // these let the widget code know when the toplevel window gets and
00118   // looses focus.
00119   void        TopLevelFocusIn (void);
00120   void        TopLevelFocusOut(void);
00121 #endif
00122 
00123   // these are when the widget itself gets focus in and focus out
00124   // events
00125   void        ChildFocusIn (void);
00126   void        ChildFocusOut(void);
00127 
00128 #ifdef MOZ_ACCESSIBILITY_ATK
00129   void *GetAtkObjectForCurrentDocument();
00130 #endif
00131 
00132   GtkMozEmbed                   *mOwningWidget;
00133 
00134   // all of the objects that we own
00135   EmbedWindow                   *mWindow;
00136   nsCOMPtr<nsISupports>          mWindowGuard;
00137   EmbedProgress                 *mProgress;
00138   nsCOMPtr<nsISupports>          mProgressGuard;
00139   EmbedContentListener          *mContentListener;
00140   nsCOMPtr<nsISupports>          mContentListenerGuard;
00141   EmbedEventListener            *mEventListener;
00142   nsCOMPtr<nsISupports>          mEventListenerGuard;
00143 
00144   nsCOMPtr<nsIWebNavigation>     mNavigation;
00145   nsCOMPtr<nsISHistory>          mSessionHistory;
00146 
00147   // our event receiver
00148   nsCOMPtr<nsIDOMEventReceiver>  mEventReceiver;
00149 
00150   // the currently loaded uri
00151   nsString                       mURI;
00152 
00153   // the number of widgets that have been created
00154   static PRUint32                sWidgetCount;
00155   // the path to components
00156   static char                   *sCompPath;
00157   // the list of application-specific components to register
00158   static const nsModuleComponentInfo  *sAppComps;
00159   static int                     sNumAppComps;
00160   // the appshell we have created
00161   static nsIAppShell            *sAppShell;
00162   // the list of all open windows
00163   static nsVoidArray            *sWindowList;
00164   // what is our profile path?
00165   static char                   *sProfileDir;
00166   static char                   *sProfileName;
00167   // for profiles
00168   static nsProfileDirServiceProvider *sProfileDirServiceProvider;
00169   static nsIPref                *sPrefs;
00170 
00171   static nsIDirectoryServiceProvider * sAppFileLocProvider;
00172 
00173   // chrome mask
00174   PRUint32                       mChromeMask;
00175   // is this a chrome window?
00176   PRBool                         mIsChrome;
00177   // has the chrome finished loading?
00178   PRBool                         mChromeLoaded;
00179   // saved window ID for reparenting later
00180   GtkWidget                     *mMozWindowWidget;
00181   // has someone called Destroy() on us?
00182   PRBool                         mIsDestroyed;
00183 
00184  private:
00185 
00186   // is the chrome listener attached yet?
00187   PRBool                         mListenersAttached;
00188 
00189   void GetListener    (void);
00190   void AttachListeners(void);
00191   void DetachListeners(void);
00192 
00193   // this will get the PIDOMWindow for this widget
00194   nsresult        GetPIDOMWindow   (nsPIDOMWindow **aPIWin);
00195   
00196   static nsresult StartupProfile (void);
00197   static void     ShutdownProfile(void);
00198 
00199   static nsresult RegisterAppComponents();
00200 
00201   // offscreen window methods and the offscreen widget
00202   static void       EnsureOffscreenWindow(void);
00203   static void       DestroyOffscreenWindow(void);
00204   static GtkWidget *sOffscreenWindow;
00205   static GtkWidget *sOffscreenFixed;
00206   
00207 };
00208 
00209 #endif /* __EmbedPrivate_h */