You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.2 KiB

  1. /* global Services, APP_STARTUP, APP_SHUTDOWN */
  2. /* exported startup, shutdown, install, uninstall */
  3. 'use strict';
  4. Components.utils['import']('resource://gre/modules/Services.jsm');
  5. var bgProcess;
  6. function startup(data, reason) {
  7. bgProcess = function(ev) {
  8. if (ev) {
  9. this.removeEventListener('load', bgProcess);
  10. }
  11. bgProcess = Services.appShell.hiddenDOMWindow.document;
  12. bgProcess = bgProcess.documentElement.appendChild(
  13. bgProcess.createElementNS('http://www.w3.org/1999/xhtml', 'iframe')
  14. );
  15. bgProcess.setAttribute('src', 'chrome://ublock/content/background.html');
  16. };
  17. if (reason === APP_STARTUP) {
  18. Services.ww.registerNotification({
  19. observe: function(subject) {
  20. Services.ww.unregisterNotification(this);
  21. subject.addEventListener('load', bgProcess);
  22. }
  23. });
  24. }
  25. else {
  26. bgProcess();
  27. }
  28. }
  29. function shutdown(data, reason) {
  30. if (reason !== APP_SHUTDOWN) {
  31. bgProcess.parentNode.removeChild(bgProcess);
  32. }
  33. }
  34. function install() {
  35. // https://bugzil.la/719376
  36. Services.strings.flushBundles();
  37. }
  38. function uninstall() {}