B2G/gaia/apps/homescreen/js/grid.js
/*
   * Initialize the mozApps event handlers and synchronize our grid
   * state with the applications known to the system.
   */
Initialize the mozApps event handlers and synchronize our grid
state with the applications known to the system.
Initialize the mozApps event handlers and synchronize our grid state with the applications known to the system .
function initApps(apps) {
    var appMgr = navigator.mozApps.mgmt;
    appMgr.oninstall = function oninstall(event) {
     GridManager.install(event.application);
    };
    appMgr.onuninstall = function onuninstall(event) {
      GridManager.uninstall(event.application);
    };
    appMgr.getAll().onsuccess = function onsuccess(event) {
      var iconsByManifestURL = Object.create(null);
      for (var manifestURL in appIcons) {
        iconsByManifestURL[manifestURL] = appIcons[manifestURL];
      }
      pageHelper.addPage([]);
      var apps = event.target.result;
      apps.forEach(function eachApp(app) {
        delete iconsByManifestURL[app.manifestURL];
        processApp(app);
      });
      for (var origin in bookmarksByOrigin) {
        appsByOrigin[origin] = bookmarksByOrigin[origin];
      }
      bookmarksByOrigin = null;
      for (var manifestURL in iconsByManifestURL) {
        var iconsForApp = iconsByManifestURL[manifestURL];
        for (var entryPoint in iconsForApp) {
          var icon = iconsForApp[entryPoint];
          icon.remove();
          markDirtyState();
        }
      }
      ensurePagesOverflow(removeEmptyPages);
    };
  }
function initApps ( apps ) { var appMgr = navigator . mozApps . mgmt ; appMgr . oninstall = function oninstall ( event ) { GridManager . install ( event . application ) ; } ; appMgr . onuninstall = function onuninstall ( event ) { GridManager . uninstall ( event . application ) ; } ; appMgr . getAll ( ) . onsuccess = function onsuccess ( event ) { var iconsByManifestURL = Object . create ( null ) ; for ( var manifestURL in appIcons ) { iconsByManifestURL [ manifestURL ] = appIcons [ manifestURL ] ; } pageHelper . addPage ( [ ] ) ; var apps = event . target . result ; apps . forEach ( function eachApp ( app ) { delete iconsByManifestURL [ app . manifestURL ] ; processApp ( app ) ; } ) ; for ( var origin in bookmarksByOrigin ) { appsByOrigin [ origin ] = bookmarksByOrigin [ origin ] ; } bookmarksByOrigin = null ; for ( var manifestURL in iconsByManifestURL ) { var iconsForApp = iconsByManifestURL [ manifestURL ] ; for ( var entryPoint in iconsForApp ) { var icon = iconsForApp [ entryPoint ] ; icon . remove ( ) ; markDirtyState ( ) ; } } ensurePagesOverflow ( removeEmptyPages ) ; } ; }
Initialize the mozApps event handlers and synchronize our grid
 state with the applications known to the system.
Initialize the mozApps event handlers and synchronize our grid state with the applications known to the system .
// Create a copy of all icons we know about so we can find out which icons // should be removed. // Add an empty page where we drop the icons for any extra apps we // discover at this stage.