B2G/gecko/toolkit/mozapps/extensions/XPIProviderUtils.js
/**
   * Writes out the XPI add-ons list for the platform to read.
   */
Writes out the XPI add-ons list for the platform to read.
Writes out the XPI add - ons list for the platform to read .
function XPIDB_writeAddonsList() {
    Services.appinfo.invalidateCachesOnRestart();
    let addonsList = FileUtils.getFile(KEY_PROFILEDIR, [FILE_XPI_ADDONS_LIST],
                                       true);
    if (!this.connection) {
      try {
        addonsList.remove(false);
        LOG("Deleted add-ons list");
      }
      catch (e) {
      }
      Services.prefs.clearUserPref(PREF_EM_ENABLED_ADDONS);
      return;
    }
    let enabledAddons = [];
    let text = "[ExtensionDirs]\r\n";
    let count = 0;
    let fullCount = 0;
    let stmt = this.getStatement("getActiveAddons");
    for (let row in resultRows(stmt)) {
      text += "Extension" + (count++) + "=" + row.descriptor + "\r\n";
      enabledAddons.push(encodeURIComponent(row.id) + ":" +
                         encodeURIComponent(row.version));
    }
    fullCount += count;
    text += "\r\n[ThemeDirs]\r\n";
    let dssEnabled = false;
    try {
      dssEnabled = Services.prefs.getBoolPref(PREF_EM_DSS_ENABLED);
    } catch (e) {}
    if (dssEnabled) {
      stmt = this.getStatement("getThemes");
    }
    else {
      stmt = this.getStatement("getActiveTheme");
      stmt.params.internalName = XPIProvider.selectedSkin;
    }
    if (stmt) {
      count = 0;
      for (let row in resultRows(stmt)) {
        text += "Extension" + (count++) + "=" + row.descriptor + "\r\n";
        enabledAddons.push(encodeURIComponent(row.id) + ":" +
                           encodeURIComponent(row.version));
      }
      fullCount += count;
    }
    if (fullCount > 0) {
      LOG("Writing add-ons list");
      let addonsListTmp = FileUtils.getFile(KEY_PROFILEDIR, [FILE_XPI_ADDONS_LIST + ".tmp"],
                                            true);
      var fos = FileUtils.openFileOutputStream(addonsListTmp);
      fos.write(text, text.length);
      fos.close();
      addonsListTmp.moveTo(addonsListTmp.parent, FILE_XPI_ADDONS_LIST);
      Services.prefs.setCharPref(PREF_EM_ENABLED_ADDONS, enabledAddons.join(","));
    }
    else {
      if (addonsList.exists()) {
        LOG("Deleting add-ons list");
        addonsList.remove(false);
      }
      Services.prefs.clearUserPref(PREF_EM_ENABLED_ADDONS);
    }
  }
function XPIDB_writeAddonsList ( ) { Services . appinfo . invalidateCachesOnRestart ( ) ; let addonsList = FileUtils . getFile ( KEY_PROFILEDIR , [ FILE_XPI_ADDONS_LIST ] , true ) ; if ( ! this . connection ) { try { addonsList . remove ( false ) ; LOG ( "Deleted add-ons list" ) ; } catch ( e ) { } Services . prefs . clearUserPref ( PREF_EM_ENABLED_ADDONS ) ; return ; } let enabledAddons = [ ] ; let text = "[ExtensionDirs]\r\n" ; let count = 0 ; let fullCount = 0 ; let stmt = this . getStatement ( "getActiveAddons" ) ; for ( let row in resultRows ( stmt ) ) { text += "Extension" + ( count ++ ) + "=" + row . descriptor + "\r\n" ; enabledAddons . push ( encodeURIComponent ( row . id ) + ":" + encodeURIComponent ( row . version ) ) ; } fullCount += count ; text += "\r\n[ThemeDirs]\r\n" ; let dssEnabled = false ; try { dssEnabled = Services . prefs . getBoolPref ( PREF_EM_DSS_ENABLED ) ; } catch ( e ) { } if ( dssEnabled ) { stmt = this . getStatement ( "getThemes" ) ; } else { stmt = this . getStatement ( "getActiveTheme" ) ; stmt . params . internalName = XPIProvider . selectedSkin ; } if ( stmt ) { count = 0 ; for ( let row in resultRows ( stmt ) ) { text += "Extension" + ( count ++ ) + "=" + row . descriptor + "\r\n" ; enabledAddons . push ( encodeURIComponent ( row . id ) + ":" + encodeURIComponent ( row . version ) ) ; } fullCount += count ; } if ( fullCount > 0 ) { LOG ( "Writing add-ons list" ) ; let addonsListTmp = FileUtils . getFile ( KEY_PROFILEDIR , [ FILE_XPI_ADDONS_LIST + ".tmp" ] , true ) ; var fos = FileUtils . openFileOutputStream ( addonsListTmp ) ; fos . write ( text , text . length ) ; fos . close ( ) ; addonsListTmp . moveTo ( addonsListTmp . parent , FILE_XPI_ADDONS_LIST ) ; Services . prefs . setCharPref ( PREF_EM_ENABLED_ADDONS , enabledAddons . join ( "," ) ) ; } else { if ( addonsList . exists ( ) ) { LOG ( "Deleting add-ons list" ) ; addonsList . remove ( false ) ; } Services . prefs . clearUserPref ( PREF_EM_ENABLED_ADDONS ) ; } }
Writes out the XPI add-ons list for the platform to read.
Writes out the XPI add - ons list for the platform to read .
// The selected skin may come from an inactive theme (the default theme // when a lightweight theme is applied for example)