bug 421552 - allow users to send a crash report and quit firefox. patch by Mike Beltzner <beltzner@mozilla.com>, r=me, a=shaver
authorted.mielczarek@gmail.com
Fri, 07 Mar 2008 14:17:17 -0800
changeset 12746 9f4593267d8659d9ba5f531b7d146d5a4863abcd
parent 12745 7a8b4178ae44cd27cc886f32025bb78836d5fc55
child 12747 25aee7722720cb22aeb1ac27f419e6c8a1939eb0
push idunknown
push userunknown
push dateunknown
reviewersme, shaver
bugs421552
milestone1.9b5pre
bug 421552 - allow users to send a crash report and quit firefox. patch by Mike Beltzner <beltzner@mozilla.com>, r=me, a=shaver
toolkit/crashreporter/client/crashreporter.cpp
toolkit/crashreporter/client/crashreporter.h
toolkit/crashreporter/client/crashreporter_linux.cpp
toolkit/crashreporter/client/crashreporter_osx.h
toolkit/crashreporter/client/crashreporter_osx.mm
toolkit/crashreporter/client/crashreporter_win.cpp
toolkit/locales/en-US/crashreporter/crashreporter.ini
--- a/toolkit/crashreporter/client/crashreporter.cpp
+++ b/toolkit/crashreporter/client/crashreporter.cpp
@@ -416,16 +416,20 @@ void RewriteStrings(StringTable& queryPa
               vendor.c_str());
   gStrings[ST_CHECKSUBMIT] = buf;
 
   UI_SNPRINTF(buf, sizeof(buf),
               gStrings[ST_RESTART].c_str(),
               product.c_str());
   gStrings[ST_RESTART] = buf;
 
+  UI_SNPRINTF(buf, sizeof(buf),
+              gStrings[ST_QUIT].c_str(),
+              product.c_str());
+  gStrings[ST_QUIT] = buf;
 
   UI_SNPRINTF(buf, sizeof(buf),
               gStrings[ST_ERROR_ENDOFLIFE].c_str(),
               product.c_str());
   gStrings[ST_ERROR_ENDOFLIFE] = buf;
 }
 
 bool CheckEndOfLifed(string version)
--- a/toolkit/crashreporter/client/crashreporter.h
+++ b/toolkit/crashreporter/client/crashreporter.h
@@ -45,21 +45,21 @@ typedef std::map<std::string, std::strin
 #define ST_VIEWREPORT                "Details"
 #define ST_VIEWREPORTTITLE           "ViewReportTitle"
 #define ST_COMMENTGRAYTEXT           "CommentGrayText"
 #define ST_EXTRAREPORTINFO           "ExtraReportInfo"
 #define ST_CHECKSUBMIT               "CheckSendReport"
 #define ST_CHECKURL                  "CheckIncludeURL"
 #define ST_CHECKEMAIL                "CheckSendEmail"
 #define ST_EMAILGRAYTEXT             "EmailGrayText"
-#define ST_REPORTPRESUBMIT           "ReportPreSubmit"
-#define ST_REPORTDURINGSUBMIT        "ReportDuringSubmit"
+#define ST_REPORTPRESUBMIT           "ReportPreSubmit2"
+#define ST_REPORTDURINGSUBMIT        "ReportDuringSubmit2"
 #define ST_REPORTSUBMITSUCCESS       "ReportSubmitSuccess"
 #define ST_SUBMITFAILED              "ReportSubmitFailed"
-#define ST_QUIT                      "Quit"
+#define ST_QUIT                      "Quit2"
 #define ST_RESTART                   "Restart"
 #define ST_OK                        "Ok"
 #define ST_CLOSE                     "Close"
 
 #define ST_ERROR_BADARGUMENTS        "ErrorBadArguments"
 #define ST_ERROR_EXTRAFILEEXISTS     "ErrorExtraFileExists"
 #define ST_ERROR_EXTRAFILEREAD       "ErrorExtraFileRead"
 #define ST_ERROR_EXTRAFILEMOVE       "ErrorExtraFileMove"
--- a/toolkit/crashreporter/client/crashreporter_linux.cpp
+++ b/toolkit/crashreporter/client/crashreporter_linux.cpp
@@ -260,35 +260,39 @@ static gboolean WindowDeleted(GtkWidget*
                               GdkEvent* event,
                               gpointer userData)
 {
   SaveSettings();
   gtk_main_quit();
   return TRUE;
 }
 
+static void MaybeSubmitReport()
+{
+  if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gSubmitReportCheck))) {
+    gDidTrySend = true;
+    SendReport();
+  } else {
+    gtk_main_quit();
+  }
+}
+
 static void CloseClicked(GtkButton* button,
                          gpointer userData)
 {
   SaveSettings();
-  gtk_main_quit();
+  MaybeSubmitReport();
 }
 
 static void RestartClicked(GtkButton* button,
                            gpointer userData)
 {
   SaveSettings();
   RestartApplication();
-
-  if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gSubmitReportCheck))) {
-    gDidTrySend = true;
-    SendReport();
-  } else {
-    gtk_main_quit();
-  }
+  MaybeSubmitReport();
 }
 
 static void UpdateSubmit()
 {
   if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gSubmitReportCheck))) {
     gtk_widget_set_sensitive(gViewReportButton, TRUE);
     gtk_widget_set_sensitive(gCommentText, TRUE);
     gtk_widget_set_sensitive(gIncludeURLCheck, TRUE);
--- a/toolkit/crashreporter/client/crashreporter_osx.h
+++ b/toolkit/crashreporter/client/crashreporter_osx.h
@@ -80,16 +80,17 @@
     HTTPMultipartUpload* mPost;
 }
 
 - (void)showCrashUI:(const std::string&)dumpfile
     queryParameters:(const StringTable&)queryParameters
             sendURL:(const std::string&)sendURL;
 - (void)showErrorUI:(const std::string&)dumpfile;
 - (void)showReportInfo;
+- (void)maybeSubmitReport;
 
 - (IBAction)submitReportClicked:(id)sender;
 - (IBAction)viewReportClicked:(id)sender;
 - (IBAction)viewReportOkClicked:(id)sender;
 - (IBAction)closeClicked:(id)sender;
 - (IBAction)restartClicked:(id)sender;
 - (IBAction)includeURLClicked:(id)sender;
 - (IBAction)emailMeClicked:(id)sender;
--- a/toolkit/crashreporter/client/crashreporter_osx.mm
+++ b/toolkit/crashreporter/client/crashreporter_osx.mm
@@ -212,16 +212,35 @@ static bool RestartApplication()
 
   NSAttributedString* extra = [[NSAttributedString alloc]
                                initWithString:NSSTR("\n" + gStrings[ST_EXTRAREPORTINFO])
                                attributes:normalAttr];
   [[mViewReportTextView textStorage] appendAttributedString: extra];
   [extra release];
 }
 
+- (void)maybeSubmitReport
+{
+  if ([mSubmitReportButton state] == NSOnState) {
+    [self setStringFitVertically:mProgressText
+                          string:Str(ST_REPORTDURINGSUBMIT)
+                    resizeWindow:YES];
+    // disable all the controls
+    [self enableControls:NO];
+    [mSubmitReportButton setEnabled:NO];
+    [mRestartButton setEnabled:NO];
+    [mCloseButton setEnabled:NO];
+    [mProgressIndicator startAnimation:self];
+    gDidTrySend = true;
+    [self sendReport];
+  } else {
+    [NSApp terminate:self];
+  }
+}
+
 -(IBAction)submitReportClicked:(id)sender
 {
   [self updateSubmit];
 }
 
 -(IBAction)viewReportClicked:(id)sender
 {
   [self showReportInfo];
@@ -232,38 +251,23 @@ static bool RestartApplication()
 - (IBAction)viewReportOkClicked:(id)sender;
 {
   [mViewReportWindow orderOut:nil];
   [NSApp endSheet:mViewReportWindow];
 }
 
 -(IBAction)closeClicked:(id)sender
 {
-  [NSApp terminate: self];
+  [self maybeSubmitReport];
 }
 
 -(IBAction)restartClicked:(id)sender
 {
   RestartApplication();
-
-  if ([mSubmitReportButton state] == NSOnState) {
-    [self setStringFitVertically:mProgressText
-                          string:Str(ST_REPORTDURINGSUBMIT)
-                    resizeWindow:YES];
-    // disable all the controls
-    [self enableControls:NO];
-    [mSubmitReportButton setEnabled:NO];
-    [mRestartButton setEnabled:NO];
-    [mCloseButton setEnabled:NO];
-    [mProgressIndicator startAnimation:self];
-    gDidTrySend = true;
-    [self sendReport];
-  } else {
-    [NSApp terminate:self];
-  }
+  [self maybeSubmitReport];
 }
 
 - (IBAction)includeURLClicked:(id)sender
 {
   [self updateURL];
 }
 
 -(IBAction)emailMeClicked:(id)sender
--- a/toolkit/crashreporter/client/crashreporter_win.cpp
+++ b/toolkit/crashreporter/client/crashreporter_win.cpp
@@ -874,17 +874,17 @@ static BOOL CALLBACK CrashReporterDialog
         break;
       case IDC_INCLUDEURLCHECK:
         UpdateURL(hwndDlg);
         break;
       case IDC_EMAILMECHECK:
         UpdateEmail(hwndDlg);
         break;
       case IDC_CLOSEBUTTON:
-        EndCrashReporterDialog(hwndDlg, 0);
+        MaybeSendReport(hwndDlg);
         break;
       case IDC_RESTARTBUTTON:
         RestartApplication();
         MaybeSendReport(hwndDlg);
         break;
       }
     } else if (HIWORD(wParam) == EN_CHANGE) {
       switch(LOWORD(wParam)) {
--- a/toolkit/locales/en-US/crashreporter/crashreporter.ini
+++ b/toolkit/locales/en-US/crashreporter/crashreporter.ini
@@ -8,29 +8,30 @@ CrashReporterErrorText=The application h
 # LOCALIZATION NOTE (CrashReporterProductErrorText2): The first %s is replaced with the product name (i.e. "Firefox"), the second is replaced with another string containing detailed information.  These two substitutions can not be reordered!
 CrashReporterProductErrorText2=%s had a problem and crashed.\n\nUnfortunately the crash reporter is unable to submit a crash report.\n\nDetails: %s
 CrashReporterSorry=We're Sorry
 # LOCALIZATION NOTE (CrashReporterDescriptionText2): The %s is replaced with the product name.
 CrashReporterDescriptionText2=%s had a problem and crashed.\n\nTo help us diagnose and fix the problem, you can send us a crash report.
 CrashReporterDefault=This application is run after a crash to report the problem to the application vendor.  It should not be run directly.
 Details=Details…
 ViewReportTitle=Report Contents
-CommentGrayText=Add a comment.  Note: Comments are publicly visible
+CommentGrayText=Add a comment (comments are publicly visible)
 ExtraReportInfo=This report also contains technical information about the state of the application when it crashed.
 # LOCALIZATION NOTE (CheckSendReport): The %s is replaced with the vendor name.
 CheckSendReport=Tell %s about this crash so they can fix it
 CheckIncludeURL=Include the address of the page I was on
 CheckSendEmail=Email me when more information is available
 EmailGrayText=Enter your email address here
-ReportPreSubmit=Your crash report will be submitted when you restart.
-ReportDuringSubmit=Submitting your report and restarting…
+ReportPreSubmit2=Your crash report will be submitted before you quit or restart.
+ReportDuringSubmit2=Submitting your report…
 ReportSubmitSuccess=Report submitted successfully!
 ReportSubmitFailed=There was a problem submitting your report.
 ReportResubmit=Resending reports that previously failed to send…
-Quit=Quit without sending
+# LOCALIZATION NOTE (Quit2): The %s is replaced with the product name.
+Quit2=Quit %s
 # LOCALIZATION NOTE (Restart): The %s is replaced with the product name.
 Restart=Restart %s
 Ok=OK
 Close=Close
 
 # LOCALIZATION NOTE (CrashID): The %s is replaced with the Crash ID from the server, which is a string like abc12345-6789-0abc-def1-23456abcdef1
 CrashID=Crash ID: %s
 # LOCALIZATION NOTE (CrashDetailsURL): The %s is replaced with a URL that the user can visit to view the crash details.