Preference not found in pref_service_

197 views
Skip to first unread message

Phoebe Gong

unread,
Jun 26, 2025, 11:07:22 AMJun 26
to Chromium-discuss, Suki. Yang
Hi there,

In components/prefs/pref_notifier_impl.cc, we check if a given preference's `path` exists in `pref_service_` (code) before triggering any observer changes.

We registered preference A as a LocalStatePref, and then initialized a PrefChangeRegistrar P1 where PrefService* points to `Shell::Get()->local_state()`. We then added preference A to the PrefChangeRegistrar P1.

Meanwhile, we initialized a separate PrefChangeRegistrar P2 where PrefService* points to user pref. Specifically, we used the `pref_service` value from the parameter in function `void WallpaperControllerImpl::OnActiveUserPrefServiceChanged(PrefService* pref_service)` (code). We did *not* add preference A to PrefChangeRegistrar P2.

We then noticed that PrefNotifierImpl::FireObservers was triggered on preference A with `pref_service_` pointing to user pref. Then it returns early because `pref_service_->FindPreference(path)` is `false`.

Question: Why is the pref notifier associated with user pref triggered on the preference change of A?

In addition, we notice that the pref notifier associated with local state triggered on a number of preferences native to Chromium (i.e. we did not add or modify them) and also returns early because the preference is not found in the corresponding `pref_service_`. However, we are under the impression that all prefs can be found in `local_state`.

Question: Why are those prefs native to Chromium not found in the `local_state`?

We would really appreciate any pointers or help regarding our questions above.

Thanks in advance!

Phoebe
Reply all
Reply to author
Forward
0 new messages