diff --git a/.gitignore b/.gitignore index 7d105c26b11..310d31f5a34 100644 --- a/.gitignore +++ b/.gitignore @@ -56,7 +56,7 @@ app/extensions/gen app/extensions/brave/gen app/extensions/torrent/gen *.pfx -buildConfig.js +js/constants/buildConfig.js # HTTPS Everywhere files rulesets.json diff --git a/app/buildConfig.js b/app/buildConfig.js new file mode 100644 index 00000000000..9f17a458905 --- /dev/null +++ b/app/buildConfig.js @@ -0,0 +1,12 @@ +/* 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/. */ + +'use strict' + +// The package npm task builds this module +const config = require('../js/constants/buildConfig') + +exports.browserLaptopRev = () => process.env.NODE_ENV === 'development' + ? require('git-rev-sync').long() + : config.BROWSER_LAPTOP_REV diff --git a/app/channel.js b/app/channel.js index f7411242515..e7c1241d6bb 100644 --- a/app/channel.js +++ b/app/channel.js @@ -24,12 +24,31 @@ exports.formattedChannel = () => { const locale = require('./locale') const channelMapping = { - 'dev': locale.translation('channelDev'), - 'beta': locale.translation('channelBeta') + 'dev': locale.translation('channelRelease'), + 'beta': locale.translation('channelBeta'), + 'developer': locale.translation('channelDeveloper'), + 'nightly': locale.translation('channelNightly') } return Object.keys(channelMapping).includes(channel) ? channelMapping[channel] : channel } -exports.browserLaptopRev = () => process.env.NODE_ENV === 'development' - ? require('git-rev-sync').long() - : config.BROWSER_LAPTOP_REV +exports.getLinuxDesktopName = () => { + let desktopName + switch (channel) { + case 'dev': + desktopName = 'brave.desktop' + break + case 'beta': + desktopName = 'brave-beta.desktop' + break + case 'developer': + desktopName = 'brave-developer.desktop' + break + case 'nightly': + desktopName = 'brave-nightly.desktop' + break + default: + desktopName = 'brave.desktop' + } + return desktopName +} diff --git a/app/extensions/brave/locales/en-US/app.properties b/app/extensions/brave/locales/en-US/app.properties index 3acb222222e..283a1de9e02 100644 --- a/app/extensions/brave/locales/en-US/app.properties +++ b/app/extensions/brave/locales/en-US/app.properties @@ -52,7 +52,9 @@ certErrorSafety=Back to safety certErrorShowCertificate=Show Certificate certErrorText=This site cannot be loaded due to a certificate error: channelBeta=Beta -channelDev=Release +channelRelease=Release +channelDeveloper=Developer +channelNightly=Nightly checkDefaultOnStartup=Always check on startup city=City clear=Clear diff --git a/app/index.js b/app/index.js index 9e2cb4fcc9e..171df629bbd 100644 --- a/app/index.js +++ b/app/index.js @@ -218,7 +218,8 @@ app.on('ready', () => { if (['development', 'test'].includes(process.env.NODE_ENV)) { isDefaultBrowser = true } else if (process.platform === 'linux') { - const desktopName = 'brave.desktop' + const Channel = require('./channel') + const desktopName = Channel.getLinuxDesktopName() isDefaultBrowser = app.isDefaultProtocolClient('', desktopName) } else { isDefaultBrowser = defaultProtocols.every(p => app.isDefaultProtocolClient(p)) diff --git a/app/locale.js b/app/locale.js index 18c36da7e58..a1b574c0de9 100644 --- a/app/locale.js +++ b/app/locale.js @@ -267,8 +267,10 @@ var rendererIdentifiers = function () { 'allowAutoplay', 'autoplayMedia', // Release channels - 'channelDev', + 'channelRelease', 'channelBeta', + 'channelDeveloper', + 'channelNightly', 'spellCheckLanguages' ].concat(countryCodes).concat(availableLanguages) } diff --git a/app/sessionStore.js b/app/sessionStore.js index 129d36d6cb8..1f0afa9a156 100644 --- a/app/sessionStore.js +++ b/app/sessionStore.js @@ -37,6 +37,7 @@ const filtering = require('./filtering') const autofill = require('./autofill') const {navigatableTypes} = require('../js/lib/appUrlUtil') const Channel = require('./channel') +const BuildConfig = require('./buildConfig') const {isImmutable, makeImmutable, deleteImmutablePaths} = require('./common/state/immutableUtil') const {getSetting} = require('../js/settings') const platformUtil = require('./common/lib/platformUtil') @@ -470,7 +471,7 @@ const safeGetVersion = (fieldName, getFieldVersion) => { const setVersionInformation = (immutableData) => { const versionFields = [ ['Brave', app.getVersion], - ['rev', Channel.browserLaptopRev], + ['rev', BuildConfig.browserLaptopRev], ['Muon', () => { return process.versions['atom-shell'] }], ['libchromiumcontent', () => { return process.versions['chrome'] }], ['V8', () => { return process.versions.v8 }], diff --git a/app/windowsInit.js b/app/windowsInit.js index 966191efa5a..213edc004b7 100644 --- a/app/windowsInit.js +++ b/app/windowsInit.js @@ -9,7 +9,25 @@ const spawn = childProcess.spawn const spawnSync = childProcess.spawnSync const execSync = childProcess.execSync const app = electron.app -const appUserModelId = 'com.squirrel.brave.Brave' +const Channel = require('./channel') +let appUserModelId = 'com.squirrel.brave.Brave' +switch (Channel.channel()) { + case 'nightly': + appUserModelId = 'com.squirrel.BraveNightly.BraveNightly' + break + case 'developer': + appUserModelId = 'com.squirrel.BraveDeveloper.BraveDeveloper' + break + case 'beta': + appUserModelId = 'com.squirrel.BraveBeta.BraveBeta' + break + case 'dev': + appUserModelId = 'com.squirrel.brave.Brave' + break + default: + appUserModelId = 'com.squirrel.brave.Brave' + break +} const getBraveBinPath = () => { const appPath = app.getPath('exe') @@ -39,6 +57,7 @@ function CopyManifestFile () { if (process.platform === 'win32') { const shouldQuit = require('electron-squirrel-startup') const cmd = process.argv[1] + const channel = Channel.channel() if (cmd === '--squirrel-install' || cmd === '--squirrel-updated') { // The manifest file is used to customize the look of the Start menu tile. // This function copies it from the versioned folder to the parent folder @@ -52,9 +71,19 @@ if (process.platform === 'win32') { spawnSync(getBraveDefaultsBinPath(), ['-uninstall']) } - if (shouldQuit()) { + if (shouldQuit(channel)) { process.exit(0) } + + const userDataDirSwitch = '--user-data-dir=brave-' + channel + if (channel !== 'dev' && !process.argv.includes(userDataDirSwitch)) { + if (cmd === '--squirrel-firstrun') { + app.relaunch({args: [userDataDirSwitch, '--relaunch']}) + } else { + app.relaunch({args: process.argv.slice(1) + [userDataDirSwitch, '--relaunch']}) + } + app.quit() + } } app.on('will-finish-launching', () => { diff --git a/docs/buildingReleases.md b/docs/buildingReleases.md new file mode 100644 index 00000000000..f381e432083 --- /dev/null +++ b/docs/buildingReleases.md @@ -0,0 +1,83 @@ +# Overview of our build process for releases + +[brave/browser-laptop](https://github.com/brave/browser-laptop) maintains its own version of [electron](https://github.com/brave/electron) and therefore also its own version of [electron-prebuilt](https://github.com/brave/electron-prebuilt). +Releases of `brave/electron` get added to the `gh-pages` branch of [brave/browser-electron-releases](https://github.com/brave/browser-laptop-releases/tree/gh-pages). +`brave/browser-laptop`'s dependency on `brave/electron-prebuilt` will download directly from `brave/browser-laptop-releases` github public page. + +# Creating a new Brave Electron release + +To create a new release of `brave/electron` for use in `brave/electron-prebuilt`: + +- Clone electron with `git clone --recursive git@github.com:brave/electron` +- Rebase `brave/electron`'s commits to the upstream tag you'd like to create a release for. e.g. `git rebase v0.37.2` +- Make sure the submodule dependencies in `vendor/` are up to date. +- For Linux and macOS builds, run `ELECTRON_RELEASE=1 ATOM_SHELL_GITHUB_TOKEN= LIBCHROMIUMCONTENT_MIRROR=https://s3.amazonaws.com/brave-laptop-binaries/libchromiumcontent ./script/cibuild`. Replace `` with a token generated from https://github.com/settings/tokens +- For Windows builds, run `ELECTRON_RELEASE=1 ATOM_SHELL_GITHUB_TOKEN= LIBCHROMIUMCONTENT_MIRROR=https://s3.amazonaws.com/brave-laptop-binaries/libchromiumcontent npm run cibuild-windows`. +- Manually download the release zip to a subfolder of `brave/browser-laptop-releases` and push it out. +- Mark the release draft as completed in the `brave/electron` repository releases page. +- Increase the version number of the package.json file so that `npm install` in `browser-laptop` will start using it. + +# Create a new Brave browser release + +First follow the steps in the previous section. + +``` +git clone git@github.com/brave/browser-laptop +rm -Rf ~/.electron +npm install +``` + +If you already have the repo checked out, it's recommended to `rm -Rf node_modules` instead of the clone. + +Then do the following per OS: + +**macOS:** + +``` +CHANNEL=dev npm run build-package +CHANNEL=dev IDENTIFIER=id-here npm run build-installer +``` + +**Windows:** + +``` +CHANNEL=dev npm run build-package +CHANNEL=dev CERT_PASSWORD=‘password-here’ npm run build-installer +```` + +Check virus scan: https://www.virustotal.com/en/ + +**Linux:** +``` +./node_modules/.bin/webpack +CHANNEL=dev npm run build-package +CHANNEL=dev npm run build-installer +tar -jcvf Brave.tar.bz2 ./Brave-linux-x64 +``` + +# Dependencies + +[Brave's electron](https://github.com/brave/electron) fork maintains its own versions of [brightray](https://github.com/brave/brightray), [libchromiumcontent](https://github.com/brave/libchromiumcontent), and [node](https://github.com/brave/node). +The primary purpose of doing this is to be able to update dependencies for security releases faster than Electron does. + + +# Updating Chromium / Brightray + +- Generate a new tarball from `brave/chromium-source-tarball` for the new version `./script/bootstrap` followed by `./script/sync 49.0.2623.75` followed by `GITHUB_TOKEN=key-here ./script/upload`. +- Rebase `brave/libchromiumcontent` from `atom/libchromiumcontent` upstream. +- Change `brave/libchromiumcontent/VERSION` to contain the chromium version tag to change to. Example `49.0.2623.75`. You can see the latest tags here: https://chromium.googlesource.com/chromium/src.git/+refs +- You can create patches as needed inside `brave/libchromiumcontent/patches`. They will be automatically applied when doing builds. +- Some of the patches just mentioned will need rebasing on the new version. +- run `LIBCHROMIUMCONTENT_S3_BUCKET=brave-laptop-binaries LIBCHROMIUMCONTENT_S3_ACCESS_KEY=key-here AWS_ACCESS_KEY_SECRET=key-here AWS_ACCESS_KEY_SECRET=key-here LIBCHROMIUMCONTENT_S3_SECRET_KEY=key-here ./script/cibuild`. +- Brave's S3 bucket `brave-laptop-binaries` will be updated with the needed binaries. +- Update `brave/brightray`'s `/vendor/libchromiumcontent` submodule to point to the latest `brave/libchromiumcontent` changeset. +- From `brave/electron/script/lib/config.py` change `LIBCHROMIUMCONTENT_COMMIT` to point to the correct changeset from `brave/libchromiumcontent`. +- Update `brave/electron`'s `/vendor/brighray` submodule to point to the latest `brave/brightray` changeset. +- Update `brave/electron/atom/common/chrome_version.h` to include the latest version. I think it is also set automatically on builds though. + +# Updating Node + +- Rebase `brave/node` from a tag or changeset in `https://github.com/nodejs/node`. +- Update `brave/electron/vendor/node` submodule to refer to the latest changeset in `brave/node`. +- Update each of the building machines to match the version of Node that you're upgrading to. This is needed because `postinstall` rebuilds native modules and it should match the exact Node version. +- You can tell which Node version we're on by looking at the first `brave/node` commit which is not from `electron/node`. I.e. the first one from `nodejs/node`. diff --git a/js/constants/appConfig.js b/js/constants/appConfig.js index fc8832289f5..f5bb9e1379e 100644 --- a/js/constants/appConfig.js +++ b/js/constants/appConfig.js @@ -12,6 +12,7 @@ const isTest = process.env.NODE_ENV === 'test' const buildConfig = require('./buildConfig') const isProduction = buildConfig.nodeEnv === 'production' const {fullscreenOption, autoplayOption} = require('../../app/common/constants/settingsEnums') +const Channel = require('../../app/channel') module.exports = { name: 'Brave', @@ -135,7 +136,7 @@ module.exports = { 'general.show-home-button': false, 'general.autohide-menu': true, 'general.wide-url-bar': false, - 'general.check-default-on-startup': true, + 'general.check-default-on-startup': Channel.channel() === 'dev', 'general.download-default-path': '', 'general.download-always-ask': true, 'general.spellcheck-enabled': true, diff --git a/js/stores/appStore.js b/js/stores/appStore.js index a794636defd..e497c9a17c3 100644 --- a/js/stores/appStore.js +++ b/js/stores/appStore.js @@ -493,7 +493,8 @@ const handleAppAction = (action) => { if (action.useBrave) { let isDefaultBrowser if (platformUtil.isLinux()) { - const desktopName = 'brave.desktop' + const Channel = require('../../app/channel') + const desktopName = Channel.getLinuxDesktopName() for (const p of defaultProtocols) { app.setAsDefaultProtocolClient(p, desktopName) app.setAsDefaultProtocolClient('', desktopName) diff --git a/res/UAC.dll b/res/beta/UAC.dll similarity index 100% rename from res/UAC.dll rename to res/beta/UAC.dll diff --git a/res/UAC.nsh b/res/beta/UAC.nsh similarity index 96% rename from res/UAC.nsh rename to res/beta/UAC.nsh index e2684da48af..08979aba97e 100644 --- a/res/UAC.nsh +++ b/res/beta/UAC.nsh @@ -1,299 +1,299 @@ -/*** UAC Plug-in *** - -Interactive User (MediumIL) Admin user (HighIL) -***[Setup.exe]************* ***[Setup.exe]************** -* * * * -* +++[.OnInit]+++++++++++ * * +++[.OnInit]++++++++++++ * -* + UAC_RunElevated >---+-+----> * + + * -* + NSIS.Quit + * * + + * -* +++++++++++++++++++++++ * * ++++++++++++++++++++++++ * -* * * * -* * * * -* +++[Section]+++++++++++ * * +++[Section]++++++++++++ * -* + + * /--+-+- -** -** Get integrity level of current process -** -**/ -!macro UAC_GetIntegrityLevel outvar -UAC::_ 6 -!if "${outvar}" != "s" - Pop ${outvar} -!endif -!macroend - - - -/* UAC_IsAdmin -** -** Is the current process running with administrator privileges? Result in $0 -** -** ${If} ${UAC_IsAdmin} ... -** -**/ -!macro UAC_IsAdmin -UAC::_ 2 -!macroend -!define UAC_IsAdmin `"" UAC_IsAdmin ""` -!macro _UAC_IsAdmin _a _b _t _f -!insertmacro _UAC_MakeLL_Cmp _!= 0 2s -!macroend - - - -/* UAC_IsInnerInstance -** -** Does the current process have a NSIS/UAC parent process that is part of the elevation operation? -** -** ${If} ${UAC_IsInnerInstance} ... -** -**/ -!macro UAC_IsInnerInstance -UAC::_ 3 -!macroend -!define UAC_IsInnerInstance `"" UAC_IsInnerInstance ""` -!macro _UAC_IsInnerInstance _a _b _t _f -!insertmacro _UAC_MakeLL_Cmp _!= 0 3s -!macroend - - - -/* UAC_PageElevation_OnInit, UAC_PageElevation_OnGuiInit, -** -** Helper macros for elevation on a custom elevation page, see the DualMode example for more information. -** -**/ -!macro UAC_Notify_OnGuiInit -UAC::_ 4 -!macroend -!macro UAC_PageElevation_OnGuiInit -!insertmacro UAC_Notify_OnGuiInit -!macroend -!macro UAC_PageElevation_OnInit -UAC::_ 5 -${IfThen} ${Errors} ${|} Quit ${|} -!macroend - - - -/* UAC_AsUser_Call -** -** Calls a function or label in the user process instance. -** All the UAC_AsUser_* macros use this helper macro. -** -**/ -!define UAC_SYNCREGISTERS 0x1 -;define UAC_SYNCSTACK 0x2 -!define UAC_SYNCOUTDIR 0x4 -!define UAC_SYNCINSTDIR 0x8 -;define UAC_CLEARERRFLAG 0x10 -!macro UAC_AsUser_Call type name flags -push $0 -Get${type}Address $0 ${name} -!verbose push -!verbose ${UAC_VERBOSE} -!insertmacro _UAC_ParseDefineFlagsToInt _UAC_AsUser_Call__flags ${flags} -!verbose pop -StrCpy $0 "1$0:${_UAC_AsUser_Call__flags}" -!undef _UAC_AsUser_Call__flags -Exch $0 -UAC::_ -!macroend - - - -/* -** UAC_AsUser_GetSection -*/ -!macro UAC_AsUser_GetSection secprop secidx outvar -!insertmacro _UAC_AsUser_GenOp ${outvar} SectionGet${secprop} ${secidx} "" -!macroend - - - -/* -** UAC_AsUser_GetGlobalVar -** UAC_AsUser_GetGlobal -*/ -!macro UAC_AsUser_GetGlobalVar var -!insertmacro _UAC_AsUser_GenOp ${var} StrCpy "" ${var} -!macroend -!macro UAC_AsUser_GetGlobal outvar srcvar -!insertmacro _UAC_AsUser_GenOp ${outvar} StrCpy "" ${srcvar} -!macroend - - - -/* -** UAC_AsUser_ExecShell -** -** Call ExecShell in the user process instance. -** -*/ -!macro UAC_AsUser_ExecShell verb command params workdir show -!insertmacro _UAC_IncL -goto _UAC_L_E_${__UAC_L} -_UAC_L_F_${__UAC_L}: -ExecShell "${verb}" "${command}" '${params}' ${show} -return -_UAC_L_E_${__UAC_L}: -!if "${workdir}" != "" - push $outdir - SetOutPath "${workdir}" -!endif -!insertmacro UAC_AsUser_Call Label _UAC_L_F_${__UAC_L} ${UAC_SYNCREGISTERS}|${UAC_SYNCOUTDIR}|${UAC_SYNCINSTDIR} #|${UAC_CLEARERRFLAG} -!if "${workdir}" != "" - pop $outdir - SetOutPath $outdir -!endif -!macroend - - - -!macro _UAC_MakeLL_Cmp cmpop cmp pluginparams -!insertmacro _LOGICLIB_TEMP -UAC::_ ${pluginparams} -pop $_LOGICLIB_TEMP -!insertmacro ${cmpop} $_LOGICLIB_TEMP ${cmp} `${_t}` `${_f}` -!macroend -!macro _UAC_definemath def val1 op val2 -!define /math _UAC_definemath "${val1}" ${op} ${val2} -!ifdef ${def} - !undef ${def} -!endif -!define ${def} "${_UAC_definemath}" -!undef _UAC_definemath -!macroend -!macro _UAC_ParseDefineFlags_orin parse outflags -!searchparse /noerrors ${${parse}} "" _UAC_ParseDefineFlags_orin_f1 "|" _UAC_ParseDefineFlags_orin_f2 -!define _UAC_ParseDefineFlags_orin_this ${_UAC_ParseDefineFlags_orin_f1} -!undef ${parse} -!define ${parse} ${_UAC_ParseDefineFlags_orin_f2} -!define _UAC_ParseDefineFlags_orin_saveout ${${outflags}} -!undef ${outflags} -!define /math ${outflags} "${_UAC_ParseDefineFlags_orin_saveout}" | "${_UAC_ParseDefineFlags_orin_this}" -!undef _UAC_ParseDefineFlags_orin_saveout -!undef _UAC_ParseDefineFlags_orin_this -!ifdef _UAC_ParseDefineFlags_orin_f1 - !undef _UAC_ParseDefineFlags_orin_f1 -!endif -!ifdef _UAC_ParseDefineFlags_orin_f2 - !undef _UAC_ParseDefineFlags_orin_f2 -!endif -!macroend -!macro _UAC_ParseDefineFlags_Begin _outdef _in -!define _UAC_PDF${_outdef}_parse "${_in}" -!define _UAC_PDF${_outdef}_flags "" -!define _UAC_PDF${_outdef}_r 0 -!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x1 -!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x2 -!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x4 -!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x8 -!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x10 -!macroend -!macro _UAC_ParseDefineFlags_End _outdef -!define ${_outdef} ${_UAC_PDF${_outdef}_r} -!undef _UAC_PDF${_outdef}_r -!undef _UAC_PDF${_outdef}_flags -!undef _UAC_PDF${_outdef}_parse -!macroend -!macro _UAC_ParseDefineFlags_IncludeFlag _outdef flag -!if ${_UAC_PDF${_outdef}_flags} & ${flag} - !insertmacro _UAC_definemath _UAC_PDF${_outdef}_r ${_UAC_PDF${_outdef}_r} | ${flag} -!endif -!macroend -!macro _UAC_ParseDefineFlagsToInt _outdef _in -!insertmacro _UAC_ParseDefineFlags_Begin _UAC_ParseDefineFlagsToInt_tmp "${_in}" -!define ${_outdef} ${_UAC_PDF_UAC_ParseDefineFlagsToInt_tmp_flags} -!insertmacro _UAC_ParseDefineFlags_End _UAC_ParseDefineFlagsToInt_tmp -!undef _UAC_ParseDefineFlagsToInt_tmp -!macroend -!macro _UAC_IncL -!insertmacro _UAC_definemath __UAC_L "${__UAC_L}" + 1 -!macroend -!macro _UAC_AsUser_GenOp outvar op opparam1 opparam2 -!define _UAC_AUGOGR_ID _UAC_AUGOGR_OP${outvar}${op}${opparam1}${opparam2} -!ifndef ${_UAC_AUGOGR_ID} ;Has this exact action been done before? - !if ${outvar} == $0 - !define ${_UAC_AUGOGR_ID} $1 - !else - !define ${_UAC_AUGOGR_ID} $0 - !endif - !if "${opparam1}" == "" - !define _UAC_AUGOGR_OPP1 ${${_UAC_AUGOGR_ID}} - !define _UAC_AUGOGR_OPP2 ${opparam2} - !else - !define _UAC_AUGOGR_OPP1 ${opparam1} - !define _UAC_AUGOGR_OPP2 ${${_UAC_AUGOGR_ID}} - !endif - goto ${_UAC_AUGOGR_ID}_C - ${_UAC_AUGOGR_ID}_F: - ${op} ${_UAC_AUGOGR_OPP1} ${_UAC_AUGOGR_OPP2} - return - ${_UAC_AUGOGR_ID}_C: - !undef _UAC_AUGOGR_OPP1 - !undef _UAC_AUGOGR_OPP2 -!endif -push ${${_UAC_AUGOGR_ID}} -!insertmacro UAC_AsUser_Call Label ${_UAC_AUGOGR_ID}_F ${UAC_SYNCREGISTERS} -StrCpy ${outvar} ${${_UAC_AUGOGR_ID}} -pop ${${_UAC_AUGOGR_ID}} -!undef _UAC_AUGOGR_ID -!macroend - - - -!verbose pop +/*** UAC Plug-in *** + +Interactive User (MediumIL) Admin user (HighIL) +***[Setup.exe]************* ***[Setup.exe]************** +* * * * +* +++[.OnInit]+++++++++++ * * +++[.OnInit]++++++++++++ * +* + UAC_RunElevated >---+-+----> * + + * +* + NSIS.Quit + * * + + * +* +++++++++++++++++++++++ * * ++++++++++++++++++++++++ * +* * * * +* * * * +* +++[Section]+++++++++++ * * +++[Section]++++++++++++ * +* + + * /--+-+- +** +** Get integrity level of current process +** +**/ +!macro UAC_GetIntegrityLevel outvar +UAC::_ 6 +!if "${outvar}" != "s" + Pop ${outvar} +!endif +!macroend + + + +/* UAC_IsAdmin +** +** Is the current process running with administrator privileges? Result in $0 +** +** ${If} ${UAC_IsAdmin} ... +** +**/ +!macro UAC_IsAdmin +UAC::_ 2 +!macroend +!define UAC_IsAdmin `"" UAC_IsAdmin ""` +!macro _UAC_IsAdmin _a _b _t _f +!insertmacro _UAC_MakeLL_Cmp _!= 0 2s +!macroend + + + +/* UAC_IsInnerInstance +** +** Does the current process have a NSIS/UAC parent process that is part of the elevation operation? +** +** ${If} ${UAC_IsInnerInstance} ... +** +**/ +!macro UAC_IsInnerInstance +UAC::_ 3 +!macroend +!define UAC_IsInnerInstance `"" UAC_IsInnerInstance ""` +!macro _UAC_IsInnerInstance _a _b _t _f +!insertmacro _UAC_MakeLL_Cmp _!= 0 3s +!macroend + + + +/* UAC_PageElevation_OnInit, UAC_PageElevation_OnGuiInit, +** +** Helper macros for elevation on a custom elevation page, see the DualMode example for more information. +** +**/ +!macro UAC_Notify_OnGuiInit +UAC::_ 4 +!macroend +!macro UAC_PageElevation_OnGuiInit +!insertmacro UAC_Notify_OnGuiInit +!macroend +!macro UAC_PageElevation_OnInit +UAC::_ 5 +${IfThen} ${Errors} ${|} Quit ${|} +!macroend + + + +/* UAC_AsUser_Call +** +** Calls a function or label in the user process instance. +** All the UAC_AsUser_* macros use this helper macro. +** +**/ +!define UAC_SYNCREGISTERS 0x1 +;define UAC_SYNCSTACK 0x2 +!define UAC_SYNCOUTDIR 0x4 +!define UAC_SYNCINSTDIR 0x8 +;define UAC_CLEARERRFLAG 0x10 +!macro UAC_AsUser_Call type name flags +push $0 +Get${type}Address $0 ${name} +!verbose push +!verbose ${UAC_VERBOSE} +!insertmacro _UAC_ParseDefineFlagsToInt _UAC_AsUser_Call__flags ${flags} +!verbose pop +StrCpy $0 "1$0:${_UAC_AsUser_Call__flags}" +!undef _UAC_AsUser_Call__flags +Exch $0 +UAC::_ +!macroend + + + +/* +** UAC_AsUser_GetSection +*/ +!macro UAC_AsUser_GetSection secprop secidx outvar +!insertmacro _UAC_AsUser_GenOp ${outvar} SectionGet${secprop} ${secidx} "" +!macroend + + + +/* +** UAC_AsUser_GetGlobalVar +** UAC_AsUser_GetGlobal +*/ +!macro UAC_AsUser_GetGlobalVar var +!insertmacro _UAC_AsUser_GenOp ${var} StrCpy "" ${var} +!macroend +!macro UAC_AsUser_GetGlobal outvar srcvar +!insertmacro _UAC_AsUser_GenOp ${outvar} StrCpy "" ${srcvar} +!macroend + + + +/* +** UAC_AsUser_ExecShell +** +** Call ExecShell in the user process instance. +** +*/ +!macro UAC_AsUser_ExecShell verb command params workdir show +!insertmacro _UAC_IncL +goto _UAC_L_E_${__UAC_L} +_UAC_L_F_${__UAC_L}: +ExecShell "${verb}" "${command}" '${params}' ${show} +return +_UAC_L_E_${__UAC_L}: +!if "${workdir}" != "" + push $outdir + SetOutPath "${workdir}" +!endif +!insertmacro UAC_AsUser_Call Label _UAC_L_F_${__UAC_L} ${UAC_SYNCREGISTERS}|${UAC_SYNCOUTDIR}|${UAC_SYNCINSTDIR} #|${UAC_CLEARERRFLAG} +!if "${workdir}" != "" + pop $outdir + SetOutPath $outdir +!endif +!macroend + + + +!macro _UAC_MakeLL_Cmp cmpop cmp pluginparams +!insertmacro _LOGICLIB_TEMP +UAC::_ ${pluginparams} +pop $_LOGICLIB_TEMP +!insertmacro ${cmpop} $_LOGICLIB_TEMP ${cmp} `${_t}` `${_f}` +!macroend +!macro _UAC_definemath def val1 op val2 +!define /math _UAC_definemath "${val1}" ${op} ${val2} +!ifdef ${def} + !undef ${def} +!endif +!define ${def} "${_UAC_definemath}" +!undef _UAC_definemath +!macroend +!macro _UAC_ParseDefineFlags_orin parse outflags +!searchparse /noerrors ${${parse}} "" _UAC_ParseDefineFlags_orin_f1 "|" _UAC_ParseDefineFlags_orin_f2 +!define _UAC_ParseDefineFlags_orin_this ${_UAC_ParseDefineFlags_orin_f1} +!undef ${parse} +!define ${parse} ${_UAC_ParseDefineFlags_orin_f2} +!define _UAC_ParseDefineFlags_orin_saveout ${${outflags}} +!undef ${outflags} +!define /math ${outflags} "${_UAC_ParseDefineFlags_orin_saveout}" | "${_UAC_ParseDefineFlags_orin_this}" +!undef _UAC_ParseDefineFlags_orin_saveout +!undef _UAC_ParseDefineFlags_orin_this +!ifdef _UAC_ParseDefineFlags_orin_f1 + !undef _UAC_ParseDefineFlags_orin_f1 +!endif +!ifdef _UAC_ParseDefineFlags_orin_f2 + !undef _UAC_ParseDefineFlags_orin_f2 +!endif +!macroend +!macro _UAC_ParseDefineFlags_Begin _outdef _in +!define _UAC_PDF${_outdef}_parse "${_in}" +!define _UAC_PDF${_outdef}_flags "" +!define _UAC_PDF${_outdef}_r 0 +!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x1 +!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x2 +!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x4 +!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x8 +!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x10 +!macroend +!macro _UAC_ParseDefineFlags_End _outdef +!define ${_outdef} ${_UAC_PDF${_outdef}_r} +!undef _UAC_PDF${_outdef}_r +!undef _UAC_PDF${_outdef}_flags +!undef _UAC_PDF${_outdef}_parse +!macroend +!macro _UAC_ParseDefineFlags_IncludeFlag _outdef flag +!if ${_UAC_PDF${_outdef}_flags} & ${flag} + !insertmacro _UAC_definemath _UAC_PDF${_outdef}_r ${_UAC_PDF${_outdef}_r} | ${flag} +!endif +!macroend +!macro _UAC_ParseDefineFlagsToInt _outdef _in +!insertmacro _UAC_ParseDefineFlags_Begin _UAC_ParseDefineFlagsToInt_tmp "${_in}" +!define ${_outdef} ${_UAC_PDF_UAC_ParseDefineFlagsToInt_tmp_flags} +!insertmacro _UAC_ParseDefineFlags_End _UAC_ParseDefineFlagsToInt_tmp +!undef _UAC_ParseDefineFlagsToInt_tmp +!macroend +!macro _UAC_IncL +!insertmacro _UAC_definemath __UAC_L "${__UAC_L}" + 1 +!macroend +!macro _UAC_AsUser_GenOp outvar op opparam1 opparam2 +!define _UAC_AUGOGR_ID _UAC_AUGOGR_OP${outvar}${op}${opparam1}${opparam2} +!ifndef ${_UAC_AUGOGR_ID} ;Has this exact action been done before? + !if ${outvar} == $0 + !define ${_UAC_AUGOGR_ID} $1 + !else + !define ${_UAC_AUGOGR_ID} $0 + !endif + !if "${opparam1}" == "" + !define _UAC_AUGOGR_OPP1 ${${_UAC_AUGOGR_ID}} + !define _UAC_AUGOGR_OPP2 ${opparam2} + !else + !define _UAC_AUGOGR_OPP1 ${opparam1} + !define _UAC_AUGOGR_OPP2 ${${_UAC_AUGOGR_ID}} + !endif + goto ${_UAC_AUGOGR_ID}_C + ${_UAC_AUGOGR_ID}_F: + ${op} ${_UAC_AUGOGR_OPP1} ${_UAC_AUGOGR_OPP2} + return + ${_UAC_AUGOGR_ID}_C: + !undef _UAC_AUGOGR_OPP1 + !undef _UAC_AUGOGR_OPP2 +!endif +push ${${_UAC_AUGOGR_ID}} +!insertmacro UAC_AsUser_Call Label ${_UAC_AUGOGR_ID}_F ${UAC_SYNCREGISTERS} +StrCpy ${outvar} ${${_UAC_AUGOGR_ID}} +pop ${${_UAC_AUGOGR_ID}} +!undef _UAC_AUGOGR_ID +!macroend + + + +!verbose pop !endif /* UAC_HDR__INC */ \ No newline at end of file diff --git a/res/beta/app.icns b/res/beta/app.icns new file mode 100644 index 00000000000..61338d582a3 Binary files /dev/null and b/res/beta/app.icns differ diff --git a/res/beta/app.ico b/res/beta/app.ico new file mode 100644 index 00000000000..b9fc6ed202c Binary files /dev/null and b/res/beta/app.ico differ diff --git a/res/beta/app.png b/res/beta/app.png new file mode 100644 index 00000000000..11c841c8973 Binary files /dev/null and b/res/beta/app.png differ diff --git a/res/beta/braveDefaults.nsi b/res/beta/braveDefaults.nsi new file mode 100644 index 00000000000..60014e0351d --- /dev/null +++ b/res/beta/braveDefaults.nsi @@ -0,0 +1,138 @@ +!include "MUI2.nsh" +!include "LogicLib.nsh" +!include "..\Win8WinVer.nsh" +!include "..\GetParameters.nsh" +!include "..\GetParent.nsh" +!include "..\StrStr.nsh" + +!addplugindir "." +!include "UAC.nsh" + +!define MUI_ICON "app.ico" +!insertmacro MUI_LANGUAGE "English" + +SilentInstall silent + +Name "BraveBeta" +OutFile "../../BraveBeta-win32-${ARCH}/resources/BraveDefaults.exe" +RequestExecutionLevel user +Var BraveEXEPath +Var BraveIconPath +Var IsElevated +Var IsUninstall + +Function .onInit + ; The StartMenuInternet key can be set in HKCU on Win8 and above. + ${IfNot} ${AtLeastWin8} + SetShellVarContext all + ${EndIf} + + ; Determine if we're elevated currently + ClearErrors + WriteRegStr HKLM "Software\Brave" "InstallerTest" "Write Test" + DeleteRegValue HKLM "Software\Brave" "InstallerTest" + ${If} ${Errors} + StrCpy $IsElevated "0" + ${Else} + StrCpy $IsElevated "1" + ${EndIf} + + Push $EXEDIR + Call GetParent + Call GetParent + POP $0 + + StrCpy $BraveEXEPath "$0\BraveBeta.exe" + StrCpy $BraveIconPath "$0\BraveBeta.exe,0" + + Call GetParameters + Pop $1 + + ; Determine if this is an uninstall or an install + ${StrStr} $4 $1 "-uninstall" + ${StrStr} $5 $1 "/uninstall" + + ${If} $4 != "" + ${OrIf} $5 != "" + StrCpy $IsUninstall "1" + ${Else} + StrCpy $IsUninstall "0" + ; Document / protocol handler class + ; These need to always be in HKCU becuase they contain the actual path of the exe which changes + ; on each update. If on HKLM then the user could not elevate later and cause a problem. + ; They should also be in this block early because we always want to re-create on each update. + WriteRegStr HKCU "SOFTWARE\Classes\BraveBetaHTML" "" "BraveBeta HTML Document" + WriteRegStr HKCU "SOFTWARE\Classes\BraveBetaHTML\DefaultIcon" "" "$BraveIconPath" + WriteRegStr HKCU "SOFTWARE\Classes\BraveBetaHTML\shell\open\command" "" '"$BraveEXEPath" "--user-data-dir=brave-beta" -- "%1"' + ${EndIf} + + ; If we already have the defaults key, there's nothing to do so we can abort early without even needing to elevate on Win7. + ${If} $IsUninstall == "0" + ClearErrors + ReadRegStr $2 SHCTX "SOFTWARE\RegisteredApplications" "BraveBeta" + ${IfNot} ${Errors} + Quit + ${EndIf} + ${EndIf} + + ; Elevate if we're on Win7 and below. Win8 allows keys to be set as HKCU so this is not needed there. + ${IfNot} ${AtLeastWin8} + ; Don't even try to elevate if we are already elevated. + ${AndIf} $IsElevated == "0" + !insertmacro UAC_RunElevated + ${Switch} $0 + ${Case} 0 + ${IfThen} $1 = 1 ${|} Quit ${|} ;we are the outer process, the inner process has done its work, we are done + ${IfThen} $3 <> 0 ${|} ${Break} ${|} ;we are admin, let the show go on + ;fall-through and die + ${Case} 1223 + MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Unable to elevate, Brave will not be able to be set as the default browser." + Quit + ${Case} 1062 + MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Logon service not running, aborting!" + Quit + ${Default} + MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Unable to elevate , error $0" + Quit + ${EndSwitch} + ${EndIf} +FunctionEnd + +Section "Defaults Section" SecDummy + Call GetParameters + Pop $1 + + ${If} $IsUninstall == "1" + DeleteRegKey HKCU "SOFTWARE\Classes\BraveBetaHTML" + DeleteRegKey SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveBeta" + DeleteRegValue SHCTX "SOFTWARE\RegisteredApplications" "BraveBeta" + + SetShellVarContext current + Delete "$DESKTOP\Brave.lnk" + ${Else} + + ; Define capabilities + WriteRegStr SHCTX "SOFTWARE\RegisteredApplications" "BraveBeta" "Software\Clients\StartMenuInternet\BraveBeta\Capabilities" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveBeta\Capabilities\StartMenu" "StartMenuInternet" "BraveBeta" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveBeta" "" "BraveBeta" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveBeta\Capabilities" "ApplicationDescription" "BraveBeta is the new and fast web browser that protects your privacy and security by blocking intrusive ads and trackers." + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveBeta\Capabilities" "ApplicationName" "BraveBeta" + WriteRegDWORD SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveBeta\InstallInfo" "IconsVisible" 1 + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveBeta\shell\open\command" "" "$BraveEXEPath" + ; File associations + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveBeta\Capabilities\FileAssociations" ".htm" "BraveBetaHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveBeta\Capabilities\FileAssociations" ".html" "BraveBetaHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveBeta\Capabilities\FileAssociations" ".shtml" "BraveBetaHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveBeta\Capabilities\FileAssociations" ".xht" "BraveBetaHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveBeta\Capabilities\FileAssociations" ".xhtml" "BraveBetaHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveBeta\Capabilities\FileAssociations" ".webp" "BraveBetaHTML" + ; Protocol associations + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveBeta\Capabilities\URLAssociations" "ftp" "BraveBetaHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveBeta\Capabilities\URLAssociations" "http" "BraveBetaHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveBeta\Capabilities\URLAssociations" "https" "BraveBetaHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveBeta\Capabilities\URLAssociations" "mailto" "BraveBetaHTML" + ; Uninstall icon + SetRegView 64 + WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\BraveBeta" "DisplayIcon" "$BraveIconPath" + ${EndIf} +SectionEnd diff --git a/res/brave_installer.icns b/res/beta/brave_installer.icns similarity index 100% rename from res/brave_installer.icns rename to res/beta/brave_installer.icns diff --git a/res/brave_installer.ico b/res/beta/brave_installer.ico similarity index 100% rename from res/brave_installer.ico rename to res/beta/brave_installer.ico diff --git a/res/brave_installer.png b/res/beta/brave_installer.png similarity index 100% rename from res/brave_installer.png rename to res/beta/brave_installer.png diff --git a/res/beta/builderConfig.json b/res/beta/builderConfig.json new file mode 100644 index 00000000000..7b0eaea7567 --- /dev/null +++ b/res/beta/builderConfig.json @@ -0,0 +1,18 @@ +{ + "appId": "com.electron.brave", + "productName": "Brave-Beta", + "npmRebuild": false, + "mac": { + "target": "dmg" + }, + "dmg": { + "title": "Brave-Beta", + "background": "res/background.png", + "icon": "res/beta/brave_installer.icns", + "iconSize": 80, + "contents": [ + { "x": 192, "y": 344, "type": "file" }, + { "x": 438, "y": 344, "type": "link", "path": "/Applications" } + ] + } +} diff --git a/res/beta/linuxPackaging.json b/res/beta/linuxPackaging.json new file mode 100644 index 00000000000..3eccab9460d --- /dev/null +++ b/res/beta/linuxPackaging.json @@ -0,0 +1,46 @@ +{ + "name": "brave-beta", + "bin": "brave-beta", + "userDataDir": "brave-beta", + "productName": "Brave Beta", + "genericName": "Web Browser", + "homepage": "https://brave.com/", + "icon": "res/beta/app.png", + "section": "web", + "categories": [ + "Network", + "WebBrowser" + ], + "mimeType": [ + "text/html", + "text/xml", + "application/xhtml_xml", + "image/webp", + "x-scheme-handler/http", + "x-scheme-handler/https", + "x-scheme-handler/ftp" + ], + "requires": [ + "GConf2", + "libXScrnSaver", + "lsb" + ], + "depends": [ + "gawk", + "git", + "gconf2", + "gconf-service", + "gvfs-bin", + "libc6", + "libcap2", + "libgtk2.0-0", + "libudev0 | libudev1", + "libgcrypt11 | libgcrypt20", + "libnotify4", + "libnss3", + "libxtst6", + "libxss1", + "python", + "xdg-utils" + ] +} diff --git a/res/beta/suse.json b/res/beta/suse.json new file mode 100644 index 00000000000..263ce430f69 --- /dev/null +++ b/res/beta/suse.json @@ -0,0 +1,28 @@ +{ + "name": "brave-beta", + "bin": "brave-beta", + "userDataDir": "brave-beta", + "productName": "Brave Beta", + "genericName": "Web Browser", + "homepage": "https://brave.com/", + "icon": "res/beta/app.png", + "section": "web", + "categories": [ + "Network", + "WebBrowser" + ], + "mimeType": [ + "text/html", + "text/xml", + "application/xhtml_xml", + "image/webp", + "x-scheme-handler/http", + "x-scheme-handler/https", + "x-scheme-handler/ftp" + ], + "requires": [ + "gconf2", + "libXss1", + "lsb" + ] +} diff --git a/res/brave_installer_package.icns b/res/brave_installer_package.icns deleted file mode 100644 index 58f43508ead..00000000000 Binary files a/res/brave_installer_package.icns and /dev/null differ diff --git a/res/dev/UAC.dll b/res/dev/UAC.dll new file mode 100644 index 00000000000..57a58c5399a Binary files /dev/null and b/res/dev/UAC.dll differ diff --git a/res/dev/UAC.nsh b/res/dev/UAC.nsh new file mode 100644 index 00000000000..08979aba97e --- /dev/null +++ b/res/dev/UAC.nsh @@ -0,0 +1,299 @@ +/*** UAC Plug-in *** + +Interactive User (MediumIL) Admin user (HighIL) +***[Setup.exe]************* ***[Setup.exe]************** +* * * * +* +++[.OnInit]+++++++++++ * * +++[.OnInit]++++++++++++ * +* + UAC_RunElevated >---+-+----> * + + * +* + NSIS.Quit + * * + + * +* +++++++++++++++++++++++ * * ++++++++++++++++++++++++ * +* * * * +* * * * +* +++[Section]+++++++++++ * * +++[Section]++++++++++++ * +* + + * /--+-+- +** +** Get integrity level of current process +** +**/ +!macro UAC_GetIntegrityLevel outvar +UAC::_ 6 +!if "${outvar}" != "s" + Pop ${outvar} +!endif +!macroend + + + +/* UAC_IsAdmin +** +** Is the current process running with administrator privileges? Result in $0 +** +** ${If} ${UAC_IsAdmin} ... +** +**/ +!macro UAC_IsAdmin +UAC::_ 2 +!macroend +!define UAC_IsAdmin `"" UAC_IsAdmin ""` +!macro _UAC_IsAdmin _a _b _t _f +!insertmacro _UAC_MakeLL_Cmp _!= 0 2s +!macroend + + + +/* UAC_IsInnerInstance +** +** Does the current process have a NSIS/UAC parent process that is part of the elevation operation? +** +** ${If} ${UAC_IsInnerInstance} ... +** +**/ +!macro UAC_IsInnerInstance +UAC::_ 3 +!macroend +!define UAC_IsInnerInstance `"" UAC_IsInnerInstance ""` +!macro _UAC_IsInnerInstance _a _b _t _f +!insertmacro _UAC_MakeLL_Cmp _!= 0 3s +!macroend + + + +/* UAC_PageElevation_OnInit, UAC_PageElevation_OnGuiInit, +** +** Helper macros for elevation on a custom elevation page, see the DualMode example for more information. +** +**/ +!macro UAC_Notify_OnGuiInit +UAC::_ 4 +!macroend +!macro UAC_PageElevation_OnGuiInit +!insertmacro UAC_Notify_OnGuiInit +!macroend +!macro UAC_PageElevation_OnInit +UAC::_ 5 +${IfThen} ${Errors} ${|} Quit ${|} +!macroend + + + +/* UAC_AsUser_Call +** +** Calls a function or label in the user process instance. +** All the UAC_AsUser_* macros use this helper macro. +** +**/ +!define UAC_SYNCREGISTERS 0x1 +;define UAC_SYNCSTACK 0x2 +!define UAC_SYNCOUTDIR 0x4 +!define UAC_SYNCINSTDIR 0x8 +;define UAC_CLEARERRFLAG 0x10 +!macro UAC_AsUser_Call type name flags +push $0 +Get${type}Address $0 ${name} +!verbose push +!verbose ${UAC_VERBOSE} +!insertmacro _UAC_ParseDefineFlagsToInt _UAC_AsUser_Call__flags ${flags} +!verbose pop +StrCpy $0 "1$0:${_UAC_AsUser_Call__flags}" +!undef _UAC_AsUser_Call__flags +Exch $0 +UAC::_ +!macroend + + + +/* +** UAC_AsUser_GetSection +*/ +!macro UAC_AsUser_GetSection secprop secidx outvar +!insertmacro _UAC_AsUser_GenOp ${outvar} SectionGet${secprop} ${secidx} "" +!macroend + + + +/* +** UAC_AsUser_GetGlobalVar +** UAC_AsUser_GetGlobal +*/ +!macro UAC_AsUser_GetGlobalVar var +!insertmacro _UAC_AsUser_GenOp ${var} StrCpy "" ${var} +!macroend +!macro UAC_AsUser_GetGlobal outvar srcvar +!insertmacro _UAC_AsUser_GenOp ${outvar} StrCpy "" ${srcvar} +!macroend + + + +/* +** UAC_AsUser_ExecShell +** +** Call ExecShell in the user process instance. +** +*/ +!macro UAC_AsUser_ExecShell verb command params workdir show +!insertmacro _UAC_IncL +goto _UAC_L_E_${__UAC_L} +_UAC_L_F_${__UAC_L}: +ExecShell "${verb}" "${command}" '${params}' ${show} +return +_UAC_L_E_${__UAC_L}: +!if "${workdir}" != "" + push $outdir + SetOutPath "${workdir}" +!endif +!insertmacro UAC_AsUser_Call Label _UAC_L_F_${__UAC_L} ${UAC_SYNCREGISTERS}|${UAC_SYNCOUTDIR}|${UAC_SYNCINSTDIR} #|${UAC_CLEARERRFLAG} +!if "${workdir}" != "" + pop $outdir + SetOutPath $outdir +!endif +!macroend + + + +!macro _UAC_MakeLL_Cmp cmpop cmp pluginparams +!insertmacro _LOGICLIB_TEMP +UAC::_ ${pluginparams} +pop $_LOGICLIB_TEMP +!insertmacro ${cmpop} $_LOGICLIB_TEMP ${cmp} `${_t}` `${_f}` +!macroend +!macro _UAC_definemath def val1 op val2 +!define /math _UAC_definemath "${val1}" ${op} ${val2} +!ifdef ${def} + !undef ${def} +!endif +!define ${def} "${_UAC_definemath}" +!undef _UAC_definemath +!macroend +!macro _UAC_ParseDefineFlags_orin parse outflags +!searchparse /noerrors ${${parse}} "" _UAC_ParseDefineFlags_orin_f1 "|" _UAC_ParseDefineFlags_orin_f2 +!define _UAC_ParseDefineFlags_orin_this ${_UAC_ParseDefineFlags_orin_f1} +!undef ${parse} +!define ${parse} ${_UAC_ParseDefineFlags_orin_f2} +!define _UAC_ParseDefineFlags_orin_saveout ${${outflags}} +!undef ${outflags} +!define /math ${outflags} "${_UAC_ParseDefineFlags_orin_saveout}" | "${_UAC_ParseDefineFlags_orin_this}" +!undef _UAC_ParseDefineFlags_orin_saveout +!undef _UAC_ParseDefineFlags_orin_this +!ifdef _UAC_ParseDefineFlags_orin_f1 + !undef _UAC_ParseDefineFlags_orin_f1 +!endif +!ifdef _UAC_ParseDefineFlags_orin_f2 + !undef _UAC_ParseDefineFlags_orin_f2 +!endif +!macroend +!macro _UAC_ParseDefineFlags_Begin _outdef _in +!define _UAC_PDF${_outdef}_parse "${_in}" +!define _UAC_PDF${_outdef}_flags "" +!define _UAC_PDF${_outdef}_r 0 +!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x1 +!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x2 +!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x4 +!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x8 +!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x10 +!macroend +!macro _UAC_ParseDefineFlags_End _outdef +!define ${_outdef} ${_UAC_PDF${_outdef}_r} +!undef _UAC_PDF${_outdef}_r +!undef _UAC_PDF${_outdef}_flags +!undef _UAC_PDF${_outdef}_parse +!macroend +!macro _UAC_ParseDefineFlags_IncludeFlag _outdef flag +!if ${_UAC_PDF${_outdef}_flags} & ${flag} + !insertmacro _UAC_definemath _UAC_PDF${_outdef}_r ${_UAC_PDF${_outdef}_r} | ${flag} +!endif +!macroend +!macro _UAC_ParseDefineFlagsToInt _outdef _in +!insertmacro _UAC_ParseDefineFlags_Begin _UAC_ParseDefineFlagsToInt_tmp "${_in}" +!define ${_outdef} ${_UAC_PDF_UAC_ParseDefineFlagsToInt_tmp_flags} +!insertmacro _UAC_ParseDefineFlags_End _UAC_ParseDefineFlagsToInt_tmp +!undef _UAC_ParseDefineFlagsToInt_tmp +!macroend +!macro _UAC_IncL +!insertmacro _UAC_definemath __UAC_L "${__UAC_L}" + 1 +!macroend +!macro _UAC_AsUser_GenOp outvar op opparam1 opparam2 +!define _UAC_AUGOGR_ID _UAC_AUGOGR_OP${outvar}${op}${opparam1}${opparam2} +!ifndef ${_UAC_AUGOGR_ID} ;Has this exact action been done before? + !if ${outvar} == $0 + !define ${_UAC_AUGOGR_ID} $1 + !else + !define ${_UAC_AUGOGR_ID} $0 + !endif + !if "${opparam1}" == "" + !define _UAC_AUGOGR_OPP1 ${${_UAC_AUGOGR_ID}} + !define _UAC_AUGOGR_OPP2 ${opparam2} + !else + !define _UAC_AUGOGR_OPP1 ${opparam1} + !define _UAC_AUGOGR_OPP2 ${${_UAC_AUGOGR_ID}} + !endif + goto ${_UAC_AUGOGR_ID}_C + ${_UAC_AUGOGR_ID}_F: + ${op} ${_UAC_AUGOGR_OPP1} ${_UAC_AUGOGR_OPP2} + return + ${_UAC_AUGOGR_ID}_C: + !undef _UAC_AUGOGR_OPP1 + !undef _UAC_AUGOGR_OPP2 +!endif +push ${${_UAC_AUGOGR_ID}} +!insertmacro UAC_AsUser_Call Label ${_UAC_AUGOGR_ID}_F ${UAC_SYNCREGISTERS} +StrCpy ${outvar} ${${_UAC_AUGOGR_ID}} +pop ${${_UAC_AUGOGR_ID}} +!undef _UAC_AUGOGR_ID +!macroend + + + +!verbose pop +!endif /* UAC_HDR__INC */ \ No newline at end of file diff --git a/res/app.icns b/res/dev/app.icns similarity index 100% rename from res/app.icns rename to res/dev/app.icns diff --git a/res/app.ico b/res/dev/app.ico similarity index 100% rename from res/app.ico rename to res/dev/app.ico diff --git a/res/app.png b/res/dev/app.png similarity index 100% rename from res/app.png rename to res/dev/app.png diff --git a/res/braveDefaults.nsi b/res/dev/braveDefaults.nsi similarity index 96% rename from res/braveDefaults.nsi rename to res/dev/braveDefaults.nsi index 7ac1361fa3e..28bdc82616e 100644 --- a/res/braveDefaults.nsi +++ b/res/dev/braveDefaults.nsi @@ -1,9 +1,9 @@ !include "MUI2.nsh" !include "LogicLib.nsh" -!include "Win8WinVer.nsh" -!include "GetParameters.nsh" -!include "GetParent.nsh" -!include "StrStr.nsh" +!include "..\Win8WinVer.nsh" +!include "..\GetParameters.nsh" +!include "..\GetParent.nsh" +!include "..\StrStr.nsh" !addplugindir "." !include "UAC.nsh" @@ -14,7 +14,7 @@ SilentInstall silent Name "Brave" -OutFile "../Brave-win32-${ARCH}/resources/BraveDefaults.exe" +OutFile "../../Brave-win32-${ARCH}/resources/BraveDefaults.exe" RequestExecutionLevel user Var BraveEXEPath Var BraveIconPath @@ -118,7 +118,7 @@ Section "Defaults Section" SecDummy WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\Brave\Capabilities" "ApplicationDescription" "Brave is the new and fast web browser that protects your privacy and security by blocking intrusive ads and trackers." WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\Brave\Capabilities" "ApplicationName" "Brave" WriteRegDWORD SHCTX "SOFTWARE\Clients\StartMenuInternet\Brave\InstallInfo" "IconsVisible" 1 - WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\Brave\shell\open\command" "" "" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\Brave\shell\open\command" "" "$BraveEXEPath" ; File associations WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\Brave\Capabilities\FileAssociations" ".htm" "BraveHTML" WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\Brave\Capabilities\FileAssociations" ".html" "BraveHTML" diff --git a/res/dev/brave_installer.icns b/res/dev/brave_installer.icns new file mode 100644 index 00000000000..49951e4749f Binary files /dev/null and b/res/dev/brave_installer.icns differ diff --git a/res/dev/brave_installer.ico b/res/dev/brave_installer.ico new file mode 100644 index 00000000000..3664ca2bda4 Binary files /dev/null and b/res/dev/brave_installer.ico differ diff --git a/res/dev/brave_installer.png b/res/dev/brave_installer.png new file mode 100644 index 00000000000..c637db6a764 Binary files /dev/null and b/res/dev/brave_installer.png differ diff --git a/res/builderConfig.json b/res/dev/builderConfig.json similarity index 89% rename from res/builderConfig.json rename to res/dev/builderConfig.json index 468d33aa4d7..a730077c50e 100644 --- a/res/builderConfig.json +++ b/res/dev/builderConfig.json @@ -8,7 +8,7 @@ "dmg": { "title": "Brave", "background": "res/background.png", - "icon": "res/brave_installer.icns", + "icon": "res/dev/brave_installer.icns", "iconSize": 80, "contents": [ { "x": 192, "y": 344, "type": "file" }, diff --git a/res/linuxPackaging.json b/res/dev/linuxPackaging.json similarity index 88% rename from res/linuxPackaging.json rename to res/dev/linuxPackaging.json index d3bc7a08e17..621a2e3685e 100644 --- a/res/linuxPackaging.json +++ b/res/dev/linuxPackaging.json @@ -1,8 +1,11 @@ { + "name": "brave", + "bin": "brave", + "userDataDir": "brave", "productName": "Brave", "genericName": "Web Browser", "homepage": "https://brave.com/", - "icon": "res/app.png", + "icon": "res/dev/app.png", "section": "web", "categories": [ "Network", diff --git a/res/suse.json b/res/dev/suse.json similarity index 81% rename from res/suse.json rename to res/dev/suse.json index 4bbb77d549b..f540e9c9087 100644 --- a/res/suse.json +++ b/res/dev/suse.json @@ -1,8 +1,11 @@ { + "name": "brave", + "bin": "brave", + "userDataDir": "brave", "productName": "Brave", "genericName": "Web Browser", "homepage": "https://brave.com/", - "icon": "res/app.png", + "icon": "res/dev/app.png", "section": "web", "categories": [ "Network", diff --git a/res/developer/UAC.dll b/res/developer/UAC.dll new file mode 100644 index 00000000000..57a58c5399a Binary files /dev/null and b/res/developer/UAC.dll differ diff --git a/res/developer/UAC.nsh b/res/developer/UAC.nsh new file mode 100644 index 00000000000..08979aba97e --- /dev/null +++ b/res/developer/UAC.nsh @@ -0,0 +1,299 @@ +/*** UAC Plug-in *** + +Interactive User (MediumIL) Admin user (HighIL) +***[Setup.exe]************* ***[Setup.exe]************** +* * * * +* +++[.OnInit]+++++++++++ * * +++[.OnInit]++++++++++++ * +* + UAC_RunElevated >---+-+----> * + + * +* + NSIS.Quit + * * + + * +* +++++++++++++++++++++++ * * ++++++++++++++++++++++++ * +* * * * +* * * * +* +++[Section]+++++++++++ * * +++[Section]++++++++++++ * +* + + * /--+-+- +** +** Get integrity level of current process +** +**/ +!macro UAC_GetIntegrityLevel outvar +UAC::_ 6 +!if "${outvar}" != "s" + Pop ${outvar} +!endif +!macroend + + + +/* UAC_IsAdmin +** +** Is the current process running with administrator privileges? Result in $0 +** +** ${If} ${UAC_IsAdmin} ... +** +**/ +!macro UAC_IsAdmin +UAC::_ 2 +!macroend +!define UAC_IsAdmin `"" UAC_IsAdmin ""` +!macro _UAC_IsAdmin _a _b _t _f +!insertmacro _UAC_MakeLL_Cmp _!= 0 2s +!macroend + + + +/* UAC_IsInnerInstance +** +** Does the current process have a NSIS/UAC parent process that is part of the elevation operation? +** +** ${If} ${UAC_IsInnerInstance} ... +** +**/ +!macro UAC_IsInnerInstance +UAC::_ 3 +!macroend +!define UAC_IsInnerInstance `"" UAC_IsInnerInstance ""` +!macro _UAC_IsInnerInstance _a _b _t _f +!insertmacro _UAC_MakeLL_Cmp _!= 0 3s +!macroend + + + +/* UAC_PageElevation_OnInit, UAC_PageElevation_OnGuiInit, +** +** Helper macros for elevation on a custom elevation page, see the DualMode example for more information. +** +**/ +!macro UAC_Notify_OnGuiInit +UAC::_ 4 +!macroend +!macro UAC_PageElevation_OnGuiInit +!insertmacro UAC_Notify_OnGuiInit +!macroend +!macro UAC_PageElevation_OnInit +UAC::_ 5 +${IfThen} ${Errors} ${|} Quit ${|} +!macroend + + + +/* UAC_AsUser_Call +** +** Calls a function or label in the user process instance. +** All the UAC_AsUser_* macros use this helper macro. +** +**/ +!define UAC_SYNCREGISTERS 0x1 +;define UAC_SYNCSTACK 0x2 +!define UAC_SYNCOUTDIR 0x4 +!define UAC_SYNCINSTDIR 0x8 +;define UAC_CLEARERRFLAG 0x10 +!macro UAC_AsUser_Call type name flags +push $0 +Get${type}Address $0 ${name} +!verbose push +!verbose ${UAC_VERBOSE} +!insertmacro _UAC_ParseDefineFlagsToInt _UAC_AsUser_Call__flags ${flags} +!verbose pop +StrCpy $0 "1$0:${_UAC_AsUser_Call__flags}" +!undef _UAC_AsUser_Call__flags +Exch $0 +UAC::_ +!macroend + + + +/* +** UAC_AsUser_GetSection +*/ +!macro UAC_AsUser_GetSection secprop secidx outvar +!insertmacro _UAC_AsUser_GenOp ${outvar} SectionGet${secprop} ${secidx} "" +!macroend + + + +/* +** UAC_AsUser_GetGlobalVar +** UAC_AsUser_GetGlobal +*/ +!macro UAC_AsUser_GetGlobalVar var +!insertmacro _UAC_AsUser_GenOp ${var} StrCpy "" ${var} +!macroend +!macro UAC_AsUser_GetGlobal outvar srcvar +!insertmacro _UAC_AsUser_GenOp ${outvar} StrCpy "" ${srcvar} +!macroend + + + +/* +** UAC_AsUser_ExecShell +** +** Call ExecShell in the user process instance. +** +*/ +!macro UAC_AsUser_ExecShell verb command params workdir show +!insertmacro _UAC_IncL +goto _UAC_L_E_${__UAC_L} +_UAC_L_F_${__UAC_L}: +ExecShell "${verb}" "${command}" '${params}' ${show} +return +_UAC_L_E_${__UAC_L}: +!if "${workdir}" != "" + push $outdir + SetOutPath "${workdir}" +!endif +!insertmacro UAC_AsUser_Call Label _UAC_L_F_${__UAC_L} ${UAC_SYNCREGISTERS}|${UAC_SYNCOUTDIR}|${UAC_SYNCINSTDIR} #|${UAC_CLEARERRFLAG} +!if "${workdir}" != "" + pop $outdir + SetOutPath $outdir +!endif +!macroend + + + +!macro _UAC_MakeLL_Cmp cmpop cmp pluginparams +!insertmacro _LOGICLIB_TEMP +UAC::_ ${pluginparams} +pop $_LOGICLIB_TEMP +!insertmacro ${cmpop} $_LOGICLIB_TEMP ${cmp} `${_t}` `${_f}` +!macroend +!macro _UAC_definemath def val1 op val2 +!define /math _UAC_definemath "${val1}" ${op} ${val2} +!ifdef ${def} + !undef ${def} +!endif +!define ${def} "${_UAC_definemath}" +!undef _UAC_definemath +!macroend +!macro _UAC_ParseDefineFlags_orin parse outflags +!searchparse /noerrors ${${parse}} "" _UAC_ParseDefineFlags_orin_f1 "|" _UAC_ParseDefineFlags_orin_f2 +!define _UAC_ParseDefineFlags_orin_this ${_UAC_ParseDefineFlags_orin_f1} +!undef ${parse} +!define ${parse} ${_UAC_ParseDefineFlags_orin_f2} +!define _UAC_ParseDefineFlags_orin_saveout ${${outflags}} +!undef ${outflags} +!define /math ${outflags} "${_UAC_ParseDefineFlags_orin_saveout}" | "${_UAC_ParseDefineFlags_orin_this}" +!undef _UAC_ParseDefineFlags_orin_saveout +!undef _UAC_ParseDefineFlags_orin_this +!ifdef _UAC_ParseDefineFlags_orin_f1 + !undef _UAC_ParseDefineFlags_orin_f1 +!endif +!ifdef _UAC_ParseDefineFlags_orin_f2 + !undef _UAC_ParseDefineFlags_orin_f2 +!endif +!macroend +!macro _UAC_ParseDefineFlags_Begin _outdef _in +!define _UAC_PDF${_outdef}_parse "${_in}" +!define _UAC_PDF${_outdef}_flags "" +!define _UAC_PDF${_outdef}_r 0 +!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x1 +!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x2 +!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x4 +!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x8 +!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x10 +!macroend +!macro _UAC_ParseDefineFlags_End _outdef +!define ${_outdef} ${_UAC_PDF${_outdef}_r} +!undef _UAC_PDF${_outdef}_r +!undef _UAC_PDF${_outdef}_flags +!undef _UAC_PDF${_outdef}_parse +!macroend +!macro _UAC_ParseDefineFlags_IncludeFlag _outdef flag +!if ${_UAC_PDF${_outdef}_flags} & ${flag} + !insertmacro _UAC_definemath _UAC_PDF${_outdef}_r ${_UAC_PDF${_outdef}_r} | ${flag} +!endif +!macroend +!macro _UAC_ParseDefineFlagsToInt _outdef _in +!insertmacro _UAC_ParseDefineFlags_Begin _UAC_ParseDefineFlagsToInt_tmp "${_in}" +!define ${_outdef} ${_UAC_PDF_UAC_ParseDefineFlagsToInt_tmp_flags} +!insertmacro _UAC_ParseDefineFlags_End _UAC_ParseDefineFlagsToInt_tmp +!undef _UAC_ParseDefineFlagsToInt_tmp +!macroend +!macro _UAC_IncL +!insertmacro _UAC_definemath __UAC_L "${__UAC_L}" + 1 +!macroend +!macro _UAC_AsUser_GenOp outvar op opparam1 opparam2 +!define _UAC_AUGOGR_ID _UAC_AUGOGR_OP${outvar}${op}${opparam1}${opparam2} +!ifndef ${_UAC_AUGOGR_ID} ;Has this exact action been done before? + !if ${outvar} == $0 + !define ${_UAC_AUGOGR_ID} $1 + !else + !define ${_UAC_AUGOGR_ID} $0 + !endif + !if "${opparam1}" == "" + !define _UAC_AUGOGR_OPP1 ${${_UAC_AUGOGR_ID}} + !define _UAC_AUGOGR_OPP2 ${opparam2} + !else + !define _UAC_AUGOGR_OPP1 ${opparam1} + !define _UAC_AUGOGR_OPP2 ${${_UAC_AUGOGR_ID}} + !endif + goto ${_UAC_AUGOGR_ID}_C + ${_UAC_AUGOGR_ID}_F: + ${op} ${_UAC_AUGOGR_OPP1} ${_UAC_AUGOGR_OPP2} + return + ${_UAC_AUGOGR_ID}_C: + !undef _UAC_AUGOGR_OPP1 + !undef _UAC_AUGOGR_OPP2 +!endif +push ${${_UAC_AUGOGR_ID}} +!insertmacro UAC_AsUser_Call Label ${_UAC_AUGOGR_ID}_F ${UAC_SYNCREGISTERS} +StrCpy ${outvar} ${${_UAC_AUGOGR_ID}} +pop ${${_UAC_AUGOGR_ID}} +!undef _UAC_AUGOGR_ID +!macroend + + + +!verbose pop +!endif /* UAC_HDR__INC */ \ No newline at end of file diff --git a/res/developer/app.icns b/res/developer/app.icns new file mode 100644 index 00000000000..98721c154f9 Binary files /dev/null and b/res/developer/app.icns differ diff --git a/res/developer/app.ico b/res/developer/app.ico new file mode 100644 index 00000000000..befc37cd24d Binary files /dev/null and b/res/developer/app.ico differ diff --git a/res/developer/app.png b/res/developer/app.png new file mode 100644 index 00000000000..abe3c3070b1 Binary files /dev/null and b/res/developer/app.png differ diff --git a/res/developer/braveDefaults.nsi b/res/developer/braveDefaults.nsi new file mode 100644 index 00000000000..569874a4199 --- /dev/null +++ b/res/developer/braveDefaults.nsi @@ -0,0 +1,138 @@ +!include "MUI2.nsh" +!include "LogicLib.nsh" +!include "..\Win8WinVer.nsh" +!include "..\GetParameters.nsh" +!include "..\GetParent.nsh" +!include "..\StrStr.nsh" + +!addplugindir "." +!include "UAC.nsh" + +!define MUI_ICON "app.ico" +!insertmacro MUI_LANGUAGE "English" + +SilentInstall silent + +Name "BraveDeveloper" +OutFile "../../BraveDeveloper-win32-${ARCH}/resources/BraveDefaults.exe" +RequestExecutionLevel user +Var BraveEXEPath +Var BraveIconPath +Var IsElevated +Var IsUninstall + +Function .onInit + ; The StartMenuInternet key can be set in HKCU on Win8 and above. + ${IfNot} ${AtLeastWin8} + SetShellVarContext all + ${EndIf} + + ; Determine if we're elevated currently + ClearErrors + WriteRegStr HKLM "Software\Brave" "InstallerTest" "Write Test" + DeleteRegValue HKLM "Software\Brave" "InstallerTest" + ${If} ${Errors} + StrCpy $IsElevated "0" + ${Else} + StrCpy $IsElevated "1" + ${EndIf} + + Push $EXEDIR + Call GetParent + Call GetParent + POP $0 + + StrCpy $BraveEXEPath "$0\BraveDeveloper.exe" + StrCpy $BraveIconPath "$0\BraveDeveloper.exe,0" + + Call GetParameters + Pop $1 + + ; Determine if this is an uninstall or an install + ${StrStr} $4 $1 "-uninstall" + ${StrStr} $5 $1 "/uninstall" + + ${If} $4 != "" + ${OrIf} $5 != "" + StrCpy $IsUninstall "1" + ${Else} + StrCpy $IsUninstall "0" + ; Document / protocol handler class + ; These need to always be in HKCU becuase they contain the actual path of the exe which changes + ; on each update. If on HKLM then the user could not elevate later and cause a problem. + ; They should also be in this block early because we always want to re-create on each update. + WriteRegStr HKCU "SOFTWARE\Classes\BraveDeveloperHTML" "" "BraveDeveloper HTML Document" + WriteRegStr HKCU "SOFTWARE\Classes\BraveDeveloperHTML\DefaultIcon" "" "$BraveIconPath" + WriteRegStr HKCU "SOFTWARE\Classes\BraveDeveloperHTML\shell\open\command" "" '"$BraveEXEPath" "--user-data-dir=brave-developer" -- "%1"' + ${EndIf} + + ; If we already have the defaults key, there's nothing to do so we can abort early without even needing to elevate on Win7. + ${If} $IsUninstall == "0" + ClearErrors + ReadRegStr $2 SHCTX "SOFTWARE\RegisteredApplications" "BraveDeveloper" + ${IfNot} ${Errors} + Quit + ${EndIf} + ${EndIf} + + ; Elevate if we're on Win7 and below. Win8 allows keys to be set as HKCU so this is not needed there. + ${IfNot} ${AtLeastWin8} + ; Don't even try to elevate if we are already elevated. + ${AndIf} $IsElevated == "0" + !insertmacro UAC_RunElevated + ${Switch} $0 + ${Case} 0 + ${IfThen} $1 = 1 ${|} Quit ${|} ;we are the outer process, the inner process has done its work, we are done + ${IfThen} $3 <> 0 ${|} ${Break} ${|} ;we are admin, let the show go on + ;fall-through and die + ${Case} 1223 + MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Unable to elevate, Brave will not be able to be set as the default browser." + Quit + ${Case} 1062 + MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Logon service not running, aborting!" + Quit + ${Default} + MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Unable to elevate , error $0" + Quit + ${EndSwitch} + ${EndIf} +FunctionEnd + +Section "Defaults Section" SecDummy + Call GetParameters + Pop $1 + + ${If} $IsUninstall == "1" + DeleteRegKey HKCU "SOFTWARE\Classes\BraveDeveloperHTML" + DeleteRegKey SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveDeveloper" + DeleteRegValue SHCTX "SOFTWARE\RegisteredApplications" "BraveDeveloper" + + SetShellVarContext current + Delete "$DESKTOP\BraveDeveloper.lnk" + ${Else} + + ; Define capabilities + WriteRegStr SHCTX "SOFTWARE\RegisteredApplications" "BraveDeveloper" "Software\Clients\StartMenuInternet\BraveDeveloper\Capabilities" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveDeveloper\Capabilities\StartMenu" "StartMenuInternet" "BraveDeveloper" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveDeveloper" "" "BraveDeveloper" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveDeveloper\Capabilities" "ApplicationDescription" "BraveDeveloper is the new and fast web browser that protects your privacy and security by blocking intrusive ads and trackers." + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveDeveloper\Capabilities" "ApplicationName" "BraveDeveloper" + WriteRegDWORD SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveDeveloper\InstallInfo" "IconsVisible" 1 + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveDeveloper\shell\open\command" "" "$BraveEXEPath" + ; File associations + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveDeveloper\Capabilities\FileAssociations" ".htm" "BraveDeveloperHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveDeveloper\Capabilities\FileAssociations" ".html" "BraveDeveloperHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveDeveloper\Capabilities\FileAssociations" ".shtml" "BraveDeveloperHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveDeveloper\Capabilities\FileAssociations" ".xht" "BraveDeveloperHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveDeveloper\Capabilities\FileAssociations" ".xhtml" "BraveDeveloperHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveDeveloper\Capabilities\FileAssociations" ".webp" "BraveDeveloperHTML" + ; Protocol associations + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveDeveloper\Capabilities\URLAssociations" "ftp" "BraveDeveloperHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveDeveloper\Capabilities\URLAssociations" "http" "BraveDeveloperHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveDeveloper\Capabilities\URLAssociations" "https" "BraveDeveloperHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveDeveloper\Capabilities\URLAssociations" "mailto" "BraveDeveloperHTML" + ; Uninstall icon + SetRegView 64 + WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\BraveDeveloper" "DisplayIcon" "$BraveIconPath" + ${EndIf} +SectionEnd diff --git a/res/developer/brave_installer.icns b/res/developer/brave_installer.icns new file mode 100644 index 00000000000..49951e4749f Binary files /dev/null and b/res/developer/brave_installer.icns differ diff --git a/res/developer/brave_installer.ico b/res/developer/brave_installer.ico new file mode 100644 index 00000000000..3664ca2bda4 Binary files /dev/null and b/res/developer/brave_installer.ico differ diff --git a/res/developer/brave_installer.png b/res/developer/brave_installer.png new file mode 100644 index 00000000000..c637db6a764 Binary files /dev/null and b/res/developer/brave_installer.png differ diff --git a/res/developer/builderConfig.json b/res/developer/builderConfig.json new file mode 100644 index 00000000000..49053976787 --- /dev/null +++ b/res/developer/builderConfig.json @@ -0,0 +1,18 @@ +{ + "appId": "com.electron.brave", + "productName": "Brave-Developer", + "npmRebuild": false, + "mac": { + "target": "dmg" + }, + "dmg": { + "title": "Brave-Developer", + "background": "res/background.png", + "icon": "res/developer/brave_installer.icns", + "iconSize": 80, + "contents": [ + { "x": 192, "y": 344, "type": "file" }, + { "x": 438, "y": 344, "type": "link", "path": "/Applications" } + ] + } +} diff --git a/res/developer/linuxPackaging.json b/res/developer/linuxPackaging.json new file mode 100644 index 00000000000..affe34d1865 --- /dev/null +++ b/res/developer/linuxPackaging.json @@ -0,0 +1,46 @@ +{ + "name": "brave-developer", + "bin": "brave-developer", + "userDataDir": "brave-developer", + "productName": "Brave Developer", + "genericName": "Web Browser", + "homepage": "https://brave.com/", + "icon": "res/developer/app.png", + "section": "web", + "categories": [ + "Network", + "WebBrowser" + ], + "mimeType": [ + "text/html", + "text/xml", + "application/xhtml_xml", + "image/webp", + "x-scheme-handler/http", + "x-scheme-handler/https", + "x-scheme-handler/ftp" + ], + "requires": [ + "GConf2", + "libXScrnSaver", + "lsb" + ], + "depends": [ + "gawk", + "git", + "gconf2", + "gconf-service", + "gvfs-bin", + "libc6", + "libcap2", + "libgtk2.0-0", + "libudev0 | libudev1", + "libgcrypt11 | libgcrypt20", + "libnotify4", + "libnss3", + "libxtst6", + "libxss1", + "python", + "xdg-utils" + ] +} diff --git a/res/developer/suse.json b/res/developer/suse.json new file mode 100644 index 00000000000..e5bbae66691 --- /dev/null +++ b/res/developer/suse.json @@ -0,0 +1,28 @@ +{ + "name": "brave-developer", + "bin": "brave-developer", + "userDataDir": "brave-developer", + "productName": "Brave Developer", + "genericName": "Web Browser", + "homepage": "https://brave.com/", + "icon": "res/developer/app.png", + "section": "web", + "categories": [ + "Network", + "WebBrowser" + ], + "mimeType": [ + "text/html", + "text/xml", + "application/xhtml_xml", + "image/webp", + "x-scheme-handler/http", + "x-scheme-handler/https", + "x-scheme-handler/ftp" + ], + "requires": [ + "gconf2", + "libXss1", + "lsb" + ] +} diff --git a/res/nightly/UAC.dll b/res/nightly/UAC.dll new file mode 100644 index 00000000000..57a58c5399a Binary files /dev/null and b/res/nightly/UAC.dll differ diff --git a/res/nightly/UAC.nsh b/res/nightly/UAC.nsh new file mode 100644 index 00000000000..08979aba97e --- /dev/null +++ b/res/nightly/UAC.nsh @@ -0,0 +1,299 @@ +/*** UAC Plug-in *** + +Interactive User (MediumIL) Admin user (HighIL) +***[Setup.exe]************* ***[Setup.exe]************** +* * * * +* +++[.OnInit]+++++++++++ * * +++[.OnInit]++++++++++++ * +* + UAC_RunElevated >---+-+----> * + + * +* + NSIS.Quit + * * + + * +* +++++++++++++++++++++++ * * ++++++++++++++++++++++++ * +* * * * +* * * * +* +++[Section]+++++++++++ * * +++[Section]++++++++++++ * +* + + * /--+-+- +** +** Get integrity level of current process +** +**/ +!macro UAC_GetIntegrityLevel outvar +UAC::_ 6 +!if "${outvar}" != "s" + Pop ${outvar} +!endif +!macroend + + + +/* UAC_IsAdmin +** +** Is the current process running with administrator privileges? Result in $0 +** +** ${If} ${UAC_IsAdmin} ... +** +**/ +!macro UAC_IsAdmin +UAC::_ 2 +!macroend +!define UAC_IsAdmin `"" UAC_IsAdmin ""` +!macro _UAC_IsAdmin _a _b _t _f +!insertmacro _UAC_MakeLL_Cmp _!= 0 2s +!macroend + + + +/* UAC_IsInnerInstance +** +** Does the current process have a NSIS/UAC parent process that is part of the elevation operation? +** +** ${If} ${UAC_IsInnerInstance} ... +** +**/ +!macro UAC_IsInnerInstance +UAC::_ 3 +!macroend +!define UAC_IsInnerInstance `"" UAC_IsInnerInstance ""` +!macro _UAC_IsInnerInstance _a _b _t _f +!insertmacro _UAC_MakeLL_Cmp _!= 0 3s +!macroend + + + +/* UAC_PageElevation_OnInit, UAC_PageElevation_OnGuiInit, +** +** Helper macros for elevation on a custom elevation page, see the DualMode example for more information. +** +**/ +!macro UAC_Notify_OnGuiInit +UAC::_ 4 +!macroend +!macro UAC_PageElevation_OnGuiInit +!insertmacro UAC_Notify_OnGuiInit +!macroend +!macro UAC_PageElevation_OnInit +UAC::_ 5 +${IfThen} ${Errors} ${|} Quit ${|} +!macroend + + + +/* UAC_AsUser_Call +** +** Calls a function or label in the user process instance. +** All the UAC_AsUser_* macros use this helper macro. +** +**/ +!define UAC_SYNCREGISTERS 0x1 +;define UAC_SYNCSTACK 0x2 +!define UAC_SYNCOUTDIR 0x4 +!define UAC_SYNCINSTDIR 0x8 +;define UAC_CLEARERRFLAG 0x10 +!macro UAC_AsUser_Call type name flags +push $0 +Get${type}Address $0 ${name} +!verbose push +!verbose ${UAC_VERBOSE} +!insertmacro _UAC_ParseDefineFlagsToInt _UAC_AsUser_Call__flags ${flags} +!verbose pop +StrCpy $0 "1$0:${_UAC_AsUser_Call__flags}" +!undef _UAC_AsUser_Call__flags +Exch $0 +UAC::_ +!macroend + + + +/* +** UAC_AsUser_GetSection +*/ +!macro UAC_AsUser_GetSection secprop secidx outvar +!insertmacro _UAC_AsUser_GenOp ${outvar} SectionGet${secprop} ${secidx} "" +!macroend + + + +/* +** UAC_AsUser_GetGlobalVar +** UAC_AsUser_GetGlobal +*/ +!macro UAC_AsUser_GetGlobalVar var +!insertmacro _UAC_AsUser_GenOp ${var} StrCpy "" ${var} +!macroend +!macro UAC_AsUser_GetGlobal outvar srcvar +!insertmacro _UAC_AsUser_GenOp ${outvar} StrCpy "" ${srcvar} +!macroend + + + +/* +** UAC_AsUser_ExecShell +** +** Call ExecShell in the user process instance. +** +*/ +!macro UAC_AsUser_ExecShell verb command params workdir show +!insertmacro _UAC_IncL +goto _UAC_L_E_${__UAC_L} +_UAC_L_F_${__UAC_L}: +ExecShell "${verb}" "${command}" '${params}' ${show} +return +_UAC_L_E_${__UAC_L}: +!if "${workdir}" != "" + push $outdir + SetOutPath "${workdir}" +!endif +!insertmacro UAC_AsUser_Call Label _UAC_L_F_${__UAC_L} ${UAC_SYNCREGISTERS}|${UAC_SYNCOUTDIR}|${UAC_SYNCINSTDIR} #|${UAC_CLEARERRFLAG} +!if "${workdir}" != "" + pop $outdir + SetOutPath $outdir +!endif +!macroend + + + +!macro _UAC_MakeLL_Cmp cmpop cmp pluginparams +!insertmacro _LOGICLIB_TEMP +UAC::_ ${pluginparams} +pop $_LOGICLIB_TEMP +!insertmacro ${cmpop} $_LOGICLIB_TEMP ${cmp} `${_t}` `${_f}` +!macroend +!macro _UAC_definemath def val1 op val2 +!define /math _UAC_definemath "${val1}" ${op} ${val2} +!ifdef ${def} + !undef ${def} +!endif +!define ${def} "${_UAC_definemath}" +!undef _UAC_definemath +!macroend +!macro _UAC_ParseDefineFlags_orin parse outflags +!searchparse /noerrors ${${parse}} "" _UAC_ParseDefineFlags_orin_f1 "|" _UAC_ParseDefineFlags_orin_f2 +!define _UAC_ParseDefineFlags_orin_this ${_UAC_ParseDefineFlags_orin_f1} +!undef ${parse} +!define ${parse} ${_UAC_ParseDefineFlags_orin_f2} +!define _UAC_ParseDefineFlags_orin_saveout ${${outflags}} +!undef ${outflags} +!define /math ${outflags} "${_UAC_ParseDefineFlags_orin_saveout}" | "${_UAC_ParseDefineFlags_orin_this}" +!undef _UAC_ParseDefineFlags_orin_saveout +!undef _UAC_ParseDefineFlags_orin_this +!ifdef _UAC_ParseDefineFlags_orin_f1 + !undef _UAC_ParseDefineFlags_orin_f1 +!endif +!ifdef _UAC_ParseDefineFlags_orin_f2 + !undef _UAC_ParseDefineFlags_orin_f2 +!endif +!macroend +!macro _UAC_ParseDefineFlags_Begin _outdef _in +!define _UAC_PDF${_outdef}_parse "${_in}" +!define _UAC_PDF${_outdef}_flags "" +!define _UAC_PDF${_outdef}_r 0 +!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x1 +!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x2 +!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x4 +!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x8 +!insertmacro _UAC_ParseDefineFlags_orin _UAC_PDF${_outdef}_parse _UAC_PDF${_outdef}_flags ;0x10 +!macroend +!macro _UAC_ParseDefineFlags_End _outdef +!define ${_outdef} ${_UAC_PDF${_outdef}_r} +!undef _UAC_PDF${_outdef}_r +!undef _UAC_PDF${_outdef}_flags +!undef _UAC_PDF${_outdef}_parse +!macroend +!macro _UAC_ParseDefineFlags_IncludeFlag _outdef flag +!if ${_UAC_PDF${_outdef}_flags} & ${flag} + !insertmacro _UAC_definemath _UAC_PDF${_outdef}_r ${_UAC_PDF${_outdef}_r} | ${flag} +!endif +!macroend +!macro _UAC_ParseDefineFlagsToInt _outdef _in +!insertmacro _UAC_ParseDefineFlags_Begin _UAC_ParseDefineFlagsToInt_tmp "${_in}" +!define ${_outdef} ${_UAC_PDF_UAC_ParseDefineFlagsToInt_tmp_flags} +!insertmacro _UAC_ParseDefineFlags_End _UAC_ParseDefineFlagsToInt_tmp +!undef _UAC_ParseDefineFlagsToInt_tmp +!macroend +!macro _UAC_IncL +!insertmacro _UAC_definemath __UAC_L "${__UAC_L}" + 1 +!macroend +!macro _UAC_AsUser_GenOp outvar op opparam1 opparam2 +!define _UAC_AUGOGR_ID _UAC_AUGOGR_OP${outvar}${op}${opparam1}${opparam2} +!ifndef ${_UAC_AUGOGR_ID} ;Has this exact action been done before? + !if ${outvar} == $0 + !define ${_UAC_AUGOGR_ID} $1 + !else + !define ${_UAC_AUGOGR_ID} $0 + !endif + !if "${opparam1}" == "" + !define _UAC_AUGOGR_OPP1 ${${_UAC_AUGOGR_ID}} + !define _UAC_AUGOGR_OPP2 ${opparam2} + !else + !define _UAC_AUGOGR_OPP1 ${opparam1} + !define _UAC_AUGOGR_OPP2 ${${_UAC_AUGOGR_ID}} + !endif + goto ${_UAC_AUGOGR_ID}_C + ${_UAC_AUGOGR_ID}_F: + ${op} ${_UAC_AUGOGR_OPP1} ${_UAC_AUGOGR_OPP2} + return + ${_UAC_AUGOGR_ID}_C: + !undef _UAC_AUGOGR_OPP1 + !undef _UAC_AUGOGR_OPP2 +!endif +push ${${_UAC_AUGOGR_ID}} +!insertmacro UAC_AsUser_Call Label ${_UAC_AUGOGR_ID}_F ${UAC_SYNCREGISTERS} +StrCpy ${outvar} ${${_UAC_AUGOGR_ID}} +pop ${${_UAC_AUGOGR_ID}} +!undef _UAC_AUGOGR_ID +!macroend + + + +!verbose pop +!endif /* UAC_HDR__INC */ \ No newline at end of file diff --git a/res/nightly/app.icns b/res/nightly/app.icns new file mode 100644 index 00000000000..bb01349eba4 Binary files /dev/null and b/res/nightly/app.icns differ diff --git a/res/nightly/app.ico b/res/nightly/app.ico new file mode 100644 index 00000000000..986af1b433f Binary files /dev/null and b/res/nightly/app.ico differ diff --git a/res/nightly/app.png b/res/nightly/app.png new file mode 100644 index 00000000000..9b4b0c97a55 Binary files /dev/null and b/res/nightly/app.png differ diff --git a/res/nightly/braveDefaults.nsi b/res/nightly/braveDefaults.nsi new file mode 100644 index 00000000000..982ddf22d64 --- /dev/null +++ b/res/nightly/braveDefaults.nsi @@ -0,0 +1,140 @@ +!include "MUI2.nsh" +!include "LogicLib.nsh" +!include "..\Win8WinVer.nsh" +!include "..\GetParameters.nsh" +!include "..\GetParent.nsh" +!include "..\StrStr.nsh" + +!addplugindir "." +!include "UAC.nsh" + +!define MUI_ICON "app.ico" +!insertmacro MUI_LANGUAGE "English" + +SilentInstall silent + +Name "BraveNightly" +OutFile "../../BraveNightly-win32-${ARCH}/resources/BraveDefaults.exe" + +RequestExecutionLevel user +Var BraveEXEPath +Var BraveIconPath +Var IsElevated +Var IsUninstall + +Function .onInit + ; The StartMenuInternet key can be set in HKCU on Win8 and above. + ${IfNot} ${AtLeastWin8} + SetShellVarContext all + ${EndIf} + + ; Determine if we're elevated currently + ClearErrors + WriteRegStr HKLM "Software\Brave" "InstallerTest" "Write Test" + DeleteRegValue HKLM "Software\Brave" "InstallerTest" + ${If} ${Errors} + StrCpy $IsElevated "0" + ${Else} + StrCpy $IsElevated "1" + ${EndIf} + + + Push $EXEDIR + Call GetParent + Call GetParent + POP $0 + + StrCpy $BraveEXEPath "$0\BraveNightly.exe" + StrCpy $BraveIconPath "$0\BraveNightly.exe,0" + + Call GetParameters + Pop $1 + + ; Determine if this is an uninstall or an install + ${StrStr} $4 $1 "-uninstall" + ${StrStr} $5 $1 "/uninstall" + + ${If} $4 != "" + ${OrIf} $5 != "" + StrCpy $IsUninstall "1" + ${Else} + StrCpy $IsUninstall "0" + ; Document / protocol handler class + ; These need to always be in HKCU becuase they contain the actual path of the exe which changes + ; on each update. If on HKLM then the user could not elevate later and cause a problem. + ; They should also be in this block early because we always want to re-create on each update. + WriteRegStr HKCU "SOFTWARE\Classes\BraveNightlyHTML" "" "Brave Nightly HTML Document" + WriteRegStr HKCU "SOFTWARE\Classes\BraveNightlyHTML\DefaultIcon" "" "$BraveIconPath" + WriteRegStr HKCU "SOFTWARE\Classes\BraveNightlyHTML\shell\open\command" "" '"$BraveEXEPath" "--user-data-dir=brave-nightly" -- "%1"' + ${EndIf} + + ; If we already have the defaults key, there's nothing to do so we can abort early without even needing to elevate on Win7. + ${If} $IsUninstall == "0" + ClearErrors + ReadRegStr $2 SHCTX "SOFTWARE\RegisteredApplications" "BraveNightly" + ${IfNot} ${Errors} + Quit + ${EndIf} + ${EndIf} + + ; Elevate if we're on Win7 and below. Win8 allows keys to be set as HKCU so this is not needed there. + ${IfNot} ${AtLeastWin8} + ; Don't even try to elevate if we are already elevated. + ${AndIf} $IsElevated == "0" + !insertmacro UAC_RunElevated + ${Switch} $0 + ${Case} 0 + ${IfThen} $1 = 1 ${|} Quit ${|} ;we are the outer process, the inner process has done its work, we are done + ${IfThen} $3 <> 0 ${|} ${Break} ${|} ;we are admin, let the show go on + ;fall-through and die + ${Case} 1223 + MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Unable to elevate, Brave will not be able to be set as the default browser." + Quit + ${Case} 1062 + MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Logon service not running, aborting!" + Quit + ${Default} + MessageBox mb_IconStop|mb_TopMost|mb_SetForeground "Unable to elevate , error $0" + Quit + ${EndSwitch} + ${EndIf} +FunctionEnd + +Section "Defaults Section" SecDummy + Call GetParameters + Pop $1 + + ${If} $IsUninstall == "1" + DeleteRegKey HKCU "SOFTWARE\Classes\BraveNightlyHTML" + DeleteRegKey SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveNightly" + DeleteRegValue SHCTX "SOFTWARE\RegisteredApplications" "BraveNightly" + + SetShellVarContext current + Delete "$DESKTOP\BraveNightly.lnk" + ${Else} + + ; Define capabilities + WriteRegStr SHCTX "SOFTWARE\RegisteredApplications" "BraveNightly" "Software\Clients\StartMenuInternet\BraveNightly\Capabilities" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveNightly\Capabilities\StartMenu" "StartMenuInternet" "BraveNightly" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveNightly" "" "BraveNightly" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveNightly\Capabilities" "ApplicationDescription" "BraveNightly is the new and fast web browser that protects your privacy and security by blocking intrusive ads and trackers." + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveNightly\Capabilities" "ApplicationName" "BraveNightly" + WriteRegDWORD SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveNightly\InstallInfo" "IconsVisible" 1 + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveNightly\shell\open\command" "" "$BraveEXEPath" + ; File associations + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveNightly\Capabilities\FileAssociations" ".htm" "BraveNightlyHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveNightly\Capabilities\FileAssociations" ".html" "BraveNightlyHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveNightly\Capabilities\FileAssociations" ".shtml" "BraveNightlyHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveNightly\Capabilities\FileAssociations" ".xht" "BraveNightlyHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveNightly\Capabilities\FileAssociations" ".xhtml" "BraveNightlyHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveNightly\Capabilities\FileAssociations" ".webp" "BraveNightlyHTML" + ; Protocol associations + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveNightly\Capabilities\URLAssociations" "ftp" "BraveNightlyHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveNightly\Capabilities\URLAssociations" "http" "BraveNightlyHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveNightly\Capabilities\URLAssociations" "https" "BraveNightlyHTML" + WriteRegStr SHCTX "SOFTWARE\Clients\StartMenuInternet\BraveNightly\Capabilities\URLAssociations" "mailto" "BraveNightlyHTML" + ; Uninstall icon + SetRegView 64 + WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\BraveNightly" "DisplayIcon" "$BraveIconPath" + ${EndIf} +SectionEnd diff --git a/res/nightly/brave_installer.icns b/res/nightly/brave_installer.icns new file mode 100644 index 00000000000..49951e4749f Binary files /dev/null and b/res/nightly/brave_installer.icns differ diff --git a/res/nightly/brave_installer.ico b/res/nightly/brave_installer.ico new file mode 100644 index 00000000000..3664ca2bda4 Binary files /dev/null and b/res/nightly/brave_installer.ico differ diff --git a/res/nightly/brave_installer.png b/res/nightly/brave_installer.png new file mode 100644 index 00000000000..c637db6a764 Binary files /dev/null and b/res/nightly/brave_installer.png differ diff --git a/res/nightly/builderConfig.json b/res/nightly/builderConfig.json new file mode 100644 index 00000000000..394cfed2400 --- /dev/null +++ b/res/nightly/builderConfig.json @@ -0,0 +1,18 @@ +{ + "appId": "com.electron.brave", + "productName": "Brave-Nightly", + "npmRebuild": false, + "mac": { + "target": "dmg" + }, + "dmg": { + "title": "Brave-Nightly", + "background": "res/background.png", + "icon": "res/nightly/brave_installer.icns", + "iconSize": 80, + "contents": [ + { "x": 192, "y": 344, "type": "file" }, + { "x": 438, "y": 344, "type": "link", "path": "/Applications" } + ] + } +} diff --git a/res/nightly/linuxPackaging.json b/res/nightly/linuxPackaging.json new file mode 100644 index 00000000000..8aebc99fbfb --- /dev/null +++ b/res/nightly/linuxPackaging.json @@ -0,0 +1,46 @@ +{ + "name": "brave-nightly", + "bin": "brave-nightly", + "userDataDir": "brave-nightly", + "productName": "Brave Nightly", + "genericName": "Web Browser", + "homepage": "https://brave.com/", + "icon": "res/nightly/app.png", + "section": "web", + "categories": [ + "Network", + "WebBrowser" + ], + "mimeType": [ + "text/html", + "text/xml", + "application/xhtml_xml", + "image/webp", + "x-scheme-handler/http", + "x-scheme-handler/https", + "x-scheme-handler/ftp" + ], + "requires": [ + "GConf2", + "libXScrnSaver", + "lsb" + ], + "depends": [ + "gawk", + "git", + "gconf2", + "gconf-service", + "gvfs-bin", + "libc6", + "libcap2", + "libgtk2.0-0", + "libudev0 | libudev1", + "libgcrypt11 | libgcrypt20", + "libnotify4", + "libnss3", + "libxtst6", + "libxss1", + "python", + "xdg-utils" + ] +} diff --git a/res/nightly/suse.json b/res/nightly/suse.json new file mode 100644 index 00000000000..55b35d74b85 --- /dev/null +++ b/res/nightly/suse.json @@ -0,0 +1,28 @@ +{ + "name": "brave-nightly", + "bin": "brave-nightly", + "userDataDir": "brave-nightly", + "productName": "Brave Nightly", + "genericName": "Web Browser", + "homepage": "https://brave.com/", + "icon": "res/nightly/app.png", + "section": "web", + "categories": [ + "Network", + "WebBrowser" + ], + "mimeType": [ + "text/html", + "text/xml", + "application/xhtml_xml", + "image/webp", + "x-scheme-handler/http", + "x-scheme-handler/https", + "x-scheme-handler/ftp" + ], + "requires": [ + "gconf2", + "libXss1", + "lsb" + ] +} diff --git a/tools/buildInstaller.js b/tools/buildInstaller.js index ca317a4ad67..084d095eabc 100644 --- a/tools/buildInstaller.js +++ b/tools/buildInstaller.js @@ -17,7 +17,41 @@ if (isWindows) { widevineCdmArch = 'win_x86' } } -const buildDir = 'Brave-' + process.platform + '-' + arch + +const channel = process.env.CHANNEL + +var channels = { nightly: true, developer: true, beta: true, dev: true } +if (!channels[channel]) { + throw new Error('CHANNEL environment variable must be set to nightly, developer, beta or dev') +} + +var appName +switch (channel) { + case 'nightly': + appName = 'Brave-Nightly' + break + case 'developer': + appName = 'Brave-Developer' + break + case 'beta': + appName = 'Brave-Beta' + break + case 'dev': + appName = 'Brave' + break + default: + throw new Error('CHANNEL environment variable must be set to nightly, developer, beta or dev') +} + +if (isLinux) { + appName = appName.toLowerCase() +} + +if (isWindows) { + appName = appName.replace(/-/, '') +} + +const buildDir = appName + '-' + process.platform + '-' + arch console.log('Building install and update for version ' + VersionInfo.braveVersion + ' in ' + buildDir + ' with Electron ' + VersionInfo.electronVersion) @@ -51,39 +85,39 @@ if (isDarwin) { raiseError('IDENTIFIER needs to be set to the certificate organization') } - const wvBundle = buildDir + '/Brave.app/Contents/Frameworks/Brave Framework.framework/Brave Framework' - const wvBundleDir = buildDir + '/Brave.app/Contents/Frameworks/Widevine Resources.bundle' + const wvBundle = buildDir + `/${appName}.app/Contents/Frameworks/Brave Framework.framework/Brave Framework` + const wvBundleDir = buildDir + `/${appName}.app/Contents/Frameworks/Widevine Resources.bundle` const wvContents = wvBundleDir + '/Contents' const wvResources = wvContents + '/Resources' const wvBundleSig = wvResources + '/Brave Framework.sig' - const wvPlugin = buildDir + '/Brave.app/Contents/Frameworks/Brave Framework.framework/Libraries/WidevineCdm/_platform_specific/mac_x64/widevinecdmadapter.plugin' + const wvPlugin = buildDir + `/${appName}.app/Contents/Frameworks/Brave Framework.framework/Libraries/WidevineCdm/_platform_specific/mac_x64/widevinecdmadapter.plugin` cmds = [ // Remove old - 'rm -f ' + outDir + '/Brave.dmg', + 'rm -f ' + outDir + `/${appName}.dmg`, // sign for widevine 'mkdir -p "' + wvResources + '"', - 'cp ' + buildDir + '/Brave.app/Contents/Info.plist "' + wvContents + '"', + 'cp ' + buildDir + `/${appName}.app/Contents/Info.plist "` + wvContents + '"', 'codesign --deep --force --strict --verbose --sign $IDENTIFIER "' + wvBundle + '"', 'codesign --deep --force --strict --verbose --sign $IDENTIFIER "' + wvPlugin + '"', 'python tools/signature_generator.py --input_file "' + wvBundle + '" --output_file "' + wvBundleSig + '" --flag 1', 'python tools/signature_generator.py --input_file "' + wvPlugin + '"', // Sign it - 'cd ' + buildDir + '/Brave.app/Contents/Frameworks', + 'cd ' + buildDir + `/${appName}.app/Contents/Frameworks`, 'codesign --deep --force --strict --verbose --sign $IDENTIFIER *', 'cd ../../..', - 'codesign --deep --force --strict --verbose --sign $IDENTIFIER Brave.app/', + `codesign --deep --force --strict --verbose --sign $IDENTIFIER ${appName}.app/`, // Package it into a dmg 'cd ..', 'build ' + - '--prepackaged="' + buildDir + '/Brave.app" ' + + '--prepackaged="' + buildDir + `/${appName}.app" ` + '--mac=dmg ' + - ' --config=res/builderConfig.json ', + ` --config=res/${channel}/builderConfig.json `, // Create an update zip - 'ditto -c -k --sequesterRsrc --keepParent ' + buildDir + '/Brave.app dist/Brave-' + VersionInfo.braveVersion + '.zip' + 'ditto -c -k --sequesterRsrc --keepParent ' + buildDir + `/${appName}.app dist/${appName}-` + VersionInfo.braveVersion + '.zip' ] execute(cmds, {}, (err) => { if (err) { @@ -110,7 +144,7 @@ if (isDarwin) { } // sign for widevine - const wvExe = buildDir + '/Brave.exe' + const wvExe = buildDir + `/${appName}.exe` const wvPlugin = buildDir + '/WidevineCdm/_platform_specific/' + widevineCdmArch + '/widevinecdmadapter.dll' cmds = [ getSignCmd(wvExe), @@ -132,46 +166,47 @@ if (isDarwin) { var resultPromise = muonInstaller.createWindowsInstaller({ appDirectory: buildDir, outputDirectory: outDir, - title: 'Brave', + title: appName, + name: appName, authors: 'Brave Software', loadingGif: 'res/brave_splash_installing.gif', - setupIcon: 'res/brave_installer.ico', - iconUrl: 'https://brave.com/favicon.ico', + setupIcon: `res/${channel}/brave_installer.ico`, + iconUrl: `https://raw.githubusercontent.com/brave/browser-laptop/coexisted-channels/res/${channel}/app.ico`, signWithParams: format('-a -fd sha256 -f "%s" -p "%s"', path.resolve(cert), certPassword), noMsi: true, - exe: 'Brave.exe' + exe: `${appName}.exe`, + setupExe: `${appName}-Setup-${arch}.exe` }) resultPromise.then(() => { cmds = [ - `mv ${outDir}/Setup.exe ${outDir}/BraveSetup-${arch}.exe` ] execute(cmds, {}, console.log.bind(null, 'done')) }, (e) => console.log(`No dice: ${e.message}`)) }) } else if (isLinux) { - console.log('Install with sudo dpkg -i dist/brave_' + VersionInfo.braveVersion + '_amd64.deb') - console.log('Or install with sudo dnf install dist/brave_' + VersionInfo.braveVersion + '.x86_64.rpm') + console.log(`Install with sudo dpkg -i dist/${appName}_` + VersionInfo.braveVersion + '_amd64.deb') + console.log(`Or install with sudo dnf install dist/${appName}_` + VersionInfo.braveVersion + '.x86_64.rpm') cmds = [ // .deb file 'electron-installer-debian' + - ' --src Brave-linux-x64/' + - ' --dest dist/deb' + + ` --src ${appName}-linux-x64/` + + ' --dest dist/' + ' --arch amd64' + - ' --config res/linuxPackaging.json', + ` --config res/${channel}/linuxPackaging.json`, // .rpm file 'electron-installer-redhat' + - ' --src Brave-linux-x64/' + - ' --dest dist/redhat/' + + ` --src ${appName}-linux-x64/` + + ' --dest dist/' + ' --arch x86_64' + - ' --config res/linuxPackaging.json', + ` --config res/${channel}/linuxPackaging.json`, // OpenSuse .rpm file 'electron-installer-redhat' + - ' --src Brave-linux-x64/' + + ` --src ${appName}-linux-x64/` + ' --dest dist/suse/' + ' --arch x86_64' + - ' --config res/suse.json', + ` --config res/${channel}/suse.json`, // .tar.bz2 file - 'tar -jcvf dist/Brave.tar.bz2 ./Brave-linux-x64' + `tar -jcvf dist/${appName}.tar.bz2 ./${appName}-linux-x64` ] execute(cmds, {}, (err) => { if (err) { diff --git a/tools/buildPackage.js b/tools/buildPackage.js index bc5e685e157..0baa8e16096 100644 --- a/tools/buildPackage.js +++ b/tools/buildPackage.js @@ -13,34 +13,67 @@ const isDarwin = process.platform === 'darwin' var arch = 'x64' const isLinux = process.platform === 'linux' +var env = { + NODE_ENV: 'production', + CHANNEL: process.env.CHANNEL +} + +const channel = env.CHANNEL + +var channels = { nightly: true, developer: true, beta: true, dev: true } +if (!channels[channel]) { + throw new Error('CHANNEL environment variable must be set to nightly, developer, beta or dev') +} + var appIcon if (isWindows) { - appIcon = 'res/app.ico' + appIcon = `res/${channel}/app.ico` if (process.env.TARGET_ARCH === 'ia32') { arch = 'ia32' } } else if (isDarwin) { - appIcon = 'res/app.icns' + appIcon = `res/${channel}/app.icns` } else { - appIcon = 'res/app.png' + appIcon = `res/${channel}/app.png` } -const buildDir = 'Brave-' + process.platform + '-' + arch +var appName +switch (channel) { + case 'nightly': + appName = 'Brave-Nightly' + break + case 'developer': + appName = 'Brave-Developer' + break + case 'beta': + appName = 'Brave-Beta' + break + case 'dev': + appName = 'Brave' + break + default: + throw new Error('CHANNEL environment variable must be set to nightly, developer, beta or dev') +} -var env = { - NODE_ENV: 'production', - CHANNEL: process.env.CHANNEL +if (isLinux) { + appName = appName.toLowerCase() } -var channels = { dev: true, beta: true, stable: true, nightly: true, developer: true } -if (!channels[env.CHANNEL]) { - throw new Error('CHANNEL environment variable must be set to dev, beta, stable, nightly, or developer') +if (isWindows) { + appName = appName.replace(/-/, '') +} + +var productDirName = 'brave' +if (channel !== 'dev') { + productDirName += `-${channel}` } +const buildDir = appName + '-' + process.platform + '-' + arch + console.log('Writing buildConfig.js...') config.writeBuildConfig( { - channel: env.CHANNEL, + channel: channel, BROWSER_LAPTOP_REV: require('git-rev-sync').long(), nodeEnv: env.NODE_ENV }, @@ -51,8 +84,8 @@ var cmds = ['echo cleaning up target...'] if (isWindows) { cmds = cmds.concat([ - '(if exist Brave-win32-x64 rmdir /s /q Brave-win32-x64)', - '(if exist Brave-win32-ia32 rmdir /s /q Brave-win32-ia32)' + `(if exist ${appName}-win32-x64 rmdir /s /q ${appName}-win32-x64)`, + `(if exist ${appName}-win32-ia32 rmdir /s /q ${appName}-win32-ia32)` ]) // Remove the destination folder for the selected arch @@ -69,7 +102,7 @@ if (isWindows) { cmds = cmds.concat([ 'rm -Rf ' + buildDir, 'rm -Rf dist', - 'rm -f Brave.tar.bz2' + `rm -f ${appName}.tar.bz2` ]) } @@ -83,11 +116,12 @@ console.log('Building version ' + VersionInfo.braveVersion + ' in ' + buildDir + cmds = cmds.concat([ '"./node_modules/.bin/webpack"', 'npm run checks', - 'node ./node_modules/electron-packager/cli.js . Brave' + - ' --overwrite' + + `node ./node_modules/electron-packager/cli.js . ${appName}` + + ' --overwrite=true' + ' --ignore="' + ignoredPaths.join('|') + '"' + ' --platform=' + process.platform + ' --arch=' + arch + + ` --name="${appName}"` + ' --version=' + VersionInfo.electronVersion + ' --icon=' + appIcon + ' --asar=true' + @@ -95,11 +129,11 @@ cmds = cmds.concat([ ' --build-version=' + VersionInfo.electronVersion + ' --protocol="http" --protocol-name="HTTP Handler"' + ' --protocol="https" --protocol-name="HTTPS Handler"' + - ' --product-dir-name="brave"' + + ` --product-dir-name="${productDirName}"` + ' --version-string.CompanyName="Brave Software"' + - ' --version-string.ProductName="Brave"' + + ` --version-string.ProductName="${appName}"` + ' --version-string.Copyright="Copyright 2017, Brave Software"' + - ' --version-string.FileDescription="Brave"' + ` --version-string.FileDescription="${appName}"` ]) function BuildManifestFile () { @@ -110,24 +144,25 @@ function BuildManifestFile () { } if (isLinux) { - cmds.push('mv Brave-linux-x64/Brave Brave-linux-x64/brave') cmds.push('ncp ./app/extensions ' + path.join(buildDir, 'resources', 'extensions')) } else if (isDarwin) { - cmds.push('ncp ./app/extensions ' + path.join(buildDir, 'Brave.app', 'Contents', 'Resources', 'extensions')) + const macAppName = `${appName}.app` + cmds.push('ncp ./app/extensions ' + path.join(buildDir, macAppName, 'Contents', 'Resources', 'extensions')) } else if (isWindows) { BuildManifestFile() cmds.push('move .\\temp.VisualElementsManifest.xml "' + path.join(buildDir, 'resources', 'Update.VisualElementsManifest.xml') + '"') cmds.push('copy .\\res\\start-tile-70.png "' + path.join(buildDir, 'resources', 'start-tile-70.png') + '"') cmds.push('copy .\\res\\start-tile-150.png "' + path.join(buildDir, 'resources', 'start-tile-150.png') + '"') - cmds.push('makensis.exe -DARCH=' + arch + ' res/braveDefaults.nsi') + cmds.push('makensis.exe -DARCH=' + arch + ` res/${channel}/braveDefaults.nsi`) cmds.push('ncp ./app/extensions ' + path.join(buildDir, 'resources', 'extensions')) // Make sure the Brave.exe binary is squirrel aware so we get squirrel events and so that Squirrel doesn't auto create shortcuts. - cmds.push('"node_modules/rcedit/bin/rcedit.exe" ./Brave-win32-' + arch + '/Brave.exe --set-version-string "SquirrelAwareVersion" "1"') + cmds.push(`"node_modules/rcedit/bin/rcedit.exe" ./${appName}-win32-` + arch + `/${appName}.exe --set-version-string "SquirrelAwareVersion" "1"`) } if (isDarwin) { - cmds.push('mkdirp ' + path.join(buildDir, 'Brave.app', 'Contents', 'Resources', 'app.asar.unpacked', 'node_modules', 'node-anonize2-relic-emscripten')) - cmds.push('ncp ' + path.join('node_modules', 'node-anonize2-relic-emscripten', 'anonize2.js.mem') + ' ' + path.join(buildDir, 'Brave.app', 'Contents', 'Resources', 'app.asar.unpacked', 'node_modules', 'node-anonize2-relic-emscripten', 'anonize2.js.mem')) + const macAppName = `${appName}.app` + cmds.push('mkdirp ' + path.join(buildDir, macAppName, 'Contents', 'Resources', 'app.asar.unpacked', 'node_modules', 'node-anonize2-relic-emscripten')) + cmds.push('ncp ' + path.join('node_modules', 'node-anonize2-relic-emscripten', 'anonize2.js.mem') + ' ' + path.join(buildDir, macAppName, 'Contents', 'Resources', 'app.asar.unpacked', 'node_modules', 'node-anonize2-relic-emscripten', 'anonize2.js.mem')) } else { cmds.push('mkdirp ' + path.join(buildDir, 'resources', 'app.asar.unpacked', 'node_modules', 'node-anonize2-relic-emscripten')) cmds.push('ncp ' + path.join('node_modules', 'node-anonize2-relic-emscripten', 'anonize2.js.mem') + ' ' + path.join(buildDir, 'resources', 'app.asar.unpacked', 'node_modules', 'node-anonize2-relic-emscripten', 'anonize2.js.mem')) diff --git a/tools/lib/ignoredPaths.js b/tools/lib/ignoredPaths.js index 8abc7ba1fb7..608ba0632a4 100644 --- a/tools/lib/ignoredPaths.js +++ b/tools/lib/ignoredPaths.js @@ -55,5 +55,7 @@ module.exports = [ 'sqlite3', 'uglify-js', 'webdriverio', - 'webpack-dev-server' + 'webpack-dev-server', + 'Brave(.+)', + 'brave-(.+)' ]