Skip to content

Commit 600235a

Browse files
authored
Merge pull request #6147 from brave/pr6126_issues/9481_1.12.x
don't fire notifications on initialization (uplift to 1.12.x)
2 parents 9f5ea00 + 2e55715 commit 600235a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

components/content_settings/core/browser/brave_content_settings_pref_provider.cc

+6-2
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ BravePrefProvider::BravePrefProvider(PrefService* prefs,
114114
bool store_last_modified,
115115
bool restore_session)
116116
: PrefProvider(prefs, off_the_record, store_last_modified, restore_session),
117+
initialized_(false),
117118
weak_factory_(this) {
118119
brave_pref_change_registrar_.Init(prefs_);
119120
brave_pref_change_registrar_.Add(
@@ -138,8 +139,11 @@ BravePrefProvider::BravePrefProvider(PrefService* prefs,
138139

139140
MigrateShieldsSettings(off_the_record);
140141

141-
AddObserver(this);
142142
OnCookieSettingsChanged(ContentSettingsType::PLUGINS);
143+
144+
// Enable change notifications after initial setup to avoid notification spam
145+
initialized_ = true;
146+
AddObserver(this);
143147
}
144148

145149
BravePrefProvider::~BravePrefProvider() {}
@@ -442,7 +446,7 @@ void BravePrefProvider::UpdateCookieRules(ContentSettingsType content_type,
442446
}
443447

444448
// Notify brave cookie changes as ContentSettingsType::COOKIES
445-
if (content_type == ContentSettingsType::PLUGINS) {
449+
if (initialized_ && content_type == ContentSettingsType::PLUGINS) {
446450
// PostTask here to avoid content settings autolock DCHECK
447451
base::PostTask(
448452
FROM_HERE,

components/content_settings/core/browser/brave_content_settings_pref_provider.h

+2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ class BravePrefProvider : public PrefProvider,
7575
std::map<bool /* is_incognito */, std::vector<Rule>> cookie_rules_;
7676
std::map<bool /* is_incognito */, std::vector<Rule>> brave_cookie_rules_;
7777

78+
bool initialized_;
79+
7880
base::WeakPtrFactory<BravePrefProvider> weak_factory_;
7981

8082
DISALLOW_COPY_AND_ASSIGN(BravePrefProvider);

0 commit comments

Comments
 (0)