On 1/15/06, Steven D Tine <[EMAIL PROTECTED]> wrote: > I'm going to apologize up front if the question I'm > asking is very basic but I'm new to extension > development and JavaScript. > > It appears that each instance of the browser (e.g. > when I choose 'File->New Window' or ctrl-n, a new > browser window opens) has a unique copy of the > extension code running it. So, for example, the > SwitchProxy extension (not my extension, but an easier > example to describe than my extension) has an icon in > the status bar. When you click the icon, it > alternates between red (no proxy configured) and green > (proxy configured). The problem is that when you have > two browser windows open, the status bar is not in > sync between the two windows. By that I mean, when > you click the icon in one window, the other window is > not updated and the instance of the code in that > window does not know that a change happened, so one > window shows red and one shows green but obviously > there is only one proxy setting for both windows so > one window is wrong. Is there a way for the code in > the first instance to notify the code in the other > window instances that a change was requested and > completed? > > And to clarify my question, I don't just want to > update the icon, but actually somehow notify my code > in the other instance to update some state and then > update the icon. > > I searched the archives for this mailing list and I > found Eric Jung posted this code: <snip code using nsIWindowMediator>
In the case of proxy settings, it probably modifies some preferences to tell Firefox which proxy to use; thus it would probably make sense to have a pref observer to update the icons (which would also mean that if you modify them via Firefox options or about:config they'd notice that too). See: http://mozdev.org/pipermail/project_owners/2004-November/003324.html Strangely, I can't find a devmo or kb.mz.org article on this... If it's not prefs, you'd probably use a XPCOM service (i.e. make your own XPCOM component and use .getService() to get it instead of .createInstance()); that gets the same instance of your component every time (and thus it's shared between windows). Combined with an observer (like the pref one, but with a different topic), it should work just as well. HTH :) -- Mook [EMAIL PROTECTED]
_______________________________________________ Project_owners mailing list [email protected] http://mozdev.org/mailman/listinfo/project_owners
