2001-04-27 13:03:17 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2005-08-23 00:24:57 +00:00
|
|
|
* vim: set ts=4 sw=4 et tw=80:
|
1999-10-26 01:44:00 +00:00
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
1999-10-26 01:44:00 +00:00
|
|
|
* The Original Code is the Mozilla browser.
|
2004-04-17 21:52:36 +00:00
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications, Inc.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1999
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
1999-10-26 01:44:00 +00:00
|
|
|
* Contributor(s):
|
|
|
|
* Travis Bogard <travis@netscape.com>
|
2004-04-17 21:52:36 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-10-26 01:44:00 +00:00
|
|
|
|
1999-11-12 07:28:25 +00:00
|
|
|
#ifndef nsDocShell_h__
|
|
|
|
#define nsDocShell_h__
|
1999-10-26 01:44:00 +00:00
|
|
|
|
1999-10-28 02:20:44 +00:00
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsIDOMNode.h"
|
|
|
|
#include "nsIDOMNodeList.h"
|
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsIScrollableView.h"
|
1999-10-30 02:30:13 +00:00
|
|
|
#include "nsIContentViewer.h"
|
2004-09-06 19:31:22 +00:00
|
|
|
#include "nsIPrefBranch.h"
|
1999-12-12 10:15:26 +00:00
|
|
|
#include "nsVoidArray.h"
|
2006-05-19 05:57:36 +00:00
|
|
|
#include "nsInterfaceHashtable.h"
|
2001-07-16 02:40:48 +00:00
|
|
|
#include "nsIScriptContext.h"
|
2002-09-07 05:38:16 +00:00
|
|
|
#include "nsITimer.h"
|
1999-10-26 22:56:59 +00:00
|
|
|
|
1999-11-12 07:28:25 +00:00
|
|
|
#include "nsCDocShell.h"
|
1999-12-12 10:15:26 +00:00
|
|
|
#include "nsIDocShellTreeOwner.h"
|
1999-11-11 00:34:41 +00:00
|
|
|
#include "nsIContentViewerContainer.h"
|
2000-03-08 03:58:33 +00:00
|
|
|
#include "nsIDeviceContext.h"
|
1999-11-11 00:34:41 +00:00
|
|
|
|
2004-12-08 17:32:06 +00:00
|
|
|
#include "nsDocLoader.h"
|
2001-10-27 02:52:39 +00:00
|
|
|
#include "nsIURILoader.h"
|
2002-02-02 05:13:56 +00:00
|
|
|
#include "nsIEditorDocShell.h"
|
1999-11-11 00:34:41 +00:00
|
|
|
|
2000-05-28 09:25:55 +00:00
|
|
|
#include "nsWeakReference.h"
|
2000-03-29 10:29:58 +00:00
|
|
|
|
|
|
|
// Local Includes
|
|
|
|
#include "nsDSURIContentListener.h"
|
2002-02-02 05:13:56 +00:00
|
|
|
#include "nsDocShellEditorData.h"
|
2000-03-29 10:29:58 +00:00
|
|
|
|
2000-04-16 08:39:15 +00:00
|
|
|
// Helper Classes
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsPoint.h" // mCurrent/mDefaultScrollbarPreferences
|
|
|
|
#include "nsString.h"
|
2005-02-18 18:20:42 +00:00
|
|
|
#include "nsAutoPtr.h"
|
2006-05-10 17:30:15 +00:00
|
|
|
#include "nsThreadUtils.h"
|
2000-04-16 08:39:15 +00:00
|
|
|
|
2001-02-15 19:10:16 +00:00
|
|
|
// Threshold value in ms for META refresh based redirects
|
|
|
|
#define REFRESH_REDIRECT_TIMER 15000
|
2000-06-22 05:36:13 +00:00
|
|
|
|
2000-02-17 02:03:02 +00:00
|
|
|
// Interfaces Needed
|
2000-04-12 00:07:04 +00:00
|
|
|
#include "nsIDocumentCharsetInfo.h"
|
2001-05-17 02:12:51 +00:00
|
|
|
#include "nsIDocCharset.h"
|
2004-02-11 02:10:04 +00:00
|
|
|
#include "nsIGlobalHistory2.h"
|
2000-04-16 08:39:15 +00:00
|
|
|
#include "nsIInterfaceRequestor.h"
|
2001-09-05 21:28:38 +00:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2000-04-21 23:31:40 +00:00
|
|
|
#include "nsIPrompt.h"
|
2000-04-13 03:11:44 +00:00
|
|
|
#include "nsIRefreshURI.h"
|
2000-04-16 08:39:15 +00:00
|
|
|
#include "nsIScriptGlobalObject.h"
|
|
|
|
#include "nsIScriptGlobalObjectOwner.h"
|
2000-02-17 02:03:02 +00:00
|
|
|
#include "nsISHistory.h"
|
2003-05-30 00:21:01 +00:00
|
|
|
#include "nsILayoutHistoryState.h"
|
2000-04-13 03:11:44 +00:00
|
|
|
#include "nsIStringBundle.h"
|
2000-04-16 08:39:15 +00:00
|
|
|
#include "nsISupportsArray.h"
|
2000-02-14 06:40:28 +00:00
|
|
|
#include "nsIWebNavigation.h"
|
2002-04-01 21:22:27 +00:00
|
|
|
#include "nsIWebPageDescriptor.h"
|
2000-03-26 04:52:06 +00:00
|
|
|
#include "nsIWebProgressListener.h"
|
2000-06-21 06:40:08 +00:00
|
|
|
#include "nsISHContainer.h"
|
2000-06-22 07:22:23 +00:00
|
|
|
#include "nsIDocShellLoadInfo.h"
|
2000-07-05 23:10:29 +00:00
|
|
|
#include "nsIDocShellHistory.h"
|
2000-11-08 21:00:37 +00:00
|
|
|
#include "nsIURIFixup.h"
|
2001-04-27 21:11:03 +00:00
|
|
|
#include "nsIWebBrowserFind.h"
|
2001-11-27 23:14:15 +00:00
|
|
|
#include "nsIHttpChannel.h"
|
2003-04-17 13:16:05 +00:00
|
|
|
#include "nsDocShellTransferableHooks.h"
|
2004-09-02 05:13:25 +00:00
|
|
|
#include "nsIAuthPromptProvider.h"
|
2005-05-04 20:22:32 +00:00
|
|
|
#include "nsISecureBrowserUI.h"
|
2005-09-22 20:38:56 +00:00
|
|
|
#include "nsIObserver.h"
|
2006-02-11 00:17:36 +00:00
|
|
|
#include "nsDocShellLoadTypes.h"
|
2000-09-20 12:23:53 +00:00
|
|
|
|
2002-04-04 22:10:10 +00:00
|
|
|
/* load commands were moved to nsIDocShell.h */
|
2006-02-11 00:17:36 +00:00
|
|
|
/* load types were moved to nsDocShellLoadTypes.h */
|
2000-09-20 12:23:53 +00:00
|
|
|
|
2001-04-16 20:17:36 +00:00
|
|
|
/* internally used ViewMode types */
|
|
|
|
enum ViewMode {
|
2001-04-27 13:03:17 +00:00
|
|
|
viewNormal = 0x0,
|
|
|
|
viewSource = 0x1
|
2001-04-16 20:17:36 +00:00
|
|
|
};
|
2000-09-20 12:23:53 +00:00
|
|
|
|
2000-04-13 03:11:44 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
//*** nsRefreshTimer
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
class nsRefreshTimer : public nsITimerCallback
|
|
|
|
{
|
|
|
|
public:
|
2001-04-27 13:03:17 +00:00
|
|
|
nsRefreshTimer();
|
2000-04-13 03:11:44 +00:00
|
|
|
|
2001-04-27 13:03:17 +00:00
|
|
|
NS_DECL_ISUPPORTS
|
2002-09-07 05:38:16 +00:00
|
|
|
NS_DECL_NSITIMERCALLBACK
|
|
|
|
|
2002-02-08 22:46:09 +00:00
|
|
|
PRInt32 GetDelay() { return mDelay ;}
|
2000-04-13 03:11:44 +00:00
|
|
|
|
2001-04-27 13:03:17 +00:00
|
|
|
nsCOMPtr<nsIDocShell> mDocShell;
|
|
|
|
nsCOMPtr<nsIURI> mURI;
|
|
|
|
PRInt32 mDelay;
|
2004-02-11 06:09:51 +00:00
|
|
|
PRPackedBool mRepeat;
|
|
|
|
PRPackedBool mMetaRefresh;
|
2002-02-08 22:46:09 +00:00
|
|
|
|
2000-04-13 03:11:44 +00:00
|
|
|
protected:
|
2001-04-27 13:03:17 +00:00
|
|
|
virtual ~nsRefreshTimer();
|
2000-04-13 03:11:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
//*** nsDocShell
|
|
|
|
//*****************************************************************************
|
|
|
|
|
2004-12-08 17:32:06 +00:00
|
|
|
class nsDocShell : public nsDocLoader,
|
|
|
|
public nsIDocShell,
|
1999-12-03 10:29:08 +00:00
|
|
|
public nsIDocShellTreeItem,
|
1999-12-03 09:24:22 +00:00
|
|
|
public nsIDocShellTreeNode,
|
2000-07-05 23:10:29 +00:00
|
|
|
public nsIDocShellHistory,
|
2000-02-14 06:40:28 +00:00
|
|
|
public nsIWebNavigation,
|
1999-11-19 07:35:27 +00:00
|
|
|
public nsIBaseWindow,
|
|
|
|
public nsIScrollable,
|
|
|
|
public nsITextScroll,
|
2001-05-17 02:12:51 +00:00
|
|
|
public nsIDocCharset,
|
1999-11-23 10:15:10 +00:00
|
|
|
public nsIContentViewerContainer,
|
2000-04-13 03:11:44 +00:00
|
|
|
public nsIScriptGlobalObjectOwner,
|
2000-05-28 09:25:55 +00:00
|
|
|
public nsIRefreshURI,
|
2000-06-20 07:59:45 +00:00
|
|
|
public nsIWebProgressListener,
|
2002-02-02 05:13:56 +00:00
|
|
|
public nsIEditorDocShell,
|
2002-04-01 21:22:27 +00:00
|
|
|
public nsIWebPageDescriptor,
|
2005-09-22 20:38:56 +00:00
|
|
|
public nsIAuthPromptProvider,
|
|
|
|
public nsIObserver
|
1999-10-26 01:44:00 +00:00
|
|
|
{
|
1999-11-07 10:03:51 +00:00
|
|
|
friend class nsDSURIContentListener;
|
|
|
|
|
1999-10-26 01:44:00 +00:00
|
|
|
public:
|
2001-04-27 13:03:17 +00:00
|
|
|
// Object Management
|
|
|
|
nsDocShell();
|
|
|
|
|
2004-12-08 17:32:06 +00:00
|
|
|
virtual nsresult Init();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2001-04-27 13:03:17 +00:00
|
|
|
|
|
|
|
NS_DECL_NSIDOCSHELL
|
|
|
|
NS_DECL_NSIDOCSHELLTREEITEM
|
|
|
|
NS_DECL_NSIDOCSHELLTREENODE
|
|
|
|
NS_DECL_NSIDOCSHELLHISTORY
|
|
|
|
NS_DECL_NSIWEBNAVIGATION
|
|
|
|
NS_DECL_NSIBASEWINDOW
|
|
|
|
NS_DECL_NSISCROLLABLE
|
|
|
|
NS_DECL_NSITEXTSCROLL
|
2001-05-17 02:12:51 +00:00
|
|
|
NS_DECL_NSIDOCCHARSET
|
2001-04-27 13:03:17 +00:00
|
|
|
NS_DECL_NSIINTERFACEREQUESTOR
|
|
|
|
NS_DECL_NSIWEBPROGRESSLISTENER
|
|
|
|
NS_DECL_NSIREFRESHURI
|
|
|
|
NS_DECL_NSICONTENTVIEWERCONTAINER
|
2002-02-02 05:13:56 +00:00
|
|
|
NS_DECL_NSIEDITORDOCSHELL
|
2002-04-01 21:22:27 +00:00
|
|
|
NS_DECL_NSIWEBPAGEDESCRIPTOR
|
2004-09-02 05:13:25 +00:00
|
|
|
NS_DECL_NSIAUTHPROMPTPROVIDER
|
2005-09-22 20:38:56 +00:00
|
|
|
NS_DECL_NSIOBSERVER
|
2001-04-27 13:03:17 +00:00
|
|
|
|
2004-12-08 17:32:06 +00:00
|
|
|
NS_IMETHOD Stop() {
|
|
|
|
// Need this here because otherwise nsIWebNavigation::Stop
|
|
|
|
// overrides the docloader's Stop()
|
|
|
|
return nsDocLoader::Stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Need to implement (and forward) nsISecurityEventSink, because
|
|
|
|
// nsIWebProgressListener has methods with identical names...
|
|
|
|
NS_FORWARD_NSISECURITYEVENTSINK(nsDocLoader::)
|
|
|
|
|
2001-11-30 22:35:33 +00:00
|
|
|
nsDocShellInfoLoadType ConvertLoadTypeToDocShellLoadInfo(PRUint32 aLoadType);
|
2001-04-27 13:03:17 +00:00
|
|
|
PRUint32 ConvertDocShellLoadInfoToLoadType(nsDocShellInfoLoadType aDocShellLoadType);
|
2000-06-20 07:59:45 +00:00
|
|
|
|
2004-07-16 17:03:10 +00:00
|
|
|
// nsIScriptGlobalObjectOwner methods
|
|
|
|
virtual nsIScriptGlobalObject* GetScriptGlobalObject();
|
2005-08-02 18:35:07 +00:00
|
|
|
|
|
|
|
// Restores a cached presentation from history (mLSHE).
|
|
|
|
// This method swaps out the content viewer and simulates loads for
|
|
|
|
// subframes. It then simulates the completion of the toplevel load.
|
|
|
|
nsresult RestoreFromHistory();
|
|
|
|
|
1999-10-26 01:44:00 +00:00
|
|
|
protected:
|
2001-04-27 13:03:17 +00:00
|
|
|
// Object Management
|
|
|
|
virtual ~nsDocShell();
|
2004-12-08 17:32:06 +00:00
|
|
|
virtual void DestroyChildren();
|
2001-04-27 13:03:17 +00:00
|
|
|
|
|
|
|
// Content Viewer Management
|
|
|
|
NS_IMETHOD EnsureContentViewer();
|
|
|
|
NS_IMETHOD EnsureDeviceContext();
|
2006-11-22 18:27:54 +00:00
|
|
|
// aPrincipal can be passed in if the caller wants. If null is
|
|
|
|
// passed in, the about:blank principal will end up being used.
|
|
|
|
nsresult CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal);
|
2001-04-27 13:03:17 +00:00
|
|
|
NS_IMETHOD CreateContentViewer(const char * aContentType,
|
|
|
|
nsIRequest * request, nsIStreamListener ** aContentHandler);
|
|
|
|
NS_IMETHOD NewContentViewerObj(const char * aContentType,
|
|
|
|
nsIRequest * request, nsILoadGroup * aLoadGroup,
|
|
|
|
nsIStreamListener ** aContentHandler, nsIContentViewer ** aViewer);
|
|
|
|
NS_IMETHOD SetupNewViewer(nsIContentViewer * aNewViewer);
|
|
|
|
|
2005-04-05 03:28:54 +00:00
|
|
|
void SetupReferrerFromChannel(nsIChannel * aChannel);
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
NS_IMETHOD GetEldestPresContext(nsPresContext** aPresContext);
|
2006-08-15 17:31:16 +00:00
|
|
|
|
|
|
|
// Get the principal that we'll set on the channel if we're inheriting. If
|
|
|
|
// aConsiderCurrentDocument is true, we try to use the current document if
|
|
|
|
// at all possible. If that fails, we fall back on the parent document.
|
|
|
|
// If that fails too, we force creation of a content viewer and use the
|
|
|
|
// resulting principal. If aConsiderCurrentDocument is false, we just look
|
|
|
|
// at the parent.
|
|
|
|
nsIPrincipal* GetInheritedPrincipal(PRBool aConsiderCurrentDocument);
|
|
|
|
|
|
|
|
// Actually open a channel and perform a URI load. Note: whatever owner is
|
|
|
|
// passed to this function will be set on the channel. Callers who wish to
|
|
|
|
// not have an owner on the channel should just pass null.
|
2001-05-14 02:16:27 +00:00
|
|
|
virtual nsresult DoURILoad(nsIURI * aURI,
|
|
|
|
nsIURI * aReferrer,
|
2005-01-05 06:04:46 +00:00
|
|
|
PRBool aSendReferrer,
|
2001-05-14 02:16:27 +00:00
|
|
|
nsISupports * aOwner,
|
2003-10-03 22:11:47 +00:00
|
|
|
const char * aTypeHint,
|
2001-05-14 02:16:27 +00:00
|
|
|
nsIInputStream * aPostData,
|
2002-03-02 01:26:49 +00:00
|
|
|
nsIInputStream * aHeadersData,
|
2002-03-13 06:08:56 +00:00
|
|
|
PRBool firstParty,
|
|
|
|
nsIDocShell ** aDocShell,
|
2006-07-04 20:48:33 +00:00
|
|
|
nsIRequest ** aRequest,
|
|
|
|
PRBool aIsNewWindowTarget);
|
2001-04-27 13:03:17 +00:00
|
|
|
NS_IMETHOD AddHeadersToChannel(nsIInputStream * aHeadersData,
|
|
|
|
nsIChannel * aChannel);
|
2001-05-14 02:16:27 +00:00
|
|
|
virtual nsresult DoChannelLoad(nsIChannel * aChannel,
|
|
|
|
nsIURILoader * aURILoader);
|
2005-03-09 14:31:02 +00:00
|
|
|
NS_IMETHOD ScrollIfAnchor(nsIURI * aURI, PRBool * aWasAnchor,
|
|
|
|
PRUint32 aLoadType, nscoord *cx, nscoord *cy);
|
2001-04-27 13:03:17 +00:00
|
|
|
|
2005-03-30 04:22:00 +00:00
|
|
|
// Returns PR_TRUE if would have called FireOnLocationChange,
|
|
|
|
// but did not because aFireOnLocationChange was false on entry.
|
|
|
|
// In this case it is the caller's responsibility to ensure
|
|
|
|
// FireOnLocationChange is called.
|
|
|
|
// In all other cases PR_FALSE is returned.
|
|
|
|
PRBool OnLoadingSite(nsIChannel * aChannel,
|
2005-07-27 12:38:38 +00:00
|
|
|
PRBool aFireOnLocationChange,
|
|
|
|
PRBool aAddToGlobalHistory = PR_TRUE);
|
2005-03-30 04:22:00 +00:00
|
|
|
|
|
|
|
// Returns PR_TRUE if would have called FireOnLocationChange,
|
|
|
|
// but did not because aFireOnLocationChange was false on entry.
|
|
|
|
// In this case it is the caller's responsibility to ensure
|
|
|
|
// FireOnLocationChange is called.
|
|
|
|
// In all other cases PR_FALSE is returned.
|
|
|
|
PRBool OnNewURI(nsIURI * aURI, nsIChannel * aChannel, PRUint32 aLoadType,
|
2005-07-27 12:38:38 +00:00
|
|
|
PRBool aFireOnLocationChange,
|
|
|
|
PRBool aAddToGlobalHistory = PR_TRUE);
|
2001-04-27 13:03:17 +00:00
|
|
|
|
|
|
|
virtual void SetReferrerURI(nsIURI * aURI);
|
|
|
|
|
|
|
|
// Session History
|
|
|
|
virtual PRBool ShouldAddToSessionHistory(nsIURI * aURI);
|
|
|
|
virtual nsresult AddToSessionHistory(nsIURI * aURI, nsIChannel * aChannel,
|
2004-04-13 01:42:40 +00:00
|
|
|
nsISHEntry ** aNewEntry);
|
|
|
|
nsresult DoAddChildSHEntry(nsISHEntry* aNewEntry, PRInt32 aChildOffset);
|
2001-04-27 13:03:17 +00:00
|
|
|
|
|
|
|
NS_IMETHOD LoadHistoryEntry(nsISHEntry * aEntry, PRUint32 aLoadType);
|
|
|
|
NS_IMETHOD PersistLayoutHistoryState();
|
2005-08-03 22:32:10 +00:00
|
|
|
|
|
|
|
// Clone a session history tree for subframe navigation.
|
|
|
|
// The tree rooted at |aSrcEntry| will be cloned into |aDestEntry|, except
|
|
|
|
// for the entry with id |aCloneID|, which will be replaced with
|
|
|
|
// |aReplaceEntry|. |aSrcShell| is a (possibly null) docshell which
|
|
|
|
// corresponds to |aSrcEntry| via its mLSHE or mOHE pointers, and will
|
|
|
|
// have that pointer updated to point to the cloned history entry.
|
|
|
|
static nsresult CloneAndReplace(nsISHEntry *aSrcEntry,
|
|
|
|
nsDocShell *aSrcShell,
|
|
|
|
PRUint32 aCloneID,
|
|
|
|
nsISHEntry *aReplaceEntry,
|
|
|
|
nsISHEntry **aDestEntry);
|
|
|
|
|
|
|
|
// Child-walking callback for CloneAndReplace
|
|
|
|
static nsresult CloneAndReplaceChild(nsISHEntry *aEntry,
|
|
|
|
nsDocShell *aShell,
|
|
|
|
PRInt32 aChildIndex, void *aData);
|
|
|
|
|
2001-11-20 20:14:02 +00:00
|
|
|
nsresult GetRootSessionHistory(nsISHistory ** aReturn);
|
2001-11-27 23:14:15 +00:00
|
|
|
nsresult GetHttpChannel(nsIChannel * aChannel, nsIHttpChannel ** aReturn);
|
2002-05-09 20:32:35 +00:00
|
|
|
PRBool ShouldDiscardLayoutState(nsIHttpChannel * aChannel);
|
2005-08-03 22:32:10 +00:00
|
|
|
|
|
|
|
// Determine whether this docshell corresponds to the given history entry,
|
|
|
|
// via having a pointer to it in mOSHE or mLSHE.
|
|
|
|
PRBool HasHistoryEntry(nsISHEntry *aEntry) const
|
|
|
|
{
|
|
|
|
return aEntry && (aEntry == mOSHE || aEntry == mLSHE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update any pointers (mOSHE or mLSHE) to aOldEntry to point to aNewEntry
|
|
|
|
void SwapHistoryEntries(nsISHEntry *aOldEntry, nsISHEntry *aNewEntry);
|
|
|
|
|
|
|
|
// Call this method to swap in a new history entry to m[OL]SHE, rather than
|
|
|
|
// setting it directly. This completes the navigation in all docshells
|
|
|
|
// in the case of a subframe navigation.
|
|
|
|
void SetHistoryEntry(nsCOMPtr<nsISHEntry> *aPtr, nsISHEntry *aEntry);
|
|
|
|
|
|
|
|
// Child-walking callback for SetHistoryEntry
|
|
|
|
static nsresult SetChildHistoryEntry(nsISHEntry *aEntry,
|
|
|
|
nsDocShell *aShell,
|
|
|
|
PRInt32 aEntryIndex, void *aData);
|
|
|
|
|
|
|
|
// Callback prototype for WalkHistoryEntries.
|
|
|
|
// aEntry is the child history entry, aShell is its corresponding docshell,
|
|
|
|
// aChildIndex is the child's index in its parent entry, and aData is
|
|
|
|
// the opaque pointer passed to WalkHistoryEntries.
|
|
|
|
typedef nsresult (*WalkHistoryEntriesFunc)(nsISHEntry *aEntry,
|
|
|
|
nsDocShell *aShell,
|
|
|
|
PRInt32 aChildIndex,
|
|
|
|
void *aData);
|
|
|
|
|
|
|
|
// For each child of aRootEntry, find the corresponding docshell which is
|
|
|
|
// a child of aRootShell, and call aCallback. The opaque pointer aData
|
|
|
|
// is passed to the callback.
|
|
|
|
static nsresult WalkHistoryEntries(nsISHEntry *aRootEntry,
|
|
|
|
nsDocShell *aRootShell,
|
|
|
|
WalkHistoryEntriesFunc aCallback,
|
|
|
|
void *aData);
|
|
|
|
|
2006-02-06 20:52:18 +00:00
|
|
|
// overridden from nsDocLoader, this provides more information than the
|
|
|
|
// normal OnStateChange with flags STATE_REDIRECTING
|
|
|
|
virtual void OnRedirectStateChange(nsIChannel* aOldChannel,
|
|
|
|
nsIChannel* aNewChannel,
|
|
|
|
PRUint32 aRedirectFlags,
|
|
|
|
PRUint32 aStateFlags);
|
|
|
|
|
2001-04-27 13:03:17 +00:00
|
|
|
// Global History
|
2006-02-07 02:02:56 +00:00
|
|
|
nsresult AddToGlobalHistory(nsIURI * aURI, PRBool aRedirect,
|
|
|
|
nsIChannel * aChannel);
|
2001-04-27 13:03:17 +00:00
|
|
|
|
|
|
|
// Helper Routines
|
2006-11-07 03:28:50 +00:00
|
|
|
nsresult ConfirmRepost(PRBool * aRepost);
|
2001-04-27 13:03:17 +00:00
|
|
|
NS_IMETHOD GetPromptAndStringBundle(nsIPrompt ** aPrompt,
|
|
|
|
nsIStringBundle ** aStringBundle);
|
|
|
|
NS_IMETHOD GetChildOffset(nsIDOMNode * aChild, nsIDOMNode * aParent,
|
|
|
|
PRInt32 * aOffset);
|
|
|
|
NS_IMETHOD GetRootScrollableView(nsIScrollableView ** aOutScrollView);
|
|
|
|
NS_IMETHOD EnsureScriptEnvironment();
|
2002-02-02 05:13:56 +00:00
|
|
|
NS_IMETHOD EnsureEditorData();
|
2003-04-17 13:16:05 +00:00
|
|
|
nsresult EnsureTransferableHookData();
|
2001-04-27 21:11:03 +00:00
|
|
|
NS_IMETHOD EnsureFind();
|
2005-05-04 20:22:32 +00:00
|
|
|
nsresult RefreshURIFromQueue();
|
2005-01-31 11:26:31 +00:00
|
|
|
NS_IMETHOD DisplayLoadError(nsresult aError, nsIURI *aURI,
|
|
|
|
const PRUnichar *aURL,
|
|
|
|
nsIChannel* aFailedChannel = nsnull);
|
|
|
|
NS_IMETHOD LoadErrorPage(nsIURI *aURI, const PRUnichar *aURL,
|
|
|
|
const PRUnichar *aPage,
|
|
|
|
const PRUnichar *aDescription,
|
|
|
|
nsIChannel* aFailedChannel);
|
2002-10-08 13:17:56 +00:00
|
|
|
PRBool IsPrintingOrPP(PRBool aDisplayErrorDialog = PR_TRUE);
|
2001-04-27 13:03:17 +00:00
|
|
|
|
2002-09-19 21:59:34 +00:00
|
|
|
nsresult SetBaseUrlForWyciwyg(nsIContentViewer * aContentViewer);
|
|
|
|
|
2001-09-07 22:06:08 +00:00
|
|
|
static inline PRUint32
|
|
|
|
PRTimeToSeconds(PRTime t_usec)
|
|
|
|
{
|
|
|
|
PRTime usec_per_sec;
|
|
|
|
PRUint32 t_sec;
|
|
|
|
LL_I2L(usec_per_sec, PR_USEC_PER_SEC);
|
|
|
|
LL_DIV(t_usec, t_usec, usec_per_sec);
|
|
|
|
LL_L2I(t_sec, t_usec);
|
|
|
|
return t_sec;
|
|
|
|
}
|
|
|
|
|
2001-04-27 13:03:17 +00:00
|
|
|
PRBool IsFrame();
|
|
|
|
|
|
|
|
//
|
|
|
|
// Helper method that is called when a new document (including any
|
|
|
|
// sub-documents - ie. frames) has been completely loaded.
|
|
|
|
//
|
2001-07-17 20:17:38 +00:00
|
|
|
virtual nsresult EndPageLoad(nsIWebProgress * aProgress,
|
|
|
|
nsIChannel * aChannel,
|
|
|
|
nsresult aResult);
|
2004-06-15 08:28:52 +00:00
|
|
|
|
2004-06-23 17:42:31 +00:00
|
|
|
nsresult CheckLoadingPermissions();
|
2004-06-15 08:28:52 +00:00
|
|
|
|
2005-01-21 16:58:45 +00:00
|
|
|
// Security checks to prevent frameset spoofing. See comments at
|
|
|
|
// implementation sites.
|
|
|
|
static PRBool CanAccessItem(nsIDocShellTreeItem* aTargetItem,
|
|
|
|
nsIDocShellTreeItem* aAccessingItem,
|
|
|
|
PRBool aConsiderOpener = PR_TRUE);
|
|
|
|
static PRBool ValidateOrigin(nsIDocShellTreeItem* aOriginTreeItem,
|
|
|
|
nsIDocShellTreeItem* aTargetTreeItem);
|
|
|
|
|
2005-03-30 04:22:00 +00:00
|
|
|
// Returns PR_TRUE if would have called FireOnLocationChange,
|
|
|
|
// but did not because aFireOnLocationChange was false on entry.
|
|
|
|
// In this case it is the caller's responsibility to ensure
|
|
|
|
// FireOnLocationChange is called.
|
|
|
|
// In all other cases PR_FALSE is returned.
|
|
|
|
PRBool SetCurrentURI(nsIURI *aURI, nsIRequest *aRequest,
|
|
|
|
PRBool aFireOnLocationChange);
|
2005-01-12 00:00:53 +00:00
|
|
|
|
2005-05-04 20:22:32 +00:00
|
|
|
// The following methods deal with saving and restoring content viewers
|
|
|
|
// in session history.
|
|
|
|
|
|
|
|
// mContentViewer points to the current content viewer associated with
|
|
|
|
// this docshell. When loading a new document, the content viewer is
|
|
|
|
// either destroyed or stored into a session history entry. To make sure
|
|
|
|
// that destruction happens in a controlled fashion, a given content viewer
|
|
|
|
// is always owned in exactly one of these ways:
|
|
|
|
// 1) The content viewer is active and owned by a docshell's
|
|
|
|
// mContentViewer.
|
|
|
|
// 2) The content viewer is still being displayed while we begin loading
|
|
|
|
// a new document. The content viewer is owned by the _new_
|
|
|
|
// content viewer's mPreviousViewer, and has a pointer to the
|
|
|
|
// nsISHEntry where it will eventually be stored. The content viewer
|
|
|
|
// has been close()d by the docshell, which detaches the document from
|
|
|
|
// the window object.
|
|
|
|
// 3) The content viewer is cached in session history. The nsISHEntry
|
|
|
|
// has the only owning reference to the content viewer. The viewer
|
|
|
|
// has released its nsISHEntry pointer to prevent circular ownership.
|
|
|
|
//
|
|
|
|
// When restoring a content viewer from session history, open() is called
|
|
|
|
// to reattach the document to the window object. The content viewer is
|
|
|
|
// then placed into mContentViewer and removed from the history entry.
|
|
|
|
// (mContentViewer is put into session history as described above, if
|
|
|
|
// applicable).
|
|
|
|
|
|
|
|
// Determines whether we can safely cache the current mContentViewer in
|
|
|
|
// session history. This checks a number of factors such as cache policy,
|
2005-06-24 20:53:43 +00:00
|
|
|
// pending requests, and unload handlers.
|
|
|
|
// |aLoadType| should be the load type that will replace the current
|
|
|
|
// presentation. |aNewRequest| should be the request for the document to
|
|
|
|
// be loaded in place of the current document, or null if such a request
|
2005-08-23 00:24:57 +00:00
|
|
|
// has not been created yet. |aNewDocument| should be the document that will
|
|
|
|
// replace the current document.
|
|
|
|
PRBool CanSavePresentation(PRUint32 aLoadType,
|
|
|
|
nsIRequest *aNewRequest,
|
|
|
|
nsIDocument *aNewDocument);
|
2005-05-04 20:22:32 +00:00
|
|
|
|
|
|
|
// Captures the state of the supporting elements of the presentation
|
|
|
|
// (the "window" object, docshell tree, meta-refresh loads, and security
|
|
|
|
// state) and stores them on |mOSHE|.
|
|
|
|
nsresult CaptureState();
|
|
|
|
|
2005-08-02 18:35:07 +00:00
|
|
|
// Begin the toplevel restore process for |aSHEntry|.
|
|
|
|
// This simulates a channel open, and defers the real work until
|
|
|
|
// RestoreFromHistory is called from a PLEvent.
|
|
|
|
nsresult RestorePresentation(nsISHEntry *aSHEntry, PRBool *aRestoring);
|
2005-05-04 20:22:32 +00:00
|
|
|
|
2005-07-14 16:24:32 +00:00
|
|
|
// Call BeginRestore(nsnull, PR_FALSE) for each child of this shell.
|
|
|
|
nsresult BeginRestoreChildren();
|
|
|
|
|
2006-05-02 18:54:19 +00:00
|
|
|
// Check whether aURI should inherit our security context
|
|
|
|
static nsresult URIInheritsSecurityContext(nsIURI* aURI, PRBool* aResult);
|
2006-08-15 17:31:16 +00:00
|
|
|
|
|
|
|
// Check whether aURI is about:blank
|
|
|
|
static PRBool IsAboutBlank(nsIURI* aURI);
|
2006-05-02 18:54:19 +00:00
|
|
|
|
1999-10-26 01:44:00 +00:00
|
|
|
protected:
|
2004-12-08 17:32:06 +00:00
|
|
|
// Override the parent setter from nsDocLoader
|
|
|
|
virtual nsresult SetDocLoaderParent(nsDocLoader * aLoader);
|
|
|
|
|
2006-05-10 17:30:15 +00:00
|
|
|
// Event type dispatched by RestorePresentation
|
|
|
|
class RestorePresentationEvent : public nsRunnable {
|
|
|
|
public:
|
|
|
|
NS_DECL_NSIRUNNABLE
|
|
|
|
RestorePresentationEvent(nsDocShell *ds) : mDocShell(ds) {}
|
|
|
|
void Revoke() { mDocShell = nsnull; }
|
|
|
|
private:
|
|
|
|
nsDocShell *mDocShell;
|
|
|
|
};
|
|
|
|
|
2004-05-11 00:12:09 +00:00
|
|
|
PRPackedBool mAllowSubframes;
|
2001-06-26 01:19:11 +00:00
|
|
|
PRPackedBool mAllowPlugins;
|
|
|
|
PRPackedBool mAllowJavascript;
|
|
|
|
PRPackedBool mAllowMetaRedirects;
|
|
|
|
PRPackedBool mAllowImages;
|
|
|
|
PRPackedBool mFocusDocFirst;
|
2001-12-11 02:41:22 +00:00
|
|
|
PRPackedBool mHasFocus;
|
|
|
|
PRPackedBool mCreatingDocument; // (should be) debugging only
|
2002-07-11 20:59:03 +00:00
|
|
|
PRPackedBool mUseErrorPages;
|
2005-09-22 20:38:56 +00:00
|
|
|
PRPackedBool mObserveErrorPages;
|
2003-04-25 23:29:17 +00:00
|
|
|
PRPackedBool mAllowAuth;
|
2006-04-03 23:17:51 +00:00
|
|
|
PRPackedBool mAllowKeywordFixup;
|
2001-06-26 01:19:11 +00:00
|
|
|
|
2004-02-11 06:09:51 +00:00
|
|
|
PRPackedBool mFiredUnloadEvent;
|
2001-07-17 20:17:38 +00:00
|
|
|
|
2001-04-27 13:03:17 +00:00
|
|
|
// this flag is for bug #21358. a docshell may load many urls
|
2004-05-11 00:12:09 +00:00
|
|
|
// which don't result in new documents being created (i.e. a new
|
|
|
|
// content viewer) we want to make sure we don't call a on load
|
|
|
|
// event more than once for a given content viewer.
|
2004-02-11 06:09:51 +00:00
|
|
|
PRPackedBool mEODForCurrentDocument;
|
|
|
|
PRPackedBool mURIResultedInDocument;
|
|
|
|
|
|
|
|
PRPackedBool mIsBeingDestroyed;
|
2001-04-27 13:03:17 +00:00
|
|
|
|
2003-03-13 19:58:23 +00:00
|
|
|
PRPackedBool mIsExecutingOnLoadHandler;
|
|
|
|
|
2004-02-11 06:09:51 +00:00
|
|
|
// Indicates that a DocShell in this "docshell tree" is printing
|
|
|
|
PRPackedBool mIsPrintingOrPP;
|
|
|
|
|
2005-06-24 20:53:43 +00:00
|
|
|
// Indicates to CreateContentViewer() that it is safe to cache the old
|
|
|
|
// presentation of the page, and to SetupNewViewer() that the old viewer
|
|
|
|
// should be passed a SHEntry to save itself into.
|
2005-05-04 20:22:32 +00:00
|
|
|
PRPackedBool mSavingOldViewer;
|
|
|
|
|
2004-05-11 00:12:09 +00:00
|
|
|
PRUint32 mAppType;
|
|
|
|
|
|
|
|
// Offset in the parent's child list.
|
|
|
|
PRInt32 mChildOffset;
|
|
|
|
|
|
|
|
PRUint32 mBusyFlags;
|
|
|
|
|
|
|
|
PRInt32 mMarginWidth;
|
|
|
|
PRInt32 mMarginHeight;
|
|
|
|
PRInt32 mItemType;
|
|
|
|
|
|
|
|
PRUint32 mLoadType;
|
|
|
|
|
|
|
|
nsString mName;
|
|
|
|
nsString mTitle;
|
2004-07-01 17:04:31 +00:00
|
|
|
/**
|
|
|
|
* Content-Type Hint of the most-recently initiated load. Used for
|
|
|
|
* session history entries.
|
|
|
|
*/
|
|
|
|
nsCString mContentTypeHint;
|
2004-05-11 00:12:09 +00:00
|
|
|
nsCOMPtr<nsISupportsArray> mRefreshURIList;
|
2005-08-11 20:14:00 +00:00
|
|
|
nsCOMPtr<nsISupportsArray> mSavedRefreshURIList;
|
2005-02-18 18:20:42 +00:00
|
|
|
nsRefPtr<nsDSURIContentListener> mContentListener;
|
2004-05-11 00:12:09 +00:00
|
|
|
nsRect mBounds; // Dimensions of the docshell
|
|
|
|
nsCOMPtr<nsIContentViewer> mContentViewer;
|
|
|
|
nsCOMPtr<nsIDocumentCharsetInfo> mDocumentCharsetInfo;
|
|
|
|
nsCOMPtr<nsIDeviceContext> mDeviceContext;
|
|
|
|
nsCOMPtr<nsIWidget> mParentWidget;
|
2004-09-06 19:31:22 +00:00
|
|
|
nsCOMPtr<nsIPrefBranch> mPrefs;
|
2006-05-31 17:57:14 +00:00
|
|
|
|
|
|
|
// mCurrentURI should be marked immutable on set if possible.
|
2004-05-11 00:12:09 +00:00
|
|
|
nsCOMPtr<nsIURI> mCurrentURI;
|
|
|
|
nsCOMPtr<nsIURI> mReferrerURI;
|
|
|
|
nsCOMPtr<nsIScriptGlobalObject> mScriptGlobal;
|
|
|
|
nsCOMPtr<nsISHistory> mSessionHistory;
|
|
|
|
nsCOMPtr<nsIGlobalHistory2> mGlobalHistory;
|
|
|
|
nsCOMPtr<nsIWebBrowserFind> mFind;
|
|
|
|
nsPoint mDefaultScrollbarPref; // persistent across doc loads
|
|
|
|
// Reference to the SHEntry for this docshell until the page is destroyed.
|
|
|
|
// Somebody give me better name
|
|
|
|
nsCOMPtr<nsISHEntry> mOSHE;
|
|
|
|
// Reference to the SHEntry for this docshell until the page is loaded
|
|
|
|
// Somebody give me better name
|
|
|
|
nsCOMPtr<nsISHEntry> mLSHE;
|
|
|
|
|
2006-05-10 17:30:15 +00:00
|
|
|
// Holds a weak pointer to a RestorePresentationEvent object if any that
|
|
|
|
// holds a weak pointer back to us. We use this pointer to possibly revoke
|
|
|
|
// the event whenever necessary.
|
|
|
|
nsRevocableEventPtr<RestorePresentationEvent> mRestorePresentationEvent;
|
|
|
|
|
2006-05-19 05:57:36 +00:00
|
|
|
// hash of session storages, keyed by domain
|
|
|
|
nsInterfaceHashtable<nsCStringHashKey, nsIDOMStorage> mStorages;
|
|
|
|
|
2005-09-23 18:16:40 +00:00
|
|
|
// Index into the SHTransaction list, indicating the previous and current
|
|
|
|
// transaction at the time that this DocShell begins to load
|
|
|
|
PRInt32 mPreviousTransIndex;
|
|
|
|
PRInt32 mLoadedTransIndex;
|
|
|
|
|
2002-02-02 05:13:56 +00:00
|
|
|
// Editor stuff
|
|
|
|
nsDocShellEditorData* mEditorData; // editor data, if any
|
|
|
|
|
2003-04-17 13:16:05 +00:00
|
|
|
// Transferable hooks/callbacks
|
2003-04-18 02:03:44 +00:00
|
|
|
nsCOMPtr<nsIClipboardDragDropHookList> mTransferableHookData;
|
2003-04-17 13:16:05 +00:00
|
|
|
|
2005-05-04 20:22:32 +00:00
|
|
|
// Secure browser UI object
|
|
|
|
nsCOMPtr<nsISecureBrowserUI> mSecurityUI;
|
|
|
|
|
2001-04-27 13:03:17 +00:00
|
|
|
// WEAK REFERENCES BELOW HERE.
|
|
|
|
// Note these are intentionally not addrefd. Doing so will create a cycle.
|
|
|
|
// For that reasons don't use nsCOMPtr.
|
|
|
|
|
|
|
|
nsIDocShellTreeOwner * mTreeOwner; // Weak Reference
|
|
|
|
nsIChromeEventHandler * mChromeEventHandler; //Weak Reference
|
2002-02-06 07:26:26 +00:00
|
|
|
|
2004-05-11 00:12:09 +00:00
|
|
|
static nsIURIFixup *sURIFixup;
|
|
|
|
|
2002-10-08 13:17:56 +00:00
|
|
|
|
2002-02-06 14:39:42 +00:00
|
|
|
public:
|
2002-02-06 07:26:26 +00:00
|
|
|
class InterfaceRequestorProxy : public nsIInterfaceRequestor {
|
|
|
|
public:
|
|
|
|
InterfaceRequestorProxy(nsIInterfaceRequestor* p);
|
|
|
|
virtual ~InterfaceRequestorProxy();
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIINTERFACEREQUESTOR
|
|
|
|
|
2002-02-06 14:39:42 +00:00
|
|
|
protected:
|
2002-02-06 07:26:26 +00:00
|
|
|
InterfaceRequestorProxy() {}
|
|
|
|
nsWeakPtr mWeakPtr;
|
|
|
|
};
|
1999-10-26 01:44:00 +00:00
|
|
|
};
|
|
|
|
|
1999-11-12 07:28:25 +00:00
|
|
|
#endif /* nsDocShell_h__ */
|