Back to index

lightning-sunbird  0.9+nobinonly
nsWebShell.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is the Mozilla browser.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications, Inc.
00020  * Portions created by the Initial Developer are Copyright (C) 1999
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or 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 #ifndef webshell____h
00039 #define webshell____h
00040 
00041 #include "nsError.h"
00042 #include "nsIWebShellServices.h"
00043 #include "nsILinkHandler.h"
00044 #include "nsIClipboardCommands.h"
00045 #include "nsDocShell.h"
00046 #include "nsICommandManager.h"
00047 #include "nsIIOService.h"
00048 #include "nsCRT.h"
00049 #include "nsIDocumentLoader.h"
00050 
00051 class nsIEventQueue;
00052 class nsIController;
00053 struct PRThread;
00054 struct OnLinkClickEvent;
00055 
00056 typedef enum {
00057     eCharsetReloadInit,
00058     eCharsetReloadRequested,
00059     eCharsetReloadStopOrigional
00060 } eCharsetReloadState;
00061 
00062 #define NS_ERROR_WEBSHELL_REQUEST_REJECTED  NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL,1001)
00063 
00064 // Class ID for webshell
00065 #define NS_WEB_SHELL_CID \
00066  { 0xa6cf9059, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
00067 
00068 class nsWebShell : public nsDocShell,
00069                    public nsIWebShellServices,
00070                    public nsILinkHandler,
00071                    public nsIClipboardCommands
00072 {
00073 public:
00074     nsWebShell();
00075     virtual ~nsWebShell();
00076 
00077     NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
00078 
00079     NS_DECL_ISUPPORTS_INHERITED
00080     NS_DECL_NSIINTERFACEREQUESTOR
00081     NS_DECL_NSICLIPBOARDCOMMANDS
00082     NS_DECL_NSIWEBSHELLSERVICES
00083 
00084     // nsILinkHandler
00085     NS_IMETHOD OnLinkClick(nsIContent* aContent,
00086         nsLinkVerb aVerb,
00087         nsIURI* aURI,
00088         const PRUnichar* aTargetSpec,
00089         nsIInputStream* aPostDataStream = 0,
00090         nsIInputStream* aHeadersDataStream = 0);
00091     NS_IMETHOD OnLinkClickSync(nsIContent* aContent,
00092         nsLinkVerb aVerb,
00093         nsIURI* aURI,
00094         const PRUnichar* aTargetSpec,
00095         nsIInputStream* aPostDataStream = 0,
00096         nsIInputStream* aHeadersDataStream = 0,
00097         nsIDocShell** aDocShell = 0,
00098         nsIRequest** aRequest = 0);
00099     NS_IMETHOD OnOverLink(nsIContent* aContent,
00100         nsIURI* aURI,
00101         const PRUnichar* aTargetSpec);
00102     NS_IMETHOD OnLeaveLink();
00103     NS_IMETHOD GetLinkState(nsIURI* aLinkURI, nsLinkState& aState);
00104 
00105     NS_IMETHOD Create();
00106 
00107   // nsWebShell
00108     nsresult GetEventQueue(nsIEventQueue **aQueue);
00109 
00110     static nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent);
00111 
00112     // NS_IMETHOD SetURL(const PRUnichar* aURL);
00113 
00114     friend struct OnLinkClickEvent;
00115 
00116 protected:
00117     void InitFrameData();
00118 
00119     // helpers for executing commands
00120     virtual nsresult GetControllerForCommand ( const char *inCommand, nsIController** outController );
00121     virtual nsresult IsCommandEnabled ( const char * inCommand, PRBool* outEnabled );
00122     virtual nsresult DoCommand ( const char * inCommand );
00123     nsresult EnsureCommandHandler();
00124 
00125     //
00126     // Helper method that is called when a new document (including any
00127     // sub-documents - ie. frames) has been completely loaded.
00128     //
00129     virtual nsresult EndPageLoad(nsIWebProgress *aProgress,
00130         nsIChannel* channel,
00131         nsresult aStatus);
00132 
00133     PRThread *mThread;
00134 
00135     eCharsetReloadState mCharsetReloadState;
00136 
00137     nsresult CreateViewer(nsIRequest* request,
00138         const char* aContentType,
00139         const char* aCommand,
00140         nsIStreamListener** aResult);
00141 
00142     nsCOMPtr<nsICommandManager> mCommandManager;
00143     
00144 #ifdef DEBUG
00145 private:
00146     // We're counting the number of |nsWebShells| to help find leaks
00147     static unsigned long gNumberOfWebShells;
00148 #endif /* DEBUG */
00149 };
00150 
00151 #endif /* webshell____h */
00152