Proper chromium browser branding?

2019-04-16 03:45发布

I'm working on Chromium fork. How can i replace Chromium resources and app package?

  1. Resources

I've found that one day android_branding_res_dirs gn argument was introduced:

@@ -43,10 +43,10 @@

 # GYP: //chrome/chrome.gyp:chrome_java (resources part)
 android_resources("chrome_java_resources") {
-  resource_dirs = [
-    "java/res",
-    "java/res_default",
-  ]
+  if (!defined(android_branding_res_dirs)) {
+    android_branding_res_dirs = [ "//chrome/android/java/res_chromium" ]
+  }
+  resource_dirs = [ "java/res" ] + android_branding_res_dirs
   deps = [
     ":chrome_locale_paks",
     ":chrome_strings_grd",

but then broken:

@@ -43,10 +43,10 @@

 # GYP: //chrome/chrome.gyp:chrome_java (resources part)
 android_resources("chrome_java_resources") {
-  if (!defined(android_branding_res_dirs)) {
-    android_branding_res_dirs = [ "//chrome/android/java/res_chromium" ]
-  }
-  resource_dirs = [ "java/res" ] + android_branding_res_dirs
+  resource_dirs = [
+    "java/res",
+    "//chrome/android/java/res_chromium",
+  ]
   deps = [
     ":chrome_locale_paks",
     ":chrome_strings_grd",

So is adding res_myfork directory and replacing res_chromium with res_myfork in chrome/android/BUILD.gn proper way to add fork resources now?

  1. App package

I've found manifest_package in chrome/android/BUILD.gn:

manifest_package = "org.chromium.chrome"

Also i can see custom_package = "org.chromium.chrome":

android_resources("chrome_java_resources") {
  resource_dirs = [
    "java/res",
    "//chrome/android/java/res_chromium", // replaced to `res_myfork`
  ]
  ...

  custom_package = "org.chromium.chrome" // replaced to `org.company.myfork` by me
}

When building i'm getting errors:

Since i can see in most java classes package resource namespace is hardcoded (eg. /chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/ActionItem.java):

import org.chromium.chrome.R;

What is proper way to reference resources? Should i just replace such lines to my package resources namespace? Is there any python script to do it automatically while building?

Should i replace custom_package or leave it as-is?

UPDATE 1.

I've found word "Chrome" to be hardcoded in most strings like in ./chrome/android/java/strings/android_chrome_strings.grd:

  <!-- Sign-in preference -->
  <message name="IDS_SIGN_IN_TO_CHROME" desc="Title for the button to sign in to Chrome using one's Google account. [CHAR-LIMIT=27]">
    Sign in to Chrome
  </message>

Is there any way to adjust it (script) or should i just change it? I'd like to avoid conflicts while merging in the future so i'm looking for proper way (or lest painless way) to do it.

UPDATE 2.

I can see how Brave browser did it: https://github.com/brave/browser-android-tabs/commit/b3fa10a7b10379c8ce5cdbeb68e3c52b580292da

https://github.com/brave/browser-android-tabs/commit/956bd321871844f72d98b9666434e5aceac7da81

is it really good way?

0条回答
登录 后发表回答