diff --git a/app/brave_generated_resources.grd b/app/brave_generated_resources.grd index ff5d920dee658..cc3e3f2ccfd97 100644 --- a/app/brave_generated_resources.grd +++ b/app/brave_generated_resources.grd @@ -595,6 +595,10 @@ Or change later at $2brave://settings/ext No thanks + + + Don't show again + diff --git a/browser/ui/BUILD.gn b/browser/ui/BUILD.gn index e322011416a0d..a8934be66b693 100644 --- a/browser/ui/BUILD.gn +++ b/browser/ui/BUILD.gn @@ -1,3 +1,8 @@ +# Copyright (c) 2022 The Brave Authors. All rights reserved. +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at https://mozilla.org/MPL/2.0/. + import("//brave/browser/ethereum_remote_client/buildflags/buildflags.gni") import("//brave/browser/shell_integrations/buildflags/buildflags.gni") import("//brave/build/config.gni") @@ -95,6 +100,8 @@ source_set("ui") { "omnibox/brave_omnibox_client_impl.cc", "omnibox/brave_omnibox_client_impl.h", "session_crashed_bubble_brave.cc", + "startup/brave_obsolete_system_infobar_delegate.cc", + "startup/brave_obsolete_system_infobar_delegate.h", "toolbar/brave_app_menu_model.cc", "toolbar/brave_app_menu_model.h", "toolbar/brave_recent_tabs_sub_menu_model.h", diff --git a/browser/ui/startup/brave_obsolete_system_infobar_delegate.cc b/browser/ui/startup/brave_obsolete_system_infobar_delegate.cc new file mode 100644 index 0000000000000..bb32b6201dbc5 --- /dev/null +++ b/browser/ui/startup/brave_obsolete_system_infobar_delegate.cc @@ -0,0 +1,46 @@ +/* Copyright (c) 2022 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#include + +#include "brave/browser/ui/startup/brave_obsolete_system_infobar_delegate.h" +#include "brave/grit/brave_generated_resources.h" +#include "chrome/browser/browser_process.h" +#include "chrome/browser/infobars/confirm_infobar_creator.h" +#include "chrome/common/pref_names.h" +#include "components/infobars/content/content_infobar_manager.h" +#include "components/infobars/core/infobar.h" +#include "components/prefs/pref_service.h" +#include "ui/base/l10n/l10n_util.h" + +// static +void BraveObsoleteSystemInfoBarDelegate::Create( + infobars::ContentInfoBarManager* infobar_manager) { + infobar_manager->AddInfoBar( + CreateConfirmInfoBar(std::unique_ptr( + new BraveObsoleteSystemInfoBarDelegate()))); +} + +BraveObsoleteSystemInfoBarDelegate::BraveObsoleteSystemInfoBarDelegate() = + default; +BraveObsoleteSystemInfoBarDelegate::~BraveObsoleteSystemInfoBarDelegate() = + default; + +int BraveObsoleteSystemInfoBarDelegate::GetButtons() const { + return BUTTON_OK; +} + +std::u16string BraveObsoleteSystemInfoBarDelegate::GetButtonLabel( + InfoBarButton button) const { + return l10n_util::GetStringUTF16( + IDS_OBSOLERE_SYSTEM_INFOBAR_DONT_SHOW_BUTTON); +} + +bool BraveObsoleteSystemInfoBarDelegate::Accept() { + if (PrefService* local_state = g_browser_process->local_state()) { + local_state->SetBoolean(prefs::kSuppressUnsupportedOSWarning, true); + } + return true; +} diff --git a/browser/ui/startup/brave_obsolete_system_infobar_delegate.h b/browser/ui/startup/brave_obsolete_system_infobar_delegate.h new file mode 100644 index 0000000000000..d30854e501c0c --- /dev/null +++ b/browser/ui/startup/brave_obsolete_system_infobar_delegate.h @@ -0,0 +1,39 @@ +/* Copyright (c) 2022 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_BROWSER_UI_STARTUP_BRAVE_OBSOLETE_SYSTEM_INFOBAR_DELEGATE_H_ +#define BRAVE_BROWSER_UI_STARTUP_BRAVE_OBSOLETE_SYSTEM_INFOBAR_DELEGATE_H_ + +#include + +#include "chrome/browser/ui/startup/obsolete_system_infobar_delegate.h" + +namespace infobars { +class ContentInfoBarManager; +} // namespace infobars + +// Subclassed for showing "Don't show again" button. +// W/o this button, user will see this infobar whenever launched. +class BraveObsoleteSystemInfoBarDelegate + : public ObsoleteSystemInfoBarDelegate { + public: + static void Create(infobars::ContentInfoBarManager* infobar_manager); + + BraveObsoleteSystemInfoBarDelegate( + const BraveObsoleteSystemInfoBarDelegate&) = delete; + BraveObsoleteSystemInfoBarDelegate& operator=( + const BraveObsoleteSystemInfoBarDelegate&) = delete; + + private: + BraveObsoleteSystemInfoBarDelegate(); + ~BraveObsoleteSystemInfoBarDelegate() override; + + // ObsoleteSystemInfoBarDelegate overrides: + int GetButtons() const override; + std::u16string GetButtonLabel(InfoBarButton button) const override; + bool Accept() override; +}; + +#endif // BRAVE_BROWSER_UI_STARTUP_BRAVE_OBSOLETE_SYSTEM_INFOBAR_DELEGATE_H_ diff --git a/chromium_src/chrome/browser/ui/startup/infobar_utils.cc b/chromium_src/chrome/browser/ui/startup/infobar_utils.cc index c875c90c97772..c584171fe1f18 100644 --- a/chromium_src/chrome/browser/ui/startup/infobar_utils.cc +++ b/chromium_src/chrome/browser/ui/startup/infobar_utils.cc @@ -1,8 +1,9 @@ /* Copyright (c) 2021 The Brave Authors. All rights reserved. * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ + * You can obtain one at https://mozilla.org/MPL/2.0/. */ +#include "brave/browser/ui/startup/brave_obsolete_system_infobar_delegate.h" #include "chrome/browser/ui/session_crashed_bubble.h" #include "chrome/browser/ui/startup/google_api_keys_infobar_delegate.h" #include "components/infobars/content/content_infobar_manager.h" @@ -16,7 +17,10 @@ class BraveGoogleKeysInfoBarDelegate { #define ShowIfNotOffTheRecordProfile ShowIfNotOffTheRecordProfileBrave #define GoogleApiKeysInfoBarDelegate BraveGoogleKeysInfoBarDelegate +#define ObsoleteSystemInfoBarDelegate BraveObsoleteSystemInfoBarDelegate #include "src/chrome/browser/ui/startup/infobar_utils.cc" + +#undef ObsoleteSystemInfoBarDelegate #undef GoogleApiKeysInfoBarDelegate #undef ShowIfNotOffTheRecordProfile diff --git a/chromium_src/chrome/browser/ui/startup/obsolete_system_infobar_delegate.h b/chromium_src/chrome/browser/ui/startup/obsolete_system_infobar_delegate.h new file mode 100644 index 0000000000000..17d76010bfeb5 --- /dev/null +++ b/chromium_src/chrome/browser/ui/startup/obsolete_system_infobar_delegate.h @@ -0,0 +1,20 @@ +/* Copyright (c) 2022 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_STARTUP_OBSOLETE_SYSTEM_INFOBAR_DELEGATE_H_ +#define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_STARTUP_OBSOLETE_SYSTEM_INFOBAR_DELEGATE_H_ + +#include "components/infobars/core/confirm_infobar_delegate.h" + +#define Create \ + Create_UnUsed() {} \ + friend class BraveObsoleteSystemInfoBarDelegate; \ + static void Create + +#include "src/chrome/browser/ui/startup/obsolete_system_infobar_delegate.h" + +#undef Create + +#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_STARTUP_OBSOLETE_SYSTEM_INFOBAR_DELEGATE_H_