Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes
nsCommandManager Class Reference

#include <nsCommandManager.h>

Inheritance diagram for nsCommandManager:
Inheritance graph
Collaboration diagram for nsCommandManager:
Collaboration graph

List of all members.

Public Member Functions

 nsCommandManager ()
virtual ~nsCommandManager ()
void addCommandObserver (in nsIObserver aCommandObserver, in string aCommandToObserve)
void removeCommandObserver (in nsIObserver aCommandObserver, in string aCommandObserved)
boolean isCommandSupported (in string aCommandName, in nsIDOMWindow aTargetWindow)
boolean isCommandEnabled (in string aCommandName, in nsIDOMWindow aTargetWindow)
void getCommandState (in string aCommandName, in nsIDOMWindow aTargetWindow, in nsICommandParams aCommandParams)
void doCommand (in string aCommandName, in nsICommandParams aCommandParams, in nsIDOMWindow aTargetWindow)
void init (in nsIDOMWindow aWindow)
void commandStatusChanged (in string aCommandName)

Protected Member Functions

nsresult IsCallerChrome (PRBool *aIsCallerChrome)
nsresult GetControllerForCommand (const char *aCommand, nsIDOMWindow *aDirectedToThisWindow, nsIController **outController)

Protected Attributes

nsSupportsHashtable mCommandObserversTable

Detailed Description

Definition at line 54 of file nsCommandManager.h.

Constructor & Destructor Documentation

Definition at line 61 of file nsCommandManager.cpp.

: mWindow(nsnull)
  /* member initializers and constructor code */

Definition at line 67 of file nsCommandManager.cpp.

  /* destructor code */

Member Function Documentation

void nsICommandManager::addCommandObserver ( in nsIObserver  aCommandObserver,
in string  aCommandToObserve 
) [inherited]
void nsPICommandUpdater::commandStatusChanged ( in string  aCommandName) [inherited]
void nsICommandManager::doCommand ( in string  aCommandName,
in nsICommandParams  aCommandParams,
in nsIDOMWindow  aTargetWindow 
) [inherited]
void nsICommandManager::getCommandState ( in string  aCommandName,
in nsIDOMWindow  aTargetWindow,
in nsICommandParams  aCommandParams 
) [inherited]
nsresult nsCommandManager::GetControllerForCommand ( const char *  aCommand,
nsIDOMWindow aDirectedToThisWindow,
nsIController **  outController 
) [protected]

Definition at line 281 of file nsCommandManager.cpp.

  nsresult rv = NS_ERROR_FAILURE;
  *outController = nsnull;

  // check if we're in content or chrome
  // if we're not chrome we must have a target window or we bail
  PRBool isChrome = PR_FALSE;
  rv = IsCallerChrome(&isChrome);
  if (NS_FAILED(rv))
    return rv;

  if (!isChrome) {
    if (!aTargetWindow)
      return rv;

    // if a target window is specified, it must be the window we expect
    if (aTargetWindow != mWindow)
        return NS_ERROR_FAILURE;

  if (aTargetWindow)
    // get the controller for this particular window
    nsCOMPtr<nsIDOMWindowInternal> domWindowInternal = do_QueryInterface(aTargetWindow);
    if (!domWindowInternal)
      return NS_ERROR_FAILURE;

    nsCOMPtr<nsIControllers> controllers;
    rv = domWindowInternal->GetControllers(getter_AddRefs(controllers));
    if (NS_FAILED(rv))
      return rv;
    if (!controllers)
      return NS_ERROR_FAILURE;

    // dispatch the command
    return controllers->GetControllerForCommand(aCommand, outController);

  // else we're not targeted to a particular window so use focus
  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(mWindow);
  if (!window)
    return NS_ERROR_FAILURE;

  nsIFocusController *focusController = window->GetRootFocusController();
  if (!focusController)
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsIDOMWindowInternal> focusWindowInternal;
  rv = focusController->GetFocusedWindow(getter_AddRefs(focusWindowInternal));
  if (NS_FAILED(rv))
    return rv;

  // get the destination window so we can check if it's in content or chrome
  nsCOMPtr<nsIDOMWindow> destWindow = do_QueryInterface(focusWindowInternal);
  if (!destWindow)
    return NS_ERROR_FAILURE;

  // no target window; send command to focus controller
  return focusController->GetControllerForCommand(aCommand, outController);

Here is the call graph for this function:

void nsPICommandUpdater::init ( in nsIDOMWindow  aWindow) [inherited]
nsresult nsCommandManager::IsCallerChrome ( PRBool aIsCallerChrome) [protected]

Definition at line 265 of file nsCommandManager.cpp.

  *is_caller_chrome = PR_FALSE;
  nsresult rv = NS_OK;
  nsCOMPtr<nsIScriptSecurityManager> secMan = 
  if (NS_FAILED(rv))
    return rv;
  if (!secMan)
    return NS_ERROR_FAILURE;

  rv = secMan->SubjectPrincipalIsSystem(is_caller_chrome);
  return rv;

Here is the call graph for this function:

Here is the caller graph for this function:

boolean nsICommandManager::isCommandEnabled ( in string  aCommandName,
in nsIDOMWindow  aTargetWindow 
) [inherited]
boolean nsICommandManager::isCommandSupported ( in string  aCommandName,
in nsIDOMWindow  aTargetWindow 
) [inherited]
void nsICommandManager::removeCommandObserver ( in nsIObserver  aCommandObserver,
in string  aCommandObserved 
) [inherited]

Member Data Documentation

nsSupportsHashtable nsCommandManager::mCommandObserversTable [protected]

Definition at line 85 of file nsCommandManager.h.

Definition at line 87 of file nsCommandManager.h.

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