Don't show account deleted informer for Brave Sync setup page
This commit is contained in:
@@ -150,8 +150,8 @@ void BraveBrowserMainParts::PostBrowserStart() {
|
||||
|
||||
SyncCannotRunInfoBarDelegate::Create(infobar_manager, profile, browser);
|
||||
|
||||
BraveSyncAccountDeletedInfoBarDelegate::Create(infobar_manager, profile,
|
||||
browser);
|
||||
BraveSyncAccountDeletedInfoBarDelegate::Create(active_web_contents,
|
||||
profile, browser);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,27 +6,22 @@
|
||||
#include "brave/browser/infobars/brave_sync_account_deleted_infobar_delegate.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "base/feature_list.h"
|
||||
#include "brave/browser/ui/brave_pages.h"
|
||||
#include "brave/components/brave_sync/brave_sync_prefs.h"
|
||||
#include "brave/components/constants/pref_names.h"
|
||||
#include "brave/components/constants/webui_url_constants.h"
|
||||
#include "brave/components/l10n/common/locale_util.h"
|
||||
#include "brave/grit/brave_generated_resources.h"
|
||||
#include "chrome/browser/infobars/confirm_infobar_creator.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
#include "chrome/grit/chromium_strings.h"
|
||||
#include "chrome/browser/ui/chrome_pages.h"
|
||||
#include "components/infobars/content/content_infobar_manager.h"
|
||||
#include "components/infobars/core/infobar.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "components/strings/grit/components_strings.h"
|
||||
#include "ui/views/vector_icons.h"
|
||||
|
||||
// static
|
||||
void BraveSyncAccountDeletedInfoBarDelegate::Create(
|
||||
infobars::ContentInfoBarManager* infobar_manager,
|
||||
content::WebContents* active_web_contents,
|
||||
Profile* profile,
|
||||
Browser* browser) {
|
||||
brave_sync::Prefs brave_sync_prefs(profile->GetPrefs());
|
||||
@@ -36,6 +31,20 @@ void BraveSyncAccountDeletedInfoBarDelegate::Create(
|
||||
return;
|
||||
}
|
||||
|
||||
// If we already are on brave://settings/braveSync/setup page, don't show
|
||||
// informer
|
||||
if (!active_web_contents || active_web_contents->GetURL() ==
|
||||
chrome::GetSettingsUrl(kBraveSyncSetupPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
infobars::ContentInfoBarManager* infobar_manager =
|
||||
infobars::ContentInfoBarManager::FromWebContents(active_web_contents);
|
||||
|
||||
if (!infobar_manager) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Show infobar
|
||||
infobar_manager->AddInfoBar(
|
||||
CreateConfirmInfoBar(std::unique_ptr<ConfirmInfoBarDelegate>(
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
class Browser;
|
||||
class Profile;
|
||||
|
||||
namespace infobars {
|
||||
class ContentInfoBarManager;
|
||||
} // namespace infobars
|
||||
namespace content {
|
||||
class WebContents;
|
||||
}
|
||||
|
||||
// An infobar that is run with a string, buttons, and a "Learn More" link.
|
||||
class BraveSyncAccountDeletedInfoBarDelegate : public ConfirmInfoBarDelegate {
|
||||
@@ -25,7 +25,7 @@ class BraveSyncAccountDeletedInfoBarDelegate : public ConfirmInfoBarDelegate {
|
||||
BraveSyncAccountDeletedInfoBarDelegate& operator=(
|
||||
const BraveSyncAccountDeletedInfoBarDelegate&) = delete;
|
||||
|
||||
static void Create(infobars::ContentInfoBarManager* infobar_manager,
|
||||
static void Create(content::WebContents* active_web_contents,
|
||||
Profile* profile,
|
||||
Browser* browser);
|
||||
|
||||
|
||||
@@ -63,11 +63,8 @@ void BraveSyncAlertsService::ShowInfobar() {
|
||||
content::WebContents* active_web_contents =
|
||||
browser->tab_strip_model()->GetActiveWebContents();
|
||||
if (active_web_contents) {
|
||||
infobars::ContentInfoBarManager* infobar_manager =
|
||||
infobars::ContentInfoBarManager::FromWebContents(active_web_contents);
|
||||
|
||||
BraveSyncAccountDeletedInfoBarDelegate::Create(infobar_manager, profile_,
|
||||
browser);
|
||||
BraveSyncAccountDeletedInfoBarDelegate::Create(active_web_contents,
|
||||
profile_, browser);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user