Hi, thanks for your reply and your suggestion. As far as I know the unload event doesn't allow to event handler to prevent the default action, so I suppose that also in that case the browser will shut down.
>From my point of view Chrome API should allow to prevent default action in tab/window event handlers. In that way if the last tab is closed, the event handler can stop the default action and let the tab open. Thinking about your proposal I get the following doubt: if in unload event handler for last tab I open a new tab, Chrome will evaluate the complete shut down before or after the unload event handler? (this solution requires that I communicate with a background script that is allowed to access to Chrome API to get the number of opened tabs) What do you think about? Thanks, Luca On 11 Dic, 21:53, Aaron Boodman <a...@google.com> wrote: > On Fri, Dec 11, 2009 at 5:21 AM, Luca C. <luca1...@gmail.com> wrote: > > Hi, > > > I'am trying to write an extension to avoid Chrome to shut down when > > the last tab is closed. > > Ah interesting idea. > > > My idea was, adding an event listener when a tab is closed, to check > > if it's the last tab and in that case to open a new one. > > > The extension is working but only when the tab is not the last: if I > > set that when there are two remaining tabs are open a new one shall be > > created it's working fine, but when I trigger the creation of the new > > tab when the last one is closed, Chrome continues shutting down > > completely. > > > My expectation was that Chrome evaluate if complete shutting down is > > needed only after the tab event handler, instead I suppose that this > > evaluation is done before. Do you think this is a bug? > > It's not a bug, it is by design. One way you could do this is with a > content script - you can put an unload handler in each page and in it, > show an alert box confirming if the user would like to shut down. > > - a -- You received this message because you are subscribed to the Google Groups "Chromium-extensions" group. To post to this group, send email to chromium-extensi...@googlegroups.com. To unsubscribe from this group, send email to chromium-extensions+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/chromium-extensions?hl=en.