Example #1
0
  getJsonContentTypes().forEach(function(contentType) {
    // Get a reference to the existing Gecko viewer for this content type, if it exists
    var geckoViewer;
    try {
      geckoViewer = categoryManager.getCategoryEntry(GECKO_VIEWER, contentType);
    } catch (err) {
      // The category entry doesn't have to exist.
    }

    // Create and register the a service for each content type
    // This component is an implementation of nsIStreamConverter that converts
    // application/json to html
    var contractId = "@mozilla.org/streamconv;1?from=" + contentType + "&to=*/*";
    var service = xpcom.Service({
      contract: contractId,
      Component: JSONView,
      register: false,
      unregister: false
    });

    // Keep track of everything so we can undo it in onUnload
    services.push({
      service: service,
      contentType: contentType,
      geckoViewer: geckoViewer
    });

    if (!xpcom.isRegistered(service)) {
      xpcom.register(service);
    }

    // Remove built-in JSON viewer
    categoryManager.deleteCategoryEntry(GECKO_VIEWER, contentType, false);
  });
Example #2
0
function unregister() {
  if (xpcom.isRegistered(service)) {
    xpcom.unregister(service);
    return true;
  }
  return false;
}
function unregister() {
  if (xpcom.isRegistered(service)) {
    categoryManager.deleteCategoryEntry(CONTENT_SNIFFER_CATEGORY,
      JSON_VIEW_TYPE, false)
    xpcom.unregister(service);
    return true;
  }
  return false;
}
Example #4
0
  services.forEach(function(serviceInfo) {
    if (xpcom.isRegistered(serviceInfo.service)) {
      xpcom.unregister(serviceInfo.service);
    }

    // Re-add built-in JSON viewer
    if (serviceInfo.geckoViewer) {
      categoryManager.addCategoryEntry(GECKO_VIEWER, serviceInfo.contentType, serviceInfo.geckoViewer, false, false);
    }
  });
function register() {
  if (!xpcom.isRegistered(service)) {
    xpcom.register(service);
    categoryManager.addCategoryEntry(CONTENT_SNIFFER_CATEGORY, JSON_VIEW_TYPE,
      CONTRACT_ID, false, false);
    return true;
  }

  return false;
}
Example #6
0
function search_load_events() {
  categoryManager.addCategoryEntry("content-policy", "http-request", contractId, false, true);
  if (xpcom.isRegistered(factory)) xpcom.unregister(factory);
  xpcom.register(factory);

  //observerService.addObserver(httpRequestObserver, "http-on-examine-response", false);
  observerService.addObserver(httpRequestObserver, "http-on-modify-request", false);
  windows.browserWindows.on('open', onWindowOpen);

  onWindowOpen(); // load events in current window
  pageMod.PageMod({
    include: [/.*google.*/, /.*bing.*/, /.*yahoo.*/, /.*duckduckgo.*/],
    contentScriptFile: self.data.url("scripts/serp.js"),
    contentScriptWhen: "ready"
  });
};