Browse Source

Re-add flag to hide the extensions menu (the puzzle piece icon)

Jiawei Wang 1 year ago
parent
commit
ac758db8b9

+ 1 - 0
docs/flags.md

@@ -36,6 +36,7 @@ If a switch requires a value, you must specify it with an `=` sign; e.g. flag `-
   `--close-window-with-last-tab` | Determines whether a window should close once the last tab is closed. Only takes the value `never`.
   `--custom-ntp` | Allows setting a custom URL for the new tab page. Value can be internal (e.g. `about:blank`), external (e.g. `example.com`), or local (e.g. `file:///tmp/startpage.html`). This applies for incognito windows as well when not set to a `chrome://` internal page.
   `--disable-sharing-hub` | Disables the sharing hub button.
+  `--hide-extensions-menu` | Hides the extensions menu (the puzzle piece icon).
   `--hide-sidepanel-button` | Hides the SidePanel Button.
   `--hide-tab-close-buttons` | Hides the close buttons on tabs.
   `--remove-grab-handle` | Removes the reserved empty space in the tabstrip for moving the window.

+ 57 - 0
patches/extra/ungoogled-chromium/add-flag-to-hide-extensions-menu.patch

@@ -0,0 +1,57 @@
+--- a/chrome/browser/ui/views/extensions/extensions_toolbar_container.cc
++++ b/chrome/browser/ui/views/extensions/extensions_toolbar_container.cc
+@@ -7,6 +7,7 @@
+ #include <memory>
+ #include "base/bind.h"
+ #include "base/callback_helpers.h"
++#include "base/command_line.h"
+ #include "base/cxx17_backports.h"
+ #include "base/feature_list.h"
+ #include "base/no_destructor.h"
+@@ -26,6 +27,7 @@
+ #include "chrome/browser/ui/views/extensions/extensions_toolbar_button.h"
+ #include "chrome/browser/ui/views/frame/browser_view.h"
+ #include "chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.h"
++#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
+ #include "chrome/browser/ui/views/web_apps/frame_toolbar/web_app_frame_toolbar_view.h"
+ #include "extensions/common/extension_features.h"
+ #include "ui/base/dragdrop/drag_drop_types.h"
+@@ -318,6 +320,17 @@ void ExtensionsToolbarContainer::AnchorA
+   widget->widget_delegate()->AsBubbleDialogDelegate()->SetAnchorView(
+       anchor_view && anchor_view->GetVisible() ? anchor_view
+                                                : GetExtensionsButton());
++
++  // Fix the position of widgets. Without this fix, extension-installed-bubble
++  // and extension-uninstall-dialog may be out of the window border on Linux.
++  if (base::CommandLine::ForCurrentProcess()->HasSwitch("hide-extensions-menu"))
++  {
++    views::View* anchor_view = BrowserView::GetBrowserViewForBrowser(browser_)
++      ->toolbar_button_provider()->GetAppMenuButton();
++    widget->widget_delegate()->AsBubbleDialogDelegate()
++      ->SetAnchorView(anchor_view);
++  }
++
+   widget->Show();
+ }
+ 
+@@ -810,6 +823,9 @@ void ExtensionsToolbarContainer::UpdateC
+ }
+ 
+ bool ExtensionsToolbarContainer::ShouldContainerBeVisible() const {
++  if (base::CommandLine::ForCurrentProcess()->HasSwitch("hide-extensions-menu"))
++    return false;
++
+   // The container (and extensions-menu button) should not be visible if we have
+   // no extensions.
+   if (!HasAnyExtensions())
+--- a/chrome/browser/ungoogled_flag_entries.h
++++ b/chrome/browser/ungoogled_flag_entries.h
+@@ -112,4 +112,8 @@
+      "Disable link drag",
+      "Prevents dragging of links and selected text. ungoogled-chromium flag.",
+      kOsDesktop, FEATURE_VALUE_TYPE(blink::features::kDisableLinkDrag)},
++    {"hide-extensions-menu",
++     "Hide Extensions Menu",
++     "Hides the extensions menu (the puzzle piece icon). ungoogled-chromium flag.",
++     kOsDesktop, SINGLE_VALUE_TYPE("hide-extensions-menu")},
+ #endif  // CHROME_BROWSER_UNGOOGLED_FLAG_ENTRIES_H_

+ 1 - 0
patches/series

@@ -100,3 +100,4 @@ extra/ungoogled-chromium/add-flag-to-change-http-accept-header.patch
 extra/ungoogled-chromium/add-flag-to-disable-sharing-hub.patch
 extra/ungoogled-chromium/add-flag-to-hide-side-panel-button.patch
 extra/ungoogled-chromium/add-flag-for-disabling-link-drag.patch
+extra/ungoogled-chromium/add-flag-to-hide-extensions-menu.patch