home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / firefox-3.0.14 / chrome / browser.jar / content / browser / safebrowsing / sb-loader.js < prev   
Encoding:
JavaScript  |  2008-08-15  |  2.0 KB  |  68 lines

  1. //@line 36 "/build/buildd/firefox-3.0-3.0.14+build2+nobinonly/build-tree/mozilla/browser/components/safebrowsing/content/sb-loader.js"
  2.  
  3. var safebrowsing = {
  4.   appContext: null,
  5.  
  6.   startup: function() {
  7.     setTimeout(function() {
  8.       safebrowsing.deferredStartup();
  9.     }, 2000);
  10.     window.removeEventListener("load", safebrowsing.startup, false);
  11.   },
  12.  
  13.   deferredStartup: function() {
  14.     this.appContext.initialize();
  15.   },
  16.  
  17.   setReportPhishingMenu: function() {
  18.       
  19.     // A phishing page will have a specific about:blocked content documentURI
  20.     var isPhishingPage = /^about:blocked\?e=phishingBlocked/.test(content.document.documentURI);
  21.     
  22.     // Show/hide the appropriate menu item.
  23.     document.getElementById("menu_HelpPopup_reportPhishingtoolmenu")
  24.             .hidden = isPhishingPage;
  25.     document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu")
  26.             .hidden = !isPhishingPage;
  27.  
  28.     var broadcasterId = isPhishingPage
  29.                         ? "reportPhishingErrorBroadcaster"
  30.                         : "reportPhishingBroadcaster";
  31.  
  32.     var broadcaster = document.getElementById(broadcasterId);
  33.     if (!broadcaster)
  34.       return;
  35.  
  36.     var uri = getBrowser().currentURI;
  37.     if (uri && (uri.schemeIs("http") || uri.schemeIs("https")))
  38.       broadcaster.removeAttribute("disabled");
  39.     else
  40.       broadcaster.setAttribute("disabled", true);
  41.   },
  42.   
  43.   /**
  44.    * Lazy init getter for appContext
  45.    */
  46.   get appContext() {
  47.     delete this.appContext;
  48.     return this.appContext = Cc["@mozilla.org/safebrowsing/application;1"]
  49.                             .getService().wrappedJSObject;
  50.   },
  51.  
  52.   /**
  53.    * Used to report a phishing page or a false positive
  54.    * @param name String either "Phish" or "Error"
  55.    * @return String the report phishing URL.
  56.    */
  57.   getReportURL: function(name) {
  58.     var reportUrl = this.appContext.getReportURL(name);
  59.  
  60.     var pageUrl = getBrowser().currentURI.asciiSpec;
  61.     reportUrl += "&url=" + encodeURIComponent(pageUrl);
  62.  
  63.     return reportUrl;
  64.   }
  65. }
  66.  
  67. window.addEventListener("load", safebrowsing.startup, false);
  68.