diff --git a/app/extensions/brave/locales/en-US/preferences.properties b/app/extensions/brave/locales/en-US/preferences.properties index e51a9b1116b..dca67ced4d1 100644 --- a/app/extensions/brave/locales/en-US/preferences.properties +++ b/app/extensions/brave/locales/en-US/preferences.properties @@ -222,3 +222,4 @@ enableAutofill=Enable Autofill importBrowserData=Import Browser Data importNow=Import now… clearAll=Clear all +sendCrashReports=Send anonymous crash reports to Brave (requires browser restart) \ No newline at end of file diff --git a/app/index.js b/app/index.js index a19164b5a5c..524db8e4efe 100644 --- a/app/index.js +++ b/app/index.js @@ -9,7 +9,6 @@ let ready = false // Setup the crash handling const CrashHerald = require('./crash-herald') -CrashHerald.init() const handleUncaughtError = (error) => { var message, ref, stack @@ -244,10 +243,16 @@ let flashInitialized = false // Some settings must be set right away on startup, those settings should be handled here. loadAppStatePromise.then((initialState) => { - const {HARDWARE_ACCELERATION_ENABLED, SMOOTH_SCROLL_ENABLED} = require('../js/constants/settings') + const {HARDWARE_ACCELERATION_ENABLED, SMOOTH_SCROLL_ENABLED, SEND_CRASH_REPORTS} = require('../js/constants/settings') if (initialState.settings[HARDWARE_ACCELERATION_ENABLED] === false) { app.disableHardwareAcceleration() } + if (initialState.settings[SEND_CRASH_REPORTS] !== false) { + console.log('Crash reporting enabled') + CrashHerald.init() + } else { + console.log('Crash reporting disabled') + } if (initialState.settings[SMOOTH_SCROLL_ENABLED] === false) { app.commandLine.appendSwitch('disable-smooth-scrolling') } diff --git a/docs/state.md b/docs/state.md index 360c930578a..efb8f82469a 100644 --- a/docs/state.md +++ b/docs/state.md @@ -176,6 +176,7 @@ AppStore 'advanced.default-zoom-level': number, // the default zoom level for sites that have no specific setting 'advanced.pdfjs-enabled': boolean, // Whether or not to render PDF documents in the browser 'advanced.smooth-scroll-enabled': boolean, // false if smooth scrolling should be explicitly disabled + 'advanced.send-crash-reports': boolean, // true or undefined if crash reports should be sent 'shutdown.clear-history': boolean, // true to clear history on shutdown 'shutdown.clear-downloads': boolean, // true to clear downloads on shutdown 'shutdown.clear-cache': boolean, // true to clear cache on shutdown diff --git a/js/about/preferences.js b/js/about/preferences.js index 40643ca6124..acf05146937 100644 --- a/js/about/preferences.js +++ b/js/about/preferences.js @@ -1281,6 +1281,7 @@ class AdvancedTab extends ImmutableComponent { + } @@ -1455,7 +1456,8 @@ class AboutPreferences extends React.Component { }) aboutActions.changeSetting(key, value) if (key === settings.DO_NOT_TRACK || key === settings.HARDWARE_ACCELERATION_ENABLED || - key === settings.PDFJS_ENABLED || key === settings.SMOOTH_SCROLL_ENABLED) { + key === settings.PDFJS_ENABLED || key === settings.SMOOTH_SCROLL_ENABLED || + key === settings.SEND_CRASH_REPORTS) { ipc.send(messages.PREFS_RESTART, key, value) } if (key === settings.PAYMENTS_ENABLED) { diff --git a/js/constants/appConfig.js b/js/constants/appConfig.js index 88a7b20db2c..46ff517e6a2 100644 --- a/js/constants/appConfig.js +++ b/js/constants/appConfig.js @@ -124,6 +124,7 @@ module.exports = { 'advanced.default-zoom-level': null, 'advanced.pdfjs-enabled': true, 'advanced.smooth-scroll-enabled': false, + 'advanced.send-crash-reports': true, 'shutdown.clear-history': false, 'shutdown.clear-downloads': false, 'shutdown.clear-cache': false, diff --git a/js/constants/settings.js b/js/constants/settings.js index 06d9dd3e8aa..7d2e5dd71a9 100644 --- a/js/constants/settings.js +++ b/js/constants/settings.js @@ -57,6 +57,7 @@ const settings = { PDFJS_ENABLED: 'advanced.pdfjs-enabled', DEFAULT_ZOOM_LEVEL: 'advanced.default-zoom-level', SMOOTH_SCROLL_ENABLED: 'advanced.smooth-scroll-enabled', + SEND_CRASH_REPORTS: 'advanced.send-crash-reports', ADBLOCK_CUSTOM_RULES: 'adblock.customRules' } diff --git a/js/entry.js b/js/entry.js index d3d0f43e2cf..ff741d545c1 100644 --- a/js/entry.js +++ b/js/entry.js @@ -21,11 +21,19 @@ require('../less/notificationBar.less') require('../less/addEditBookmark.less') require('../node_modules/font-awesome/css/font-awesome.css') -if (process.platform === 'darwin') { - // Setup the crash handling for mac renderer processes - // https://github.com/electron/electron/blob/master/docs/api/crash-reporter.md#crashreporterstartoptions - const CrashHerald = require('../app/crash-herald') - CrashHerald.init() +// Enable or disable crash reporting based on platform +const setupCrashReporting = () => { + if (process.platform === 'darwin') { + // Setup the crash handling for mac renderer processes + // https://github.com/electron/electron/blob/master/docs/api/crash-reporter.md#crashreporterstartoptions + console.log('macOS renderer crash reporting initialized') + require('../app/crash-herald').init() + } +} + +// Notify that renderer crash reporting is disabled +const disableCrashReporting = () => { + console.log('Disabling renderer crash reporting') } const React = require('react') @@ -77,6 +85,12 @@ window.addEventListener('beforeunload', function () { // get appStore from url ipc.on(messages.INITIALIZE_WINDOW, (e, disposition, appState, frames, initWindowState) => { + // Configure renderer crash reporting + if (appState.settings[require('./constants/settings').SEND_CRASH_REPORTS] !== false) { + setupCrashReporting() + } else { + disableCrashReporting() + } appStoreRenderer.state = Immutable.fromJS(appState) ReactDOM.render( ,