|
| 1 | +--- a/chrome/common/pref_names.h |
| 2 | ++++ b/chrome/common/pref_names.h |
| 3 | +@@ -1416,6 +1416,11 @@ inline constexpr char kExtensionCommands |
| 4 | + inline constexpr char kPluginsAlwaysOpenPdfExternally[] = |
| 5 | + "plugins.always_open_pdf_externally"; |
| 6 | + |
| 7 | ++// Boolean indicating that the user has rejected setting |
| 8 | ++// the browser as default for an indefinite amount of time. |
| 9 | ++inline constexpr char kHeliumDefaultBrowserRejected[] = |
| 10 | ++ "helium.browser.default_browser_infobar_rejected"; |
| 11 | ++ |
| 12 | + // Int64 containing the internal value of the time at which the default browser |
| 13 | + // infobar was last dismissed by the user. |
| 14 | + inline constexpr char kDefaultBrowserLastDeclined[] = |
| 15 | +--- a/chrome/browser/ui/browser_ui_prefs.cc |
| 16 | ++++ b/chrome/browser/ui/browser_ui_prefs.cc |
| 17 | +@@ -77,6 +77,8 @@ void RegisterBrowserPrefs(PrefRegistrySi |
| 18 | + registry->RegisterIntegerPref(prefs::kDefaultBrowserDeclinedCount, 0); |
| 19 | + registry->RegisterTimePref(prefs::kDefaultBrowserFirstShownTime, |
| 20 | + base::Time()); |
| 21 | ++ registry->RegisterBooleanPref(prefs::kHeliumDefaultBrowserRejected, false); |
| 22 | ++ |
| 23 | + #if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) |
| 24 | + registry->RegisterTimePref(prefs::kPdfInfoBarLastShown, base::Time()); |
| 25 | + registry->RegisterIntegerPref(prefs::kPdfInfoBarTimesShown, 0); |
| 26 | +--- a/chrome/browser/ui/startup/infobar_utils.cc |
| 27 | ++++ b/chrome/browser/ui/startup/infobar_utils.cc |
| 28 | +@@ -208,6 +208,11 @@ void AddInfoBarsIfNecessary(Browser* bro |
| 29 | + return; |
| 30 | + } |
| 31 | + |
| 32 | ++ PrefService* local_state = g_browser_process->local_state(); |
| 33 | ++ if (local_state && local_state->GetBoolean(prefs::kHeliumDefaultBrowserRejected)) { |
| 34 | ++ return; |
| 35 | ++ } |
| 36 | ++ |
| 37 | + base::OnceCallback<void(bool)> default_browser_prompt_shown_callback = |
| 38 | + base::DoNothing(); |
| 39 | + #if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) |
| 40 | +--- a/components/infobars/core/confirm_infobar_delegate.h |
| 41 | ++++ b/components/infobars/core/confirm_infobar_delegate.h |
| 42 | +@@ -81,6 +81,8 @@ class ConfirmInfoBarDelegate : public in |
| 43 | + // custom layout to show the link text before the button. |
| 44 | + virtual bool ShouldShowLinkBeforeButton() const; |
| 45 | + |
| 46 | ++ virtual bool OkButtonShouldAlwaysLead() const; |
| 47 | ++ |
| 48 | + #if BUILDFLAG(IS_IOS) |
| 49 | + // Returns whether or not a tint should be applied to the icon background. |
| 50 | + // Defaults to true. |
| 51 | +--- a/components/infobars/core/confirm_infobar_delegate.cc |
| 52 | ++++ b/components/infobars/core/confirm_infobar_delegate.cc |
| 53 | +@@ -67,6 +67,10 @@ bool ConfirmInfoBarDelegate::ShouldShowL |
| 54 | + return false; |
| 55 | + } |
| 56 | + |
| 57 | ++bool ConfirmInfoBarDelegate::OkButtonShouldAlwaysLead() const { |
| 58 | ++ return false; |
| 59 | ++} |
| 60 | ++ |
| 61 | + #if BUILDFLAG(IS_IOS) |
| 62 | + bool ConfirmInfoBarDelegate::UseIconBackgroundTint() const { |
| 63 | + return true; |
| 64 | +--- a/chrome/browser/ui/startup/default_browser_prompt/default_browser_infobar_delegate.cc |
| 65 | ++++ b/chrome/browser/ui/startup/default_browser_prompt/default_browser_infobar_delegate.cc |
| 66 | +@@ -112,13 +112,15 @@ std::u16string DefaultBrowserInfoBarDele |
| 67 | + } |
| 68 | + |
| 69 | + int DefaultBrowserInfoBarDelegate::GetButtons() const { |
| 70 | +- return BUTTON_OK; |
| 71 | ++ return BUTTON_OK | BUTTON_CANCEL; |
| 72 | + } |
| 73 | + |
| 74 | + std::u16string DefaultBrowserInfoBarDelegate::GetButtonLabel( |
| 75 | + InfoBarButton button) const { |
| 76 | +- DCHECK_EQ(BUTTON_OK, button); |
| 77 | +- return l10n_util::GetStringUTF16(IDS_DEFAULT_BROWSER_INFOBAR_OK_BUTTON_LABEL); |
| 78 | ++ DCHECK(button == BUTTON_OK || button == BUTTON_CANCEL); |
| 79 | ++ return l10n_util::GetStringUTF16( |
| 80 | ++ button == BUTTON_OK ? IDS_DEFAULT_BROWSER_INFOBAR_OK_BUTTON_LABEL |
| 81 | ++ : IDS_CARET_BROWSING_DO_NOT_ASK); |
| 82 | + } |
| 83 | + |
| 84 | + bool DefaultBrowserInfoBarDelegate::Accept() { |
| 85 | +@@ -155,6 +157,21 @@ bool DefaultBrowserInfoBarDelegate::Acce |
| 86 | + return ConfirmInfoBarDelegate::Accept(); |
| 87 | + } |
| 88 | + |
| 89 | ++bool DefaultBrowserInfoBarDelegate::Cancel() { |
| 90 | ++ PrefService* local_state = g_browser_process->local_state(); |
| 91 | ++ if (!local_state) { |
| 92 | ++ return true; |
| 93 | ++ } |
| 94 | ++ |
| 95 | ++ local_state->SetBoolean(prefs::kHeliumDefaultBrowserRejected, true); |
| 96 | ++ |
| 97 | ++ return ConfirmInfoBarDelegate::Cancel(); |
| 98 | ++} |
| 99 | ++ |
| 100 | + bool DefaultBrowserInfoBarDelegate::ShouldHideInFullscreen() const { |
| 101 | + return true; |
| 102 | + } |
| 103 | ++ |
| 104 | ++bool DefaultBrowserInfoBarDelegate::OkButtonShouldAlwaysLead() const { |
| 105 | ++ return true; |
| 106 | ++} |
| 107 | +--- a/chrome/browser/ui/startup/default_browser_prompt/default_browser_infobar_delegate.h |
| 108 | ++++ b/chrome/browser/ui/startup/default_browser_prompt/default_browser_infobar_delegate.h |
| 109 | +@@ -61,7 +61,9 @@ class DefaultBrowserInfoBarDelegate : pu |
| 110 | + int GetButtons() const override; |
| 111 | + std::u16string GetButtonLabel(InfoBarButton button) const override; |
| 112 | + bool Accept() override; |
| 113 | ++ bool Cancel() override; |
| 114 | + bool ShouldHideInFullscreen() const override; |
| 115 | ++ bool OkButtonShouldAlwaysLead() const override; |
| 116 | + |
| 117 | + // The WebContents's corresponding profile. |
| 118 | + raw_ptr<Profile> profile_; |
| 119 | +--- a/chrome/browser/ui/views/infobars/confirm_infobar.cc |
| 120 | ++++ b/chrome/browser/ui/views/infobars/confirm_infobar.cc |
| 121 | +@@ -123,7 +123,9 @@ void ConfirmInfoBar::Layout(PassKey) { |
| 122 | + } |
| 123 | + |
| 124 | + if constexpr (!views::PlatformStyle::kIsOkButtonLeading) { |
| 125 | +- std::ranges::reverse(order_of_buttons); |
| 126 | ++ if (!GetDelegate()->OkButtonShouldAlwaysLead()) { |
| 127 | ++ std::ranges::reverse(order_of_buttons); |
| 128 | ++ } |
| 129 | + } |
| 130 | + |
| 131 | + for (views::MdTextButton* button : order_of_buttons) { |
0 commit comments