B2G/gecko/toolkit/mozapps/extensions/ChromeManifestParser.jsm
/**
   * Reads and parses a chrome manifest file located at a specified URI, and all
   * secondary manifests it references.
   *
   * @param  aURI
   *         A nsIURI pointing to a chrome manifest.
   *         Typically a file: or jar: URI.
   * @return Array of objects describing each manifest instruction, in the form:
   *         { type: instruction-type, baseURI: string-uri, args: [arguments] }
   **/
Reads and parses a chrome manifest file located at a specified URI, and all
secondary manifests it references.

@param  aURI
A nsIURI pointing to a chrome manifest.
Typically a file: or jar: URI.
@return Array of objects describing each manifest instruction, in the form:
{ type: instruction-type, baseURI: string-uri, args: [arguments] }
Reads and parses a chrome manifest file located at a specified URI and all secondary manifests it references . @param aURI A nsIURI pointing to a chrome manifest . Typically a file : or jar : URI . @return Array of objects describing each manifest instruction in the form : { type : instruction - type baseURI : string - uri args : [ arguments ] }
function CMP_parseSync(aURI) {
    function parseLine(aLine) {
      let line = aLine.trim();
      if (line.length == 0 || line.charAt(0) == '#')
        return;
      let tokens = line.split(/\s+/);
      let type = tokens.shift();
      if (type == "manifest") {
        let uri = NetUtil.newURI(tokens.shift(), null, aURI);
        data = data.concat(this.parseSync(uri));
      } else {
        data.push({type: type, baseURI: baseURI, args: tokens});
      }
    }
    let contents = "";
    try {
      if (aURI.scheme == "jar")
        contents = this._readFromJar(aURI);
      else
        contents = this._readFromFile(aURI);
    } catch (e) {
    }
    if (!contents)
      return [];
    let baseURI = NetUtil.newURI(".", null, aURI).spec;
    let data = [];
    let lines = contents.split("\n");
    lines.forEach(parseLine.bind(this));
    return data;
  }
function CMP_parseSync ( aURI ) { function parseLine ( aLine ) { let line = aLine . trim ( ) ; if ( line . length == 0 || line . charAt ( 0 ) == '#' ) return ; let tokens = line . split ( / \s+ / ) ; let type = tokens . shift ( ) ; if ( type == "manifest" ) { let uri = NetUtil . newURI ( tokens . shift ( ) , null , aURI ) ; data = data . concat ( this . parseSync ( uri ) ) ; } else { data . push ( { type : type , baseURI : baseURI , args : tokens } ) ; } } let contents = "" ; try { if ( aURI . scheme == "jar" ) contents = this . _readFromJar ( aURI ) ; else contents = this . _readFromFile ( aURI ) ; } catch ( e ) { } if ( ! contents ) return [ ] ; let baseURI = NetUtil . newURI ( "." , null , aURI ) . spec ; let data = [ ] ; let lines = contents . split ( "\n" ) ; lines . forEach ( parseLine . bind ( this ) ) ; return data ; }
Reads and parses a chrome manifest file located at a specified URI, and all
 secondary manifests it references.
Reads and parses a chrome manifest file located at a specified URI and all secondary manifests it references .
// Silently fail.
