Skip to content

Commit

Permalink
don't fire notifications on initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
bridiver committed Jul 21, 2020
1 parent f17da73 commit 6e1d820
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ BravePrefProvider::BravePrefProvider(PrefService* prefs,
bool store_last_modified,
bool restore_session)
: PrefProvider(prefs, off_the_record, store_last_modified, restore_session),
initialized_(false),
weak_factory_(this) {
brave_pref_change_registrar_.Init(prefs_);
brave_pref_change_registrar_.Add(
Expand All @@ -138,8 +139,9 @@ BravePrefProvider::BravePrefProvider(PrefService* prefs,

MigrateShieldsSettings(off_the_record);

AddObserver(this);
OnCookieSettingsChanged(ContentSettingsType::PLUGINS);
initialized_ = true;
AddObserver(this);
}

BravePrefProvider::~BravePrefProvider() {}
Expand Down Expand Up @@ -442,7 +444,7 @@ void BravePrefProvider::UpdateCookieRules(ContentSettingsType content_type,
}

// Notify brave cookie changes as ContentSettingsType::COOKIES
if (content_type == ContentSettingsType::PLUGINS) {
if (initialized_ && content_type == ContentSettingsType::PLUGINS) {
// PostTask here to avoid content settings autolock DCHECK
base::PostTask(
FROM_HERE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class BravePrefProvider : public PrefProvider,
std::map<bool /* is_incognito */, std::vector<Rule>> cookie_rules_;
std::map<bool /* is_incognito */, std::vector<Rule>> brave_cookie_rules_;

bool initialized_;

base::WeakPtrFactory<BravePrefProvider> weak_factory_;

DISALLOW_COPY_AND_ASSIGN(BravePrefProvider);
Expand Down

0 comments on commit 6e1d820

Please sign in to comment.