<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Matt J. Wilson &#187; XUL</title>
	<atom:link href="http://www.mattjwilson.com/blog/tag/xul/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mattjwilson.com/blog</link>
	<description>General ramblings, programming frustrations, and complete randomness.  Have questions? E-mail me.</description>
	<lastBuildDate>Tue, 19 Jan 2010 19:37:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Uninstall Events for Firefox Toolbars</title>
		<link>http://www.mattjwilson.com/blog/2009/08/18/uninstall-events-for-firefox-toolbars/</link>
		<comments>http://www.mattjwilson.com/blog/2009/08/18/uninstall-events-for-firefox-toolbars/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 17:49:21 +0000</pubDate>
		<dc:creator>Matt J. Wilson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[XUL]]></category>

		<guid isPermaLink="false">http://www.mattjwilson.com/blog/?p=43</guid>
		<description><![CDATA[Recently I came across the need to run a script during the request to uninstall a Firefox toolbar (specifically for metric keeping purposes).  I could find almost zero documentation on this, so I&#8217;m posting a full example here.  This is basically accomplished by registering your observer on the toolbar&#8217;s initialization and then observing for the [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I came across the need to run a script during the request to uninstall a Firefox toolbar (specifically for metric keeping purposes).  I could find almost zero documentation on this, so I&#8217;m posting a full example here.  This is basically accomplished by registering your observer on the toolbar&#8217;s initialization and then observing for the requested action:</p>
<pre class="brush: jscript;">
function InitToolbar()
{

// Register for uninstalls
myUninstallObserver.register();
}

var myUninstallObserver = {
_uninstall : false,
_tabs : null,

observe : function(subject, topic, data) {
if (topic == &quot;em-action-requested&quot;)
{
// We flagged the extension to be uninstalled
subject.QueryInterface(Ci.nsIUpdateItem);

// The following id should match up to the id in the install.rdf file
if (subject.id == &quot;toolbar@mattjwilson.com&quot;)
{
if (data == &quot;item-uninstalled&quot;)
{
this._uninstall = true;
}
else
{
if (data == &quot;item-cancel-action&quot;)
{
this._uninstall = false;
}
}
}
}
else
{
if (topic == &quot;quit-application-granted&quot;)
{
// FireFox is shutting down
if (this._uninstall)
{
// - - - - - - - - - - - - - - - - - - - - -
//
// CODE TO RUN DURING UNINSTALLATION HERE
//
// - - - - - - - - - - - - - - - - - - - - -

}
this.unregister();
}
}
},

register : function() {
var observerService = Cc[&quot;@mozilla.org/observer-service;1&quot;]
.getService(Ci.nsIObserverService);
observerService.addObserver(this, &quot;em-action-requested&quot;, false);
observerService.addObserver(this, &quot;quit-application-granted&quot;, false);
},

unregister : function() {
var observerService = Cc[&quot;@mozilla.org/observer-service;1&quot;]
.getService(Ci.nsIObserverService);
observerService.removeObserver(this, &quot;em-action-requested&quot;);
observerService.removeObserver(this, &quot;quit-application-granted&quot;);
}
}

window.addEventListener(&quot;load&quot;, function() {InitToolbar()}, false);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mattjwilson.com/blog/2009/08/18/uninstall-events-for-firefox-toolbars/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

