diff --git a/browser/metro/base/content/browser-ui.js b/browser/metro/base/content/browser-ui.js index ba98dac5f9ca..1fc03d487346 100644 --- a/browser/metro/base/content/browser-ui.js +++ b/browser/metro/base/content/browser-ui.js @@ -85,6 +85,7 @@ var BrowserUI = { } Services.prefs.addObserver(debugServerStateChanged, this, false); Services.prefs.addObserver(debugServerPortChanged, this, false); + Services.prefs.addObserver("app.crashreporter.autosubmit", this, false); Services.obs.addObserver(this, "handle-xul-text-link", false); @@ -264,59 +265,11 @@ var BrowserUI = { if (!CrashReporter.enabled) { return; } - let lastCrashID = this.lastCrashID; - if (!lastCrashID || !lastCrashID.length) { - return; - } + // Ensure that CrashReporter state matches pref + CrashReporter.submitReports = Services.prefs.getBoolPref("app.crashreporter.autosubmit"); - let shouldReport = Services.prefs.getBoolPref("app.crashreporter.autosubmit"); - let didPrompt = Services.prefs.getBoolPref("app.crashreporter.prompted"); - - if (!shouldReport && !didPrompt) { - let crashBundle = Services.strings.createBundle("chrome://browser/locale/crashprompt.properties"); - let title = crashBundle.GetStringFromName("crashprompt.dialog.title"); - let acceptbutton = crashBundle.GetStringFromName("crashprompt.dialog.acceptbutton"); - let refusebutton = crashBundle.GetStringFromName("crashprompt.dialog.refusebutton"); - let bodyText = crashBundle.GetStringFromName("crashprompt.dialog.statement1"); - - let buttonPressed = - Services.prompt.confirmEx( - null, - title, - bodyText, - Ci.nsIPrompt.BUTTON_POS_0 * Ci.nsIPrompt.BUTTON_TITLE_IS_STRING - + Ci.nsIPrompt.BUTTON_POS_1 * Ci.nsIPrompt.BUTTON_TITLE_IS_STRING - + Ci.nsIPrompt.BUTTON_POS_1_DEFAULT, - acceptbutton, - refusebutton, - null, - null, - { value: false }); - - Services.prefs.setBoolPref("app.crashreporter.prompted", true); - - if (buttonPressed == 0) { - Services.prefs.setBoolPref('app.crashreporter.autosubmit', true); - BrowserUI.crashReportingPrefChanged(true); - shouldReport = true; - } else { - Services.prefs.setBoolPref('app.crashreporter.autosubmit', false); - BrowserUI.crashReportingPrefChanged(false); - } - } - - // We've already prompted, return if the user doesn't want to report. - if (!shouldReport) { - return; - } - - Util.dumpLn("Submitting last crash id:", lastCrashID); - try { - this.CrashSubmit.submit(lastCrashID); - } catch (ex) { - Util.dumpLn(ex); - } + BrowserUI.submitLastCrashReportOrShowPrompt(); #endif }, @@ -632,11 +585,48 @@ var BrowserUI = { case debugServerPortChanged: this.changeDebugPort(Services.prefs.getIntPref(aData)); break; + case "app.crashreporter.autosubmit": +#ifdef MOZ_CRASHREPORTER + CrashReporter.submitReports = Services.prefs.getBoolPref(aData); + + // The user explicitly set the autosubmit option, so there is no + // need to prompt them about crash reporting in the future + Services.prefs.setBoolPref("app.crashreporter.prompted", true); + + BrowserUI.submitLastCrashReportOrShowPrompt; +#endif + break; + + } break; } }, + submitLastCrashReportOrShowPrompt: function() { +#ifdef MOZ_CRASHREPORTER + let lastCrashID = this.lastCrashID; + if (lastCrashID && lastCrashID.length) { + if (Services.prefs.getBoolPref("app.crashreporter.autosubmit")) { + Util.dumpLn("Submitting last crash id:", lastCrashID); + let params = {}; + if (!Services.prefs.getBoolPref("app.crashreporter.submitURLs")) { + params['extraExtraKeyVals'] = { URL: '' }; + } + try { + this.CrashSubmit.submit(lastCrashID, params); + } catch (ex) { + Util.dumpLn(ex); + } + } else if (!Services.prefs.getBoolPref("app.crashreporter.prompted")) { + BrowserUI.addAndShowTab("about:crashprompt", null); + } + } +#endif + }, + + + /********************************* * Internal utils */ @@ -1108,10 +1098,6 @@ var BrowserUI = { SanitizeUI.onSanitize(); } }, - - crashReportingPrefChanged: function crashReportingPrefChanged(aState) { - CrashReporter.submitReports = aState; - } }; var PanelUI = { diff --git a/browser/metro/base/content/browser.xul b/browser/metro/base/content/browser.xul index d461cb3e5a93..7e9fd2cfc941 100644 --- a/browser/metro/base/content/browser.xul +++ b/browser/metro/base/content/browser.xul @@ -672,7 +672,13 @@ Desktop browser's sync prefs. - + + diff --git a/browser/metro/base/content/flyoutpanels/PrefsFlyoutPanel.js b/browser/metro/base/content/flyoutpanels/PrefsFlyoutPanel.js index 6eec2ac7add1..7867edf061c1 100644 --- a/browser/metro/base/content/flyoutpanels/PrefsFlyoutPanel.js +++ b/browser/metro/base/content/flyoutpanels/PrefsFlyoutPanel.js @@ -44,6 +44,12 @@ let PrefsFlyoutPanel = { Services.prefs.addObserver("privacy.donottrackheader.enabled", this._prefObserver, false); + Services.prefs.addObserver("app.crashreporter.autosubmit", + this._prefObserver, + false); + Services.prefs.addObserver("app.crashreporter.submitURLs", + this._prefObserver, + false); } this._topmostElement.show(); @@ -81,6 +87,29 @@ let PrefsFlyoutPanel = { Services.prefs.setIntPref('privacy.donottrackheader.value', -1); } break; + + case "app.crashreporter.autosubmit": + let autosubmit = Services.prefs.getBoolPref("app.crashreporter.autosubmit"); + if (!autosubmit) { + // If the user has selected not to submit crash reports, the UI + // should reflect also that URLs will not be included. + // TODO: Ideally we would grey out the text and the toggle for + // the "include URLs" pref, but the |setting| binding doesn't + // appear to support enabling/disabling. In the meantime, we just + // set the "include URLs" pref to false if the "send crash reports" + // pref has been set to false. + Services.prefs.setBoolPref('app.crashreporter.submitURLs', false); + } + break; + + case "app.crashreporter.submitURLs": + let submitURLs = Services.prefs.getBoolPref("app.crashreporter.submitURLs"); + if (submitURLs) { + // If the user has selected to submit URLs, they are implicitly also + // selecting to submit crash reports. Let's update the autosubmit pref + Services.prefs.setBoolPref('app.crashreporter.autosubmit', true); + } + break; } }, }; diff --git a/browser/metro/base/content/pages/crashprompt.xhtml b/browser/metro/base/content/pages/crashprompt.xhtml new file mode 100644 index 000000000000..a3287167ace2 --- /dev/null +++ b/browser/metro/base/content/pages/crashprompt.xhtml @@ -0,0 +1,392 @@ + + + + %htmlDTD; + + %globalDTD; + + %brandDTD; + + %crashPromptDTD; +]> + + + + + + + + &crashprompt.title; + + + + + + + + + + + +
+

&crashprompt.title;

+
+

&crashprompt.message;

+

+ + + + + +

+ +