How to build a Chrome extension into Chromium for Mac

340 views
Skip to first unread message

Deewan Singh

unread,
Jan 2, 2020, 6:36:42 AM1/2/20
to Chromium-dev
Hi,

I wants to build chromium for mac with my own extension so that when launch browser, extensions should be pre-bundled in browser. 
for windows i follow the instructions given here - https://stackoverflow.com/questions/50125821/standard-way-to-build-a-chrome-extension-into-chromium  and it is working. but for mac they are not working.
is there any way to do this?

Thank You






Message has been deleted

Asesh Shrestha

unread,
Jan 8, 2020, 11:25:25 PM1/8/20
to Chromium-dev
Like I have mentioned in that answer, the same code should work on macOS, Windows and Linux, but the bundling process should be different for each operating system. That bundling is handled here: src\chrome\browser\extensions\default_extensions\BUILD.gnThat bundling process specifically targets Windows operating system. I don't do Chromium development on Mac but you could spend some time debugging to find out where it should be. 

Deewan Singh

unread,
Mar 4, 2020, 6:24:46 AM3/4/20
to asesh.s...@cloudfactory.com, chromi...@chromium.org
Hi Ashesh,

you are right about the code. it is also working with mac but there are few issues.

1. i was trying with non root user and it did not work. then i switched to root user and it is working fine.
i debug for this and found that CRX file of extensions are being copied in the directory /Library/Application Support/Google/Chrome/External Extensions/
which is not accessible by non root user and that is why it was not working with non root user.
in case of window off-course this path is different and it is in the build directory of chromium code and thats why no issue was there.

2. if i run chromium.app file from terminal with sudo command on non root user. this also work fine and launch chromium with extensions but
i do not want to use sudo.

3. to get it work on non root without sudo i did a small change in your code. 
i replaced chrome::DIR_EXTERNAL_EXTENSIONS to chrome::DIR_USER_EXTERNAL_EXTENSIONS 
in line
if first_run::IsChromeFirstRun()   &&  base::PathService::Get(chrome::DIR_EXTERNAL_EXTENSIONS, &extension_dir)) {} 
of LaunchBrowser Method in startup_browser_creator.cc file.

this is working but it also have one problem. when i launch browser for the first time it does not install extensions but when i launch it for second time
extensions get installed. off-course to get it work i replaced && with || in above if condition because it check for chrome first run.
i debug for this also and this time the path to store the CRX file is ~/Library/Application Support/Chromium/External Extensions/
which is inside the user profile directory and i remember that you told that only BUILD.gn file have some possible changes and i think it need one change
of outputs path and off-course i added extensions name in else condition of that file. but unfortunately i still do not know what is right path. i think
the above user profile path might be the right path but i don't know how to pass it in build.gn file. So what i am doing is that i am copying CRX file by a script at runtime
into above path So when i launch profile first time, script is not able to copy extensions because profile path does not exist at that time. for second time it find path and 
chrome launches extensions. i know this is not the right way of doing it. ideally this should have been done by source code itself if BUILD.gn was provided the right path.

i studied documentations on gn files but unfortunately i could not find a way to pass above path in gn file because almost all outputs path are correspond to build directory.
i know you don't do development on mac but i think the problem is only about passing right path to build.gn file.
please help if you can.

ThankYou 
 
 

”This email and any files transmitted with it may be confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender.”

--
--
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/b7d04259-4128-4fa3-90ab-a75d6f2c8c47%40chromium.org.
Reply all
Reply to author
Forward
0 new messages