Skip to content
This repository was archived by the owner on Jun 16, 2020. It is now read-only.

Commit

Permalink
feat: mix in IPFS
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Aug 22, 2017
1 parent eced5c4 commit a3a481b
Show file tree
Hide file tree
Showing 45 changed files with 431 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ Brave.tar.bz2
app/extensions/gen
app/extensions/brave/gen
app/extensions/torrent/gen
app/extensions/ipfs/gen

*.pfx
buildConfig.js

Expand Down
24 changes: 18 additions & 6 deletions app/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,17 @@ module.exports.init = () => {
return object
}

let loadExtension = (extensionId, extensionPath, manifest = {}, manifestLocation = 'unpacked') => {
if (extensionId === config.PDFJSExtensionId) {
const loadExtension = (extensionId, extensionPath, manifest = {}, manifestLocation = 'unpacked') => {
if (extensionId === config.PDFJSExtensionId ||
extensionId === config.ipfsExtensionId) {
manifestLocation = 'component'
}
if (!extensionInfo.isLoaded(extensionId) && !extensionInfo.isLoading(extensionId)) {
if (!extensionInfo.isLoaded(extensionId) &&
!extensionInfo.isLoading(extensionId)) {
extensionInfo.setState(extensionId, extensionStates.LOADING)
if (extensionId === config.braveExtensionId || extensionId === config.torrentExtensionId || extensionId === config.syncExtensionId) {
if (extensionId === config.braveExtensionId ||
extensionId === config.torrentExtensionId ||
extensionId === config.syncExtensionId) {
session.defaultSession.extensions.load(extensionPath, manifest, manifestLocation)
return
}
Expand All @@ -430,6 +434,7 @@ module.exports.init = () => {
// just a safety net.
fs.exists(path.join(extensionPath, 'manifest.json'), (exists) => {
if (exists) {
console.log('Loading:', extensionId, manifestLocation)
session.defaultSession.extensions.load(extensionPath, manifest, manifestLocation)
} else {
// This is an error condition, but we can recover.
Expand All @@ -454,18 +459,21 @@ module.exports.init = () => {
const extensions = extensionState.getExtensions(appStore.getState())
const extensionPath = extensions.getIn([extensionId, 'filePath'])
if (extensionPath) {
// Otheriwse just install it
// Otherwise just install it
loadExtension(extensionId, extensionPath)
}
}
}

// Manually install the braveExtension and torrentExtension
// Manually install the braveExtension, torrentExtension and ipfsExtension

// braveExtension
extensionInfo.setState(config.braveExtensionId, extensionStates.REGISTERED)
loadExtension(config.braveExtensionId, getExtensionsPath('brave'), generateBraveManifest(), 'component')
extensionInfo.setState(config.syncExtensionId, extensionStates.REGISTERED)
loadExtension(config.syncExtensionId, getExtensionsPath('brave'), generateSyncManifest(), 'unpacked')

// torrentExtension
if (getSetting(settings.TORRENT_VIEWER_ENABLED)) {
extensionInfo.setState(config.torrentExtensionId, extensionStates.REGISTERED)
loadExtension(config.torrentExtensionId, getExtensionsPath('torrent'), generateTorrentManifest(), 'component')
Expand All @@ -474,6 +482,10 @@ module.exports.init = () => {
extensionActions.extensionDisabled(config.torrentExtensionId)
}

// ipfsExtension
extensionInfo.setState(config.ipfsExtensionId, extensionStates.REGISTERED)
loadExtension(config.ipfsExtensionId, getExtensionsPath('ipfs'))

let registerComponents = (diff) => {
if (getSetting(settings.PDFJS_ENABLED)) {
registerComponent(config.PDFJSExtensionId, config.PDFJSExtensionPublicKey)
Expand Down
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/bn-BD/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=URL Bar Options
disableTitleMode=সর্বদা URL বার দেখান
wideURLbar=Use wide URL bar
autoplay=Autoplay Media
<<<<<<< HEAD
tabPreviewTiming=Time to wait before previewing a tab
long=Long
normal=Normal
short=Short
useIPFS=Enable IPFS (requires browser restart)
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/bn-IN/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=URL Bar Options
disableTitleMode=Always show the URL bar
wideURLbar=Use wide URL bar
autoplay=Autoplay Media
<<<<<<< HEAD
tabPreviewTiming=Time to wait before previewing a tab
long=Long
normal=Normal
short=Short
useIPFS=Enable IPFS (requires browser restart)
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/cs/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=Volby pro adresní řádek
disableTitleMode=Vždy ukázat adresní řádek
wideURLbar=Použít široký adresní řádek
autoplay=Automatické přehrávání
<<<<<<< HEAD
tabPreviewTiming=Time to wait before previewing a tab
long=Dlouhý
normal=Normal
short=Krátký
useIPFS=Enable IPFS (requires browser restart)
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/de-DE/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=Einstellungen der URL-Zeile
disableTitleMode=URL Zeile immer anzeigen
wideURLbar=Lange URL-Zeile verwenden
autoplay=Automatisch Medien abspielen
<<<<<<< HEAD
tabPreviewTiming=Time to wait before previewing a tab
long=Long
normal=Normal
short=Short
useIPFS=Enable IPFS (requires browser restart)
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/en-US/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=URL Bar Options
disableTitleMode=Always show the URL bar
wideURLbar=Use wide URL bar
autoplay=Autoplay Media
<<<<<<< HEAD
tabPreviewTiming=Time to wait before previewing a tab
long=Long
normal=Normal
short=Short
useIPFS=Enable IPFS (requires browser restart)
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/es/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=URL Bar Options
disableTitleMode=Mostrar siempre la barra de URL
wideURLbar=Use wide URL bar
autoplay=Autoplay Media
<<<<<<< HEAD
tabPreviewTiming=Time to wait before previewing a tab
long=Long
normal=Normal
short=Short
useIPFS=Enable IPFS (requires browser restart)
1 change: 1 addition & 0 deletions app/extensions/brave/locales/eu/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -384,3 +384,4 @@ tabPreviewTiming=Time to wait before previewing a tab
long=Long
normal=Normal
short=Short
useIPFS=Enable IPFS (requires browser restart)
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/fr-FR/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=URL Bar Options
disableTitleMode=Toujours afficher la barre d'adresse
wideURLbar=Use wide URL bar
autoplay=Autoplay Media
<<<<<<< HEAD
tabPreviewTiming=Time to wait before previewing a tab
long=Long
normal=Normal
short=Short
useIPFS=Enable IPFS (requires browser restart)
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/hi-IN/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=URL Bar Options
disableTitleMode=Always show the URL bar
wideURLbar=Use wide URL bar
autoplay=Autoplay Media
<<<<<<< HEAD
tabPreviewTiming=Time to wait before previewing a tab
long=Long
normal=Normal
short=Short
useIPFS=Enable IPFS (requires browser restart)
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/id-ID/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=Pilihan bilah URL
disableTitleMode=Selalu tampilkan bilah URL
wideURLbar=Gunakan bilah URL yang lebar
autoplay=Media Putar Otomatis
<<<<<<< HEAD
tabPreviewTiming=Waktunya menunggu sebelum meninjau tab baru
long=Panjang
normal=Normal
short=Pendek
useIPFS=Enable IPFS (requires browser restart)
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/it-IT/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=Opzioni della barra degli indirizzi
disableTitleMode=Visualizza sempre la barra degli indirizzi
wideURLbar=Utilizza barra degli indirizzi ampia
autoplay=Riproduzione automatica dei file multimediali
<<<<<<< HEAD
tabPreviewTiming=Time to wait before previewing a tab
long=Long
normal=Normal
short=Short
useIPFS=Enable IPFS (requires browser restart)
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/ja-JP/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=URLバーの設定
disableTitleMode=URLバーを常に表示
wideURLbar=幅の広いURLバーを使う
autoplay=自動再生
<<<<<<< HEAD
tabPreviewTiming=Time to wait before previewing a tab
long=長い
normal=Normal
short=短い
useIPFS=Enable IPFS (requires browser restart)
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/ko-KR/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=URL Bar Options
disableTitleMode=주소창 항상 표시
wideURLbar=Use wide URL bar
autoplay=Autoplay Media
<<<<<<< HEAD
tabPreviewTiming=Time to wait before previewing a tab
long=Long
normal=Normal
short=Short
useIPFS=Enable IPFS (requires browser restart)
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/ms-MY/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=Pilihan Bar URL
disableTitleMode=Sentiasa pamer bar URL
wideURLbar=Guna bar URL lebar
autoplay=Media Autoplay
<<<<<<< HEAD
tabPreviewTiming=Tempoh menunggu sebelum previu tab
long=Panjang
normal=Normal
short=Pendek
useIPFS=Enable IPFS (requires browser restart)
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/nl-NL/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=URL Bar Options
disableTitleMode=Altijd de URL-balk laten zien
wideURLbar=Use wide URL bar
autoplay=Autoplay Media
<<<<<<< HEAD
tabPreviewTiming=Time to wait before previewing a tab
long=Lang
normal=Normal
short=Kort
useIPFS=Enable IPFS (requires browser restart)
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/pl-PL/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=URL Bar Options
disableTitleMode=Always show the URL bar
wideURLbar=Use wide URL bar
autoplay=Autoplay Media
<<<<<<< HEAD
tabPreviewTiming=Time to wait before previewing a tab
long=Long
normal=Normal
short=Short
useIPFS=Enable IPFS (requires browser restart)
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/pt-BR/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=URL Bar Options
disableTitleMode=Mostrar sempre a barra de URL
wideURLbar=Use wide URL bar
autoplay=Reproduzir mídia automaticamente
<<<<<<< HEAD
tabPreviewTiming=Time to wait before previewing a tab
long=Long
normal=Normal
short=Short
useIPFS=Enable IPFS (requires browser restart)
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/ru/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=Параметры панели адресной строки
disableTitleMode=Всегда отображать строку адреса
wideURLbar=Использовать широкую панель адресной строки
autoplay=Автовоспроизведение медиа
<<<<<<< HEAD
tabPreviewTiming=Время ожидания перед просмотром вкладки
long=Длинное
normal=Normal
short=Короткое
useIPFS=Enable IPFS (requires browser restart)
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/sl/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=Možnosti vrstice URL
disableTitleMode=Vedno pokaži vrstico naslova URL
wideURLbar=Uporabi široko vrstico URL
autoplay=Samodejno predvajaj datoteke
<<<<<<< HEAD
tabPreviewTiming=Time to wait before previewing a tab
long=Dolga
normal=Normal
short=Kratka
useIPFS=Enable IPFS (requires browser restart)
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/ta/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=URL Bar Options
disableTitleMode=Always show the URL bar
wideURLbar=Use wide URL bar
autoplay=Autoplay Media
<<<<<<< HEAD
tabPreviewTiming=Time to wait before previewing a tab
long=Long
normal=Normal
short=Short
useIPFS=Enable IPFS (requires browser restart)
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/te/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=URL Bar Options
disableTitleMode=Always show the URL bar
wideURLbar=Use wide URL bar
autoplay=Autoplay Media
<<<<<<< HEAD
tabPreviewTiming=Time to wait before previewing a tab
long=Long
normal=Normal
short=Short
useIPFS=Enable IPFS (requires browser restart)
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/tr-TR/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=URL Bar Options
disableTitleMode=Url çubuğunu her zaman göster
wideURLbar=Use wide URL bar
autoplay=Autoplay Media
<<<<<<< HEAD
tabPreviewTiming=Time to wait before previewing a tab
long=Long
normal=Normal
short=Short
useIPFS=Enable IPFS (requires browser restart)
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/uk/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=Опції панелі URL
disableTitleMode=Завжди показувати панель адреси
wideURLbar=Використовувати широку панель URL-адреси
autoplay=Авто-відтворення медіа
<<<<<<< HEAD
tabPreviewTiming=Time to wait before previewing a tab
long=Long
normal=Normal
short=Short
useIPFS=Enable IPFS (requires browser restart)
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/zh-CN/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ urlBarOptions=URL Bar Options
disableTitleMode=总是显示URL栏
wideURLbar=Use wide URL bar
autoplay=Autoplay Media
<<<<<<< HEAD
tabPreviewTiming=Time to wait before previewing a tab
long=Long
normal=Normal
short=Short
useIPFS=Enable IPFS (requires browser restart)
23 changes: 23 additions & 0 deletions app/extensions/ipfs/_locales/en/app.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
startPrompt=Start Downloading "{{name}}"?
startPromptUntitled=Start Downloading?
startDownload=Start Download
saveTorrentFile=Save Torrent File...
legalNotice=When you start a torrent, its data will be made available to others by means of upload. You are responsible for abiding by your local laws.
missingFilesList=Click "Start Download" to load the torrent file list.
loadingFilesList=Loading the torrent file list...
name=Name
size=Size
poweredByWebTorrent=Powered By WebTorrent.
seeding=Seeding
seedingTorrent=Seeding Torrent
downloading=Downloading
downloadingTorrent=Downloading Torrent
files=Files
num=#
downloadFile=Save File
torrentStatus=Torrent Status
torrentLoadingInfo=Loading torrent info...
torrentLoadingMedia=Loading...
copyMagnetLink=Copy Magnet Link
webtorrentPage=WebTorrent
stopDownload=Stop Download
1 change: 1 addition & 0 deletions app/extensions/ipfs/_locales/en/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
3 changes: 3 additions & 0 deletions app/extensions/ipfs/ext/l20n.min.js

Large diffs are not rendered by default.

Binary file added app/extensions/ipfs/img/favicon.ico
Binary file not shown.
Binary file added app/extensions/ipfs/img/ipfs-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/extensions/ipfs/img/ipfs-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/extensions/ipfs/img/ipfs-48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/extensions/ipfs/img/ipfs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
240 changes: 240 additions & 0 deletions app/extensions/ipfs/js/ipfs.min.js

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions app/extensions/ipfs/js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// const ipc = window.chrome.ipcRenderer

chrome.protocol.registerStringProtocol('ipfs', (request, callback) => {
/*
const node = new IPFS()
node.on('ready', () => {
callback('hi there!' + test() + IPFS) // eslint-disable-line
})
*/
callback('hi there!' + test() + IPFS) // eslint-disable-line
})
1 change: 1 addition & 0 deletions app/extensions/ipfs/js/some-other.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
function test () { return 'yeeah' }
21 changes: 21 additions & 0 deletions app/extensions/ipfs/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"manifest_version": 2,
"name": "IPFS",
"version": "0.1.0",
"default_locale": "en",
"description": "InterPlanetary FileSystem",
"icons": {
"128": "img/ipfs-128.png",
"48": "img/ipfs-48.png",
"16": "img/ipfs-16.png"
},
"offline_enabled": true,
"background": {
"scripts": [
"js/some-other.js",
"js/ipfs.min.js",
"js/main.js"
],
"persistent": true
}
}
1 change: 1 addition & 0 deletions docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ AppStore
'advanced.send-usage-statistics': boolean, // true or undefined if usage reports should be sent
'advanced.smooth-scroll-enabled': boolean, // false if smooth scrolling should be explicitly disabled
'advanced.torrent-viewer-enabled': boolean, // whether to render magnet links in the browser
'advanced.ipfs-enabled': boolean, // whether to use IPFS to render ipfs:// or dweb: links in the browser
'bookmarks.toolbar.show': boolean, // true if the bookmakrs toolbar should be shown
'bookmarks.toolbar.showFavicon': boolean, // true if bookmark favicons should be shown on the bookmarks toolbar
'bookmarks.toolbar.showOnlyFavicon': boolean, // true if only favicons should be shown on the bookmarks toolbar
Expand Down
1 change: 1 addition & 0 deletions js/about/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,7 @@ class AboutPreferences extends React.Component {
settings.LANGUAGE,
settings.PDFJS_ENABLED,
settings.TORRENT_VIEWER_ENABLED,
settings.IPFS_ENABLED,
settings.SMOOTH_SCROLL_ENABLED,
settings.SEND_CRASH_REPORTS,
settings.UPDATE_TO_PREVIEW_RELEASES
Expand Down
Loading

0 comments on commit a3a481b

Please sign in to comment.