I am working on a chrome plug. How can I replace Chromium resources and application package?
I found that one day the android_branding_res_dirs gn argument was presented :
@@ -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, adds the res_myfork directory and replaces res_chromium with res_myfork in chrome/android/BUILD.gn correct way to add fork resources now?
- Application package
I found manifest_package in chrome/android/BUILD.gn :
manifest_package = "org.chromium.chrome"
I also 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 creating, I get errors:
As I see in most Java class classes, the resource namespace is hard-coded (e.g. /chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/ActionItem.java ):
import org.chromium.chrome.R;
What is the correct way to link to resources? Should I just replace such strings with the package resource namespace? Is there any python script to do this automatically when creating?
Should I replace custom_package or leave it as is?
UPDATE 1.
I found the word "Chrome" for hard coding in most lines, for example in ./chrome/android/java/strings/android_chrome_strings.grd :
<message name="IDS_SIGN_IN_TO_CHROME" desc="Title for the button to sign in to Chrome using one Google account. [CHAR-LIMIT=27]"> Sign in to Chrome </message>
Is there a way to adjust it (script) or should I just change it? I would like to avoid conflicts when merging in the future, so I'm looking for a suitable way (or not a painless way) to do this.
UPDATE 2.
I see how the Brave browser did it: https://github.com/brave/browser-android-tabs/commit/b3fa10a7b10379c8ce5cdbeb68e3c52b580292da
https://github.com/brave/browser-android-tabs/commit/956bd321871844f72d98b9666434e5aceac7da81
Is this a really good way?