Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add forcereload menu item role #8570

Merged
merged 2 commits into from
Feb 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions default_app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ app.once('ready', () => {
{
role: 'reload'
},
{
role: 'forcereload'
},
{
role: 'toggledevtools'
},
Expand Down
1 change: 1 addition & 0 deletions docs/api/menu-item.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ The `role` property can have following values:
* `close` - Close current window
* `quit`- Quit the application
* `reload` - Reload the current window
* `forcereload` - Reload the current window ignoring the cache.
* `toggledevtools` - Toggle developer tools in the current window
* `togglefullscreen`- Toggle full screen mode on the current window
* `resetzoom` - Reset the focused page's zoom level to the original size
Expand Down
3 changes: 3 additions & 0 deletions docs/api/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ const template = [
{
role: 'reload'
},
{
role: 'forcereload'
},
{
role: 'toggledevtools'
},
Expand Down
17 changes: 15 additions & 2 deletions lib/browser/api/menu-item-roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ const roles = {
label: 'Delete',
webContentsMethod: 'delete'
},
forcereload: {
label: 'Force Reload',
accelerator: 'Shift+CmdOrCtrl+R',
nonNativeMacOSRole: true,
windowMethod: (window) => {
window.webContents.reloadIgnoringCache()
}
},
front: {
label: 'Bring All to Front'
},
Expand Down Expand Up @@ -75,11 +83,13 @@ const roles = {
reload: {
label: 'Reload',
accelerator: 'CmdOrCtrl+R',
nonNativeMacOSRole: true,
windowMethod: 'reload'
},
resetzoom: {
label: 'Actual Size',
accelerator: 'CommandOrControl+0',
nonNativeMacOSRole: true,
webContentsMethod: (webContents) => {
webContents.setZoomLevel(0)
}
Expand All @@ -101,6 +111,7 @@ const roles = {
toggledevtools: {
label: 'Toggle Developer Tools',
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
nonNativeMacOSRole: true,
windowMethod: 'toggleDevTools'
},
togglefullscreen: {
Expand All @@ -127,6 +138,7 @@ const roles = {
zoomin: {
label: 'Zoom In',
accelerator: 'CommandOrControl+Plus',
nonNativeMacOSRole: true,
webContentsMethod: (webContents) => {
webContents.getZoomLevel((zoomLevel) => {
webContents.setZoomLevel(zoomLevel + 0.5)
Expand All @@ -136,6 +148,7 @@ const roles = {
zoomout: {
label: 'Zoom Out',
accelerator: 'CommandOrControl+-',
nonNativeMacOSRole: true,
webContentsMethod: (webContents) => {
webContents.getZoomLevel((zoomLevel) => {
webContents.setZoomLevel(zoomLevel - 0.5)
Expand All @@ -147,8 +160,8 @@ const roles = {
const canExecuteRole = (role) => {
if (!roles.hasOwnProperty(role)) return false
if (process.platform !== 'darwin') return true
// macOS handles all roles natively except the ones listed below
return ['reload', 'resetzoom', 'toggledevtools', 'zoomin', 'zoomout'].includes(role)
// macOS handles all roles natively except for a few
return roles[role].nonNativeMacOSRole
}

exports.getDefaultLabel = (role) => {
Expand Down