Move files that are copied to chromium to their own directory (#33159)

Separate files that overwrite chromium resources from brave specific resources and validate that there is a corresponding file in upstream.
This commit is contained in:
Brian Johnson
2026-01-14 05:18:58 -07:00
committed by GitHub
parent 2feaeccbae
commit 9324eec2d3
88 changed files with 22 additions and 356 deletions
+10 -4
View File
@@ -251,7 +251,7 @@ def CheckNewThemeFilesForUpstreamOverride(input_api, output_api):
source_file_filter = lambda f: input_api.FilterSourceFile(
f,
files_to_check=[r"^app/theme/.*"],
files_to_check=[r"^app/theme/.*", r"^build/chromium/resources/.*"],
files_to_skip=input_api.DEFAULT_FILES_TO_SKIP)
new_sources = []
@@ -274,9 +274,15 @@ def CheckNewThemeFilesForUpstreamOverride(input_api, output_api):
upstream_file = f.replace('/brave_origin/', '/chromium/', 1)
elif '/brave/' in f:
upstream_file = f.replace('/brave/', '/chromium/', 1)
if 'build/chromium/resources/' in f:
upstream_file = f.replace('build/chromium/resources/', '//', 1)
elif 'app/theme/' in f:
upstream_file = f'//chrome/{upstream_file}'
else:
upstream_file = f
path = brave_chromium_utils.wspath(f'//chrome/{upstream_file}')
path = brave_chromium_utils.wspath(upstream_file)
if not os.path.exists(path):
problems.append(upstream_file)
@@ -285,8 +291,8 @@ def CheckNewThemeFilesForUpstreamOverride(input_api, output_api):
output_api.PresubmitError(
'Missing upstream theme file to override',
items=sorted(problems),
long_text='app/theme should only be used for overrides of '
'upstream theme files in chrome/app/theme. Channel-specific '
long_text='app/theme and build/chromium/resources should only '
'be used for overrides of upstream files. Channel-specific '
'theme assets (e.g., dev/beta/nightly) are exempt.')
]
return []
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- The attributes in this XML file provide configuration information -->
<!-- for the SyncAdapter. -->
<sync-adapter />
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

@@ -1 +0,0 @@
<svg width="169" height="400" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h400v169H0z" fill="#3c4043" style="fill-opacity: 0.0;"/></svg>

Before

Width:  |  Height:  |  Size: 153 B

@@ -1 +0,0 @@
<svg width="169" height="400" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h400v169H0z" fill="#3c4043" style="fill-opacity: 0.0;"/></svg>

Before

Width:  |  Height:  |  Size: 153 B

@@ -1 +0,0 @@
<svg width="169" height="400" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h400v169H0z" fill="#f8f9fa" style="fill-opacity: 0.0;"/></svg>

Before

Width:  |  Height:  |  Size: 153 B

@@ -1 +0,0 @@
<svg width="169" height="400" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h400v169H0z" fill="#f8f9fa" style="fill-opacity: 0.0;"/></svg>

Before

Width:  |  Height:  |  Size: 153 B

+1
View File
@@ -0,0 +1 @@
This directory contains resource files that should overwrite upstream. It is for resource files only (jpg, svg, xml, etc...)

Before

Width:  |  Height:  |  Size: 963 B

After

Width:  |  Height:  |  Size: 963 B

Before

Width:  |  Height:  |  Size: 647 B

After

Width:  |  Height:  |  Size: 647 B

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Before

Width:  |  Height:  |  Size: 153 B

After

Width:  |  Height:  |  Size: 153 B

Before

Width:  |  Height:  |  Size: 153 B

After

Width:  |  Height:  |  Size: 153 B

Before

Width:  |  Height:  |  Size: 562 B

After

Width:  |  Height:  |  Size: 562 B

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Before

Width:  |  Height:  |  Size: 836 B

After

Width:  |  Height:  |  Size: 836 B

Before

Width:  |  Height:  |  Size: 580 B

After

Width:  |  Height:  |  Size: 580 B

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Before

Width:  |  Height:  |  Size: 215 B

After

Width:  |  Height:  |  Size: 215 B

Before

Width:  |  Height:  |  Size: 172 B

After

Width:  |  Height:  |  Size: 172 B

Before

Width:  |  Height:  |  Size: 251 B

After

Width:  |  Height:  |  Size: 251 B

Before

Width:  |  Height:  |  Size: 357 B

After

Width:  |  Height:  |  Size: 357 B

Before

Width:  |  Height:  |  Size: 452 B

After

Width:  |  Height:  |  Size: 452 B

+11 -342
View File
@@ -16,15 +16,10 @@ exports.update = () => {
const braveComponentsDir = path.join(config.braveCoreDir, 'components')
const chromeAppDir = path.join(config.srcDir, 'chrome', 'app')
const braveAppDir = path.join(config.braveCoreDir, 'app')
const chromeBrowserResourcesDir = path.join(
config.srcDir,
'chrome',
'browser',
'resources',
)
const braveBrowserResourcesDir = path.join(
const braveChromiumResources = path.join(
config.braveCoreDir,
'browser',
'build',
'chromium',
'resources',
)
const braveAppVectorIconsDir = path.join(config.braveCoreDir, 'components')
@@ -123,14 +118,7 @@ exports.update = () => {
])
}
}
fileMap.add([
path.join(braveAppDir, 'theme', 'default_100_percent', 'common'),
path.join(chromeAppDir, 'theme', 'default_100_percent', 'common'),
])
fileMap.add([
path.join(braveAppDir, 'theme', 'default_200_percent', 'common'),
path.join(chromeAppDir, 'theme', 'default_200_percent', 'common'),
])
fileMap.add([path.join(braveChromiumResources), path.join(config.srcDir)])
// Copy product_logo for version UI (about:version page).
// product_logo_name_48.png is renamed to product_logo.png during copy.
// Use brave_origin logos when is_brave_origin_branded is true.
@@ -171,95 +159,12 @@ exports.update = () => {
),
])
}
// Replace history page's favicon.
fileMap.add([
path.join(
braveComponentsDir,
'resources',
'default_100_percent',
'favicon_history.png',
),
path.join(
chromeComponentsDir,
'resources',
'default_100_percent',
'favicon_history.png',
),
])
fileMap.add([
path.join(
braveComponentsDir,
'resources',
'default_200_percent',
'favicon_history.png',
),
path.join(
chromeComponentsDir,
'resources',
'default_200_percent',
'favicon_history.png',
),
])
for (const branding of ['brave', 'brave_origin']) {
fileMap.add([
path.join(braveAppVectorIconsDir, 'vector_icons', branding),
path.join(chromeComponentsDir, 'vector_icons', branding),
])
}
// Copy chrome-logo-faded.png for replacing chrome logo of welcome page with brave's on Win8.
fileMap.add([
path.join(braveBrowserResourcesDir, 'chrome-logo-faded.png'),
path.join(chromeBrowserResourcesDir, 'chrome-logo-faded.png'),
])
fileMap.add([
path.join(
braveBrowserResourcesDir,
'downloads',
'images',
'incognito_marker.svg',
),
path.join(
chromeBrowserResourcesDir,
'downloads',
'images',
'incognito_marker.svg',
),
])
fileMap.add([
path.join(braveBrowserResourcesDir, 'settings', 'images'),
path.join(chromeBrowserResourcesDir, 'settings', 'images'),
])
fileMap.add([
path.join(braveBrowserResourcesDir, 'signin', 'images'),
path.join(chromeBrowserResourcesDir, 'signin', 'images'),
])
fileMap.add([
path.join(
braveBrowserResourcesDir,
'signin',
'profile_customization',
'images',
),
path.join(
chromeBrowserResourcesDir,
'signin',
'profile_customization',
'images',
),
])
fileMap.add([
path.join(braveBrowserResourcesDir, 'signin', 'profile_picker', 'images'),
path.join(chromeBrowserResourcesDir, 'signin', 'profile_picker', 'images'),
])
fileMap.add([
path.join(braveBrowserResourcesDir, 'side_panel', 'reading_list', 'images'),
path.join(
chromeBrowserResourcesDir,
'side_panel',
'reading_list',
'images',
),
])
// Copy to make our ${branding_path_product}_behaviors.cc
fileMap.add([
@@ -423,6 +328,9 @@ exports.update = () => {
}
for (let sourceFile of sourceFiles) {
if (path.basename(sourceFile) === 'README.md') {
continue
}
const destinationFile = path.join(
output,
path.relative(source, sourceFile),
@@ -497,20 +405,15 @@ exports.update = () => {
androidIconSet = 'res_brave_nightly'
}
const androidTranslateResSource = path.join(
const androidResSource = path.join(
config.braveCoreDir,
'components',
'translate',
'content',
'android',
'java',
'res',
)
const androidTranslateResDest = path.join(
const androidResDest = path.join(
config.srcDir,
'components',
'translate',
'content',
'chrome',
'android',
'java',
'res',
@@ -543,246 +446,12 @@ exports.update = () => {
'java',
'res_chromium_base',
)
const androidResSource = path.join(
config.braveCoreDir,
'android',
'java',
'res',
)
const androidResDest = path.join(
config.srcDir,
'chrome',
'android',
'java',
'res',
)
const androidResTemplateSource = path.join(
config.braveCoreDir,
'android',
'java',
'res_template',
)
const androidResTemplateDest = path.join(
config.srcDir,
'chrome',
'android',
'java',
'res_template',
)
const androidContentPublicResSource = path.join(
config.braveCoreDir,
'content',
'public',
'android',
'java',
'res',
)
const androidContentPublicResDest = path.join(
config.srcDir,
'content',
'public',
'android',
'java',
'res',
)
const androidTouchtoFillResSource = path.join(
config.braveCoreDir,
'browser',
'touch_to_fill',
'password_manager',
'android',
'internal',
'java',
'res',
)
const androidTouchtoFillResDest = path.join(
config.srcDir,
'chrome',
'browser',
'touch_to_fill',
'password_manager',
'android',
'internal',
'java',
'res',
)
const androidToolbarResSource = path.join(
config.braveCoreDir,
'browser',
'ui',
'android',
'toolbar',
'java',
'res',
)
const androidToolbarResDest = path.join(
config.srcDir,
'chrome',
'browser',
'ui',
'android',
'toolbar',
'java',
'res',
)
const androidComponentsWidgetResSource = path.join(
config.braveCoreDir,
'components',
'browser_ui',
'widget',
'android',
'java',
'res',
)
const androidComponentsWidgetResDest = path.join(
config.srcDir,
'components',
'browser_ui',
'widget',
'android',
'java',
'res',
)
const androidComponentsStylesResSource = path.join(
config.braveCoreDir,
'components',
'browser_ui',
'styles',
'android',
'java',
'res',
)
const androidComponentsStylesResDest = path.join(
config.srcDir,
'components',
'browser_ui',
'styles',
'android',
'java',
'res',
)
const androidSafeBrowsingResSource = path.join(
config.braveCoreDir,
'browser',
'safe_browsing',
'android',
'java',
'res',
)
const androidSafeBrowsingResDest = path.join(
config.srcDir,
'chrome',
'browser',
'safe_browsing',
'android',
'java',
'res',
)
const androidDownloadInternalResSource = path.join(
config.braveCoreDir,
'browser',
'download',
'internal',
'android',
'java',
'res',
)
const androidDownloadInternalResDest = path.join(
config.srcDir,
'chrome',
'browser',
'download',
'internal',
'android',
'java',
'res',
)
const androidFeaturesTabUiResSource = path.join(
config.braveCoreDir,
'android',
'features',
'tab_ui',
'java',
'res',
)
const androidFeaturesTabUiDest = path.join(
config.srcDir,
'chrome',
'android',
'features',
'tab_ui',
'java',
'res',
)
const androidComponentsOmniboxResSource = path.join(
config.braveCoreDir,
'components',
'omnibox',
'browser',
'android',
'java',
'res',
)
const androidComponentsOmniboxResDest = path.join(
config.srcDir,
'components',
'omnibox',
'browser',
'android',
'java',
'res',
)
const androidBrowserPrivateResSource = path.join(
config.braveCoreDir,
'browser',
'incognito',
'android',
'java',
'res',
)
const androidBrowserPrivateResDest = path.join(
config.srcDir,
'chrome',
'browser',
'incognito',
'android',
'java',
'res',
)
const uiAndroidResSource = path.join(
config.braveCoreDir,
'ui',
'android',
'java',
'res',
)
const uiAndroidResDest = path.join(
config.srcDir,
'ui',
'android',
'java',
'res',
)
// Mapping for copying Brave's Android resource into chromium folder.
const copyAndroidResourceMapping = {
[androidTranslateResSource]: [androidTranslateResDest],
[androidResSource]: [androidResDest],
[androidIconSource]: [androidIconDest],
[androidIconBaseSource]: [androidIconBaseDest],
[androidResSource]: [androidResDest],
[androidResTemplateSource]: [androidResTemplateDest],
[androidContentPublicResSource]: [androidContentPublicResDest],
[androidTouchtoFillResSource]: [androidTouchtoFillResDest],
[androidToolbarResSource]: [androidToolbarResDest],
[androidComponentsWidgetResSource]: [androidComponentsWidgetResDest],
[androidComponentsStylesResSource]: [androidComponentsStylesResDest],
[androidSafeBrowsingResSource]: [androidSafeBrowsingResDest],
[androidDownloadInternalResSource]: [androidDownloadInternalResDest],
[androidFeaturesTabUiResSource]: [androidFeaturesTabUiDest],
[androidComponentsOmniboxResSource]: [androidComponentsOmniboxResDest],
[androidBrowserPrivateResSource]: [androidBrowserPrivateResDest],
[uiAndroidResSource]: [uiAndroidResDest],
}
console.log('copy Android app icons and app resources')