Bug 750554 - If service is not used for updates then do not show it in preferences. r=bbondy

This commit is contained in:
Pranav Ravichandran 2012-05-31 10:28:01 -04:00
parent 5b1b2aa3b0
commit a74d2889e8
3 changed files with 38 additions and 7 deletions

View File

@ -5,6 +5,7 @@
// Load DownloadUtils module for convertByteUnits
Components.utils.import("resource://gre/modules/DownloadUtils.jsm");
Components.utils.import("resource://gre/modules/ctypes.jsm");
var gAdvancedPane = {
_inited: false,
@ -52,7 +53,7 @@ var gAdvancedPane = {
var preference = document.getElementById("browser.preferences.advanced.selectedTabIndex");
preference.valueFromPreferences = advancedPrefs.selectedIndex;
},
// GENERAL TAB
/*
@ -170,7 +171,7 @@ var gAdvancedPane = {
document.documentElement.openSubDialog("chrome://browser/content/preferences/connection.xul",
"", null);
},
// Retrieves the amount of space currently used by disk or offline cache
updateActualCacheSize: function (device)
{
@ -220,7 +221,7 @@ var gAdvancedPane = {
var disabled = document.getElementById("browser.cache.disk.smart_size.enabled").value;
this.updateCacheSizeUI(!disabled);
},
/**
* Converts the cache size from units of KB to units of MB and returns that
* value.
@ -451,7 +452,7 @@ var gAdvancedPane = {
* based on the pref values and locked states.
*
* UI state matrix for update preference conditions
*
*
* UI Components: Preferences
* Radiogroup i = app.update.enabled
* Warn before disabling extensions checkbox ii = app.update.auto
@ -517,6 +518,24 @@ var gAdvancedPane = {
if (installed != 1) {
document.getElementById("useService").hidden = true;
}
try {
const DRIVE_FIXED = 3;
const LPCWSTR = ctypes.jschar.ptr;
const UINT = ctypes.uint32_t;
let kernel32 = ctypes.open("kernel32");
let GetDriveType = kernel32.declare("GetDriveTypeW", ctypes.default_abi, UINT, LPCWSTR);
var UpdatesDir = Components.classes["@mozilla.org/updates/update-service;1"].
getService(Components.interfaces.nsIApplicationUpdateService);
let rootPath = UpdatesDir.getUpdatesDirectory();
while (rootPath.parent != null) {
rootPath = rootPath.parent;
}
if (GetDriveType(rootPath.path) != DRIVE_FIXED) {
document.getElementById("useService").hidden = true;
}
kernel32.close();
} catch(e) {
}
#endif
},
@ -635,7 +654,7 @@ var gAdvancedPane = {
*/
showCRLs: function ()
{
document.documentElement.openWindow("mozilla:crlmanager",
document.documentElement.openWindow("mozilla:crlmanager",
"chrome://pippki/content/crlManager.xul",
"", null);
},

View File

@ -12,13 +12,14 @@ interface nsIRequest;
interface nsIRequestObserver;
interface nsISimpleEnumerator;
interface nsIXMLHttpRequest;
interface nsIFile;
/**
* An interface that describes an object representing a patch file that can
* be downloaded and applied to a version of this application so that it
* can be updated.
*/
[scriptable, uuid(60523512-bb69-417c-9b2c-87a0664b0bbe)]
[scriptable, uuid(1134957d-9449-481b-a515-4d88b9998278)]
interface nsIUpdatePatch : nsISupports
{
/**
@ -399,6 +400,12 @@ interface nsIApplicationUpdateService : nsISupports
*/
void applyUpdateInBackground(in nsIUpdate update);
/**
* Get the Active Updates directory
* @returns The active updates directory.
*/
nsIFile getUpdatesDirectory();
/**
* Pauses the active update download process
*/

View File

@ -11,7 +11,7 @@ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/FileUtils.jsm");
Components.utils.import("resource://gre/modules/AddonManager.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/ctypes.jsm")
Components.utils.import("resource://gre/modules/ctypes.jsm");
const Cc = Components.classes;
const Ci = Components.interfaces;
@ -2144,6 +2144,11 @@ UpdateService.prototype = {
this._downloader.cancel();
},
/**
* See nsIUpdateService.idl
*/
getUpdatesDirectory: getUpdatesDir,
/**
* See nsIUpdateService.idl
*/