B2G/gecko/dom/apps/src/Webapps.jsm
// aNext() is called after we load the current webapps list.
aNext() is called after we load the current webapps list.
aNext () is called after we load the current webapps list .
function loadCurrentRegistry(aNext) {
    let file = FileUtils.getFile(DIRECTORY_NAME, ["webapps", "webapps.json"], false);
    if (file && file.exists()) {
      this._loadJSONAsync(file, (function loadRegistry(aData) {
        if (aData) {
          this.webapps = aData;
          let appDir = FileUtils.getDir(DIRECTORY_NAME, ["webapps"], false);
          for (let id in this.webapps) {
            let app = this.webapps[id];
            if (!app) {
              delete this.webapps[id];
              continue;
            }
            app.id = id;
            if (app.localId === undefined) {
              app.localId = this._nextLocalId();
            }
            if (app.basePath === undefined) {
              app.basePath = appDir.path;
            }
            if (app.removable === undefined) {
              app.removable = true;
            }
            if (app.appStatus === undefined) {
              app.appStatus = Ci.nsIPrincipal.APP_STATUS_INSTALLED;
            }
            if (app.installerAppId === undefined) {
              app.installerAppId = Ci.nsIScriptSecurityManager.NO_APP_ID;
            }
            if (app.installerIsBrowser === undefined) {
              app.installerIsBrowser = false;
            }
            if (app.installState === undefined ||
                app.installState === "updating") {
              app.installState = "installed";
            }
            if (this.webapps[id].storeId === undefined) {
              this.webapps[id].storeId = "";
            }
            if (this.webapps[id].storeVersion === undefined) {
              this.webapps[id].storeVersion = 0;
            }
            app.downloading = false;
            app.readyToApplyDownload = false;
          };
        }
        aNext();
      }).bind(this));
    } else {
      aNext();
    }
  }
function loadCurrentRegistry ( aNext ) { let file = FileUtils . getFile ( DIRECTORY_NAME , [ "webapps" , "webapps.json" ] , false ) ; if ( file && file . exists ( ) ) { this . _loadJSONAsync ( file , ( function loadRegistry ( aData ) { if ( aData ) { this . webapps = aData ; let appDir = FileUtils . getDir ( DIRECTORY_NAME , [ "webapps" ] , false ) ; for ( let id in this . webapps ) { let app = this . webapps [ id ] ; if ( ! app ) { delete this . webapps [ id ] ; continue ; } app . id = id ; if ( app . localId === undefined ) { app . localId = this . _nextLocalId ( ) ; } if ( app . basePath === undefined ) { app . basePath = appDir . path ; } if ( app . removable === undefined ) { app . removable = true ; } if ( app . appStatus === undefined ) { app . appStatus = Ci . nsIPrincipal . APP_STATUS_INSTALLED ; } if ( app . installerAppId === undefined ) { app . installerAppId = Ci . nsIScriptSecurityManager . NO_APP_ID ; } if ( app . installerIsBrowser === undefined ) { app . installerIsBrowser = false ; } if ( app . installState === undefined || app . installState === "updating" ) { app . installState = "installed" ; } if ( this . webapps [ id ] . storeId === undefined ) { this . webapps [ id ] . storeId = "" ; } if ( this . webapps [ id ] . storeVersion === undefined ) { this . webapps [ id ] . storeVersion = 0 ; } app . downloading = false ; app . readyToApplyDownload = false ; } ; } aNext ( ) ; } ) . bind ( this ) ) ; } else { aNext ( ) ; } }
aNext() is called after we load the current webapps list.
aNext () is called after we load the current webapps list .
// Make sure we have a localId // Default to removable apps. // Default to a non privileged status. // Default to NO_APP_ID and not in browser. // Default installState to "installed", and reset if we shutdown // during an update. // Default storeId to "" and storeVersion to 0 // At startup we can't be downloading, and the $TMP directory // will be empty so we can't just apply a staged update.