summaryrefslogtreecommitdiff
path: root/www/chromium-uc/patches/extra/ungoogled-chromium/add-flag-to-scroll-tabs.patch
blob: d657480931bd6d5afbecff63b56ef00f88f93179 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
--- chrome/browser/ui/views/frame/browser_root_view.cc.orig
+++ chrome/browser/ui/views/frame/browser_root_view.cc
@@ -11,6 +11,7 @@
 
 #include "base/bind.h"
 #include "base/callback_helpers.h"
+#include "base/command_line.h"
 #include "base/metrics/user_metrics.h"
 #include "base/task/post_task.h"
 #include "base/task/thread_pool.h"
@@ -109,6 +110,18 @@ DragOperation GetDropEffect(const ui::Dr
   return DragOperation::kMove;
 }
 
+bool ShouldScrollChangesTab() {
+  const std::string flag_value =
+    base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII("scroll-tabs");
+
+  if (flag_value == "always")
+    return true;
+  else if (flag_value == "never")
+    return false;
+
+  return browser_defaults::kScrollEventChangesTab;
+}
+
 }  // namespace
 
 BrowserRootView::DropInfo::DropInfo() = default;
@@ -120,7 +133,9 @@ BrowserRootView::DropInfo::~DropInfo() {
 
 BrowserRootView::BrowserRootView(BrowserView* browser_view,
                                  views::Widget* widget)
-    : views::internal::RootView(widget), browser_view_(browser_view) {}
+    : views::internal::RootView(widget), browser_view_(browser_view) {
+  scroll_event_changes_tab_ = ShouldScrollChangesTab();
+}
 
 BrowserRootView::~BrowserRootView() {
   // It's possible to destroy the browser while a drop is active.  In this case,
@@ -245,7 +260,7 @@ bool BrowserRootView::OnMouseWheel(const
 
   // Scroll-event-changes-tab is incompatible with scrolling tabstrip, so
   // disable it if the latter feature is enabled.
-  if (browser_defaults::kScrollEventChangesTab &&
+  if (scroll_event_changes_tab_ &&
       !base::FeatureList::IsEnabled(features::kScrollableTabStrip)) {
     // Switch to the left/right tab if the wheel-scroll happens over the
     // tabstrip, or the empty space beside the tabstrip.
--- chrome/browser/ui/views/frame/browser_root_view.h.orig
+++ chrome/browser/ui/views/frame/browser_root_view.h
@@ -143,6 +143,8 @@ class BrowserRootView : public views::in
   int scroll_remainder_x_ = 0;
   int scroll_remainder_y_ = 0;
 
+  bool scroll_event_changes_tab_ = false;
+
   std::unique_ptr<DropInfo> drop_info_;
 
   base::WeakPtrFactory<BrowserRootView> weak_ptr_factory_{this};
--- chrome/browser/ungoogled_flag_choices.h.orig
+++ chrome/browser/ungoogled_flag_choices.h
@@ -25,4 +25,13 @@ const FeatureEntry::Choice kShowAvatarBu
      "show-avatar-button",
      "never"}
 };
+const FeatureEntry::Choice kScrollEventChangesTab[] = {
+    {flags_ui::kGenericExperimentChoiceDefault, "", ""},
+    {"Always",
+     "scroll-tabs",
+     "always"},
+    {"Never",
+     "scroll-tabs",
+     "never"}
+};
 #endif  // CHROME_BROWSER_UNGOOGLED_FLAG_CHOICES_H_
--- chrome/browser/ungoogled_flag_entries.h.orig
+++ chrome/browser/ungoogled_flag_entries.h
@@ -36,4 +36,8 @@
      "Hide crashed bubble",
      "Hides the bubble box with the message \"Restore Pages? Chromium didn't shut down correctly.\" that shows on startup after the browser did not exit cleanly.  ungoogled-chromium flag.",
      kOsAll, SINGLE_VALUE_TYPE("hide-crashed-bubble")},
+    {"scroll-tabs",
+     "Scroll switches tab",
+     "Switch to the left/right tab if the wheel-scroll happens over the tabstrip, or the empty space beside the tabstrip.  ungoogled-chromium flag.",
+     kOsDesktop, MULTI_VALUE_TYPE(kScrollEventChangesTab)},
 #endif  // CHROME_BROWSER_UNGOOGLED_FLAG_ENTRIES_H_