Skip to content

Commit

Permalink
prefs that require browser restart should show prompt for browser res…
Browse files Browse the repository at this point in the history
…tart

fix brave#2543
  • Loading branch information
darkdh committed Jul 17, 2016
1 parent 1d15bfe commit 5b37100
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
27 changes: 26 additions & 1 deletion app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ let throttleKeytar = false
// Map of password notification bar messages to their callbacks
const passwordCallbacks = {}

const prefsRestartCallbacks = {}

/**
* Gets the master key for encrypting login credentials from the OS keyring.
*/
Expand Down Expand Up @@ -381,6 +383,26 @@ app.on('ready', () => {
app.quit()
})

ipcMain.on(messages.PREFS_RESTART, () => {
var message = 'Do you want to restart now ?'

appActions.showMessageBox({
buttons: ['Yes', 'No'],
options: {
persist: false
},
message
})
prefsRestartCallbacks[message] = (buttonIndex, persist) => {
if (buttonIndex === 0) {
app.relaunch({args: process.argv.slice(1) + ['--relaunch']})
app.exit(0)
} else {
appActions.hideMessageBox(message)
}
}
})

ipcMain.on(messages.UPDATE_APP_MENU, (e, args) => {
Menu.init(AppStore.getState().get('settings'), args)
})
Expand Down Expand Up @@ -633,10 +655,13 @@ app.on('ready', () => {
}
})

ipcMain.on(messages.NOTIFICATION_RESPONSE, (e, message, buttonIndex) => {
ipcMain.on(messages.NOTIFICATION_RESPONSE, (e, message, buttonIndex, persist) => {
if (passwordCallbacks[message]) {
passwordCallbacks[message](buttonIndex)
}
if (prefsRestartCallbacks[message]) {
prefsRestartCallbacks[message](buttonIndex, persist)
}
})

// Setup the crash handling
Expand Down
5 changes: 5 additions & 0 deletions js/about/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ class ShieldsTab extends ImmutableComponent {
class SecurityTab extends ImmutableComponent {
onToggleFlash (e) {
aboutActions.setResourceEnabled(flash, e.target.value)
ipc.send(messages.PREFS_RESTART)
}
render () {
return <div>
Expand Down Expand Up @@ -591,6 +592,10 @@ class AboutPreferences extends React.Component {
settings: this.state.settings.set(key, value)
})
aboutActions.changeSetting(key, value)
if (key === settings.DO_NOT_TRACK || key === settings.HARDWARE_ACCELERATION_ENABLED ||
key === settings.PDFJS_ENABLED) {
ipc.send(messages.PREFS_RESTART)
}
}

render () {
Expand Down
1 change: 1 addition & 0 deletions js/constants/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const messages = {
SHORTCUT_PREV_TAB: _,
// Misc application events
QUIT_APPLICATION: _,
PREFS_RESTART: _,
UPDATE_APP_MENU: _, /** @arg {Object} args menu args to update */
CERT_ERROR: _, /** @arg {Object} details of certificate error */
LOGIN_REQUIRED: _, /** @arg {Object} details of the login required request */
Expand Down

0 comments on commit 5b37100

Please sign in to comment.