Hatena::Groupmoz-addon

Ci.nsIZIGOROu

2008-03-12グリス

今の拡張スクリプトを晒す

| 15:28 |  今の拡張スクリプトを晒す - Ci.nsIZIGOROu を含むブックマーク はてなブックマーク -  今の拡張スクリプトを晒す - Ci.nsIZIGOROu

/**
 * browser startup service utility
 */
var browser = {
  startUpService: Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(Components.interfaces.nsIAppStartup),
  restart: function() {
    this.startUpService.quit(Components.interfaces.nsIAppStartup.eForceQuit | Components.interfaces.nsIAppStartup.eRestart); 
  },
  stop: function() {
    this.startUpService.quit(Components.interfaces.nsIAppStartup.eForceQuit); 
  }
}

/**
 * Open document for component from xulplanet.com
 */
function docForComponent(comp) {
    if (comp instanceof this.Ci.nsIJSCID) {
        comp = comp.toString();
    }

    if (!comp || !comp.match(/^@mozilla.org/)) {
        return;
    }

    var window = this.Cc["@mozilla.org/appshell/window-mediator;1"].getService(this.Ci.nsIWindowMediator).getMostRecentWindow("");
    var url = "http://www.xulplanet.com/references/xpcomref/comps/c_" + comp.replace("@mozilla.org", "").replace(/[¥/¥-¥?¥;¥=]/g, "") + ".html";

    window.getBrowser().addTab(url);
}

function docForInterface(iface, methodName) {
  if (iface instanceof this.Ci.nsISupports) {
    iface = iface.toString();
  }

  var window = repl.Cc["@mozilla.org/appshell/window-mediator;1"].getService(repl.Ci.nsIWindowMediator).getMostRecentWindow("");
  var url = "http://www.xulplanet.com/references/xpcomref/ifaces/" + iface + ".html";

  if (methodName) {
    url += "#method_" + methodName;
  }

  window.getBrowser().addTab(url);
}

function getInterfaceInfoByInterface(iface) {
  if (iface instanceof this.Ci.nsISupports) {
    iface = iface.toString();
  }

  var iinfo = this.Cc["@mozilla.org/scriptableInterfaceInfo;1"].createInstance(this.Ci.nsIScriptableInterfaceInfo);
  iinfo.initWithName(iface);

  return iinfo;
}

function getInterfacesByObject(obj, excludeSupports) {
  if (!excludeSupports) {
    excludeSupports = true;
  }

  var ifaces = [];

  for (var iface in this.Ci) {
    if (obj instanceof this.Ci[iface]) {
      if (excludeSupports && iface == "nsISupports") {
        continue;
      }

      ifaces.push(this.Ci[iface]);
    }
  }

  return ifaces;
}