add-flag-to-show-avatar-button.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. --- a/chrome/browser/about_flags.cc
  2. +++ b/chrome/browser/about_flags.cc
  3. @@ -259,6 +259,19 @@ const FeatureEntry::Choice kExtensionHan
  4. "always-prompt-for-install"},
  5. };
  6. +const FeatureEntry::Choice kShowAvatarButtonChoices[] = {
  7. + {flags_ui::kGenericExperimentChoiceDefault, "", ""},
  8. + {"Always",
  9. + "show-avatar-button",
  10. + "always"},
  11. + {"Incognito and Guest",
  12. + "show-avatar-button",
  13. + "incognito-and-guest"},
  14. + {"Never",
  15. + "show-avatar-button",
  16. + "never"}
  17. +};
  18. +
  19. const FeatureEntry::Choice kTouchEventFeatureDetectionChoices[] = {
  20. {flags_ui::kGenericExperimentChoiceDisabled, "", ""},
  21. {flags_ui::kGenericExperimentChoiceEnabled,
  22. @@ -4023,6 +4036,11 @@ const FeatureEntry kFeatureEntries[] = {
  23. FEATURE_VALUE_TYPE(arc::kEnableUnifiedAudioFocusFeature)},
  24. #endif // defined(OS_CHROMEOS)
  25. + {"show-avatar-button",
  26. + "Show avatar button",
  27. + "Show avatar button in the browser toolbar", kOsDesktop,
  28. + MULTI_VALUE_TYPE(kShowAvatarButtonChoices)},
  29. +
  30. #if defined(OS_WIN)
  31. {"use-angle", flag_descriptions::kUseAngleName,
  32. flag_descriptions::kUseAngleDescription, kOsWin,
  33. --- a/chrome/browser/ui/views/toolbar/toolbar_view.cc
  34. +++ b/chrome/browser/ui/views/toolbar/toolbar_view.cc
  35. @@ -223,14 +223,30 @@ void ToolbarView::Init() {
  36. std::unique_ptr<ToolbarAccountIconContainerView>
  37. toolbar_account_icon_container;
  38. +
  39. + const base::CommandLine& command_line =
  40. + *base::CommandLine::ForCurrentProcess();
  41. + const std::string flag_value =
  42. + command_line.GetSwitchValueASCII("show-avatar-button");
  43. +
  44. + bool in_incognito_or_guest_mode = browser_->profile()->IsOffTheRecord() ||
  45. + browser_->profile()->IsGuestSession();
  46. +
  47. bool show_avatar_toolbar_button = true;
  48. #if defined(OS_CHROMEOS)
  49. if (!base::FeatureList::IsEnabled(chromeos::features::kAvatarToolbarButton)) {
  50. // ChromeOS only badges Incognito and Guest icons in the browser window.
  51. - show_avatar_toolbar_button = browser_->profile()->IsOffTheRecord() ||
  52. - browser_->profile()->IsGuestSession();
  53. + show_avatar_toolbar_button = in_incognito_or_guest_mode;
  54. }
  55. #endif
  56. +
  57. + if (flag_value == "always")
  58. + show_avatar_toolbar_button = true;
  59. + else if (flag_value == "incognito-and-guest")
  60. + show_avatar_toolbar_button = in_incognito_or_guest_mode;
  61. + else if (flag_value == "never")
  62. + show_avatar_toolbar_button = false;
  63. +
  64. if (base::FeatureList::IsEnabled(
  65. autofill::features::kAutofillEnableToolbarStatusChip)) {
  66. // The avatar button is contained inside the page-action container and