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

Commit

Permalink
Merge pull request #15309 from brave/muon-upgrade-windows
Browse files Browse the repository at this point in the history
Final browser-laptop update
  • Loading branch information
bsclifton authored Dec 7, 2018
2 parents 646212b + ef8f8dc commit de4ff2d
Show file tree
Hide file tree
Showing 32 changed files with 1,772 additions and 2,158 deletions.
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()}`)
} 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

0 comments on commit de4ff2d

Please sign in to comment.