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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. --- a/chrome/browser/about_flags.cc
  2. +++ b/chrome/browser/about_flags.cc
  3. @@ -235,6 +235,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. @@ -3548,6 +3561,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. @@ -248,6 +248,15 @@ void ToolbarView::Init() {
  36. std::unique_ptr<ToolbarPageActionIconContainerView>
  37. toolbar_page_action_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 (base::FeatureList::IsEnabled(
  49. autofill::features::kAutofillEnableToolbarStatusChip)) {
  50. @@ -259,11 +268,17 @@ void ToolbarView::Init() {
  51. } else {
  52. #if defined(OS_CHROMEOS)
  53. // ChromeOS only badges Incognito and Guest icons in the browser window.
  54. - show_avatar_toolbar_button = browser_->profile()->IsOffTheRecord() ||
  55. - browser_->profile()->IsGuestSession();
  56. + show_avatar_toolbar_button = in_incognito_or_guest_mode;
  57. #endif
  58. }
  59. + if (flag_value == "always")
  60. + show_avatar_toolbar_button = true;
  61. + else if (flag_value == "incognito-and-guest")
  62. + show_avatar_toolbar_button = in_incognito_or_guest_mode;
  63. + else if (flag_value == "never")
  64. + show_avatar_toolbar_button = false;
  65. +
  66. std::unique_ptr<AvatarToolbarButton> avatar;
  67. if (show_avatar_toolbar_button)
  68. avatar = std::make_unique<AvatarToolbarButton>(browser_);