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 authored and bbondy committed Dec 4, 2016
1 parent c252087 commit 44c9e19
Show file tree
Hide file tree
Showing 22 changed files with 100 additions and 108 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
16 changes: 16 additions & 0 deletions app/extensions/brave/about-blank.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<html>
<head>
<meta charset="utf-8">
<meta name="availableLanguages" content="">
<meta name="defaultLanguage" content="en-US">
<title data-l10n-id="aboutBlank"></title>
<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 />
</html>
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-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='#035500'>
<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://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://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.

22 changes: 12 additions & 10 deletions app/filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ const registeredSessions = {}
*/
const permissionCallbacks = {}

let entryPages = ['gen/app.entry.js', 'gen/webtorrentPage.entry.js', 'gen/aboutPages.entry.js']

module.exports.registerBeforeSendHeadersFilteringCB = (filteringFn) => {
beforeSendHeadersFilteringFns.push(filteringFn)
}
Expand Down Expand Up @@ -96,16 +98,16 @@ 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
if (process.env.NODE_ENV === 'development') {
for (let i = 0; i < entryPages.length; i++) {
let page = entryPages[i]
if (appUrlUtil.getBraveExtUrl(page) === details.url) {
let redirectURL = 'http://localhost:' + (process.env.BRAVE_PORT || process.env.npm_package_config_port) + '/' + page
cb({
redirectURL
})
return
}
}
}

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

0 comments on commit 44c9e19

Please sign in to comment.