-
Notifications
You must be signed in to change notification settings - Fork 838
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added don't show again button to obsolete system infobar
fix brave/brave-browser#27122 W/o this, user will see this infobar whenever brave is launched.
- Loading branch information
1 parent
9fb9faa
commit 8b1a90f
Showing
6 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
browser/ui/startup/brave_obsolete_system_infobar_delegate.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <memory> | ||
|
||
#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<ConfirmInfoBarDelegate>( | ||
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; | ||
} |
39 changes: 39 additions & 0 deletions
39
browser/ui/startup/brave_obsolete_system_infobar_delegate.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <string> | ||
|
||
#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_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
chromium_src/chrome/browser/ui/startup/obsolete_system_infobar_delegate.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_ |