Removing the Close Button on Chromium's tab

I have the fat mouse syndrome – there have been numerous times when I accidentally closed a tab when I actually meant to switch to that tab. I tend to keep many tabs open, which probably made the problem worse. It looks something like this:

While Chromium automatically hides the close button when the length of the tabs becomes very small, it does not help much since fat mouse errors can occur way before that. Also, to close a tab, I normally use the middle mouse button or the keyboard shortcut Ctrl-W, yielding a complete negative utility for these close buttons. Apparently, I’m not the only one who got annoyed.

Patching Chromium

Unfortunately, this aspect of UI isn’t user configurable. To get rid of these close buttons, some hacking on Chromium’s source code is required. I did that. It’s actually a little simpler than I had imagined thanks to the excellent code search engine and very high quality source code. After some digging, it turns out there is a well isolated function that decides whether the close button should be shown for each tab. To always hide the close button, simply short-circuit this function.

As mentioned, the patch is quite simple:

From f6283382f6f92581bd52202f400841753c5418e0 Mon Sep 17 00:00:00 2001
From: Yung Siang Liau <liauys@gmail.com>
Date: Sun, 1 Nov 2015 14:18:20 +0800
Subject: [PATCH] Always hide close button

---
 chrome/browser/ui/tabs/tab_utils.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/chrome/browser/ui/tabs/tab_utils.cc b/chrome/browser/ui/tabs/tab_utils.cc
index cd088c4..3129461 100644
--- a/chrome/browser/ui/tabs/tab_utils.cc
+++ b/chrome/browser/ui/tabs/tab_utils.cc
@@ -132,12 +132,15 @@ bool ShouldTabShowMediaIndicator(int capacity,
 bool ShouldTabShowCloseButton(int capacity,
                               bool is_pinned_tab,
                               bool is_active_tab) {
+  return false;
+  /*
   if (is_pinned_tab)
     return false;
   else if (is_active_tab)
     return true;
   else
     return capacity >= 3;
+  */
 }
 
 TabMediaState GetTabMediaStateForContents(content::WebContents* contents) {
-- 
2.6.3

Result (after two hours of compilation):

Yes!

Packaging (for ArchLinux)

I made an ArchLinux package description (PKGBUILD) for the above patched chromium based on the chromium package on ArchLinux official repository. It can be found here.