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

Commit de4ff2d

Browse files
authored
Merge pull request #15309 from brave/muon-upgrade-windows
Final browser-laptop update
2 parents 646212b + ef8f8dc commit de4ff2d

32 files changed

+1772
-2158
lines changed

app/browser/tabs.js

+4
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,10 @@ const updateAboutDetails = (tabId) => {
371371
adblockCount,
372372
httpsUpgradedCount,
373373
torEnabled,
374+
versionInformation: {
375+
browserLaptop: app.getVersion().toString(),
376+
initState: appState.getIn(['about', 'init']).toJS()
377+
},
374378
newTabDetail: newTabDetail.toJS()
375379
})
376380
} else if (location === 'about:autofill') {

app/darwinInit.js

+147
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
3+
* You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
if (process.platform === 'darwin') {
6+
const electron = require('electron')
7+
const path = require('path')
8+
const childProcess = require('child_process')
9+
const execSync = childProcess.execSync
10+
const app = electron.app
11+
const fs = require('fs')
12+
const os = require('os')
13+
const appName = 'Brave Browser.app'
14+
const homedir = os.homedir()
15+
16+
const getBraveBinPath = () => {
17+
const appPath = app.getPath('exe')
18+
const appIndex = appPath.indexOf('.app') + '.app'.length
19+
if (appPath && appIndex > 4) {
20+
// Remove the `Contents`/`MacOS`/`Brave` parts from path
21+
const runningAppPath = appPath.substring(0, appIndex)
22+
return runningAppPath
23+
}
24+
return false
25+
}
26+
27+
const braveCoreUpgradeFile = path.join(app.getPath('userData'), 'brave-core-upgrade')
28+
29+
const shouldAttemptInstall = () => {
30+
return !fs.existsSync(braveCoreUpgradeFile)
31+
}
32+
33+
const getBraveCoreInstallerPath = () => {
34+
const appDir = getBraveBinPath()
35+
if (!appDir) {
36+
return false
37+
}
38+
return path.join(getBraveBinPath(), 'Contents', 'Resources', 'Brave-Browser.pkg')
39+
}
40+
41+
const getBraveCoreInstallPath = () => {
42+
const braveCoreInstallLocations = [
43+
`${homedir}/Applications/${appName}/`,
44+
`/Applications/${appName}/`
45+
]
46+
47+
// check for existing installations
48+
for (var i = 0; i < braveCoreInstallLocations.length; i++) {
49+
if (fs.existsSync(braveCoreInstallLocations[i])) {
50+
console.log(`brave-core already installed at "${braveCoreInstallLocations[i]}"`)
51+
return braveCoreInstallLocations[i]
52+
}
53+
}
54+
55+
return false
56+
}
57+
58+
const installBraveCore = () => {
59+
// get path to the bundled brave-core binary
60+
const installerPath = getBraveCoreInstallerPath()
61+
if (!installerPath) {
62+
console.log('brave-core installer not found')
63+
return false
64+
}
65+
66+
// brave-core is not installed; go ahead with silent install
67+
const tempDir = path.join(os.tmpdir(), 'brave-upgrade')
68+
try {
69+
console.log(`Extracting brave-core binaries from "${installerPath}" into temp directory "${tempDir}"`)
70+
execSync(`pkgutil --expand-full "${installerPath}" "${tempDir}"`)
71+
72+
let installedPath = '/Applications'
73+
try {
74+
console.log(`Attempting to move extracted brave-core binaries into "${installedPath}/."`)
75+
execSync(`mv "${tempDir}/Payload/${appName}/" "${installedPath}/."`)
76+
} catch (globalPathException) {
77+
installedPath = `${homedir}/Applications`
78+
console.log(`Attempting to move extracted brave-core binaries into "${installedPath}/."`)
79+
execSync(`mv "${tempDir}/Payload/${appName}/" "${installedPath}/."`)
80+
}
81+
82+
// match expected permissions
83+
// logic borrowed from ./build/pkg-scripts/postinstall
84+
[
85+
`chmod -R 775 "${installedPath}/${appName}"`,
86+
`chown -R $USER "${installedPath}/${appName}"`,
87+
`chgrp -R admin "${installedPath}/${appName}"`
88+
].forEach((cmd) => {
89+
try {
90+
execSync(cmd)
91+
} catch (e) {
92+
console.log(`Failed adjusting permissions with "${cmd}"\nerror: "${e.toString()}"`)
93+
}
94+
})
95+
96+
// store details to disk; no further install attempts will be made
97+
try {
98+
fs.writeFileSync(braveCoreUpgradeFile, `installed: ${new Date().getTime()}`)
99+
} catch (e) {
100+
}
101+
102+
// launch into freshly installed brave-core and append argument expected in:
103+
// https://github.com/brave/brave-browser/issues/1545
104+
let openCmd = `open -a "${installedPath}/${appName}/" --args --upgrade-from-muon`
105+
console.log('Launching brave-core')
106+
execSync(openCmd)
107+
} catch (e) {
108+
return false
109+
} finally {
110+
console.log(`Removing temp directory "${tempDir}"`)
111+
try {
112+
execSync(`rm -rf ${tempDir}`)
113+
} catch (e) {}
114+
}
115+
116+
return true
117+
}
118+
119+
module.exports = function () {
120+
// If brave-core is installed, find the path and version
121+
const braveCoreInstallPath = getBraveCoreInstallPath()
122+
if (braveCoreInstallPath) {
123+
const getVersionCmd = `defaults read "${braveCoreInstallPath}/Contents/Info" CFBundleShortVersionString`
124+
let braveCoreVersion
125+
try {
126+
// format will be like `71.0.57.4`
127+
braveCoreVersion = execSync(getVersionCmd).toString().trim()
128+
// remove the Chromium version from the string
129+
const versionAsArray = braveCoreVersion.split('.')
130+
if (versionAsArray.length === 4) {
131+
braveCoreVersion = versionAsArray.slice(1).join('.')
132+
}
133+
} catch (e) {}
134+
135+
return {braveCoreInstalled: true, braveCoreInstallPath, braveCoreVersion}
136+
}
137+
138+
// If brave-core is NOT installed, attempt to install it
139+
if (shouldAttemptInstall()) {
140+
if (installBraveCore()) {
141+
app.exit()
142+
}
143+
}
144+
145+
return {braveCoreInstalled: false}
146+
}
147+
}
-994 Bytes
Loading

app/extensions/brave/locales/en-US/preferences.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ syncShowQR=Show secret QR code. (Do not share!)
379379
syncSiteSettings=Saved site settings
380380
syncStart=I am new to Sync
381381
syncTitle=Brave Sync
382-
syncTitleMessage=Sync encrypted browser data between your devices securely and privately using Brave Sync.
382+
syncTitleMessage=This version of Sync is deprecated. You can clear any existing data you have.
383383
tabCloseAction=When closing an active tab:
384384
tabCloseActionLastActive=Select the last viewed tab
385385
tabCloseActionNext=Select the next tab

app/index.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,14 @@ process.on('unhandledRejection', function (reason, promise) {
4949

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

52-
if (process.platform === 'win32') {
53-
require('./windowsInit')
54-
}
52+
let initState
5553

56-
if (process.platform === 'linux') {
54+
if (process.platform === 'win32') {
55+
initState = require('./windowsInit')()
56+
} else if (process.platform === 'linux') {
5757
require('./linuxInit')
58+
} else if (process.platform === 'darwin') {
59+
initState = require('./darwinInit')()
5860
}
5961

6062
const electron = require('electron')
@@ -185,6 +187,9 @@ app.on('ready', () => {
185187
})
186188

187189
loadAppStatePromise.then((initialImmutableState) => {
190+
// merge state which was set during optional platform-specific init
191+
initialImmutableState = initialImmutableState.setIn(['about', 'init'], Immutable.fromJS(initState || {}))
192+
188193
// Do this after loading the state
189194
// For tests we always want to load default app state
190195
const loadedPerWindowImmutableState = initialImmutableState.get('perWindowState')

app/renderer/components/preferences/syncTab.js

+13-21
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class SyncTab extends ImmutableComponent {
112112
l10nId='syncStart'
113113
testId='syncStartButton'
114114
onClick={this.showSyncStart.bind(this)}
115+
disabled
115116
/>
116117
<BrowserButton groupedItem secondaryColor
117118
l10nId='syncAdd'
@@ -130,6 +131,7 @@ class SyncTab extends ImmutableComponent {
130131
prefKey={settings.SYNC_ENABLED}
131132
settings={this.props.settings}
132133
onChangeSetting={this.toggleSync}
134+
disabled
133135
/>
134136
<div className={css(styles.device__item)}>
135137
<span className={css(styles.device__syncDeviceLabel)} data-l10n-id='syncDeviceName' />
@@ -143,6 +145,7 @@ class SyncTab extends ImmutableComponent {
143145
l10nId='syncNewDevice'
144146
testId='syncNewDeviceButton'
145147
onClick={this.showSyncNewDevice.bind(this)}
148+
disabled
146149
/>
147150
</SettingsList>
148151
}
@@ -468,15 +471,6 @@ class SyncTab extends ImmutableComponent {
468471
: null
469472
}
470473
{
471-
!this.isSetup && this.props.syncStartOverlayVisible
472-
? <ModalOverlay
473-
title={'syncStart'}
474-
content={this.startOverlayContent}
475-
footer={this.startOverlayFooter}
476-
onHide={this.props.hideOverlay.bind(this, 'syncStart')} />
477-
: null
478-
}
479-
{
480474
!this.isSetup && this.props.syncAddOverlayVisible
481475
? <ModalOverlay
482476
title={'syncAdd'}
@@ -502,16 +496,14 @@ class SyncTab extends ImmutableComponent {
502496

503497
<div className={css(styles.settingsListContainerMargin__bottom)}>
504498
<span className='settingsListTitle' data-l10n-id='syncTitleMessage' />
505-
<a href='https://github.com/brave/sync/wiki/Design' rel='noopener' target='_blank'>
506-
<span className={cx({
507-
fa: true,
508-
'fa-question-circle': true
509-
})} />
510-
</a>
511499
<div className={cx({
512-
settingsListTitle: true,
513-
[css(styles.subText)]: true
514-
})} data-l10n-id='syncBetaMessage' />
500+
settingsListTitle: true
501+
})}>
502+
Please download the <a className={css(commonStyles.linkText)}
503+
onClick={aboutActions.createTabRequested.bind(null, {
504+
url: 'https://brave.com/download'
505+
})}>new version of Brave for desktop</a>.
506+
</div>
515507
{
516508
this.setupError
517509
? this.errorContent
@@ -530,19 +522,19 @@ class SyncTab extends ImmutableComponent {
530522
dataL10nId='syncBookmarks'
531523
prefKey={settings.SYNC_TYPE_BOOKMARK}
532524
settings={this.props.settings}
533-
onChangeSetting={this.props.onChangeSetting}
525+
disabled
534526
/>
535527
<SettingCheckbox
536528
dataL10nId='syncSiteSettings'
537529
prefKey={settings.SYNC_TYPE_SITE_SETTING}
538530
settings={this.props.settings}
539-
onChangeSetting={this.props.onChangeSetting}
531+
disabled
540532
/>
541533
<SettingCheckbox
542534
dataL10nId='syncHistory'
543535
prefKey={settings.SYNC_TYPE_HISTORY}
544536
settings={this.props.settings}
545-
onChangeSetting={this.props.onChangeSetting}
537+
disabled
546538
/>
547539
</SettingsList>
548540
</section>

app/sessionStore.js

+5
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const {isImmutable, makeImmutable, deleteImmutablePaths} = require('./common/sta
4848
const {getSetting} = require('../js/settings')
4949
const platformUtil = require('./common/lib/platformUtil')
5050
const historyUtil = require('./common/lib/historyUtil')
51+
const {newTabMode} = require('./common/constants/settingsEnums')
5152

5253
const sessionStorageVersion = 1
5354
const sessionStorageName = `session-store-${sessionStorageVersion}`
@@ -692,6 +693,10 @@ module.exports.runPreMigrations = (data) => {
692693
data.settings[settings.PAYMENTS_NOTIFICATION_TRY_PAYMENTS_DISMISSED] = data.settings['payments.notificationTryPaymentsDismissed']
693694
delete data.settings['payments.notificationTryPaymentsDismissed']
694695
}
696+
697+
// force NEWTAB_MODE to be dashboard so folks can see deprecation notice
698+
// preference is also disabled (see js/about/preferences.js)
699+
data.settings[settings.NEWTAB_MODE] = newTabMode.NEW_TAB_PAGE
695700
}
696701

697702
if (data.sites) {

app/updater.js

+16
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const UpdateStatus = require('../js/constants/updateStatus')
2929
// Utils
3030
const request = require('../js/lib/request').request
3131
const ledgerUtil = require('./common/lib/ledgerUtil')
32+
const {isLinux} = require('./common/lib/platformUtil')
3233
const dates = require('./dates')
3334
const Channel = require('./channel')
3435

@@ -85,6 +86,21 @@ var scheduleUpdates = () => {
8586
}, appConfig.updates.appUpdateCheckFrequency)
8687
}
8788

89+
// Linux doesn't have an auto-update mechanism.
90+
// Instead, show a persistent nag linking to instructions
91+
if (isLinux()) {
92+
appActions.showNotification({
93+
buttons: [],
94+
options: {
95+
persist: false,
96+
advancedText: 'See instructions to upgrade to the latest version',
97+
advancedLink: 'https://brave-browser.readthedocs.io/en/latest/installing-brave.html#linux'
98+
},
99+
position: 'global',
100+
message: 'This version of Brave is no longer supported and will not be updated.'
101+
})
102+
}
103+
88104
// Startup check
89105
if (appConfig.updates.runtimeUpdateCheckDelay) {
90106
setTimeout(() => {

0 commit comments

Comments
 (0)