mirror of
https://github.com/morgan9e/helium
synced 2026-04-14 00:14:20 +09:00
helium/core: add "do not show again" to default browser nag (#264)
This commit is contained in:
131
patches/helium/core/add-default-browser-reject-button.patch
Normal file
131
patches/helium/core/add-default-browser-reject-button.patch
Normal file
@@ -0,0 +1,131 @@
|
||||
--- a/chrome/common/pref_names.h
|
||||
+++ b/chrome/common/pref_names.h
|
||||
@@ -1416,6 +1416,11 @@ inline constexpr char kExtensionCommands
|
||||
inline constexpr char kPluginsAlwaysOpenPdfExternally[] =
|
||||
"plugins.always_open_pdf_externally";
|
||||
|
||||
+// Boolean indicating that the user has rejected setting
|
||||
+// the browser as default for an indefinite amount of time.
|
||||
+inline constexpr char kHeliumDefaultBrowserRejected[] =
|
||||
+ "helium.browser.default_browser_infobar_rejected";
|
||||
+
|
||||
// Int64 containing the internal value of the time at which the default browser
|
||||
// infobar was last dismissed by the user.
|
||||
inline constexpr char kDefaultBrowserLastDeclined[] =
|
||||
--- a/chrome/browser/ui/browser_ui_prefs.cc
|
||||
+++ b/chrome/browser/ui/browser_ui_prefs.cc
|
||||
@@ -77,6 +77,8 @@ void RegisterBrowserPrefs(PrefRegistrySi
|
||||
registry->RegisterIntegerPref(prefs::kDefaultBrowserDeclinedCount, 0);
|
||||
registry->RegisterTimePref(prefs::kDefaultBrowserFirstShownTime,
|
||||
base::Time());
|
||||
+ registry->RegisterBooleanPref(prefs::kHeliumDefaultBrowserRejected, false);
|
||||
+
|
||||
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
|
||||
registry->RegisterTimePref(prefs::kPdfInfoBarLastShown, base::Time());
|
||||
registry->RegisterIntegerPref(prefs::kPdfInfoBarTimesShown, 0);
|
||||
--- a/chrome/browser/ui/startup/infobar_utils.cc
|
||||
+++ b/chrome/browser/ui/startup/infobar_utils.cc
|
||||
@@ -208,6 +208,11 @@ void AddInfoBarsIfNecessary(Browser* bro
|
||||
return;
|
||||
}
|
||||
|
||||
+ PrefService* local_state = g_browser_process->local_state();
|
||||
+ if (local_state && local_state->GetBoolean(prefs::kHeliumDefaultBrowserRejected)) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
base::OnceCallback<void(bool)> default_browser_prompt_shown_callback =
|
||||
base::DoNothing();
|
||||
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
|
||||
--- a/components/infobars/core/confirm_infobar_delegate.h
|
||||
+++ b/components/infobars/core/confirm_infobar_delegate.h
|
||||
@@ -81,6 +81,8 @@ class ConfirmInfoBarDelegate : public in
|
||||
// custom layout to show the link text before the button.
|
||||
virtual bool ShouldShowLinkBeforeButton() const;
|
||||
|
||||
+ virtual bool OkButtonShouldAlwaysLead() const;
|
||||
+
|
||||
#if BUILDFLAG(IS_IOS)
|
||||
// Returns whether or not a tint should be applied to the icon background.
|
||||
// Defaults to true.
|
||||
--- a/components/infobars/core/confirm_infobar_delegate.cc
|
||||
+++ b/components/infobars/core/confirm_infobar_delegate.cc
|
||||
@@ -67,6 +67,10 @@ bool ConfirmInfoBarDelegate::ShouldShowL
|
||||
return false;
|
||||
}
|
||||
|
||||
+bool ConfirmInfoBarDelegate::OkButtonShouldAlwaysLead() const {
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
#if BUILDFLAG(IS_IOS)
|
||||
bool ConfirmInfoBarDelegate::UseIconBackgroundTint() const {
|
||||
return true;
|
||||
--- a/chrome/browser/ui/startup/default_browser_prompt/default_browser_infobar_delegate.cc
|
||||
+++ b/chrome/browser/ui/startup/default_browser_prompt/default_browser_infobar_delegate.cc
|
||||
@@ -112,13 +112,15 @@ std::u16string DefaultBrowserInfoBarDele
|
||||
}
|
||||
|
||||
int DefaultBrowserInfoBarDelegate::GetButtons() const {
|
||||
- return BUTTON_OK;
|
||||
+ return BUTTON_OK | BUTTON_CANCEL;
|
||||
}
|
||||
|
||||
std::u16string DefaultBrowserInfoBarDelegate::GetButtonLabel(
|
||||
InfoBarButton button) const {
|
||||
- DCHECK_EQ(BUTTON_OK, button);
|
||||
- return l10n_util::GetStringUTF16(IDS_DEFAULT_BROWSER_INFOBAR_OK_BUTTON_LABEL);
|
||||
+ DCHECK(button == BUTTON_OK || button == BUTTON_CANCEL);
|
||||
+ return l10n_util::GetStringUTF16(
|
||||
+ button == BUTTON_OK ? IDS_DEFAULT_BROWSER_INFOBAR_OK_BUTTON_LABEL
|
||||
+ : IDS_CARET_BROWSING_DO_NOT_ASK);
|
||||
}
|
||||
|
||||
bool DefaultBrowserInfoBarDelegate::Accept() {
|
||||
@@ -155,6 +157,21 @@ bool DefaultBrowserInfoBarDelegate::Acce
|
||||
return ConfirmInfoBarDelegate::Accept();
|
||||
}
|
||||
|
||||
+bool DefaultBrowserInfoBarDelegate::Cancel() {
|
||||
+ PrefService* local_state = g_browser_process->local_state();
|
||||
+ if (!local_state) {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ local_state->SetBoolean(prefs::kHeliumDefaultBrowserRejected, true);
|
||||
+
|
||||
+ return ConfirmInfoBarDelegate::Cancel();
|
||||
+}
|
||||
+
|
||||
bool DefaultBrowserInfoBarDelegate::ShouldHideInFullscreen() const {
|
||||
return true;
|
||||
}
|
||||
+
|
||||
+bool DefaultBrowserInfoBarDelegate::OkButtonShouldAlwaysLead() const {
|
||||
+ return true;
|
||||
+}
|
||||
--- a/chrome/browser/ui/startup/default_browser_prompt/default_browser_infobar_delegate.h
|
||||
+++ b/chrome/browser/ui/startup/default_browser_prompt/default_browser_infobar_delegate.h
|
||||
@@ -61,7 +61,9 @@ class DefaultBrowserInfoBarDelegate : pu
|
||||
int GetButtons() const override;
|
||||
std::u16string GetButtonLabel(InfoBarButton button) const override;
|
||||
bool Accept() override;
|
||||
+ bool Cancel() override;
|
||||
bool ShouldHideInFullscreen() const override;
|
||||
+ bool OkButtonShouldAlwaysLead() const override;
|
||||
|
||||
// The WebContents's corresponding profile.
|
||||
raw_ptr<Profile> profile_;
|
||||
--- a/chrome/browser/ui/views/infobars/confirm_infobar.cc
|
||||
+++ b/chrome/browser/ui/views/infobars/confirm_infobar.cc
|
||||
@@ -123,7 +123,9 @@ void ConfirmInfoBar::Layout(PassKey) {
|
||||
}
|
||||
|
||||
if constexpr (!views::PlatformStyle::kIsOkButtonLeading) {
|
||||
- std::ranges::reverse(order_of_buttons);
|
||||
+ if (!GetDelegate()->OkButtonShouldAlwaysLead()) {
|
||||
+ std::ranges::reverse(order_of_buttons);
|
||||
+ }
|
||||
}
|
||||
|
||||
for (views::MdTextButton* button : order_of_buttons) {
|
||||
@@ -763,7 +763,7 @@
|
||||
label="$i18n{heliumExtProxyToggle}"
|
||||
--- a/chrome/browser/ui/browser_ui_prefs.cc
|
||||
+++ b/chrome/browser/ui/browser_ui_prefs.cc
|
||||
@@ -202,6 +202,7 @@ void RegisterBrowserUserPrefs(user_prefs
|
||||
@@ -204,6 +204,7 @@ void RegisterBrowserUserPrefs(user_prefs
|
||||
|
||||
{
|
||||
registry->RegisterBooleanPref(prefs::kHeliumServicesEnabled, true);
|
||||
|
||||
@@ -126,7 +126,7 @@ TODO: guard services_page.html with is_mac
|
||||
|
||||
--- a/chrome/browser/ui/browser_ui_prefs.cc
|
||||
+++ b/chrome/browser/ui/browser_ui_prefs.cc
|
||||
@@ -213,6 +213,7 @@ void RegisterBrowserUserPrefs(user_prefs
|
||||
@@ -215,6 +215,7 @@ void RegisterBrowserUserPrefs(user_prefs
|
||||
registry->RegisterStringPref(prefs::kHeliumServicesOrigin, "");
|
||||
registry->RegisterBooleanPref(prefs::kHeliumDidOnboarding, false);
|
||||
registry->RegisterBooleanPref(prefs::kHeliumServicesConsented, false);
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
E(kActionShowPasswordManager, IDC_SHOW_PASSWORD_MANAGER) \
|
||||
--- a/chrome/browser/ui/browser_ui_prefs.cc
|
||||
+++ b/chrome/browser/ui/browser_ui_prefs.cc
|
||||
@@ -117,6 +117,9 @@ void RegisterBrowserUserPrefs(user_prefs
|
||||
@@ -119,6 +119,9 @@ void RegisterBrowserUserPrefs(user_prefs
|
||||
registry->RegisterBooleanPref(prefs::kPinSplitTabButton, false,
|
||||
pref_registration_flags);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
E(kActionShowPasswordManager, IDC_SHOW_PASSWORD_MANAGER) \
|
||||
--- a/chrome/browser/ui/browser_ui_prefs.cc
|
||||
+++ b/chrome/browser/ui/browser_ui_prefs.cc
|
||||
@@ -119,6 +119,8 @@ void RegisterBrowserUserPrefs(user_prefs
|
||||
@@ -121,6 +121,8 @@ void RegisterBrowserUserPrefs(user_prefs
|
||||
|
||||
registry->RegisterBooleanPref(
|
||||
prefs::kShowAvatarButton, true);
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
label="$i18n{showTabGroupsInBookmarksBar}">
|
||||
--- a/chrome/browser/ui/browser_ui_prefs.cc
|
||||
+++ b/chrome/browser/ui/browser_ui_prefs.cc
|
||||
@@ -104,6 +104,8 @@ void RegisterBrowserUserPrefs(user_prefs
|
||||
@@ -106,6 +106,8 @@ void RegisterBrowserUserPrefs(user_prefs
|
||||
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@
|
||||
|
||||
--- a/chrome/browser/ui/browser_ui_prefs.cc
|
||||
+++ b/chrome/browser/ui/browser_ui_prefs.cc
|
||||
@@ -202,6 +202,7 @@ void RegisterBrowserUserPrefs(user_prefs
|
||||
@@ -204,6 +204,7 @@ void RegisterBrowserUserPrefs(user_prefs
|
||||
|
||||
{
|
||||
registry->RegisterBooleanPref(prefs::kHeliumServicesEnabled, true);
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
|
||||
--- a/chrome/browser/ui/browser_ui_prefs.cc
|
||||
+++ b/chrome/browser/ui/browser_ui_prefs.cc
|
||||
@@ -204,6 +204,7 @@ void RegisterBrowserUserPrefs(user_prefs
|
||||
@@ -206,6 +206,7 @@ void RegisterBrowserUserPrefs(user_prefs
|
||||
registry->RegisterBooleanPref(prefs::kHeliumServicesEnabled, true);
|
||||
registry->RegisterBooleanPref(prefs::kHeliumBangsEnabled, true);
|
||||
registry->RegisterBooleanPref(prefs::kHeliumExtProxyEnabled, true);
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
|
||||
--- a/chrome/browser/ui/browser_ui_prefs.cc
|
||||
+++ b/chrome/browser/ui/browser_ui_prefs.cc
|
||||
@@ -214,6 +214,7 @@ void RegisterBrowserUserPrefs(user_prefs
|
||||
@@ -216,6 +216,7 @@ void RegisterBrowserUserPrefs(user_prefs
|
||||
registry->RegisterBooleanPref(prefs::kHeliumDidOnboarding, false);
|
||||
registry->RegisterBooleanPref(prefs::kHeliumServicesConsented, false);
|
||||
registry->RegisterBooleanPref(prefs::kHeliumUpdateFetchingEnabled, true);
|
||||
|
||||
@@ -125,6 +125,7 @@ helium/core/search/remove-description-snippet-deps.patch
|
||||
|
||||
helium/core/keyboard-shortcuts.patch
|
||||
helium/core/update-default-browser-prefs.patch
|
||||
helium/core/add-default-browser-reject-button.patch
|
||||
helium/core/proxy-extension-downloads.patch
|
||||
helium/core/reenable-update-checks.patch
|
||||
helium/core/add-native-bangs.patch
|
||||
|
||||
Reference in New Issue
Block a user