2001-04-27 17:03:17 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2005-08-23 04:24:57 +04:00
|
|
|
* vim: set ts=4 sw=4 et tw=80:
|
1999-11-12 10:28:25 +03:00
|
|
|
*
|
2004-04-18 01:52:36 +04: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-11-12 10:28:25 +03:00
|
|
|
* The Original Code is the Mozilla browser.
|
2004-04-18 01:52:36 +04: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-11-12 10:28:25 +03:00
|
|
|
* Contributor(s):
|
|
|
|
* Travis Bogard <travis@netscape.com>
|
2004-04-18 01:52:36 +04: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-11-12 10:28:25 +03:00
|
|
|
|
|
|
|
#ifndef nsDocShell_h__
|
|
|
|
#define nsDocShell_h__
|
|
|
|
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsIDOMNode.h"
|
|
|
|
#include "nsIDOMNodeList.h"
|
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsIScrollableView.h"
|
|
|
|
#include "nsIContentViewer.h"
|
2004-09-06 23:31:22 +04:00
|
|
|
#include "nsIPrefBranch.h"
|
1999-12-12 13:15:26 +03:00
|
|
|
#include "nsVoidArray.h"
|
2001-07-16 06:40:48 +04:00
|
|
|
#include "nsIScriptContext.h"
|
2002-09-07 09:38:16 +04:00
|
|
|
#include "nsITimer.h"
|
1999-11-12 10:28:25 +03:00
|
|
|
|
|
|
|
#include "nsCDocShell.h"
|
1999-12-12 13:15:26 +03:00
|
|
|
#include "nsIDocShellTreeOwner.h"
|
1999-11-12 10:28:25 +03:00
|
|
|
#include "nsIContentViewerContainer.h"
|
2000-03-08 06:58:33 +03:00
|
|
|
#include "nsIDeviceContext.h"
|
1999-11-12 10:28:25 +03:00
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
#include "nsDocLoader.h"
|
2001-10-27 06:52:39 +04:00
|
|
|
#include "nsIURILoader.h"
|
2002-02-02 08:13:56 +03:00
|
|
|
#include "nsIEditorDocShell.h"
|
1999-11-12 10:28:25 +03:00
|
|
|
|
2000-05-28 13:25:55 +04:00
|
|
|
#include "nsWeakReference.h"
|
2000-03-29 14:29:58 +04:00
|
|
|
|
|
|
|
// Local Includes
|
|
|
|
#include "nsDSURIContentListener.h"
|
2002-02-02 08:13:56 +03:00
|
|
|
#include "nsDocShellEditorData.h"
|
2000-03-29 14:29:58 +04:00
|
|
|
|
2000-04-16 12:39:15 +04:00
|
|
|
// Helper Classes
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsPoint.h" // mCurrent/mDefaultScrollbarPreferences
|
|
|
|
#include "nsString.h"
|
2005-02-18 21:20:42 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2000-04-16 12:39:15 +04:00
|
|
|
|
2001-02-15 22:10:16 +03:00
|
|
|
// Threshold value in ms for META refresh based redirects
|
|
|
|
#define REFRESH_REDIRECT_TIMER 15000
|
2000-06-22 09:36:13 +04:00
|
|
|
|
2000-02-17 05:03:02 +03:00
|
|
|
// Interfaces Needed
|
2000-04-12 04:07:04 +04:00
|
|
|
#include "nsIDocumentCharsetInfo.h"
|
2001-05-17 06:12:51 +04:00
|
|
|
#include "nsIDocCharset.h"
|
2004-02-11 05:10:04 +03:00
|
|
|
#include "nsIGlobalHistory2.h"
|
2000-04-16 12:39:15 +04:00
|
|
|
#include "nsIInterfaceRequestor.h"
|
2001-09-06 01:28:38 +04:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2000-04-22 03:31:40 +04:00
|
|
|
#include "nsIPrompt.h"
|
2000-04-13 07:11:44 +04:00
|
|
|
#include "nsIRefreshURI.h"
|
2000-04-16 12:39:15 +04:00
|
|
|
#include "nsIScriptGlobalObject.h"
|
|
|
|
#include "nsIScriptGlobalObjectOwner.h"
|
2000-02-17 05:03:02 +03:00
|
|
|
#include "nsISHistory.h"
|
2003-05-30 04:21:01 +04:00
|
|
|
#include "nsILayoutHistoryState.h"
|
2000-04-13 07:11:44 +04:00
|
|
|
#include "nsIStringBundle.h"
|
2000-04-16 12:39:15 +04:00
|
|
|
#include "nsISupportsArray.h"
|
2000-02-14 09:40:28 +03:00
|
|
|
#include "nsIWebNavigation.h"
|
2002-04-02 01:22:27 +04:00
|
|
|
#include "nsIWebPageDescriptor.h"
|
2000-03-26 08:52:06 +04:00
|
|
|
#include "nsIWebProgressListener.h"
|
2000-06-21 10:40:08 +04:00
|
|
|
#include "nsISHContainer.h"
|
2000-06-22 11:22:23 +04:00
|
|
|
#include "nsIDocShellLoadInfo.h"
|
2000-07-06 03:10:29 +04:00
|
|
|
#include "nsIDocShellHistory.h"
|
2000-11-09 00:00:37 +03:00
|
|
|
#include "nsIURIFixup.h"
|
2001-04-28 01:11:03 +04:00
|
|
|
#include "nsIWebBrowserFind.h"
|
2001-11-28 02:14:15 +03:00
|
|
|
#include "nsIHttpChannel.h"
|
2003-04-17 17:16:05 +04:00
|
|
|
#include "nsDocShellTransferableHooks.h"
|
2004-09-02 09:13:25 +04:00
|
|
|
#include "nsIAuthPromptProvider.h"
|
2005-05-05 00:22:32 +04:00
|
|
|
#include "nsISecureBrowserUI.h"
|
2005-09-23 00:38:56 +04:00
|
|
|
#include "nsIObserver.h"
|
2000-02-14 09:40:28 +03:00
|
|
|
|
2005-01-31 14:26:31 +03:00
|
|
|
/**
|
|
|
|
* Load flag for error pages. This should be bigger than all flags on
|
|
|
|
* nsIWebNavigation.
|
|
|
|
*/
|
|
|
|
#define LOAD_FLAGS_ERROR_PAGE 0x8000U
|
2002-04-05 02:10:10 +04:00
|
|
|
|
2000-09-20 16:23:53 +04:00
|
|
|
#define MAKE_LOAD_TYPE(type, flags) ((type) | ((flags) << 16))
|
2005-01-20 19:57:04 +03:00
|
|
|
#define LOAD_TYPE_HAS_FLAGS(type, flags) ((type) & ((flags) << 16))
|
2000-09-20 16:23:53 +04:00
|
|
|
|
2002-04-05 02:10:10 +04:00
|
|
|
/* load commands were moved to nsIDocShell.h */
|
2000-09-20 16:23:53 +04:00
|
|
|
|
2003-05-26 16:14:17 +04:00
|
|
|
/* load types are legal combinations of load commands and flags
|
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
* Remember to update the IsValidLoadType function below if you change this
|
|
|
|
* enum to ensure bad flag combinations will be rejected.
|
|
|
|
*/
|
2000-09-20 16:23:53 +04:00
|
|
|
enum LoadType {
|
2002-04-05 02:10:10 +04:00
|
|
|
LOAD_NORMAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_NONE),
|
|
|
|
LOAD_NORMAL_REPLACE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY),
|
2005-07-07 13:45:47 +04:00
|
|
|
LOAD_NORMAL_EXTERNAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_FROM_EXTERNAL),
|
2002-04-05 02:10:10 +04:00
|
|
|
LOAD_HISTORY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_HISTORY, nsIWebNavigation::LOAD_FLAGS_NONE),
|
|
|
|
LOAD_RELOAD_NORMAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_NONE),
|
|
|
|
LOAD_RELOAD_BYPASS_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
|
|
|
|
LOAD_RELOAD_BYPASS_PROXY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
|
|
|
|
LOAD_RELOAD_BYPASS_PROXY_AND_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE | nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
|
|
|
|
LOAD_LINK = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_IS_LINK),
|
|
|
|
LOAD_REFRESH = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_IS_REFRESH),
|
|
|
|
LOAD_RELOAD_CHARSET_CHANGE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE),
|
2005-01-20 19:57:04 +03:00
|
|
|
LOAD_BYPASS_HISTORY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_HISTORY),
|
|
|
|
LOAD_STOP_CONTENT = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_STOP_CONTENT),
|
2005-01-31 14:26:31 +03:00
|
|
|
LOAD_STOP_CONTENT_AND_REPLACE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_STOP_CONTENT | nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY),
|
|
|
|
/**
|
|
|
|
* Load type for an error page. These loads are never triggered by users of
|
|
|
|
* Docshell. Instead, Docshell triggers the load itself when a
|
|
|
|
* consumer-triggered load failed.
|
|
|
|
*/
|
|
|
|
LOAD_ERROR_PAGE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, LOAD_FLAGS_ERROR_PAGE)
|
|
|
|
|
2003-05-26 16:14:17 +04:00
|
|
|
// NOTE: Adding a new value? Remember to update IsValidLoadType!
|
2000-09-20 16:23:53 +04:00
|
|
|
};
|
2003-05-26 16:14:17 +04:00
|
|
|
static inline PRBool IsValidLoadType(PRUint32 aLoadType)
|
|
|
|
{
|
|
|
|
switch (aLoadType)
|
|
|
|
{
|
|
|
|
case LOAD_NORMAL:
|
|
|
|
case LOAD_NORMAL_REPLACE:
|
2005-07-07 13:45:47 +04:00
|
|
|
case LOAD_NORMAL_EXTERNAL:
|
2003-05-26 16:14:17 +04:00
|
|
|
case LOAD_HISTORY:
|
|
|
|
case LOAD_RELOAD_NORMAL:
|
|
|
|
case LOAD_RELOAD_BYPASS_CACHE:
|
|
|
|
case LOAD_RELOAD_BYPASS_PROXY:
|
|
|
|
case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE:
|
|
|
|
case LOAD_LINK:
|
|
|
|
case LOAD_REFRESH:
|
|
|
|
case LOAD_RELOAD_CHARSET_CHANGE:
|
|
|
|
case LOAD_BYPASS_HISTORY:
|
2005-01-20 19:57:04 +03:00
|
|
|
case LOAD_STOP_CONTENT:
|
|
|
|
case LOAD_STOP_CONTENT_AND_REPLACE:
|
2005-01-31 14:26:31 +03:00
|
|
|
case LOAD_ERROR_PAGE:
|
2003-05-26 16:14:17 +04:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
2000-09-20 16:23:53 +04:00
|
|
|
|
2001-04-17 00:17:36 +04:00
|
|
|
/* internally used ViewMode types */
|
|
|
|
enum ViewMode {
|
2001-04-27 17:03:17 +04:00
|
|
|
viewNormal = 0x0,
|
|
|
|
viewSource = 0x1
|
2001-04-17 00:17:36 +04:00
|
|
|
};
|
2000-09-20 16:23:53 +04:00
|
|
|
|
2000-04-13 07:11:44 +04:00
|
|
|
//*****************************************************************************
|
|
|
|
//*** nsRefreshTimer
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
class nsRefreshTimer : public nsITimerCallback
|
|
|
|
{
|
|
|
|
public:
|
2001-04-27 17:03:17 +04:00
|
|
|
nsRefreshTimer();
|
2000-04-13 07:11:44 +04:00
|
|
|
|
2001-04-27 17:03:17 +04:00
|
|
|
NS_DECL_ISUPPORTS
|
2002-09-07 09:38:16 +04:00
|
|
|
NS_DECL_NSITIMERCALLBACK
|
|
|
|
|
2002-02-09 01:46:09 +03:00
|
|
|
PRInt32 GetDelay() { return mDelay ;}
|
2000-04-13 07:11:44 +04:00
|
|
|
|
2001-04-27 17:03:17 +04:00
|
|
|
nsCOMPtr<nsIDocShell> mDocShell;
|
|
|
|
nsCOMPtr<nsIURI> mURI;
|
|
|
|
PRInt32 mDelay;
|
2004-02-11 09:09:51 +03:00
|
|
|
PRPackedBool mRepeat;
|
|
|
|
PRPackedBool mMetaRefresh;
|
2002-02-09 01:46:09 +03:00
|
|
|
|
2000-04-13 07:11:44 +04:00
|
|
|
protected:
|
2001-04-27 17:03:17 +04:00
|
|
|
virtual ~nsRefreshTimer();
|
2000-04-13 07:11:44 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
//*** nsDocShell
|
|
|
|
//*****************************************************************************
|
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
class nsDocShell : public nsDocLoader,
|
|
|
|
public nsIDocShell,
|
1999-12-03 13:29:08 +03:00
|
|
|
public nsIDocShellTreeItem,
|
1999-12-03 12:24:22 +03:00
|
|
|
public nsIDocShellTreeNode,
|
2000-07-06 03:10:29 +04:00
|
|
|
public nsIDocShellHistory,
|
2000-02-14 09:40:28 +03:00
|
|
|
public nsIWebNavigation,
|
1999-11-19 10:35:27 +03:00
|
|
|
public nsIBaseWindow,
|
|
|
|
public nsIScrollable,
|
|
|
|
public nsITextScroll,
|
2001-05-17 06:12:51 +04:00
|
|
|
public nsIDocCharset,
|
1999-11-23 13:15:10 +03:00
|
|
|
public nsIContentViewerContainer,
|
2000-04-13 07:11:44 +04:00
|
|
|
public nsIScriptGlobalObjectOwner,
|
2000-05-28 13:25:55 +04:00
|
|
|
public nsIRefreshURI,
|
2000-06-20 11:59:45 +04:00
|
|
|
public nsIWebProgressListener,
|
2002-02-02 08:13:56 +03:00
|
|
|
public nsIEditorDocShell,
|
2002-04-02 01:22:27 +04:00
|
|
|
public nsIWebPageDescriptor,
|
2005-09-23 00:38:56 +04:00
|
|
|
public nsIAuthPromptProvider,
|
|
|
|
public nsIObserver
|
1999-11-12 10:28:25 +03:00
|
|
|
{
|
|
|
|
friend class nsDSURIContentListener;
|
|
|
|
|
|
|
|
public:
|
2001-04-27 17:03:17 +04:00
|
|
|
// Object Management
|
|
|
|
nsDocShell();
|
|
|
|
|
2004-12-08 20:32:06 +03:00
|
|
|
virtual nsresult Init();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2001-04-27 17:03:17 +04: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 06:12:51 +04:00
|
|
|
NS_DECL_NSIDOCCHARSET
|
2001-04-27 17:03:17 +04:00
|
|
|
NS_DECL_NSIINTERFACEREQUESTOR
|
|
|
|
NS_DECL_NSIWEBPROGRESSLISTENER
|
|
|
|
NS_DECL_NSIREFRESHURI
|
|
|
|
NS_DECL_NSICONTENTVIEWERCONTAINER
|
2002-02-02 08:13:56 +03:00
|
|
|
NS_DECL_NSIEDITORDOCSHELL
|
2002-04-02 01:22:27 +04:00
|
|
|
NS_DECL_NSIWEBPAGEDESCRIPTOR
|
2004-09-02 09:13:25 +04:00
|
|
|
NS_DECL_NSIAUTHPROMPTPROVIDER
|
2005-09-23 00:38:56 +04:00
|
|
|
NS_DECL_NSIOBSERVER
|
2001-04-27 17:03:17 +04:00
|
|
|
|
2004-12-08 20:32:06 +03: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-12-01 01:35:33 +03:00
|
|
|
nsDocShellInfoLoadType ConvertLoadTypeToDocShellLoadInfo(PRUint32 aLoadType);
|
2001-04-27 17:03:17 +04:00
|
|
|
PRUint32 ConvertDocShellLoadInfoToLoadType(nsDocShellInfoLoadType aDocShellLoadType);
|
2000-06-20 11:59:45 +04:00
|
|
|
|
2004-07-16 21:03:10 +04:00
|
|
|
// nsIScriptGlobalObjectOwner methods
|
|
|
|
virtual nsIScriptGlobalObject* GetScriptGlobalObject();
|
2005-08-02 22:35:07 +04: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-11-12 10:28:25 +03:00
|
|
|
protected:
|
2001-04-27 17:03:17 +04:00
|
|
|
// Object Management
|
|
|
|
virtual ~nsDocShell();
|
2004-12-08 20:32:06 +03:00
|
|
|
virtual void DestroyChildren();
|
2001-04-27 17:03:17 +04:00
|
|
|
|
|
|
|
// Content Viewer Management
|
|
|
|
NS_IMETHOD EnsureContentViewer();
|
|
|
|
NS_IMETHOD EnsureDeviceContext();
|
2005-08-24 21:27:41 +04:00
|
|
|
nsresult CreateAboutBlankContentViewer();
|
2001-04-27 17:03:17 +04: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 07:28:54 +04:00
|
|
|
void SetupReferrerFromChannel(nsIChannel * aChannel);
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_IMETHOD GetEldestPresContext(nsPresContext** aPresContext);
|
2004-06-23 21:42:31 +04:00
|
|
|
void GetCurrentDocumentOwner(nsISupports ** aOwner);
|
2001-05-14 06:16:27 +04:00
|
|
|
virtual nsresult DoURILoad(nsIURI * aURI,
|
|
|
|
nsIURI * aReferrer,
|
2005-01-05 09:04:46 +03:00
|
|
|
PRBool aSendReferrer,
|
2001-05-14 06:16:27 +04:00
|
|
|
nsISupports * aOwner,
|
2003-10-04 02:11:47 +04:00
|
|
|
const char * aTypeHint,
|
2001-05-14 06:16:27 +04:00
|
|
|
nsIInputStream * aPostData,
|
2002-03-02 04:26:49 +03:00
|
|
|
nsIInputStream * aHeadersData,
|
2002-03-13 09:08:56 +03:00
|
|
|
PRBool firstParty,
|
|
|
|
nsIDocShell ** aDocShell,
|
|
|
|
nsIRequest ** aRequest);
|
2001-04-27 17:03:17 +04:00
|
|
|
NS_IMETHOD AddHeadersToChannel(nsIInputStream * aHeadersData,
|
|
|
|
nsIChannel * aChannel);
|
2001-05-14 06:16:27 +04:00
|
|
|
virtual nsresult DoChannelLoad(nsIChannel * aChannel,
|
|
|
|
nsIURILoader * aURILoader);
|
2005-03-09 17:31:02 +03:00
|
|
|
NS_IMETHOD ScrollIfAnchor(nsIURI * aURI, PRBool * aWasAnchor,
|
|
|
|
PRUint32 aLoadType, nscoord *cx, nscoord *cy);
|
2001-04-27 17:03:17 +04:00
|
|
|
|
2005-03-30 08:22:00 +04: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 16:38:38 +04:00
|
|
|
PRBool aFireOnLocationChange,
|
|
|
|
PRBool aAddToGlobalHistory = PR_TRUE);
|
2005-03-30 08:22:00 +04: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 16:38:38 +04:00
|
|
|
PRBool aFireOnLocationChange,
|
|
|
|
PRBool aAddToGlobalHistory = PR_TRUE);
|
2001-04-27 17:03:17 +04:00
|
|
|
|
|
|
|
virtual void SetReferrerURI(nsIURI * aURI);
|
|
|
|
|
|
|
|
// Session History
|
|
|
|
virtual PRBool ShouldAddToSessionHistory(nsIURI * aURI);
|
|
|
|
virtual nsresult AddToSessionHistory(nsIURI * aURI, nsIChannel * aChannel,
|
2004-04-13 05:42:40 +04:00
|
|
|
nsISHEntry ** aNewEntry);
|
|
|
|
nsresult DoAddChildSHEntry(nsISHEntry* aNewEntry, PRInt32 aChildOffset);
|
2001-04-27 17:03:17 +04:00
|
|
|
|
|
|
|
NS_IMETHOD LoadHistoryEntry(nsISHEntry * aEntry, PRUint32 aLoadType);
|
|
|
|
NS_IMETHOD PersistLayoutHistoryState();
|
2005-08-04 02:32:10 +04: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 23:14:02 +03:00
|
|
|
nsresult GetRootSessionHistory(nsISHistory ** aReturn);
|
2001-11-28 02:14:15 +03:00
|
|
|
nsresult GetHttpChannel(nsIChannel * aChannel, nsIHttpChannel ** aReturn);
|
2002-05-10 00:32:35 +04:00
|
|
|
PRBool ShouldDiscardLayoutState(nsIHttpChannel * aChannel);
|
2005-08-04 02:32:10 +04: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);
|
|
|
|
|
2001-04-27 17:03:17 +04:00
|
|
|
// Global History
|
2004-09-20 00:50:32 +04:00
|
|
|
nsresult AddToGlobalHistory(nsIURI * aURI, PRBool aRedirect, nsIURI * aReferrer);
|
2001-04-27 17:03:17 +04:00
|
|
|
|
|
|
|
// Helper Routines
|
|
|
|
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 08:13:56 +03:00
|
|
|
NS_IMETHOD EnsureEditorData();
|
2003-04-17 17:16:05 +04:00
|
|
|
nsresult EnsureTransferableHookData();
|
2001-04-28 01:11:03 +04:00
|
|
|
NS_IMETHOD EnsureFind();
|
2005-05-05 00:22:32 +04:00
|
|
|
nsresult RefreshURIFromQueue();
|
2005-01-31 14:26:31 +03: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 17:17:56 +04:00
|
|
|
PRBool IsPrintingOrPP(PRBool aDisplayErrorDialog = PR_TRUE);
|
2001-04-27 17:03:17 +04:00
|
|
|
|
2002-09-20 01:59:34 +04:00
|
|
|
nsresult SetBaseUrlForWyciwyg(nsIContentViewer * aContentViewer);
|
|
|
|
|
2001-09-08 02:06:08 +04: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;
|
|
|
|
}
|
|
|
|
|
2005-01-21 19:58:45 +03:00
|
|
|
nsresult FindTarget(const PRUnichar *aTargetName,
|
|
|
|
PRBool *aIsNewWindow,
|
|
|
|
nsIDocShell **aResult);
|
2001-05-14 06:16:27 +04:00
|
|
|
|
2001-04-27 17:03:17 +04:00
|
|
|
PRBool IsFrame();
|
|
|
|
|
|
|
|
//
|
|
|
|
// Helper method that is called when a new document (including any
|
|
|
|
// sub-documents - ie. frames) has been completely loaded.
|
|
|
|
//
|
2001-07-18 00:17:38 +04:00
|
|
|
virtual nsresult EndPageLoad(nsIWebProgress * aProgress,
|
|
|
|
nsIChannel * aChannel,
|
|
|
|
nsresult aResult);
|
2004-06-15 12:28:52 +04:00
|
|
|
|
2004-06-23 21:42:31 +04:00
|
|
|
nsresult CheckLoadingPermissions();
|
2004-06-15 12:28:52 +04:00
|
|
|
|
2005-01-21 19:58:45 +03: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 08:22:00 +04: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 03:00:53 +03:00
|
|
|
|
2005-05-05 00:22:32 +04: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-25 00:53:43 +04: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 04:24:57 +04: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-05 00:22:32 +04: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 22:35:07 +04: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-05 00:22:32 +04:00
|
|
|
|
2005-07-14 20:24:32 +04:00
|
|
|
// Call BeginRestore(nsnull, PR_FALSE) for each child of this shell.
|
|
|
|
nsresult BeginRestoreChildren();
|
|
|
|
|
1999-11-12 10:28:25 +03:00
|
|
|
protected:
|
2004-12-08 20:32:06 +03:00
|
|
|
// Override the parent setter from nsDocLoader
|
|
|
|
virtual nsresult SetDocLoaderParent(nsDocLoader * aLoader);
|
|
|
|
|
2004-05-11 04:12:09 +04:00
|
|
|
PRPackedBool mAllowSubframes;
|
2001-06-26 05:19:11 +04:00
|
|
|
PRPackedBool mAllowPlugins;
|
|
|
|
PRPackedBool mAllowJavascript;
|
|
|
|
PRPackedBool mAllowMetaRedirects;
|
|
|
|
PRPackedBool mAllowImages;
|
|
|
|
PRPackedBool mFocusDocFirst;
|
2001-12-11 05:41:22 +03:00
|
|
|
PRPackedBool mHasFocus;
|
|
|
|
PRPackedBool mCreatingDocument; // (should be) debugging only
|
2002-07-12 00:59:03 +04:00
|
|
|
PRPackedBool mUseErrorPages;
|
2005-09-23 00:38:56 +04:00
|
|
|
PRPackedBool mObserveErrorPages;
|
2003-04-26 03:29:17 +04:00
|
|
|
PRPackedBool mAllowAuth;
|
2001-06-26 05:19:11 +04:00
|
|
|
|
2004-02-11 09:09:51 +03:00
|
|
|
PRPackedBool mFiredUnloadEvent;
|
2001-07-18 00:17:38 +04:00
|
|
|
|
2001-04-27 17:03:17 +04:00
|
|
|
// this flag is for bug #21358. a docshell may load many urls
|
2004-05-11 04:12:09 +04: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 09:09:51 +03:00
|
|
|
PRPackedBool mEODForCurrentDocument;
|
|
|
|
PRPackedBool mURIResultedInDocument;
|
|
|
|
|
|
|
|
PRPackedBool mIsBeingDestroyed;
|
2001-04-27 17:03:17 +04:00
|
|
|
|
2003-03-13 22:58:23 +03:00
|
|
|
PRPackedBool mIsExecutingOnLoadHandler;
|
|
|
|
|
2004-02-11 09:09:51 +03:00
|
|
|
// Indicates that a DocShell in this "docshell tree" is printing
|
|
|
|
PRPackedBool mIsPrintingOrPP;
|
|
|
|
|
2005-06-25 00:53:43 +04: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-05 00:22:32 +04:00
|
|
|
PRPackedBool mSavingOldViewer;
|
|
|
|
|
2004-05-11 04:12:09 +04: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 21:04:31 +04:00
|
|
|
/**
|
|
|
|
* Content-Type Hint of the most-recently initiated load. Used for
|
|
|
|
* session history entries.
|
|
|
|
*/
|
|
|
|
nsCString mContentTypeHint;
|
2004-05-11 04:12:09 +04:00
|
|
|
nsCOMPtr<nsISupportsArray> mRefreshURIList;
|
2005-08-12 00:14:00 +04:00
|
|
|
nsCOMPtr<nsISupportsArray> mSavedRefreshURIList;
|
2005-02-18 21:20:42 +03:00
|
|
|
nsRefPtr<nsDSURIContentListener> mContentListener;
|
2004-05-11 04:12:09 +04:00
|
|
|
nsRect mBounds; // Dimensions of the docshell
|
|
|
|
nsCOMPtr<nsIContentViewer> mContentViewer;
|
|
|
|
nsCOMPtr<nsIDocumentCharsetInfo> mDocumentCharsetInfo;
|
|
|
|
nsCOMPtr<nsIDeviceContext> mDeviceContext;
|
|
|
|
nsCOMPtr<nsIWidget> mParentWidget;
|
2004-09-06 23:31:22 +04:00
|
|
|
nsCOMPtr<nsIPrefBranch> mPrefs;
|
2004-05-11 04:12:09 +04: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;
|
|
|
|
|
2002-02-02 08:13:56 +03:00
|
|
|
// Editor stuff
|
|
|
|
nsDocShellEditorData* mEditorData; // editor data, if any
|
|
|
|
|
2003-04-17 17:16:05 +04:00
|
|
|
// Transferable hooks/callbacks
|
2003-04-18 06:03:44 +04:00
|
|
|
nsCOMPtr<nsIClipboardDragDropHookList> mTransferableHookData;
|
2003-04-17 17:16:05 +04:00
|
|
|
|
2005-05-05 00:22:32 +04:00
|
|
|
// Secure browser UI object
|
|
|
|
nsCOMPtr<nsISecureBrowserUI> mSecurityUI;
|
|
|
|
|
2001-04-27 17:03:17 +04: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 10:26:26 +03:00
|
|
|
|
2004-05-11 04:12:09 +04:00
|
|
|
static nsIURIFixup *sURIFixup;
|
|
|
|
|
2002-10-08 17:17:56 +04:00
|
|
|
|
2002-02-06 17:39:42 +03:00
|
|
|
public:
|
2002-02-06 10:26:26 +03:00
|
|
|
class InterfaceRequestorProxy : public nsIInterfaceRequestor {
|
|
|
|
public:
|
|
|
|
InterfaceRequestorProxy(nsIInterfaceRequestor* p);
|
|
|
|
virtual ~InterfaceRequestorProxy();
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIINTERFACEREQUESTOR
|
|
|
|
|
2002-02-06 17:39:42 +03:00
|
|
|
protected:
|
2002-02-06 10:26:26 +03:00
|
|
|
InterfaceRequestorProxy() {}
|
|
|
|
nsWeakPtr mWeakPtr;
|
|
|
|
};
|
1999-11-12 10:28:25 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsDocShell_h__ */
|