Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Branding in settings and history pages #462

Merged
merged 2 commits into from
Jul 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/l10nUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const braveMdExtensionsPartPath = path.resolve(path.join(srcDir, 'brave', 'app',

const braveExtensionsResourcesPath = path.resolve(path.join(srcDir, 'brave', 'browser', 'resources', 'md_extensions', 'extensions_resources.grd'))
const braveSettingsResourcesPath = path.resolve(path.join(srcDir, 'brave', 'browser', 'resources', 'settings', 'settings_resources.grd'))
const braveBrowserResourcesPath = path.resolve(path.join(srcDir, 'brave', 'browser', 'browser_resources.grd'))

// Chromium string paths
const chromiumStringsPath = path.resolve(path.join(srcDir, 'chrome', 'app', 'chromium_strings.grd'))
Expand All @@ -37,9 +38,15 @@ const chromiumMdExtensionsPartPath = path.resolve(path.join(srcDir, 'chrome', 'a

const chromiumExtensionsResourcesPath = path.resolve(path.join(srcDir, 'chrome', 'browser', 'resources', 'md_extensions', 'extensions_resources.grd'))
const chromiumSettingsResourcesPath = path.resolve(path.join(srcDir, 'chrome', 'browser', 'resources', 'settings', 'settings_resources.grd'))
const chromiumBrowserResourcesPath = path.resolve(path.join(srcDir, 'chrome', 'browser', 'browser_resources.grd'))

const autoGeneratedWarning = '<!-- This file is created by l10nUtil.js. Do not edit manually. -->'

const pageVisibility = ' <structure name="IDR_SETTINGS_PAGE_VISIBILITY_JS"\n'
const bravePageVisibility = ' <structure name="IDR_SETTINGS_BRAVE_PAGE_VISIBILITY_JS"\n' +
' file="brave_page_visibility.js"\n' +
' type="chrome_html" />\n'

module.exports.getSourceStringPaths = () => {
return [
braveStringsPath,
Expand All @@ -65,14 +72,17 @@ module.exports.rebaseBraveStringFilesOnChromiumL10nFiles = (path) =>
[chromiumSettingsStringsPartPath]: braveSettingsStringsPartPath,
[chromiumMdExtensionsPartPath]: braveMdExtensionsPartPath,
[chromiumExtensionsResourcesPath]: braveExtensionsResourcesPath,
[chromiumSettingsResourcesPath]: braveSettingsResourcesPath
[chromiumSettingsResourcesPath]: braveSettingsResourcesPath,
[chromiumBrowserResourcesPath]: braveBrowserResourcesPath
}).forEach(([sourcePath, destPath]) =>
fs.writeFileSync(destPath,
fs.readFileSync(sourcePath, 'utf8')
.replace(/<\?xml version="1.0" encoding="utf-8"\?>/i, '<?xml version="1.0" encoding="utf-8"?>\n' + autoGeneratedWarning)
.replace('<structure name="IDR_MD_EXTENSIONS_SIDEBAR_HTML"', '<structure name="IDR_MD_EXTENSIONS_SIDEBAR_HTML" preprocess="true"')
.replace('<structure name="IDR_SETTINGS_APPEARANCE_FONTS_PAGE_HTML"', '<structure name="IDR_SETTINGS_APPEARANCE_FONTS_PAGE_HTML" preprocess="true"')
.replace('<structure name="IDR_SETTINGS_PASSWORDS_SECTION_HTML"', '<structure name="IDR_SETTINGS_PASSWORDS_SECTION_HTML" preprocess="true"')
.replace('<include name="IDR_MD_HISTORY_SIDE_BAR_HTML"', '<include name="IDR_MD_HISTORY_SIDE_BAR_HTML" flattenhtml="true"')
.replace(pageVisibility, bravePageVisibility + pageVisibility)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It occurred to me that we should probably throw an error if the expected number of replacements doesn't match exactly with the number of replacements. In this case 1.
I posted this Backlog issue for that:
#475

.replace(/settings_chromium_strings.grdp/g, 'settings_brave_strings.grdp')
.replace(/The Chromium Authors/g, 'Brave Software Inc')
.replace(/Google Chrome/g, 'Brave')
Expand Down
4 changes: 4 additions & 0 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ const util = {
const braveAppDir = path.join(config.projects['brave-core'].dir, 'app')
const chromeResourcesDir = path.join(config.srcDir, 'chrome', 'browser', 'resources')
const braveResourcesDir = path.join(config.projects['brave-core'].dir, 'browser', 'resources')
const chromeBrowserDir = path.join(config.srcDir, 'chrome', 'browser')
const braveBrowserDir = path.join(config.projects['brave-core'].dir, 'browser')

fs.copySync(path.join(braveAppDir, 'brave_strings.grd'), path.join(chromeAppDir, 'brave_strings.grd'))
fs.copySync(path.join(braveAppDir, 'settings_brave_strings.grdp'), path.join(chromeAppDir, 'settings_brave_strings.grdp'))
Expand All @@ -71,6 +73,7 @@ const util = {
fs.copySync(path.join(braveAppDir, 'md_extensions_strings.grdp'), path.join(chromeAppDir, 'md_extensions_strings.grdp'))
fs.copySync(path.join(braveResourcesDir, 'md_extensions', 'extensions_resources.grd'), path.join(chromeResourcesDir, 'md_extensions', 'extensions_resources.grd'))
fs.copySync(path.join(braveResourcesDir, 'settings', 'settings_resources.grd'), path.join(chromeResourcesDir, 'settings', 'settings_resources.grd'))
fs.copySync(path.join(braveBrowserDir, 'browser_resources.grd'), path.join(chromeBrowserDir, 'browser_resources.grd'))
fs.copySync(path.join(braveAppDir, 'components_brave_strings.grd'), path.join(config.srcDir, 'components', 'components_brave_strings.grd'))
fs.copySync(path.join(braveAppDir, 'theme', 'brave'), path.join(chromeAppDir, 'theme', 'brave'))
fs.copySync(path.join(braveAppDir, 'theme', 'default_100_percent', 'brave'), path.join(chromeAppDir, 'theme', 'default_100_percent', 'brave'))
Expand All @@ -84,6 +87,7 @@ const util = {
fs.copySync(path.join(braveAppDir, 'resources'), path.join(chromeAppDir, 'resources'))
// Copy XTB files for brave/app/components_brave_strings.grd => components/components_chromium_strings.grd
fs.copySync(path.join(braveAppDir, 'strings'), path.join(chromeComponentsDir, 'strings'))
fs.copySync(path.join(braveResourcesDir, 'settings', 'brave_page_visibility.js'), path.join(chromeResourcesDir, 'settings', 'brave_page_visibility.js'))
},

// Chromium compares pre-installed midl files and generated midl files from IDL during the build to check integrity.
Expand Down