2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2025-01-22 14:48:28 +00:00

Implement disabling of developer tools

- Partially addresses #194
This commit is contained in:
Goh Jia Hao 2016-05-26 18:02:43 +08:00
parent 537dc01fd1
commit 1de9eec356
6 changed files with 24 additions and 3 deletions

View File

@ -117,7 +117,8 @@ function createMainWindow(options, onAppQuit, setDockBadge) {
goBack: onGoBack,
goForward: onGoForward,
getCurrentUrl: getCurrentUrl,
clearAppData: clearAppData
clearAppData: clearAppData,
disableDevTools: options.disableDevTools
};
createMenu(menuOptions);

View File

@ -9,8 +9,9 @@ import {Menu, shell, clipboard} from 'electron';
* @param goForward
* @param getCurrentUrl
* @param clearAppData
* @param disableDevTools
*/
function createMenu({nativefierVersion, appQuit, zoomIn, zoomOut, goBack, goForward, getCurrentUrl, clearAppData}) {
function createMenu({nativefierVersion, appQuit, zoomIn, zoomOut, goBack, goForward, getCurrentUrl, clearAppData, disableDevTools}) {
if (Menu.getApplicationMenu()) {
return;
}
@ -187,6 +188,12 @@ function createMenu({nativefierVersion, appQuit, zoomIn, zoomOut, goBack, goForw
}
];
if (disableDevTools) {
// remove last item (dev tools) from menu > view
const submenu = template[1].submenu;
submenu.splice(submenu.length - 1, 1);
}
if (process.platform === 'darwin') {
template.unshift({
label: 'Electron',

View File

@ -33,6 +33,8 @@
- [[full-screen]](#full-screen)
- [[maximize]](#maximize)
- [[verbose]](#verbose)
- [[disable-context-menu]](#disable-context-menu)
- [[disable-dev-tools]](#disable-dev-tools)
- [Programmatic API](#programmatic-api)
## Command Line
@ -317,6 +319,14 @@ Shows detailed logs in the console.
Disable the context menu
#### [disable-dev-tools]
```
--disable-dev-tools
```
Disable the Chrome developer tools
## Programmatic API
You can use the Nativefier programmatic API as well.

View File

@ -113,7 +113,8 @@ function selectAppArgs(options) {
fullScreen: options.fullScreen,
hideWindowFrame: options.hideWindowFrame,
maximize: options.maximize,
disableContextMenu: options.disableContextMenu
disableContextMenu: options.disableContextMenu,
disableDevTools: options.disableDevTools
};
}

View File

@ -49,6 +49,7 @@ if (require.main === module) {
.option('--hide-window-frame', 'disable window frame and controls')
.option('--verbose', 'if verbose logs should be displayed')
.option('--disable-context-menu', 'disable the context menu')
.option('--disable-dev-tools', 'disable developer tools')
.parse(process.argv);
if (!process.argv.slice(2).length) {

View File

@ -63,6 +63,7 @@ function optionsFactory(inpOptions, callback) {
hideWindowFrame: inpOptions.hideWindowFrame,
verbose: inpOptions.verbose,
disableContextMenu: inpOptions.disableContextMenu,
disableDevTools: inpOptions.disableDevTools,
// workaround for electron-packager#375
tmpdir: false
};