Adding a new Preference/PrefService

236 views
Skip to first unread message

Alex St-Onge

unread,
Mar 31, 2021, 2:11:43 PM3/31/21
to Chromium-dev

Hi everyone,

I’m working on a task where I would need to use the PrefService to store some data and I was wondering if there was some guidance or guideline related to adding a new pref. More specifically my questions are:

  1. The code would live under /content/browser/media but I’ve noticed there is currently no reference to PrefService under the /content directory. Was that a conscious decision?
  2. I’ve read the Preference Service User Guide but looking through codesearch it looks like most places that use the preference service are not creating their own PrefServices and instead are using static functions to register their preferences (ex.). Are there guidelines on when you should create your own PrefService vs using an existing one?
Thanks,
- Alex

Gabriel Charette

unread,
Apr 20, 2021, 10:11:50 AM4/20/21
to alst...@google.com, Chromium-dev
On Wed, Mar 31, 2021 at 2:10 PM 'Alex St-Onge' via Chromium-dev <chromi...@chromium.org> wrote:

Hi everyone,

I’m working on a task where I would need to use the PrefService to store some data and I was wondering if there was some guidance or guideline related to adding a new pref. More specifically my questions are:

  1. The code would live under /content/browser/media but I’ve noticed there is currently no reference to PrefService under the /content directory. Was that a conscious decision?

Embedders manage preferences (see the brand new prefs/README.md). In Chrome's case prefs are usually managed in //chrome. //content would delegate a call to content::ContentBrowserClient or another content interface (a //content/OWNERS would be better suited than I to answer this)
 
  1. I’ve read the Preference Service User Guide but looking through codesearch it looks like most places that use the preference service are not creating their own PrefServices and instead are using static functions to register their preferences (ex.). Are there guidelines on when you should create your own PrefService vs using an existing one?
You would pretty much never create your own PrefService.

Thanks,
- Alex

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/7aa5ed3e-07ab-4dc7-9137-a03af39e1982n%40chromium.org.

Alex St-Onge

unread,
May 6, 2021, 3:34:27 PM5/6/21
to Gabriel Charette, Chromium-dev
Awesome, the new README is super helpful, thanks! 

Follow up question: how easy it is for a user to modify the pref file itself? Is there such a thing as a 'secure' pref store?

Thanks,
-Alex
--

Alexandre St-Onge | Software Engineer | alst...@google.com | 

Alex St-Onge

unread,
May 11, 2021, 1:08:23 PM5/11/21
to Gabriel Charette, Xiaohan Wang, Chromium-dev
Kindly pinging this thread, thanks!

@Xiaohan Wang  for context.

Gabriel Charette

unread,
May 18, 2021, 11:27:11 AM5/18/21
to Alex St-Onge, Gabriel Charette, Chromium-dev
On Thu, May 6, 2021 at 3:33 PM Alex St-Onge <alst...@google.com> wrote:
Awesome, the new README is super helpful, thanks! 

Follow up question: how easy it is for a user to modify the pref file itself?

As easy as modifying any text file.
 
Is there such a thing as a 'secure' pref store?

Yes. See "Secure Preferences" in the profile directory. The relevant code is mostly in //services/preferences/tracked.
Reply all
Reply to author
Forward
0 new messages