add-flag-for-bookmark-bar-ntp.patch 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. --- a/chrome/browser/about_flags.cc
  2. +++ b/chrome/browser/about_flags.cc
  3. @@ -288,6 +288,13 @@ const FeatureEntry::Choice kPDFPluginNam
  4. {"Microsoft Edge", switches::kPDFPluginName, "edge"},
  5. };
  6. +const FeatureEntry::Choice kBookmarkBarNewTab[] = {
  7. + {flags_ui::kGenericExperimentChoiceDefault, "", ""},
  8. + {"Never",
  9. + "bookmark-bar-ntp",
  10. + "never"},
  11. +};
  12. +
  13. const FeatureEntry::Choice kTouchEventFeatureDetectionChoices[] = {
  14. {flags_ui::kGenericExperimentChoiceDisabled, "", ""},
  15. {flags_ui::kGenericExperimentChoiceEnabled,
  16. @@ -2072,6 +2079,12 @@ const FeatureEntry kFeatureEntries[] = {
  17. {"focus-mode", flag_descriptions::kFocusMode,
  18. flag_descriptions::kFocusModeDescription, kOsDesktop,
  19. FEATURE_VALUE_TYPE(features::kFocusMode)},
  20. +
  21. + {"bookmark-bar-ntp",
  22. + "Bookmark Bar on New-Tab-Page",
  23. + "Disable the Bookmark Bar on the New-Tab-Page", kOsDesktop,
  24. + MULTI_VALUE_TYPE(kBookmarkBarNewTab)},
  25. +
  26. {"touch-events", flag_descriptions::kTouchEventsName,
  27. flag_descriptions::kTouchEventsDescription, kOsDesktop,
  28. MULTI_VALUE_TYPE(kTouchEventFeatureDetectionChoices)},
  29. --- a/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc
  30. +++ b/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc
  31. @@ -4,6 +4,7 @@
  32. #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
  33. +#include "base/command_line.h"
  34. #include "base/observer_list.h"
  35. #include "build/build_config.h"
  36. #include "chrome/browser/bookmarks/bookmark_model_factory.h"
  37. @@ -71,10 +72,12 @@ bool BookmarkTabHelper::ShouldShowBookma
  38. !prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar))
  39. return false;
  40. + const std::string flag_value =
  41. + base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII("bookmark-bar-ntp");
  42. // The bookmark bar is only shown on the NTP if the user
  43. // has added something to it.
  44. return IsNTP(web_contents()) && bookmark_model_ &&
  45. - bookmark_model_->HasBookmarks();
  46. + bookmark_model_->HasBookmarks() && (flag_value != "never");
  47. }
  48. void BookmarkTabHelper::AddObserver(BookmarkTabHelperObserver* observer) {