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

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 #2543
  • Loading branch information
darkdh committed Jul 18, 2016
1 parent 60c5314 commit e14c9df
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
4 changes: 4 additions & 0 deletions app/extensions/brave/locales/en-US/app.properties
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,7 @@ flashTitle=Flash Object Blocked
flashRightClick=Right-click to run Adobe Flash
flashSubtext=from {{source}} on {{site}}.
flashExpirationText=Approvals reset 7 days after last visit.
prefsRestart=Do you want to restart now?
yes=Yes
no=No
neverForThisSite=Never for this site
33 changes: 31 additions & 2 deletions 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 = locale.translation('prefsRestart')

appActions.showMessageBox({
buttons: [locale.translation('yes'), locale.translation('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 @@ -597,7 +619,11 @@ app.on('ready', () => {
if (!(message in passwordCallbacks)) {
// Notification not shown already
appActions.showMessageBox({
buttons: ['Yes', 'No', 'Never for this site'],
buttons: [
locale.translation('yes'),
locale.translation('no'),
locale.translation('neverForThisSite')
],
options: {
persist: false,
advancedText: '[Password settings]',
Expand Down Expand Up @@ -633,10 +659,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
6 changes: 5 additions & 1 deletion app/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ var rendererIdentifiers = function () {
'historySuggestionTitle',
'aboutPagesSuggestionTitle',
'searchSuggestionTitle',
'topSiteSuggestionTitle'
'topSiteSuggestionTitle',
'prefsRestart',
'yes',
'no',
'neverForThisSite'
]
}

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 e14c9df

Please sign in to comment.