Chromium - mini_installer ignores branding

2019-07-17 17:21发布

问题:

After building chromium from source, you can create a "mini installer" for Windows by running

ninja -C out\BuildFolder mini_installer

This works fine and creates a mini_installer.exe in out\BuildFolder.

see Chromium - How to make an actual installer out of mini_installer.exe for more details.

But after running mini_installer.exe, the application ignores my branding and grd resource customizations.

It is supposed to use "IDS_PRODUCT_NAME_BASE" which I have definitely customized.

Here are the files I applied my branding in:

  • chrome\app\chromium_strings.grd
  • chrome\app\settings_chromium_strings.grdp
  • chrome\app\theme\chromium\BRANDING

But it seems to be ignoring them.

  • The program is installed in C:\Program Files (x86)\Chromium instead of C:\Program Files (x86)\CustomProductName
  • The executable is still named chrome.exe instead of CustomProductName.exe

How does one customize that?

回答1:

Branding won't change the name of generated executable files. You should modify src\chrome\BUILD.gn to change the name from chrome.exe to CustomProductName.exe as specified below:

if (is_win) {
action("reorder_imports") {
script = "//build/win/reorder-imports.py"

# See comment in chrome_dll.gypi in the hardlink_to_output
# target for why this cannot be 'initial' like the DLL.
inputs = [
  "$root_out_dir/initialexe/CustomProductName.exe",
]
outputs = [
  "$root_out_dir/CustomProductName.exe",
]
if (symbol_level != 0) {
  outputs += [ "$root_out_dir/CustomProductName.exe.pdb" ]
}
... later in the file ...
chrome_binary("chrome_initial") {
  if (is_win) {
    output_name = "initialexe/CustomProductName"

Doing so will generate CustomProductName.exe instead of Chrome.exe in your BuildFolder. After that, you should notify mini installer too by modifying this file: src\chrome\installer\mini_installer\BUILD.gn:

action(archive_name) {
script = "//chrome/tools/build/win/create_installer_archive.py"

release_file = "chrome.release"

inputs = [
  "$chrome_dll_file",
  "$root_out_dir/CustomProductName.exe",
  "$root_out_dir/locales/en-US.pak",
  "$root_out_dir/setup.exe",
  "//chrome/tools/build/win/makecab.py",
  release_file,
]

Those changes will only change the name of executable files. You will have to modify source code to reflect those changes too.

Assign the name of your browser executable in this file: src\chrome\installer\util\util_constants.cc

const wchar_t kChromeExe[] = L"CustomProductName.exe";

The path to installation folder should be specified in this file: src\chrome\install_static\chromium_install_modes.cc

const wchar_t kCompanyPathName[] = L"CompanyName";

const wchar_t kProductPathName[] = L"CustomProductName";

Similarly, you will have to change company name and app name in this file too: src\chrome\installer\util\browser_distribution.cc. I am not sure if the current version of Chromium still uses data from BrowserDistribution class.

Let me know if it works. I just went through our repo history to find out those changes.

UPDATE:

The comments reveal a couple more places:

Open chrome_elf/BUILD.gn and change here:

$root_out_dir/CustomProductName.exe

And change here: chrome/installer/mini_installer/chrome.release

CustomProductName.exe: %(ChromeDir)s\

And change here: build/win/reorder-imports.py

input_image = os.path.join(input_dir, 'CustomProductName.exe')
output_image = os.path.join(output_dir, 'CustomProductName.exe')
... later on in the file ...
for fname in glob.iglob(os.path.join(input_dir, 'CustomProductName.exe.*')):