1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is the Mozilla browser.
18 * The Initial Developer of the Original Code is
19 * Netscape Communications, Inc.
20 * Portions created by the Initial Developer are Copyright (C) 1999
21 * the Initial Developer. All Rights Reserved.
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
42 #include "nsIWebShellServices.h"
43 #include "nsILinkHandler.h"
44 #include "nsIClipboardCommands.h"
45 #include "nsDocShell.h"
46 #include "nsICommandManager.h"
47 #include "nsIIOService.h"
52 class OnLinkClickEvent
;
56 eCharsetReloadRequested
,
57 eCharsetReloadStopOrigional
58 } eCharsetReloadState
;
60 #define NS_ERROR_WEBSHELL_REQUEST_REJECTED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL,1001)
62 // Class ID for webshell
63 #define NS_WEB_SHELL_CID \
64 { 0xa6cf9059, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
66 class nsWebShell
: public nsDocShell
,
67 public nsIWebShellServices
,
68 public nsILinkHandler
,
69 public nsIClipboardCommands
73 virtual ~nsWebShell();
75 NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
77 NS_DECL_ISUPPORTS_INHERITED
78 NS_DECL_NSIINTERFACEREQUESTOR
79 NS_DECL_NSICLIPBOARDCOMMANDS
80 NS_DECL_NSIWEBSHELLSERVICES
83 NS_IMETHOD
OnLinkClick(nsIContent
* aContent
,
85 const PRUnichar
* aTargetSpec
,
86 nsIInputStream
* aPostDataStream
= 0,
87 nsIInputStream
* aHeadersDataStream
= 0);
88 NS_IMETHOD
OnLinkClickSync(nsIContent
* aContent
,
90 const PRUnichar
* aTargetSpec
,
91 nsIInputStream
* aPostDataStream
= 0,
92 nsIInputStream
* aHeadersDataStream
= 0,
93 nsIDocShell
** aDocShell
= 0,
94 nsIRequest
** aRequest
= 0);
95 NS_IMETHOD
OnOverLink(nsIContent
* aContent
,
97 const PRUnichar
* aTargetSpec
);
98 NS_IMETHOD
OnLeaveLink();
99 NS_IMETHOD
GetLinkState(nsIURI
* aLinkURI
, nsLinkState
& aState
);
103 static nsEventStatus PR_CALLBACK
HandleEvent(nsGUIEvent
*aEvent
);
105 // NS_IMETHOD SetURL(const PRUnichar* aURL);
107 friend class OnLinkClickEvent
;
110 void InitFrameData();
112 // helpers for executing commands
113 virtual nsresult
GetControllerForCommand ( const char *inCommand
, nsIController
** outController
);
114 virtual nsresult
IsCommandEnabled ( const char * inCommand
, PRBool
* outEnabled
);
115 virtual nsresult
DoCommand ( const char * inCommand
);
116 nsresult
EnsureCommandHandler();
119 // Helper method that is called when a new document (including any
120 // sub-documents - ie. frames) has been completely loaded.
122 virtual nsresult
EndPageLoad(nsIWebProgress
*aProgress
,
126 eCharsetReloadState mCharsetReloadState
;
128 nsresult
CreateViewer(nsIRequest
* request
,
129 const char* aContentType
,
130 const char* aCommand
,
131 nsIStreamListener
** aResult
);
133 nsCOMPtr
<nsICommandManager
> mCommandManager
;
137 // We're counting the number of |nsWebShells| to help find leaks
138 static unsigned long gNumberOfWebShells
;
142 #endif /* webshell____h */