changeset 2:88b12596346d

Added an about:news handler and made the default page for new tabs about:news.
author Atul Varma <varmaa@toolness.com>
date Thu, 21 Aug 2008 17:00:35 -0700
parents 44bcb4975ead
children 2f424bef178f
files ambnews/components/about.js ambnews/content/ambnews.js ambnews/content/blank.html ambnews/content/browser.xul
diffstat 4 files changed, 48 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ambnews/components/about.js	Thu Aug 21 17:00:35 2008 -0700
@@ -0,0 +1,36 @@
+Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+
+function AmbNewsAboutHandler() {
+}
+
+AmbNewsAboutHandler.prototype = {
+    newChannel : function(aURI) {
+        var ios = Cc["@mozilla.org/network/io-service;1"].
+                  getService(Ci.nsIIOService);
+
+        var channel = ios.newChannel(
+          "chrome://ambnews/content/blank.html",
+          null,
+          null
+        );
+
+        channel.originalURI = aURI;
+        return channel;
+    },
+
+    getURIFlags: function(aURI) {
+        return Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT;
+    },
+
+    classDescription: "Ambient News Page",
+    classID: Components.ID("0e6d5f40-6fdc-11dd-ad8b-0800200c9a66"),
+    contractID: "@mozilla.org/network/protocol/about;1?what=news",
+    QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule])
+};
+
+function NSGetModule(aCompMgr, aFileSpec) {
+  return XPCOMUtils.generateModule([AmbNewsAboutHandler]);
+}
--- a/ambnews/content/ambnews.js	Thu Aug 21 15:39:57 2008 -0700
+++ b/ambnews/content/ambnews.js	Thu Aug 21 17:00:35 2008 -0700
@@ -92,5 +92,11 @@
       annSvc.setPageAnnotation(page, "AmbNews/feed",
                                feed.spec, 0, annSvc.EXPIRE_WEEKS);
     }
+  },
+  onLoad: function AmbNews_onLoad(aEvent) {
+    if (aEvent.target.baseURI == "about:blank") {
+      var doc = aEvent.target;
+      doc.defaultView.location = "about:news";
+    }
   }
 };
--- a/ambnews/content/blank.html	Thu Aug 21 15:39:57 2008 -0700
+++ b/ambnews/content/blank.html	Thu Aug 21 17:00:35 2008 -0700
@@ -2,6 +2,7 @@
           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
+  <base href="chrome://ambnews/content/" />
   <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
   <link rel="stylesheet" type="text/css" media="all"
         href="blank.css" />
--- a/ambnews/content/browser.xul	Thu Aug 21 15:39:57 2008 -0700
+++ b/ambnews/content/browser.xul	Thu Aug 21 17:00:35 2008 -0700
@@ -4,6 +4,11 @@
   <script type="application/javascript;version=1.7"
           src="chrome://ambnews/content/ambnews.js"/>
   <script>
+  window.document.getElementById("content").addEventListener(
+    "DOMContentLoaded",
+    AmbNews.onLoad,
+    false
+    );
   window.addEventListener("DOMLinkAdded", AmbNews.onLinkAdded, false);
   </script>
 </overlay>