Keep Last Two Tabs is my first Chrome Extension, I wrote this post because the Extension page is only allowed 2,000 characters in description.
Note
This extension has been abandoned for years. (2016-02-10T04:03:35Z)
This is a silly extension. Its made to prevent Chrome quits when you close last tab. But its not really work as you may expect. It keeps you Chrome has at least two tabs. Because intercepting last tab closing is not possible, therefore this is one possible way to get around.
1 Source Code
You can download it on GitHub.
2 Notes
- You may want to pin the leftmost tab and leave it there unused.
- This extension is not for preventing the result after you click on windows close button by accident. That issue is not possible to resolve by using extension, currently. And this last tab closing and window closing issues are both should be resolved by core code not by extensions. This is just a temporarily silly workaround.
- How to Close Chrome after installation of this extension? Press Alt+F4 or Click on X button on top-right corner of Chrome window.
- Note by sozercan: If you have an application shortcut open, it wont close the main window. (Thanks!)
- Please go to vote for better tab controlling1.
[1] | http://www.google.com/support/chrome/bin/static.py?page=suggestions.cs&issue=107375&bucket=15653 is gone. |
3 Issues
- If there is only one normal tab with one or more pinned tab closed (aka ghost tab? still there, you can click to reopen), Chrome will exit if you close that only normal tab.
- Currently, ghost tab is not able to be detected, we can see them as normal tabs, therefore we cant stop this happening. (2010-05-19) Updated 2010-07-24: Ghost tab seems to be removed in Chrome 6.
4 Changelog
- 0.3.1 2010-08-09 - Do not close new tab which is chrome://newtab/
- 0.3.0.1 2010-07-25 - Change (fix) the closing second tab to be for closing New Tabs. The previous way didnt cover some situations.
- 0.3 2010-07-24 - Add new option for closing second tab if there were only two tabs when open new tab and second tab is the New Tab page (chrome://newtab/). (Suggested by manwe)
- 0.2 2010-02-22 - Add Options page for whether creating tab in background by user decision. (Check the new option, would have behavior like first release)
- 0.1.1 2010-02-08 - Tab creation in background for better experience (suggested by anonymous)
- 0.1 2009-12-19 - First release.
Theres a subtle bug in this extension: if you have two windows open each with one tab, and then close the last tab of one of the windows, Chrome crashes, presumably since its trying to add the new tab to the now-closed window. It should probably request the window that the last tab is on for adding the new tab to.
ReplyDeleteWhen I was developing, such situation had come to my mind, but it never happens (crashes), the extension always gets the window information after the window which has one tab is closed is destroyed.
ReplyDeleteI just tried again (I thought maybe newer Chrome/Chromium may change) but I still cant reproduce the bug.
Could you give me exact steps? E.g., 1) launch Chromium. 2)...
And please also provide your which Chrome or Chromium you are using. The version number. Your Operating System.
And if possible, please create an issue.
Hmm, unfortunately I cant seem to actually reproduce it at will. It only ever happens when I have two windows each with a single tab left, and close one of them. Both windows have been doing a lot of stuff, and for some reason the version of Chromium Im running (Chromium 9.0.597.94 Ubuntu 10.10) has been pretty unstable with other things as well, like sometimes it just randomly crashes when using Twitter or the like. So its probably some complex interdependent behavior.
ReplyDeleteThanks for the additional info. I am using the same version of Chromium. I think there is a key as you mentioned for this to be happened "have been doing a lot of stuff."
ReplyDeleteHowever, that is still not deterministic.
If anyone has a way to reproduce this bug, please add info to the issue fluffy created.
Nice workaround to an annoying problem! :)
ReplyDeleteSuggestion: I dont need to have two "New Tab" pages. If I close my last new tab, I probably did mean to close the window.
P.S. Is it really difficult to install a page closing handler in each tab? Sounds like it ought to be possible to catch the last tab closing that way ... just a though.
About your suggestion, I am not sure I understand it correctly. I have two guesses.
ReplyDeletea) The problem is when you only have one tab left, you cant intercept the closing. The last tab closing is never being notified. Therefore, I need to intercept the second last tab and thats why we must have two tabs.
b) If you were saying one is a tab loaded with page and another is new tab. You close the new tab, you want the Chrome to close. Its doable if I can use extension to close Chrome. (Not sure if an extension can close Chrome) However, it will need a new config option because some people may not like that behavior, I am one of them.
Anyway, if you want to see a new feature, please create an issue.
And, no, its not difficult but I dont like doing that way. Besides, it will be browser to pop up a box to ask you if you are sure that you want to close this page. It will be annoying for some people. Moreover, not every page is inject-able. Some Chromes pages are not allowed to be manipulated by extensions, there were some old extensions using injection which had problem with those pages, so they couldnt guarantee you wont close Chrome when you dont really want to. I am not sure if it still is the case for newer Chrome versions.