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

Final browser-laptop update #15309

Merged
merged 22 commits into from
Dec 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
31fe22f
Automate brave-core install for Windows. Includes an updated Squirrel…
bsclifton Oct 17, 2018
3cbd41c
Automate brave-core install for macOS
bsclifton Oct 25, 2018
93fa3b4
Update icons. Fixes https://github.com/brave/brave-browser/issues/1915
bsclifton Nov 2, 2018
66eb6c8
Change the order of operations on Windows brave-core install
bsclifton Oct 31, 2018
52b6946
Deprecation notice is now shown on `New Tab` page
bsclifton Oct 29, 2018
0c2a3e9
macOS and Windows will only try to install brave-core once
bsclifton Nov 4, 2018
31a006c
Show different messaging if user doesn't have brave-core installed
bsclifton Nov 4, 2018
ef52127
Added Linux only deprecation notification
bsclifton Nov 5, 2018
5daad5a
If Muon Brave is default browser, prompt user to change to Brave Core…
bsclifton Nov 6, 2018
cbe282d
Brave Core binaries
bsclifton Nov 7, 2018
f8e887c
Paths for Brave Core binaries
bsclifton Dec 3, 2018
6b93f8e
Version bump
bsclifton Oct 25, 2018
f381a3e
Address review feedback
bsclifton Nov 7, 2018
b0af328
Updates StartPage branding
jonathansampson Nov 15, 2018
782bc3f
Add debug logging, to make it easier to diagnose issues seen by teamm…
bsclifton Nov 19, 2018
cf1d2b3
Remove FindX search engine (I believe it's been EOLed). This was already
bsclifton Nov 19, 2018
09901ae
Allow packager to output a different CFBundleName for the macOS packager
petemill Nov 13, 2018
28adf74
Ran `npm audit fix` to bring vulnerabilities down from 23 to 14
bsclifton Nov 26, 2018
6c98eee
Disable sync
bsclifton Dec 4, 2018
9b52daf
review feedback
bsclifton Dec 6, 2018
f0be763
Remove default browser check (and set on launch).
bsclifton Dec 6, 2018
ef8f8dc
0.26.0
bsclifton Dec 7, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/browser/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@ const updateAboutDetails = (tabId) => {
adblockCount,
httpsUpgradedCount,
torEnabled,
versionInformation: {
browserLaptop: app.getVersion().toString(),
initState: appState.getIn(['about', 'init']).toJS()
},
newTabDetail: newTabDetail.toJS()
})
} else if (location === 'about:autofill') {
Expand Down
147 changes: 147 additions & 0 deletions app/darwinInit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
/* 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/. */

if (process.platform === 'darwin') {
const electron = require('electron')
const path = require('path')
const childProcess = require('child_process')
const execSync = childProcess.execSync
const app = electron.app
const fs = require('fs')
const os = require('os')
const appName = 'Brave Browser.app'
const homedir = os.homedir()

const getBraveBinPath = () => {
const appPath = app.getPath('exe')
const appIndex = appPath.indexOf('.app') + '.app'.length
if (appPath && appIndex > 4) {
// Remove the `Contents`/`MacOS`/`Brave` parts from path
const runningAppPath = appPath.substring(0, appIndex)
return runningAppPath
}
return false
}

const braveCoreUpgradeFile = path.join(app.getPath('userData'), 'brave-core-upgrade')

const shouldAttemptInstall = () => {
return !fs.existsSync(braveCoreUpgradeFile)
}

const getBraveCoreInstallerPath = () => {
const appDir = getBraveBinPath()
if (!appDir) {
return false
}
return path.join(getBraveBinPath(), 'Contents', 'Resources', 'Brave-Browser.pkg')
}

const getBraveCoreInstallPath = () => {
const braveCoreInstallLocations = [
`${homedir}/Applications/${appName}/`,
`/Applications/${appName}/`
]

// check for existing installations
for (var i = 0; i < braveCoreInstallLocations.length; i++) {
if (fs.existsSync(braveCoreInstallLocations[i])) {
console.log(`brave-core already installed at "${braveCoreInstallLocations[i]}"`)
return braveCoreInstallLocations[i]
}
}

return false
}

const installBraveCore = () => {
// get path to the bundled brave-core binary
const installerPath = getBraveCoreInstallerPath()
if (!installerPath) {
console.log('brave-core installer not found')
return false
}

// brave-core is not installed; go ahead with silent install
const tempDir = path.join(os.tmpdir(), 'brave-upgrade')
try {
console.log(`Extracting brave-core binaries from "${installerPath}" into temp directory "${tempDir}"`)
execSync(`pkgutil --expand-full "${installerPath}" "${tempDir}"`)

let installedPath = '/Applications'
try {
console.log(`Attempting to move extracted brave-core binaries into "${installedPath}/."`)
execSync(`mv "${tempDir}/Payload/${appName}/" "${installedPath}/."`)
} catch (globalPathException) {
installedPath = `${homedir}/Applications`
console.log(`Attempting to move extracted brave-core binaries into "${installedPath}/."`)
execSync(`mv "${tempDir}/Payload/${appName}/" "${installedPath}/."`)
}

// match expected permissions
// logic borrowed from ./build/pkg-scripts/postinstall
[
`chmod -R 775 "${installedPath}/${appName}"`,
`chown -R $USER "${installedPath}/${appName}"`,
`chgrp -R admin "${installedPath}/${appName}"`
].forEach((cmd) => {
try {
execSync(cmd)
} catch (e) {
console.log(`Failed adjusting permissions with "${cmd}"\nerror: "${e.toString()}"`)
}
})

// store details to disk; no further install attempts will be made
try {
fs.writeFileSync(braveCoreUpgradeFile, `installed: ${new Date().getTime()}`)
Copy link
Contributor

@jumde jumde Nov 12, 2018

Choose a reason for hiding this comment

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

@bsclifton - If the init script fails before this, the <platform>Init.js script will try to install brave-core again, what do you think about writing errors to the same file? In that case, if the script throws any errors before this line the init script will not run again.

} catch (e) {
}

// launch into freshly installed brave-core and append argument expected in:
// https://github.com/brave/brave-browser/issues/1545
let openCmd = `open -a "${installedPath}/${appName}/" --args --upgrade-from-muon`
console.log('Launching brave-core')
execSync(openCmd)
} catch (e) {
return false
} finally {
console.log(`Removing temp directory "${tempDir}"`)
try {
execSync(`rm -rf ${tempDir}`)
} catch (e) {}
}

return true
}

module.exports = function () {
// If brave-core is installed, find the path and version
const braveCoreInstallPath = getBraveCoreInstallPath()
if (braveCoreInstallPath) {
const getVersionCmd = `defaults read "${braveCoreInstallPath}/Contents/Info" CFBundleShortVersionString`
let braveCoreVersion
try {
// format will be like `71.0.57.4`
braveCoreVersion = execSync(getVersionCmd).toString().trim()
// remove the Chromium version from the string
const versionAsArray = braveCoreVersion.split('.')
if (versionAsArray.length === 4) {
braveCoreVersion = versionAsArray.slice(1).join('.')
}
} catch (e) {}

return {braveCoreInstalled: true, braveCoreInstallPath, braveCoreVersion}
}

// If brave-core is NOT installed, attempt to install it
if (shouldAttemptInstall()) {
if (installBraveCore()) {
app.exit()
}
}

return {braveCoreInstalled: false}
}
}
Binary file modified app/extensions/brave/img/favicons/startpage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/extensions/brave/locales/en-US/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ syncShowQR=Show secret QR code. (Do not share!)
syncSiteSettings=Saved site settings
syncStart=I am new to Sync
syncTitle=Brave Sync
syncTitleMessage=Sync encrypted browser data between your devices securely and privately using Brave Sync.
syncTitleMessage=This version of Sync is deprecated. You can clear any existing data you have.
tabCloseAction=When closing an active tab:
tabCloseActionLastActive=Select the last viewed tab
tabCloseActionNext=Select the next tab
Expand Down
13 changes: 9 additions & 4 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ process.on('unhandledRejection', function (reason, promise) {

process.on('warning', warning => console.warn(warning.stack))

if (process.platform === 'win32') {
require('./windowsInit')
}
let initState

if (process.platform === 'linux') {
if (process.platform === 'win32') {
initState = require('./windowsInit')()
} else if (process.platform === 'linux') {
require('./linuxInit')
} else if (process.platform === 'darwin') {
initState = require('./darwinInit')()
}

const electron = require('electron')
Expand Down Expand Up @@ -185,6 +187,9 @@ app.on('ready', () => {
})

loadAppStatePromise.then((initialImmutableState) => {
// merge state which was set during optional platform-specific init
initialImmutableState = initialImmutableState.setIn(['about', 'init'], Immutable.fromJS(initState || {}))

// Do this after loading the state
// For tests we always want to load default app state
const loadedPerWindowImmutableState = initialImmutableState.get('perWindowState')
Expand Down
34 changes: 13 additions & 21 deletions app/renderer/components/preferences/syncTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class SyncTab extends ImmutableComponent {
l10nId='syncStart'
testId='syncStartButton'
onClick={this.showSyncStart.bind(this)}
disabled
/>
<BrowserButton groupedItem secondaryColor
l10nId='syncAdd'
Expand All @@ -130,6 +131,7 @@ class SyncTab extends ImmutableComponent {
prefKey={settings.SYNC_ENABLED}
settings={this.props.settings}
onChangeSetting={this.toggleSync}
disabled
/>
<div className={css(styles.device__item)}>
<span className={css(styles.device__syncDeviceLabel)} data-l10n-id='syncDeviceName' />
Expand All @@ -143,6 +145,7 @@ class SyncTab extends ImmutableComponent {
l10nId='syncNewDevice'
testId='syncNewDeviceButton'
onClick={this.showSyncNewDevice.bind(this)}
disabled
/>
</SettingsList>
}
Expand Down Expand Up @@ -468,15 +471,6 @@ class SyncTab extends ImmutableComponent {
: null
}
{
!this.isSetup && this.props.syncStartOverlayVisible
? <ModalOverlay
title={'syncStart'}
content={this.startOverlayContent}
footer={this.startOverlayFooter}
onHide={this.props.hideOverlay.bind(this, 'syncStart')} />
: null
}
{
!this.isSetup && this.props.syncAddOverlayVisible
? <ModalOverlay
title={'syncAdd'}
Expand All @@ -502,16 +496,14 @@ class SyncTab extends ImmutableComponent {

<div className={css(styles.settingsListContainerMargin__bottom)}>
<span className='settingsListTitle' data-l10n-id='syncTitleMessage' />
<a href='https://github.com/brave/sync/wiki/Design' rel='noopener' target='_blank'>
<span className={cx({
fa: true,
'fa-question-circle': true
})} />
</a>
<div className={cx({
settingsListTitle: true,
[css(styles.subText)]: true
})} data-l10n-id='syncBetaMessage' />
settingsListTitle: true
})}>
Please download the <a className={css(commonStyles.linkText)}
onClick={aboutActions.createTabRequested.bind(null, {
url: 'https://brave.com/download'
})}>new version of Brave for desktop</a>.
</div>
{
this.setupError
? this.errorContent
Expand All @@ -530,19 +522,19 @@ class SyncTab extends ImmutableComponent {
dataL10nId='syncBookmarks'
prefKey={settings.SYNC_TYPE_BOOKMARK}
settings={this.props.settings}
onChangeSetting={this.props.onChangeSetting}
disabled
/>
<SettingCheckbox
dataL10nId='syncSiteSettings'
prefKey={settings.SYNC_TYPE_SITE_SETTING}
settings={this.props.settings}
onChangeSetting={this.props.onChangeSetting}
disabled
/>
<SettingCheckbox
dataL10nId='syncHistory'
prefKey={settings.SYNC_TYPE_HISTORY}
settings={this.props.settings}
onChangeSetting={this.props.onChangeSetting}
disabled
/>
</SettingsList>
</section>
Expand Down
5 changes: 5 additions & 0 deletions app/sessionStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const {isImmutable, makeImmutable, deleteImmutablePaths} = require('./common/sta
const {getSetting} = require('../js/settings')
const platformUtil = require('./common/lib/platformUtil')
const historyUtil = require('./common/lib/historyUtil')
const {newTabMode} = require('./common/constants/settingsEnums')

const sessionStorageVersion = 1
const sessionStorageName = `session-store-${sessionStorageVersion}`
Expand Down Expand Up @@ -692,6 +693,10 @@ module.exports.runPreMigrations = (data) => {
data.settings[settings.PAYMENTS_NOTIFICATION_TRY_PAYMENTS_DISMISSED] = data.settings['payments.notificationTryPaymentsDismissed']
delete data.settings['payments.notificationTryPaymentsDismissed']
}

// force NEWTAB_MODE to be dashboard so folks can see deprecation notice
// preference is also disabled (see js/about/preferences.js)
data.settings[settings.NEWTAB_MODE] = newTabMode.NEW_TAB_PAGE
}

if (data.sites) {
Expand Down
16 changes: 16 additions & 0 deletions app/updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const UpdateStatus = require('../js/constants/updateStatus')
// Utils
const request = require('../js/lib/request').request
const ledgerUtil = require('./common/lib/ledgerUtil')
const {isLinux} = require('./common/lib/platformUtil')
const dates = require('./dates')
const Channel = require('./channel')

Expand Down Expand Up @@ -85,6 +86,21 @@ var scheduleUpdates = () => {
}, appConfig.updates.appUpdateCheckFrequency)
}

// Linux doesn't have an auto-update mechanism.
// Instead, show a persistent nag linking to instructions
if (isLinux()) {
appActions.showNotification({
buttons: [],
options: {
persist: false,
advancedText: 'See instructions to upgrade to the latest version',
advancedLink: 'https://brave-browser.readthedocs.io/en/latest/installing-brave.html#linux'
},
position: 'global',
message: 'This version of Brave is no longer supported and will not be updated.'
})
}

// Startup check
if (appConfig.updates.runtimeUpdateCheckDelay) {
setTimeout(() => {
Expand Down
Loading