Sunday 15 July 2007

The implement of "Index This Link"

The browser element : A frame which is expected to contain a view of a Web document.
(From http://www.xulplanet.com/references/elemref/ref_browser.html)
In firefox extension we usually use this element to load an document in the background.
I implement "Index This Link" using browser element.
How ?
  1. When the menu item is clicked , we
    • get the link URL
    • open a new window chrome://newbeagle/content/indexLink.xul , and pass URL and current window element as arguments
  2. When chrome://newbeagle/content/indexLink.xul is loaded.
    • init beagleInvisibleBrowser with opener. (the window which this window)
    • load the passed URL
  3. once the URL is loaded.
    • call winodw.opener.beagle.indexIt with the load document .
In this way, the linked document is indexed just like I loaded it in a new tab , and then "index this page ".
Another problem , why open a new window ?
  • We can't put a browser element in the status bar / toolbar or any other place using overlay. So We have put open a new window , and put a browser element in it . (not visible,of course).
  • We should let user know that we are downloading something. And also it may take some time , We must allow the user to see the process and cancel it .