Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
cleanup about page handling and fix missing document.l10n
Browse files Browse the repository at this point in the history
fixes #6012
  • Loading branch information
bridiver committed Dec 7, 2016
1 parent 4e22d24 commit d82cb2a
Show file tree
Hide file tree
Showing 26 changed files with 111 additions and 137 deletions.
4 changes: 2 additions & 2 deletions app/extensions/brave/about-about.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<meta name="defaultLanguage" content="en-US">
<link rel="shortcut icon"type="image/x-icon" href="data:image/x-icon;,">
<title data-l10n-id="aboutPages"></title>
<script src='js/about.js'></script>
<script src="ext/l20n.min.js" async></script>
<script src="ext/l20n.min.js"></script>
<script src="gen/aboutPages.entry.js" async></script>
<link rel="localization" href="locales/{locale}/app.properties">
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions app/extensions/brave/about-adblock.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<meta name='theme-color' content='#4B0082'>
<link rel="shortcut icon"type="image/x-icon" href="data:image/x-icon;,">
<title data-l10n-id="adblockTitle"></title>
<script src='js/about.js'></script>
<script src="ext/l20n.min.js" async></script>
<script src="ext/l20n.min.js"></script>
<script src="gen/aboutPages.entry.js" async></script>
<link rel="localization" href="locales/{locale}/adblock.properties">
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions app/extensions/brave/about-autofill.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<meta name='theme-color' content='#ff5000'>
<link rel="shortcut icon"type="image/x-icon" href="data:image/x-icon;,">
<title data-l10n-id="autofillTitle"></title>
<script src='js/about.js'></script>
<script src="ext/l20n.min.js" async></script>
<script src="ext/l20n.min.js"></script>
<script src="gen/aboutPages.entry.js" async></script>
<link rel="localization" href="locales/{locale}/autofill.properties">
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions app/extensions/brave/about-blank.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<meta name="availableLanguages" content="">
<meta name="defaultLanguage" content="en-US">
<title data-l10n-id="aboutBlank"></title>
<script src='js/about.js'></script>
<script src="ext/l20n.min.js" async></script>
<script src="ext/l20n.min.js"></script>
<script src="gen/aboutPages.entry.js" async></script>
<link rel="localization" href="locales/{locale}/preferences.properties">
</head>
<body />
Expand Down
4 changes: 2 additions & 2 deletions app/extensions/brave/about-bookmarks.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<meta name='theme-color' content='#ff5000'>
<link rel="shortcut icon"type="image/x-icon" href="data:image/x-icon;,">
<title data-l10n-id="bookmarkManager"></title>
<script src='js/about.js'></script>
<script src="ext/l20n.min.js" async></script>
<script src="ext/l20n.min.js"></script>
<script src="gen/aboutPages.entry.js" async></script>
<link rel="localization" href="locales/{locale}/bookmarks.properties">
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions app/extensions/brave/about-brave.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<meta name="defaultLanguage" content="en-US">
<link rel="shortcut icon"type="image/x-icon" href="data:image/x-icon;,">
<title data-l10n-id="aboutBrave"></title>
<script src='js/about.js'></script>
<script src="ext/l20n.min.js" async></script>
<script src="ext/l20n.min.js"></script>
<script src="gen/aboutPages.entry.js" async></script>
<link rel="localization" href="locales/{locale}/app.properties">
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions app/extensions/brave/about-certerror.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<meta name="defaultLanguage" content="en-US">
<meta name='theme-color' content='#ff5000'>
<title data-l10n-id="certError"></title>
<script src='js/about.js'></script>
<script src="ext/l20n.min.js" async></script>
<script src="ext/l20n.min.js"></script>
<script src="gen/aboutPages.entry.js" async></script>
<link rel="localization" href="locales/{locale}/app.properties">
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions app/extensions/brave/about-contributions.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<meta name='theme-color' content='#ff5000'>
<link rel="shortcut icon"type="image/x-icon" href="data:image/x-icon;,">
<title data-l10n-id="contributionStatement"></title>
<script src='js/about.js'></script>
<script src="ext/l20n.min.js" async></script>
<script src="ext/l20n.min.js"></script>
<script src="gen/aboutPages.entry.js" async></script>
<link rel="localization" href="locales/{locale}/preferences.properties">
<link rel="localization" href="locales/{locale}/common.properties">
<link rel="localization" href="locales/{locale}/bravery.properties">
Expand Down
4 changes: 2 additions & 2 deletions app/extensions/brave/about-downloads.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<meta name='theme-color' content='#000080'>
<link rel="shortcut icon"type="image/x-icon" href="data:image/x-icon;,">
<title data-l10n-id="downloads"></title>
<script src='js/about.js'></script>
<script src="ext/l20n.min.js" async></script>
<script src="ext/l20n.min.js"></script>
<script src="gen/aboutPages.entry.js" async></script>
<link rel="localization" href="locales/{locale}/downloads.properties">
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions app/extensions/brave/about-error.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<meta name='theme-color' content='#ff5000'>
<link rel="shortcut icon"type="image/x-icon" href="data:image/x-icon;,">
<title data-l10n-id="error"></title>
<script src='js/about.js'></script>
<script src="ext/l20n.min.js" async></script>
<script src="ext/l20n.min.js"></script>
<script src="gen/aboutPages.entry.js" async></script>
<link rel="localization" href="locales/{locale}/app.properties">
<link rel="localization" href="locales/{locale}/error.properties">
<link rel="localization" href="locales/{locale}/errorMessages.properties">
Expand Down
4 changes: 2 additions & 2 deletions app/extensions/brave/about-extensions.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<meta name='theme-color' content='#565656'>
<link rel="shortcut icon"type="image/x-icon" href="data:image/x-icon;,">
<title data-l10n-id="extensionsTitle"></title>
<script src='js/about.js'></script>
<script src="ext/l20n.min.js" async></script>
<script src="ext/l20n.min.js"></script>
<script src="gen/aboutPages.entry.js" async></script>
<link rel="localization" href="locales/{locale}/extensions.properties">
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions app/extensions/brave/about-flash.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<meta name="defaultLanguage" content="en-US">
<meta name='theme-color' content='#ff5000'>
<title data-l10n-id="flashTitle"></title>
<script src='js/about.js'></script>
<script src="ext/l20n.min.js" async></script>
<script src="ext/l20n.min.js"></script>
<script src="gen/aboutPages.entry.js" async></script>
<link rel="localization" href="locales/{locale}/app.properties">
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions app/extensions/brave/about-history.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<meta name='theme-color' content='#565656'>
<link rel="shortcut icon"type="image/x-icon" href="data:image/x-icon;,">
<title data-l10n-id="historyTitle"></title>
<script src='js/about.js'></script>
<script src="ext/l20n.min.js" async></script>
<script src="ext/l20n.min.js"></script>
<script src="gen/aboutPages.entry.js" async></script>
<link rel="localization" href="locales/{locale}/history.properties">
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions app/extensions/brave/about-newtab.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<meta name="availableLanguages" content="">
<meta name="defaultLanguage" content="en-US">
<title data-l10n-id="newTab"></title>
<script src='js/about.js'></script>
<script src="ext/l20n.min.js" async></script>
<script src="ext/l20n.min.js"></script>
<script src="gen/aboutPages.entry.js" async></script>
<link rel="localization" href="locales/{locale}/newtab.properties">
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions app/extensions/brave/about-passwords.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<meta name='theme-color' content='#ff5000'>
<link rel="shortcut icon"type="image/x-icon" href="data:image/x-icon;,">
<title data-l10n-id="passwordsTitle"></title>
<script src='js/about.js'></script>
<script src="ext/l20n.min.js" async></script>
<script src="ext/l20n.min.js"></script>
<script src="gen/aboutPages.entry.js" async></script>
<link rel="localization" href="locales/{locale}/passwords.properties">
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions app/extensions/brave/about-preferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<meta name='theme-color' content='#ff5000'>
<link rel="shortcut icon"type="image/x-icon" href="data:image/x-icon;,">
<title data-l10n-id="preferences"></title>
<script src='js/about.js'></script>
<script src="ext/l20n.min.js" async></script>
<script src="ext/l20n.min.js"></script>
<script src="gen/aboutPages.entry.js" async></script>
<link rel="localization" href="locales/{locale}/preferences.properties">
<link rel="localization" href="locales/{locale}/common.properties">
<link rel="localization" href="locales/{locale}/bravery.properties">
Expand Down
4 changes: 2 additions & 2 deletions app/extensions/brave/about-safebrowsing.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<meta name="defaultLanguage" content="en-US">
<meta name='theme-color' content='#ff5000'>
<title data-l10n-id="safebrowsingError"></title>
<script src='js/about.js'></script>
<script src="ext/l20n.min.js" async></script>
<script src="ext/l20n.min.js"></script>
<script src="gen/aboutPages.entry.js" async></script>
<link rel="localization" href="locales/{locale}/app.properties">
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions app/extensions/brave/about-styles.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<meta name='theme-color' content='#4B0082'>
<link rel="shortcut icon"type="image/x-icon" href="data:image/x-icon;,">
<title data-l10n-id="styleGuide"></title>
<script src='js/about.js'></script>
<script src="ext/l20n.min.js" async></script>
<script src="ext/l20n.min.js"></script>
<script src="gen/aboutPages.entry.js" async></script>
<link rel="localization" href="locales/{locale}/styles.properties">
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions app/extensions/brave/index-dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<!-- TODO: Replace suggestqueries.google.com and ac.duckduckgo.com and other search engines with a single config search engine -->
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; form-action 'none'; referrer no-referrer; script-src 'self' http://localhost:*; connect-src 'self' https://s3.amazonaws.com/adblock-data/ https://s3.amazonaws.com/safe-browsing-data/ https://s3.amazonaws.com/tracking-protection-data/ https://s3.amazonaws.com/https-everywhere-data/ http://localhost:* ws://localhost:* https://suggestqueries.google.com https://ac.duckduckgo.com https://completion.amazon.com https://search.yahoo.com https://api.bing.com https://www.startpage.com https://infogalactic.com https://api.qwant.com https://brave-download.global.ssl.fastly.net https://brave-laptop-updates.global.ssl.fastly.net https://brave-download.global.ssl.fastly.net https://laptop-updates-pre.brave.com https://brave-laptop-updates-pre.brave.com; style-src 'unsafe-inline'; font-src 'self' http://localhost:*; img-src 'self' * data:; object-src 'self'; plugin-types application/browser-plugin">
<title>Brave</title>
<script src="index-load-script.js" defer></script>
<script src="ext/l20n.min.js" async></script>
<script src="ext/l20n.min.js"></script>
<script src="gen/app.entry.js" async></script>
<link rel="localization" href="locales/{locale}/app.properties">
<link rel="localization" href="locales/{locale}/common.properties">
<link rel="localization" href="locales/{locale}/bravery.properties">
Expand Down
2 changes: 1 addition & 1 deletion app/extensions/brave/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<!-- TODO: Replace suggestqueries.google.com and ac.duckduckgo.com and other search engines with a single config search engine -->
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; form-action 'none'; referrer no-referrer; script-src 'self'; img-src * data:; style-src 'self' 'unsafe-inline'; font-src 'self'; connect-src 'self' https://s3.amazonaws.com/adblock-data/ https://s3.amazonaws.com/safe-browsing-data/ https://s3.amazonaws.com/tracking-protection-data/ https://s3.amazonaws.com/https-everywhere-data/ https://suggestqueries.google.com https://ac.duckduckgo.com https://completion.amazon.com https://search.yahoo.com https://api.bing.com https://www.startpage.com https://infogalactic.com https://api.qwant.com https://brave-download.global.ssl.fastly.net https://brave-laptop-updates.global.ssl.fastly.net https://laptop-updates-pre.brave.com https://brave-laptop-updates-pre.brave.com; object-src 'self'; plugin-types application/browser-plugin"/>
<title>Brave</title>
<script src="ext/l20n.min.js"></script>
<script src="gen/app.entry.js" async></script>
<script src="ext/l20n.min.js" async></script>
<link rel="localization" href="locales/{locale}/app.properties"/>
<link rel="localization" href="locales/{locale}/common.properties"/>
<link rel="localization" href="locales/{locale}/bravery.properties">
Expand Down
63 changes: 0 additions & 63 deletions app/extensions/brave/js/about.js

This file was deleted.

17 changes: 0 additions & 17 deletions app/extensions/torrent/js/webtorrent.js

This file was deleted.

4 changes: 2 additions & 2 deletions app/extensions/torrent/webtorrent.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<meta name="defaultLanguage" content="en-US">
<link rel="shortcut icon" type="image/x-icon" href="img/webtorrent-128.png">
<title data-l10n-id="webtorrentPage"></title>
<script src='js/webtorrent.js'></script>
<script src="ext/l20n.min.js" async></script>
<script src="ext/l20n.min.js"></script>
<script src='gen/webtorrentPage.entry.js'></script>
<link rel="localization" href="locales/{locale}/app.properties">
</head>
<body>
Expand Down
24 changes: 11 additions & 13 deletions app/filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ module.exports.registerHeadersReceivedFilteringCB = (filteringFn) => {
function registerForBeforeRequest (session, partition) {
const isPrivate = !partition.startsWith('persist:')
session.webRequest.onBeforeRequest((details, cb) => {
if (process.env.NODE_ENV === 'development') {
let page = appUrlUtil.getGenDir(details.url)
if (page) {
let redirectURL = 'http://localhost:' + (process.env.BRAVE_PORT || process.env.npm_package_config_port) + '/' + page
cb({
redirectURL
})
return
}
}

if (shouldIgnoreUrl(details.url)) {
cb({})
return
Expand All @@ -96,19 +107,6 @@ function registerForBeforeRequest (session, partition) {
return
}

if (appUrlUtil.isTargetAboutUrl(details.url)) {
if (process.env.NODE_ENV === 'development' && !details.url.match(/devServerPort/)) {
// add webpack dev server port
let url = details.url
let urlComponents = url.split('#')
urlComponents[0] = urlComponents[0] + '?devServerPort=' + (process.env.BRAVE_PORT || process.env.npm_package_config_port)
cb({
redirectURL: urlComponents.join('#')
})
return
}
}

for (let i = 0; i < beforeRequestFilteringFns.length; i++) {
let results = beforeRequestFilteringFns[i](details, isPrivate)
const isAdBlock = results.resourceName === appConfig.resourceNames.ADBLOCK || appConfig[results.resourceName] && appConfig[results.resourceName].resourceType === adBlockResourceName
Expand Down
37 changes: 37 additions & 0 deletions js/about/entry.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,47 @@
var getFavicon = function () {
let favicon
const nodeList = document.getElementsByTagName('link')
for (var i = 0; i < nodeList.length; i++) {
if ((nodeList[i].getAttribute('rel') === 'icon') || (nodeList[i].getAttribute('rel') === 'shortcut icon')) {
favicon = nodeList[i].getAttribute('href')
}
}
return favicon
}

// set favicon as a data url because chrome-extension urls don't work correctly
if (getFavicon()) {
let img = new window.Image()
img.onload = function () {
let canvas = document.createElement('CANVAS')
const ctx = canvas.getContext('2d')
canvas.height = this.height
canvas.width = this.width
ctx.drawImage(this, 0, 0)
const dataURL = canvas.toDataURL()
const docHead = document.getElementsByTagName('head')[0]
const newLink = document.createElement('link')
newLink.rel = 'shortcut icon'
newLink.href = dataURL
docHead.appendChild(newLink)
canvas = null
}
img.src = 'img/favicon.ico'
}

const ReactDOM = require('react-dom')
const {getSourceAboutUrl, getBaseUrl} = require('../lib/appUrlUtil')
const {ABOUT_COMPONENT_INITIALIZED} = require('../constants/messages')
const ipc = window.chrome.ipc

let element

ipc.on('language', (e, detail) => {
document.l10n.requestLanguages([detail.langCode])
document.getElementsByName('availableLanguages')[0].content = detail.languageCodes.join(', ')
})
ipc.send('request-language')

switch (getBaseUrl(getSourceAboutUrl(window.location.href))) {
case 'about:about':
element = require('./about')
Expand Down
Loading

0 comments on commit d82cb2a

Please sign in to comment.