Back to index

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

#include <nsSecurityWarningDialogs.h>

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

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSISECURITYWARNINGDIALOGS 
nsSecurityWarningDialogs ()
virtual ~nsSecurityWarningDialogs ()
nsresult Init ()
boolean confirmEnteringSecure (in nsIInterfaceRequestor ctx)
 Inform the user that a transition from an insecure page to a secure page is happening.
boolean confirmEnteringWeak (in nsIInterfaceRequestor ctx)
 Inform the user that a transition from an insecure page or from a secure page to a weak security page is happening.
boolean confirmLeavingSecure (in nsIInterfaceRequestor ctx)
 Inform the user that a transition from a secure page to an insecure page is happening.
boolean confirmMixedMode (in nsIInterfaceRequestor ctx)
 Inform the user the currently displayed page contains some secure and some insecure page components.
boolean confirmPostToInsecure (in nsIInterfaceRequestor ctx)
 Inform the user that information is being submitted to an insecure page.
boolean confirmPostToInsecureFromSecure (in nsIInterfaceRequestor ctx)
 Inform the user: Although the currently displayed page was loaded using a secure connection, and the UI probably currently indicates a secure page, that information is being submitted to an insecure page.

Protected Member Functions

nsresult AlertDialog (nsIInterfaceRequestor *ctx, const char *prefName, const PRUnichar *messageName, const PRUnichar *showAgainName)
nsresult ConfirmDialog (nsIInterfaceRequestor *ctx, const char *prefName, const PRUnichar *messageName, const PRUnichar *showAgainName, PRBool *_result)

Protected Attributes

nsCOMPtr< nsIStringBundlemStringBundle
nsCOMPtr< nsIPrefBranchmPrefBranch

Detailed Description

Definition at line 48 of file nsSecurityWarningDialogs.h.


Constructor & Destructor Documentation

Definition at line 64 of file nsSecurityWarningDialogs.cpp.

{
}

Definition at line 68 of file nsSecurityWarningDialogs.cpp.

{
}

Member Function Documentation

nsresult nsSecurityWarningDialogs::AlertDialog ( nsIInterfaceRequestor ctx,
const char *  prefName,
const PRUnichar messageName,
const PRUnichar showAgainName 
) [protected]

Definition at line 143 of file nsSecurityWarningDialogs.cpp.

{
  nsresult rv;

  // Get user's preference for this alert
  PRBool prefValue;
  rv = mPrefBranch->GetBoolPref(prefName, &prefValue);
  if (NS_FAILED(rv)) prefValue = PR_TRUE;

  // Stop if alert is not requested
  if (!prefValue) return NS_OK;

  // Check for a show-once pref for this dialog.
  // If the show-once pref is set to true:
  //   - The default value of the "show every time" checkbox is unchecked
  //   - If the user checks the checkbox, we clear the show-once pref.

  nsCAutoString showOncePref(prefName);
  showOncePref += ".show_once";

  PRBool showOnce = PR_FALSE;
  mPrefBranch->GetBoolPref(showOncePref.get(), &showOnce);

  if (showOnce)
    prefValue = PR_FALSE;

  // Get Prompt to use
  nsCOMPtr<nsIPrompt> prompt = do_GetInterface(ctx);
  if (!prompt) return NS_ERROR_FAILURE;

  // Get messages strings from localization file
  nsXPIDLString windowTitle, message, dontShowAgain;

  mStringBundle->GetStringFromName(NS_LITERAL_STRING("Title").get(),
                                   getter_Copies(windowTitle));
  mStringBundle->GetStringFromName(dialogMessageName,
                                   getter_Copies(message));
  mStringBundle->GetStringFromName(showAgainName,
                                   getter_Copies(dontShowAgain));
  if (!windowTitle || !message || !dontShowAgain) return NS_ERROR_FAILURE;

  rv = prompt->AlertCheck(windowTitle, message, dontShowAgain, &prefValue);
  if (NS_FAILED(rv)) return rv;
      
  if (!prefValue) {
    mPrefBranch->SetBoolPref(prefName, PR_FALSE);
  } else if (showOnce) {
    mPrefBranch->SetBoolPref(showOncePref.get(), PR_FALSE);
  }

  return rv;
}

Here is the call graph for this function:

nsresult nsSecurityWarningDialogs::ConfirmDialog ( nsIInterfaceRequestor ctx,
const char *  prefName,
const PRUnichar messageName,
const PRUnichar showAgainName,
PRBool _result 
) [protected]

Definition at line 225 of file nsSecurityWarningDialogs.cpp.

{
  nsresult rv;

  // Get user's preference for this alert
  // prefName, showAgainName are null if there is no preference for this dialog
  PRBool prefValue = PR_TRUE;
  
  if (prefName != nsnull) {
    rv = mPrefBranch->GetBoolPref(prefName, &prefValue);
    if (NS_FAILED(rv)) prefValue = PR_TRUE;
  }
  
  // Stop if confirm is not requested
  if (!prefValue) {
    *_result = PR_TRUE;
    return NS_OK;
  }
  
  // See AlertDialog() for a description of how showOnce works.
  nsCAutoString showOncePref(prefName);
  showOncePref += ".show_once";

  PRBool showOnce = PR_FALSE;
  mPrefBranch->GetBoolPref(showOncePref.get(), &showOnce);

  if (showOnce)
    prefValue = PR_FALSE;

  // Get Prompt to use
  nsCOMPtr<nsIPrompt> prompt = do_GetInterface(ctx);
  if (!prompt) return NS_ERROR_FAILURE;

  // Get messages strings from localization file
  nsXPIDLString windowTitle, message, alertMe, cont;

  mStringBundle->GetStringFromName(NS_LITERAL_STRING("Title").get(),
                                   getter_Copies(windowTitle));
  mStringBundle->GetStringFromName(messageName,
                                   getter_Copies(message));
  if (showAgainName != nsnull) {
    mStringBundle->GetStringFromName(showAgainName,
                                     getter_Copies(alertMe));
  }
  mStringBundle->GetStringFromName(NS_LITERAL_STRING("Continue").get(),
                                   getter_Copies(cont));
  // alertMe is allowed to be null
  if (!windowTitle || !message || !cont) return NS_ERROR_FAILURE;
      
  // Replace # characters with newlines to lay out the dialog.
  PRUnichar* msgchars = message.BeginWriting();
  
  PRUint32 i = 0;
  for (i = 0; msgchars[i] != '\0'; i++) {
    if (msgchars[i] == '#') {
      msgchars[i] = '\n';
    }
  }  

  PRInt32 buttonPressed;

  rv  = prompt->ConfirmEx(windowTitle, 
                          message, 
                          (nsIPrompt::BUTTON_TITLE_IS_STRING * nsIPrompt::BUTTON_POS_0) +
                          (nsIPrompt::BUTTON_TITLE_CANCEL * nsIPrompt::BUTTON_POS_1),
                          cont,
                          nsnull,
                          nsnull,
                          alertMe, 
                          &prefValue, 
                          &buttonPressed);

  if (NS_FAILED(rv)) return rv;

  *_result = (buttonPressed != 1);

  if (!prefValue && prefName != nsnull) {
    mPrefBranch->SetBoolPref(prefName, PR_FALSE);
  } else if (prefValue && showOnce) {
    mPrefBranch->SetBoolPref(showOncePref.get(), PR_FALSE);
  }

  return rv;
}

Here is the call graph for this function:

Inform the user that a transition from an insecure page to a secure page is happening.

Parameters:
ctxA user interface context.
Returns:
true if the user confirms to continue

Inform the user that a transition from an insecure page or from a secure page to a weak security page is happening.

Parameters:
ctxA user interface context.
Returns:
true if the user confirms to continue

Inform the user that a transition from a secure page to an insecure page is happening.

Parameters:
ctxA user interface context.
Returns:
true if the user confirms to continue

Inform the user the currently displayed page contains some secure and some insecure page components.

Parameters:
ctxA user interface context.
Returns:
true if the user decides to show insecure objects.

Inform the user that information is being submitted to an insecure page.

Parameters:
ctxA user interface context.
Returns:
true if the user confirms to submit.

Inform the user: Although the currently displayed page was loaded using a secure connection, and the UI probably currently indicates a secure page, that information is being submitted to an insecure page.

Parameters:
ctxA user interface context.
Returns:
true if the user confirms to submit.

Definition at line 73 of file nsSecurityWarningDialogs.cpp.

{
  nsresult rv;

  mPrefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
  if (NS_FAILED(rv)) return rv;

  nsCOMPtr<nsIStringBundleService> service = do_GetService(kCStringBundleServiceCID, &rv);
  if (NS_FAILED(rv)) return rv;
  
  rv = service->CreateBundle(STRING_BUNDLE_URL,
                             getter_AddRefs(mStringBundle));
  return rv;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 67 of file nsSecurityWarningDialogs.h.

Definition at line 66 of file nsSecurityWarningDialogs.h.


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