How to access prefs in wWinMain

107 views
Skip to first unread message

Hoài Nông

unread,
Sep 1, 2021, 12:52:23 PM9/1/21
to Chromium-dev
Hi every one,

Could you help me access prefs in wWinMain.

My code (chrome\app\chrome_exe_main_win.cc):
#include "components/prefs/pref_service.h"
#include "chrome/browser/profiles/profile_manager.h"
....
int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev, wchar_t*, int) {
...
const std::string test1 = ProfileManager::GetActiveUserProfile()->GetPrefs()->GetString("test.prefs_1");
...
}

Error:
lld-link: error: undefined symbol: public: static class Profile * __cdecl ProfileManager::GetActiveUserProfile(void)
>>> referenced by .\..\..\chrome\app\chrome_exe_main_win.cc:309
>>>               obj/chrome/chrome_initial/chrome_exe_main_win.obj:(wWinMain)

Thank!

Greg Thompson

unread,
Sep 2, 2021, 1:38:57 AM9/2/21
to ngoch...@gmail.com, Chromium-dev
Hi. You can't do that for many reasons.

Could you explain what it is that you're trying to accomplish by accessing a Profile's preferences in chrome_exe_main_win.cc? Perhaps we can help you find a different way to achieve your goal.

--
--
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/8e1063f8-cd3e-4404-84aa-4256215fc4a4n%40chromium.org.

Greg Thompson

unread,
Sep 2, 2021, 8:19:19 AM9/2/21
to Hoài Nông, Chromium-dev
Prefs are a fine way to save state, but that needs to be done from within the context of the browser process after Local State and/or Profile preferences have been brought up. chrome_exe_main_win.cc is used for all process types and is far, far too early to do anything relating to prefs. I suggest you look for a place in src/chrome/browser to do your work. ChromeBrowserMainParts is a thing that does various bits of work during browser process startup/shutdown. CreatePrimaryProfile is the thing that ordinarily creates the first Profile. Maybe that'll give you some clues.

On Thu, Sep 2, 2021 at 1:18 PM Hoài Nông <ngoch...@gmail.com> wrote:
Thank for reply,

I want to fake font list on web check iphey.com

Could i save list font to prefs and read it? Or other way?

Thank

Vào Th 5, 2 thg 9, 2021 lúc 12:37 Greg Thompson <g...@chromium.org> đã viết:

Greg Thompson

unread,
Sep 2, 2021, 9:15:46 AM9/2/21
to Hoài Nông, Chromium-dev
I'm afraid that's outside of my field. You could try searching around in https://source.chromium.org/chromium. Otherwise, hopefully someone else here on the list can point you in the right direction.

On Thu, Sep 2, 2021 at 3:08 PM Hoài Nông <ngoch...@gmail.com> wrote:
Thank for reply,

Could you guide me what file handle system font?

Thank.

Vào Th 5, 2 thg 9, 2021 lúc 19:17 Greg Thompson <g...@chromium.org> đã viết:

Hoài Nông

unread,
Sep 2, 2021, 11:24:53 PM9/2/21
to Greg Thompson, Chromium-dev
Thank you for your help.

Vào Th 5, 2 thg 9, 2021 lúc 20:14 Greg Thompson <g...@chromium.org> đã viết:

Hoài Nông

unread,
Sep 3, 2021, 1:23:41 PM9/3/21
to Greg Thompson, Chromium-dev
Thank for reply,

I want to fake font list on web check iphey.com

Could i save list font to prefs and read it? Or other way?

Thank
Vào Th 5, 2 thg 9, 2021 lúc 12:37 Greg Thompson <g...@chromium.org> đã viết:
Hi. You can't do that for many reasons.
Reply all
Reply to author
Forward
0 new messages