Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
nsScriptLoader.cpp File Reference
#include "nsScriptLoader.h"
#include "nsIDOMCharacterData.h"
#include "nsParserUtils.h"
#include "nsIMIMEHeaderParam.h"
#include "nsICharsetConverterManager.h"
#include "nsIUnicodeDecoder.h"
#include "nsIContent.h"
#include "nsHTMLAtoms.h"
#include "nsNetUtil.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptContext.h"
#include "nsINodeInfo.h"
#include "nsIScriptSecurityManager.h"
#include "nsIPrincipal.h"
#include "nsContentPolicyUtils.h"
#include "nsPIDOMWindow.h"
#include "nsIHttpChannel.h"
#include "nsIScriptElement.h"
#include "nsIDOMHTMLScriptElement.h"
#include "nsIDocShell.h"
#include "jsapi.h"
#include "nsContentUtils.h"
#include "nsUnicharUtils.h"
#include "nsAutoPtr.h"
#include "nsIEventQueue.h"
#include "nsEventQueueUtils.h"

Go to the source code of this file.

Classes

class  nsScriptLoadRequest
class  nsScriptLoaderEvent

Functions

static NS_DEFINE_CID (kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID)
static PRBool DetectByteOrderMark (const unsigned char *aBytes, PRInt32 aLen, nsCString &oCharset)
static nsresult NS_GetFinalChannelURI (nsIChannel *channel, nsIURI **uri)
 Get the "final" URI for a channel.
static nsresult GetChannelPrincipal (nsIChannel *aChannel, nsIPrincipal **aPrincipal)

Function Documentation

static PRBool DetectByteOrderMark ( const unsigned char *  aBytes,
PRInt32  aLen,
nsCString oCharset 
) [static]

Definition at line 835 of file nsScriptLoader.cpp.

{
  if (aLen < 2)
    return PR_FALSE;

  switch(aBytes[0]) {
  case 0xEF:
    if (aLen >= 3 && 0xBB == aBytes[1] && 0xBF == aBytes[2]) {
      // EF BB BF
      // Win2K UTF-8 BOM
      oCharset.Assign("UTF-8");
    }
    break;
  case 0xFE:
    if (0xFF == aBytes[1]) {
      // FE FF
      // UTF-16, big-endian
      oCharset.Assign("UTF-16BE");
    }
    break;
  case 0xFF:
    if (0xFE == aBytes[1]) {
      // FF FE
      // UTF-16, little-endian
      oCharset.Assign("UTF-16LE");
    }
    break;
  }
  return !oCharset.IsEmpty();
}

Here is the caller graph for this function:

static nsresult GetChannelPrincipal ( nsIChannel aChannel,
nsIPrincipal **  aPrincipal 
) [static]

Definition at line 1069 of file nsScriptLoader.cpp.

{
  NS_PRECONDITION(aChannel, "Must have channel!");
  nsCOMPtr<nsISupports> owner;
  aChannel->GetOwner(getter_AddRefs(owner));
  if (owner) {
    CallQueryInterface(owner, aPrincipal);
    if (*aPrincipal) {
      return NS_OK;
    }
  }

  // OK, get the principal from the URI.  Make sure this does the same thing
  // as nsDocument::Reset and nsXULDocument::StartDocumentLoad.
  nsCOMPtr<nsIURI> uri;
  nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
  NS_ENSURE_SUCCESS(rv, rv);

  return nsContentUtils::GetSecurityManager()->
    GetCodebasePrincipal(uri, aPrincipal);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static NS_DEFINE_CID ( kCharsetConverterManagerCID  ,
NS_ICHARSETCONVERTERMANAGER_CID   
) [static]
static nsresult NS_GetFinalChannelURI ( nsIChannel channel,
nsIURI **  uri 
) [static]

Get the "final" URI for a channel.

This is either the same as GetURI or GetOriginalURI, depending on whether this channel has nsIChanel::LOAD_REPLACE set. For channels without that flag set, the final URI is the original URI, while for ones with the flag the final URI is the channel URI.

Definition at line 1054 of file nsScriptLoader.cpp.

{
    *uri = nsnull;
    nsLoadFlags loadFlags = 0;
    nsresult rv = channel->GetLoadFlags(&loadFlags);
    NS_ENSURE_SUCCESS(rv, rv);
    
    if (loadFlags & nsIChannel::LOAD_REPLACE) {
        return channel->GetURI(uri);
    }
    
    return channel->GetOriginalURI(uri);
}

Here is the caller graph for this function: