Commit 77911958 authored by aceman's avatar aceman
Browse files

Bug 714606 - Use Services.prompt instead of gPromptService in Toolkit. r=mossop

parent f65eb324
Loading
Loading
Loading
Loading
+14 −15
Original line number Diff line number Diff line
@@ -38,10 +38,10 @@
#
# ***** END LICENSE BLOCK *****

Components.utils.import("resource://gre/modules/Services.jsm");

const nsIPrefLocalizedString = Components.interfaces.nsIPrefLocalizedString;
const nsISupportsString = Components.interfaces.nsISupportsString;
const nsIPromptService = Components.interfaces.nsIPromptService;
const nsIPrefService = Components.interfaces.nsIPrefService;
const nsIPrefBranch = Components.interfaces.nsIPrefBranch;
const nsIClipboardHelper = Components.interfaces.nsIClipboardHelper;
const nsIAtomService = Components.interfaces.nsIAtomService;
@@ -52,9 +52,7 @@ const nsPrefService_CONTRACTID = "@mozilla.org/preferences-service;1";
const nsClipboardHelper_CONTRACTID = "@mozilla.org/widget/clipboardhelper;1";
const nsAtomService_CONTRACTID = "@mozilla.org/atom-service;1";

const gPromptService = Components.classes[nsPrompt_CONTRACTID].getService(nsIPromptService);
const gPrefService = Components.classes[nsPrefService_CONTRACTID].getService(nsIPrefService);
const gPrefBranch = gPrefService.getBranch(null);
const gPrefBranch = Services.prefs.getBranch(null);
const gClipboardHelper = Components.classes[nsClipboardHelper_CONTRACTID].getService(nsIClipboardHelper);
const gAtomService = Components.classes[nsAtomService_CONTRACTID].getService(nsIAtomService);

@@ -604,8 +602,9 @@ function NewPref(type)
{
  var result = { value: "" };
  var dummy = { value: 0 };
  if (gPromptService.prompt(window,
                            gConfigBundle.getFormattedString("new_title", [gTypeStrs[type]]),
  if (Services.prompt.prompt(window,
                             gConfigBundle.getFormattedString("new_title",
                                                              [gTypeStrs[type]]),
                             gConfigBundle.getString("new_prompt"),
                             result,
                             null,
@@ -645,13 +644,13 @@ function ModifyPref(entry)
  var title = gConfigBundle.getFormattedString("modify_title", [gTypeStrs[entry.typeCol]]);
  if (entry.typeCol == nsIPrefBranch.PREF_BOOL) {
    var check = { value: entry.valueCol == "false" };
    if (!entry.valueCol && !gPromptService.select(window, title, entry.prefCol, 2, [false, true], check))
    if (!entry.valueCol && !Services.prompt.select(window, title, entry.prefCol, 2, [false, true], check))
      return false;
    gPrefBranch.setBoolPref(entry.prefCol, check.value);
  } else {
    var result = { value: entry.valueCol };
    var dummy = { value: 0 };
    if (!gPromptService.prompt(window, title, entry.prefCol, result, null, dummy))
    if (!Services.prompt.prompt(window, title, entry.prefCol, result, null, dummy))
      return false;
    if (entry.typeCol == nsIPrefBranch.PREF_INT) {
      // | 0 converts to integer or 0; - 0 to float or NaN.
@@ -660,7 +659,7 @@ function ModifyPref(entry)
      if (val != result.value - 0) {
        var err_title = gConfigBundle.getString("nan_title");
        var err_text = gConfigBundle.getString("nan_text");
        gPromptService.alert(window, err_title, err_text);
        Services.prompt.alert(window, err_title, err_text);
        return false;
      }
      gPrefBranch.setIntPref(entry.prefCol, val);
@@ -671,6 +670,6 @@ function ModifyPref(entry)
    }
  }

  gPrefService.savePrefFile(null);
  Services.prefs.savePrefFile(null);
  return true;
}
+6 −7
Original line number Diff line number Diff line
@@ -36,7 +36,9 @@
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
var gPromptService;

Components.utils.import("resource://gre/modules/Services.jsm");

var gFindBundle;

function nsFindInstData() {}
@@ -122,13 +124,10 @@ function findAgainInPage(findInstData, reverse)

    var found = findInst.findNext();
    if (!found) {
      if (!gPromptService)
        gPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService()
                                   .QueryInterface(Components.interfaces.nsIPromptService);                                     
      if (!gFindBundle)
        gFindBundle = document.getElementById("findBundle");

      gPromptService.alert(window, gFindBundle.getString("notFoundTitle"), gFindBundle.getString("notFoundWarning"));
      Services.prompt.alert(window, gFindBundle.getString("notFoundTitle"), gFindBundle.getString("notFoundWarning"));
    }

    // Reset to normal value, otherwise setting can get changed in find dialog
+10 −12
Original line number Diff line number Diff line
@@ -41,17 +41,17 @@
 *
 * ***** END LICENSE BLOCK ***** */

Components.utils.import("resource://gre/modules/Services.jsm");

const C = Components.classes;
const I = Components.interfaces;

const ToolkitProfileService = "@mozilla.org/toolkit/profile-service;1";
const PromptService = "@mozilla.org/embedcomp/prompt-service;1";

var gDialogParams;
var gProfileManagerBundle;
var gBrandBundle;
var gProfileService;
var gPromptService;

function startup()
{
@@ -64,8 +64,6 @@ function startup()
    gProfileManagerBundle = document.getElementById("bundle_profileManager");
    gBrandBundle = document.getElementById("bundle_brand");

    gPromptService = C[PromptService].getService(I.nsIPromptService);

    document.documentElement.centerWindowOnScreen();

    var profilesElement = document.getElementById("profiles");
@@ -112,7 +110,7 @@ function acceptDialog()
    var pleaseSelectTitle = gProfileManagerBundle.getString("pleaseSelectTitle");
    var pleaseSelect =
      gProfileManagerBundle.getFormattedString("pleaseSelect", [appName]);
    gPromptService.alert(window, pleaseSelectTitle, pleaseSelect);
    Services.prompt.alert(window, pleaseSelectTitle, pleaseSelect);

    return false;
  }
@@ -126,7 +124,7 @@ function acceptDialog()
    var lockedTitle = gProfileManagerBundle.getString("profileLockedTitle");
    var locked =
      gProfileManagerBundle.getFormattedString("profileLocked2", [appName, selectedProfile.profile.name, appName]);
    gPromptService.alert(window, lockedTitle, locked);
    Services.prompt.alert(window, lockedTitle, locked);

    return false;
  }
@@ -222,7 +220,7 @@ function RenameProfile()
  var msg =
    gProfileManagerBundle.getFormattedString("renameProfilePrompt", [oldName]);

  if (gPromptService.prompt(window, dialogTitle, msg, newName, null, {value:0})) {
  if (Services.prompt.prompt(window, dialogTitle, msg, newName, null, {value:0})) {
    newName = newName.value;

    // User hasn't changed the profile name. Treat as if cancel was pressed.
@@ -235,7 +233,7 @@ function RenameProfile()
    catch (e) {
      var alTitle = gProfileManagerBundle.getString("profileNameInvalidTitle");
      var alMsg = gProfileManagerBundle.getFormattedString("profileNameInvalid", [newName]);
      gPromptService.alert(window, alTitle, alMsg);
      Services.prompt.alert(window, alTitle, alMsg);
      return false;
    }

@@ -270,10 +268,10 @@ function ConfirmDelete()
      gProfileManagerBundle.getFormattedString("deleteProfileConfirm",
                                               [selectedProfile.rootDir.path]);

    var buttonPressed = gPromptService.confirmEx(window, dialogTitle, dialogText,
                          (gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_0) +
                          (gPromptService.BUTTON_TITLE_CANCEL * gPromptService.BUTTON_POS_1) +
                          (gPromptService.BUTTON_TITLE_IS_STRING * gPromptService.BUTTON_POS_2),
    var buttonPressed = Services.prompt.confirmEx(window, dialogTitle, dialogText,
                          (Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0) +
                          (Services.prompt.BUTTON_TITLE_CANCEL * Services.prompt.BUTTON_POS_1) +
                          (Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_2),
                          gProfileManagerBundle.getString("dontDeleteFiles"),
                          null,
                          gProfileManagerBundle.getString("deleteFiles"),