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 authored and diracdeltas committed Jul 21, 2016
1 parent 38b0bf8 commit 5db7f1c
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 9 deletions.
7 changes: 4 additions & 3 deletions app/extensions/brave/locales/en-US/app.properties
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ flashSubtext=from {{source}} on {{site}}.
flashExpirationText=Approvals reset 7 days after last visit.
notificationPasswordWithUserName=Would you like Brave to remember the password for {{username}} on {{origin}}?
notificationPassword=Would you like Brave to remember your password on {{origin}}?
notificationPasswordYes=Yes
notificationPasswordNo=No
notificationPasswordNeverRemember=Never for this site
notificationPasswordSettings=[Password settings]
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 @@ -64,6 +64,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 @@ -391,6 +393,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 @@ -616,7 +638,11 @@ app.on('ready', () => {
if (!(message in passwordCallbacks)) {
// Notification not shown already
appActions.showMessageBox({
buttons: [locale.translation('notificationPasswordYes'), locale.translation('notificationPasswordNo'), locale.translation('notificationPasswordNeverRemember')],
buttons: [
locale.translation('yes'),
locale.translation('no'),
locale.translation('neverForThisSite')
],
options: {
persist: false,
advancedText: locale.translation('notificationPasswordSettings'),
Expand Down Expand Up @@ -652,10 +678,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
9 changes: 5 additions & 4 deletions app/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,11 @@ var rendererIdentifiers = function () {
'topSiteSuggestionTitle',
'notificationPasswordWithUserName',
'notificationPassword',
'notificationPasswordYes',
'notificationPasswordNo',
'notificationPasswordNeverRemember',
'notificationPasswordSettings'
'notificationPasswordSettings',
'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 5db7f1c

Please sign in to comment.