Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
nsWebNavigationInfo Class Reference

#include <nsWebNavigationInfo.h>

Inheritance diagram for nsWebNavigationInfo:
Inheritance graph
[legend]
Collaboration diagram for nsWebNavigationInfo:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsWebNavigationInfo ()
NS_DECL_ISUPPORTS
NS_DECL_NSIWEBNAVIGATIONINFO
nsresult 
Init ()
unsigned long isTypeSupported (in ACString aType, in nsIWebNavigation aWebNav)
 Query whether aType is supported.

Public Attributes

const unsigned long UNSUPPORTED = 0
 Returned by isTypeSupported to indicate lack of support for a type.
const unsigned long IMAGE = 1
 Returned by isTypeSupported to indicate that a type is supported as an image.
const unsigned long PLUGIN = 2
 Returned by isTypeSupported to indicate that a type is supported via an NPAPI ("Netscape 4 API") plug-in.
const unsigned long OTHER = 1 << 15
 Returned by isTypeSupported to indicate that a type is supported via some other means.

Private Member Functions

 ~nsWebNavigationInfo ()
nsresult IsTypeSupportedInternal (const nsCString &aType, PRUint32 *aIsSupported)

Private Attributes

nsCOMPtr< nsICategoryManagermCategoryManager
nsCOMPtr< imgILoadermImgLoader

Detailed Description

Definition at line 51 of file nsWebNavigationInfo.h.


Constructor & Destructor Documentation

Definition at line 54 of file nsWebNavigationInfo.h.

{}

Definition at line 63 of file nsWebNavigationInfo.h.

{}

Member Function Documentation

Definition at line 52 of file nsWebNavigationInfo.cpp.

{
  nsresult rv;
  mCategoryManager = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv, rv);

  mImgLoader = do_GetService("@mozilla.org/image/loader;1", &rv);

  return rv;
}

Here is the call graph for this function:

unsigned long nsIWebNavigationInfo::isTypeSupported ( in ACString  aType,
in nsIWebNavigation  aWebNav 
) [inherited]

Query whether aType is supported.

Parameters:
aTypethe MIME type in question.
aWebNavthe nsIWebNavigation object for which the request is being made. This is allowed to be null. If it is non-null, the return value of this method may depend on the exact state of aWebNav and the values set through nsIWebBrowserSetup; otherwise the method will assume that the caller is interested in information about nsIWebNavigation objects in their default state.
Returns:
an enum value indicating whether and how aType is supported.
Note:
This method may rescan plugins to ensure that they're properly registered for the types they support.
nsresult nsWebNavigationInfo::IsTypeSupportedInternal ( const nsCString aType,
PRUint32 aIsSupported 
) [private]

Definition at line 106 of file nsWebNavigationInfo.cpp.

{
  NS_PRECONDITION(mCategoryManager, "Must have category manager");
  NS_PRECONDITION(aIsSupported, "Null out param?");

  nsXPIDLCString value;
  nsresult rv = mCategoryManager->GetCategoryEntry("Gecko-Content-Viewers",
                                                   aType.get(),
                                                   getter_Copies(value));

  // If the category manager can't find what we're looking for
  // it returns NS_ERROR_NOT_AVAILABLE, we don't want to propagate
  // that to the caller since it's really not a failure

  if (NS_FAILED(rv) && rv != NS_ERROR_NOT_AVAILABLE)
    return rv;

  // Now try to get an actual document loader factory for this contractid.  If
  // there is no contractid, don't try and just return false for *aIsSupported.
  nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory;
  if (!value.IsEmpty()) {
    docLoaderFactory = do_GetService(value.get());
  }

  // If we got a factory, we should be able to handle this type
  if (!docLoaderFactory) {
    *aIsSupported = nsIWebNavigationInfo::UNSUPPORTED;
  }
  else if (value.EqualsLiteral(CONTENT_DLF_CONTRACT)) {
    PRBool isImage = PR_FALSE;
    mImgLoader->SupportImageWithMimeType(aType.get(), &isImage);
    if (isImage) {
      *aIsSupported = nsIWebNavigationInfo::IMAGE;
    }
    else {
      *aIsSupported = nsIWebNavigationInfo::OTHER;
    }
  }
  else if (value.EqualsLiteral(PLUGIN_DLF_CONTRACT)) {
    *aIsSupported = nsIWebNavigationInfo::PLUGIN;
  }
  else {
    *aIsSupported = nsIWebNavigationInfo::OTHER;
  }
  
  return NS_OK;
}

Here is the call graph for this function:


Member Data Documentation

const unsigned long nsIWebNavigationInfo::IMAGE = 1 [inherited]

Returned by isTypeSupported to indicate that a type is supported as an image.

Definition at line 63 of file nsIWebNavigationInfo.idl.

Definition at line 70 of file nsWebNavigationInfo.h.

Definition at line 74 of file nsWebNavigationInfo.h.

const unsigned long nsIWebNavigationInfo::OTHER = 1 << 15 [inherited]

Returned by isTypeSupported to indicate that a type is supported via some other means.

Note:
Other return types may be added here in the future as they become relevant.

Definition at line 81 of file nsIWebNavigationInfo.idl.

const unsigned long nsIWebNavigationInfo::PLUGIN = 2 [inherited]

Returned by isTypeSupported to indicate that a type is supported via an NPAPI ("Netscape 4 API") plug-in.

This is not the value returned for "XPCOM plug-ins".

Definition at line 70 of file nsIWebNavigationInfo.idl.

const unsigned long nsIWebNavigationInfo::UNSUPPORTED = 0 [inherited]

Returned by isTypeSupported to indicate lack of support for a type.

Note:
this is guaranteed not to change, so that boolean tests can be done on the return value if isTypeSupported to detect whether a type is supported at all.

Definition at line 57 of file nsIWebNavigationInfo.idl.


The documentation for this class was generated from the following files: