add-flag-to-close-window-with-last-tab.patch 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --- a/chrome/browser/ui/tabs/tab_strip_model.cc
  2. +++ b/chrome/browser/ui/tabs/tab_strip_model.cc
  3. @@ -11,6 +11,7 @@
  4. #include <unordered_map>
  5. #include <utility>
  6. +#include "base/command_line.h"
  7. #include "base/containers/adapters.h"
  8. #include "base/containers/contains.h"
  9. #include "base/containers/flat_map.h"
  10. @@ -1910,6 +1911,10 @@ void TabStripModel::CloseTabs(base::span
  11. return;
  12. }
  13. + const std::string flag_value = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII("close-window-with-last-tab");
  14. + if (flag_value == "never" && !closing_all_ && static_cast<int>(filtered_items.size()) == count())
  15. + delegate()->AddTabAt(GURL(), -1, true);
  16. +
  17. const bool closing_all = static_cast<int>(filtered_items.size()) == count();
  18. base::WeakPtr<TabStripModel> ref = weak_factory_.GetWeakPtr();
  19. if (closing_all) {
  20. --- a/chrome/browser/ungoogled_flag_choices.h
  21. +++ b/chrome/browser/ungoogled_flag_choices.h
  22. @@ -55,4 +55,10 @@ const FeatureEntry::Choice kOmniboxAutoc
  23. "omnibox-autocomplete-filtering",
  24. "search-bookmarks-chrome"},
  25. };
  26. +const FeatureEntry::Choice kCloseWindowWithLastTab[] = {
  27. + {flags_ui::kGenericExperimentChoiceDefault, "", ""},
  28. + {"Never",
  29. + "close-window-with-last-tab",
  30. + "never"},
  31. +};
  32. #endif // CHROME_BROWSER_UNGOOGLED_FLAG_CHOICES_H_
  33. --- a/chrome/browser/ungoogled_flag_entries.h
  34. +++ b/chrome/browser/ungoogled_flag_entries.h
  35. @@ -44,4 +44,8 @@
  36. "Omnibox Autocomplete Filtering",
  37. "Restrict omnibox autocomplete results to a combination of search suggestions (if enabled), bookmarks, and internal chrome pages. ungoogled-chromium flag.",
  38. kOsAll, MULTI_VALUE_TYPE(kOmniboxAutocompleteFiltering)},
  39. + {"close-window-with-last-tab",
  40. + "Close window with last tab",
  41. + "Determines whether a window should close once the last tab is closed. ungoogled-chromium flag.",
  42. + kOsDesktop, MULTI_VALUE_TYPE(kCloseWindowWithLastTab)},
  43. #endif // CHROME_BROWSER_UNGOOGLED_FLAG_ENTRIES_H_