Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
nsDocShell.cpp File Reference
#include "nsIBrowserDOMWindow.h"
#include "nsIComponentManager.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsIDOMNSDocument.h"
#include "nsIDOMElement.h"
#include "nsIDOMStorage.h"
#include "nsPIDOMStorage.h"
#include "nsIDocumentViewer.h"
#include "nsIDocumentLoaderFactory.h"
#include "nsCURILoader.h"
#include "nsDocShellCID.h"
#include "nsLayoutCID.h"
#include "nsDOMCID.h"
#include "nsIDOMScriptObjectFactory.h"
#include "nsNetUtil.h"
#include "nsRect.h"
#include "prprf.h"
#include "nsIMarkupDocumentViewer.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "nsIChromeEventHandler.h"
#include "nsIDOMChromeWindow.h"
#include "nsIDOMWindowInternal.h"
#include "nsIWebBrowserChrome.h"
#include "nsPoint.h"
#include "nsGfxCIID.h"
#include "nsIObserverService.h"
#include "nsIPrompt.h"
#include "nsIAuthPrompt.h"
#include "nsTextFormatter.h"
#include "nsIChannelEventSink.h"
#include "nsIUploadChannel.h"
#include "nsISecurityEventSink.h"
#include "nsIScriptSecurityManager.h"
#include "nsIJSContextStack.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsDocumentCharsetInfoCID.h"
#include "nsICanvasFrame.h"
#include "nsIScrollableFrame.h"
#include "nsContentPolicyUtils.h"
#include "nsICategoryManager.h"
#include "nsXPCOMCID.h"
#include "nsISeekableStream.h"
#include "nsAutoPtr.h"
#include "nsIPrefService.h"
#include "nsIWritablePropertyBag2.h"
#include "nsObserverService.h"
#include "nsIHttpChannelInternal.h"
#include "nsDocShell.h"
#include "nsDocShellLoadInfo.h"
#include "nsCDefaultURIFixup.h"
#include "nsDocShellEnumerator.h"
#include "nsDOMError.h"
#include "nsEscape.h"
#include "nsIDataChannel.h"
#include "nsIProgressEventSink.h"
#include "nsIWebProgress.h"
#include "nsILayoutHistoryState.h"
#include "nsITimer.h"
#include "nsISHistoryInternal.h"
#include "nsIPrincipal.h"
#include "nsIHistoryEntry.h"
#include "nsISHistoryListener.h"
#include "nsIWindowWatcher.h"
#include "nsIEditingSession.h"
#include "nsPIDOMWindow.h"
#include "nsICachingChannel.h"
#include "nsICacheVisitor.h"
#include "nsIMultiPartChannel.h"
#include "nsIWyciwygChannel.h"
#include "nsIHTMLDocument.h"
#include "nsIConsoleService.h"
#include "nsIScriptError.h"
#include "nsCExternalHandlerService.h"
#include "nsIExternalProtocolService.h"
#include "nsIFocusController.h"
#include "nsITextToSubURI.h"
#include "nsIJARChannel.h"
#include "prlog.h"
#include "prmem.h"
#include "nsISelectionDisplay.h"
#include "nsIGlobalHistory2.h"
#include "nsIGlobalHistory3.h"
#include "nsIFrame.h"
#include "nsIWebBrowserChromeFocus.h"
#include "nsPluginError.h"
#include "plevent.h"
#include "nsGUIEvent.h"
#include "nsEventQueueUtils.h"

Go to the source code of this file.

Classes

class  nsDocShellFocusController
class  RestorePresentationEvent
struct  CloneAndReplaceData
struct  SwapEntriesData

Defines

#define NS_EVENT_STARVATION_DELAY_HINT   2000
#define NS_ERROR_DOCUMENT_IS_PRINTMODE   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL,2001)
#define DIALOG_STRING_URI   "chrome://global/locale/appstrings.properties"

Functions

static NS_DEFINE_IID (kDeviceContextCID, NS_DEVICE_CONTEXT_CID)
static NS_DEFINE_CID (kSimpleURICID, NS_SIMPLEURI_CID)
static NS_DEFINE_CID (kDocumentCharsetInfoCID, NS_DOCUMENTCHARSETINFO_CID)
static NS_DEFINE_CID (kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID)
static PRBool SameOrSubdomainOfTarget (nsIURI *aOriginURI, nsIURI *aTargetURI, PRBool aDocumentDomainSet)
static PRBool ItemIsActive (nsIDocShellTreeItem *aItem)
static void DoCancelRefreshURITimers (nsISupportsArray *aTimerList)
 HandleRestorePresentationEvent (PLEvent *aEvent)
 DestroyRestorePresentationEvent (PLEvent *aEvent)
static NS_METHOD AppendSegmentToString (nsIInputStream *in, void *closure, const char *fromRawSegment, PRUint32 toOffset, PRUint32 count, PRUint32 *writeCount)
static nsISHEntryGetRootSHEntry (nsISHEntry *aEntry)

Variables

static PRInt32 gNumberOfDocumentsLoading = 0
static PRInt32 gDocShellCount = 0
static PRBool gValidateOrigin = (PRBool)0xffffffff

Class Documentation

struct SwapEntriesData

Definition at line 8187 of file nsDocShell.cpp.

Collaboration diagram for SwapEntriesData:
Class Members
nsISHEntry * destTreeParent
nsISHEntry * destTreeRoot
nsDocShell * ignoreShell

Define Documentation

#define DIALOG_STRING_URI   "chrome://global/locale/appstrings.properties"

Definition at line 8472 of file nsDocShell.cpp.

Definition at line 214 of file nsDocShell.cpp.

Definition at line 208 of file nsDocShell.cpp.


Function Documentation

static NS_METHOD AppendSegmentToString ( nsIInputStream in,
void closure,
const char *  fromRawSegment,
PRUint32  toOffset,
PRUint32  count,
PRUint32 writeCount 
) [static]

Definition at line 7161 of file nsDocShell.cpp.

{
    // aFromSegment now contains aCount bytes of data.

    nsCAutoString *buf = NS_STATIC_CAST(nsCAutoString *, closure);
    buf->Append(fromRawSegment, count);

    // Indicate that we have consumed all of aFromSegment
    *writeCount = count;
    return NS_OK;
}

Here is the caller graph for this function:

Definition at line 5234 of file nsDocShell.cpp.

Here is the caller graph for this function:

static void DoCancelRefreshURITimers ( nsISupportsArray aTimerList) [static]

Definition at line 4532 of file nsDocShell.cpp.

{
    if (!aTimerList)
        return;

    PRUint32 n=0;
    aTimerList->Count(&n);

    while (n) {
        nsCOMPtr<nsITimer> timer(do_QueryElementAt(aTimerList, --n));

        aTimerList->RemoveElementAt(n);    // bye bye owning timer ref

        if (timer)
            timer->Cancel();        
    }
}

Here is the call graph for this function:

static nsISHEntry* GetRootSHEntry ( nsISHEntry aEntry) [static]

Definition at line 8255 of file nsDocShell.cpp.

{
    nsCOMPtr<nsISHEntry> rootEntry = aEntry;
    nsISHEntry *result = nsnull;
    while (rootEntry) {
        result = rootEntry;
        result->GetParent(getter_AddRefs(rootEntry));
    }

    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 5223 of file nsDocShell.cpp.

{
    RestorePresentationEvent *event =
        NS_STATIC_CAST(RestorePresentationEvent*, aEvent);

    nsresult rv = event->mDocShell->RestoreFromHistory();
    NS_ASSERTION(NS_SUCCEEDED(rv), "RestoreFromHistory failed");
    return nsnull;
}

Here is the caller graph for this function:

static PRBool ItemIsActive ( nsIDocShellTreeItem aItem) [static]

Definition at line 2078 of file nsDocShell.cpp.

{
    nsCOMPtr<nsIDOMWindow> tmp(do_GetInterface(aItem));
    nsCOMPtr<nsIDOMWindowInternal> window(do_QueryInterface(tmp));

    if (window) {
        PRBool isClosed;

        if (NS_SUCCEEDED(window->GetClosed(&isClosed)) && !isClosed) {
            return PR_TRUE;
        }
    }

    return PR_FALSE;
}

Here is the call graph for this function:

static NS_DEFINE_CID ( kSimpleURICID  ,
NS_SIMPLEURI_CID   
) [static]
static NS_DEFINE_CID ( kDocumentCharsetInfoCID  ,
NS_DOCUMENTCHARSETINFO_CID   
) [static]
static NS_DEFINE_CID ( kDOMScriptObjectFactoryCID  ,
NS_DOM_SCRIPT_OBJECT_FACTORY_CID   
) [static]
static NS_DEFINE_IID ( kDeviceContextCID  ,
NS_DEVICE_CONTEXT_CID   
) [static]
static PRBool SameOrSubdomainOfTarget ( nsIURI aOriginURI,
nsIURI aTargetURI,
PRBool  aDocumentDomainSet 
) [static]

Definition at line 977 of file nsDocShell.cpp.

{
  if (aOriginURI == aTargetURI) {
    return PR_TRUE;
  }
  
  nsCAutoString targetScheme;
  nsresult rv = aTargetURI->GetScheme(targetScheme);
  NS_ENSURE_SUCCESS(rv, PR_TRUE);

  nsCAutoString originScheme;
  rv = aOriginURI->GetScheme(originScheme);
  NS_ENSURE_SUCCESS(rv, PR_TRUE);

  if (targetScheme != originScheme)
    return PR_FALSE; // Different schemes - check fails

  if (targetScheme.EqualsLiteral("file"))
    return PR_TRUE; // All file: urls are considered to have the same origin.

  if (targetScheme.EqualsLiteral("imap") ||
      targetScheme.EqualsLiteral("mailbox") ||
      targetScheme.EqualsLiteral("news"))
  {

    // Each message is a distinct trust domain; use the whole spec for comparison
    nsCAutoString targetSpec;
    rv =aTargetURI->GetAsciiSpec(targetSpec);
    NS_ENSURE_SUCCESS(rv, PR_TRUE);

    nsCAutoString originSpec;
    rv = aOriginURI->GetAsciiSpec(originSpec);
    NS_ENSURE_SUCCESS(rv, PR_TRUE);

    return (targetSpec == originSpec); // True if full spec is same, false otherwise
  }

  // Compare ports.  Note that failure to get this means we should return
  // false; such failure happens all the time for non-nsIURL nsIURI impls.
  int targetPort, originPort;
  rv = aTargetURI->GetPort(&targetPort);
  NS_ENSURE_SUCCESS(rv, PR_FALSE);

  rv = aOriginURI->GetPort(&originPort);
  NS_ENSURE_SUCCESS(rv, PR_FALSE);

  if (targetPort != originPort)
    return PR_FALSE; // Different port - check fails

  // Need to check the hosts.  Note that failure to get this means we should
  // return false; such failure happens all the time for non-nsIURL nsIURI
  // impls.
  nsCAutoString targetHost;
  rv = aTargetURI->GetHost(targetHost);
  NS_ENSURE_SUCCESS(rv, PR_FALSE);

  nsCAutoString originHost;
  rv = aOriginURI->GetHost(originHost);
  NS_ENSURE_SUCCESS(rv, PR_FALSE);

  if (targetHost.Equals(originHost, nsCaseInsensitiveCStringComparator()))
    return PR_TRUE; // Hosts are the same - check passed
  
  // If document.domain was set, do the relaxed check
  // Right align hostnames and compare - ensure preceeding char is . or /
  if (aDocumentDomainSet)
  {
    int targetHostLen = targetHost.Length();
    int originHostLen = originHost.Length();
    int prefixChar = originHostLen-targetHostLen-1;

    return ((originHostLen > targetHostLen) &&
            (! strcmp((originHost.get()+prefixChar+1), targetHost.get())) &&
            (originHost.CharAt(prefixChar) == '.' || originHost.CharAt(prefixChar) == '/'));
  }

  return PR_FALSE; // document.domain not set and hosts not same - check failed
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

PRInt32 gDocShellCount = 0 [static]

Definition at line 195 of file nsDocShell.cpp.

Definition at line 192 of file nsDocShell.cpp.

PRBool gValidateOrigin = (PRBool)0xffffffff [static]

Definition at line 203 of file nsDocShell.cpp.