Merge m-c to m-i harder

This commit is contained in:
Phil Ringnalda 2013-07-05 07:42:16 -07:00
commit 8be2814f99
4 changed files with 32 additions and 42 deletions

View File

@ -56,15 +56,9 @@ public final class Distribution {
return;
}
// This pref stores the path to the distribution directory. If it is null, Gecko
// looks for distribution files in /data/data/org.mozilla.xxx/distribution.
String pathKeyName = context.getPackageName() + ".distribution_path";
String distPath = null;
// Send a message to Gecko if we've set a distribution.
if (state == STATE_SET) {
distPath = settings.getString(pathKeyName, null);
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Distribution:Set", distPath));
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Distribution:Set", ""));
return;
}
@ -81,13 +75,11 @@ public final class Distribution {
File distDir = new File("/system/" + context.getPackageName() + "/distribution");
if (distDir.exists()) {
distributionSet = true;
distPath = distDir.getPath();
settings.edit().putString(pathKeyName, distPath).commit();
}
}
if (distributionSet) {
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Distribution:Set", distPath));
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Distribution:Set", ""));
settings.edit().putInt(keyName, STATE_SET).commit();
} else {
settings.edit().putInt(keyName, STATE_NONE).commit();

View File

@ -7351,9 +7351,6 @@ var Distribution = {
// File used to store campaign data
_file: null,
// Path to distribution directory for distribution customizations
_path: null,
init: function dc_init() {
Services.obs.addObserver(this, "Distribution:Set", false);
Services.obs.addObserver(this, "prefservice:after-app-defaults", false);
@ -7375,8 +7372,6 @@ var Distribution = {
observe: function dc_observe(aSubject, aTopic, aData) {
switch (aTopic) {
case "Distribution:Set":
this._path = aData;
// Reload the default prefs so we can observe "prefservice:after-app-defaults"
Services.prefs.QueryInterface(Ci.nsIObserver).observe(null, "reload-default-prefs", null);
break;
@ -7417,20 +7412,12 @@ var Distribution = {
},
getPrefs: function dc_getPrefs() {
let file;
if (this._path) {
file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
file.initWithPath(this._path);
// Store the path in a pref for DirectoryProvider to read.
Services.prefs.setCharPref("distribution.path", this._path);
} else {
// If a path isn't specified, look in the data directory:
// /data/data/org.mozilla.xxx/distribution
file = Services.dirsvc.get("XCurProcD", Ci.nsIFile);
file.append("distribution");
}
file.append("preferences.json");
// Get the distribution directory, and bail if it doesn't exist.
let file = FileUtils.getDir("XREAppDist", [], false);
if (!file.exists())
return;
file.append("preferences.json");
this.readJSON(file, this.applyPrefs);
},

View File

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#filter substitution
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
@ -19,10 +21,13 @@ const NS_APP_SEARCH_DIR = "SrchPlugns";
const NS_APP_SEARCH_DIR_LIST = "SrchPluginsDL";
const NS_APP_USER_SEARCH_DIR = "UsrSrchPlugns";
const NS_XPCOM_CURRENT_PROCESS_DIR = "XCurProcD";
const XRE_APP_DISTRIBUTION_DIR = "XREAppDist";
const XRE_UPDATE_ROOT_DIR = "UpdRootD";
const ENVVAR_UPDATE_DIR = "UPDATES_DIRECTORY";
const WEBAPPS_DIR = "webappsDir";
const SYSTEM_DIST_PATH = "/system/@ANDROID_PACKAGE_NAME@/distribution";
function DirectoryProvider() {}
DirectoryProvider.prototype = {
@ -43,6 +48,19 @@ DirectoryProvider.prototype = {
let dirsvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
let profile = dirsvc.get("ProfD", Ci.nsIFile);
return profile.parent;
} else if (prop == XRE_APP_DISTRIBUTION_DIR) {
// First, check to see if there's a distribution in the data directory.
let dataDist = FileUtils.getDir(NS_XPCOM_CURRENT_PROCESS_DIR, ["distribution"], false);
if (!dataDist.exists()) {
// Then check to see if there's distribution in the system directory.
let systemDist = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
systemDist.initWithPath(SYSTEM_DIST_PATH);
// Only return the system distribution location if it exists.
if (systemDist.exists()) {
return systemDist;
}
}
return dataDist;
} else if (prop == XRE_UPDATE_ROOT_DIR) {
let env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
if (env.exists(ENVVAR_UPDATE_DIR)) {
@ -80,20 +98,9 @@ DirectoryProvider.prototype = {
* which specifies a default locale to use.
*/
_appendDistroSearchDirs: function(array) {
let distro = FileUtils.getDir(NS_XPCOM_CURRENT_PROCESS_DIR, ["distribution"], false);
if (!distro.exists()) {
// If there's no distribution in the data directory, check for a system distribution.
let path;
try {
path = Services.prefs.getCharPref("distribution.path");
} catch (e) { }
if (!path)
return;
distro = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
distro.initWithPath(path);
}
let distro = this.getFile(XRE_APP_DISTRIBUTION_DIR);
if (!distro.exists())
return;
let searchPlugins = distro.clone();
searchPlugins.append("searchplugins");

View File

@ -25,4 +25,8 @@ EXTRA_COMPONENTS = \
FilePicker.js \
$(NULL)
DEFINES += \
-DANDROID_PACKAGE_NAME=$(ANDROID_PACKAGE_NAME) \
$(NULL)
include $(topsrcdir)/config/rules.mk