toolkit/crashreporter/client/crashreporter.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #ifndef CRASHREPORTER_H__
     6 #define CRASHREPORTER_H__
     8 #ifdef _MSC_VER
     9 # pragma warning( push )
    10 // Disable exception handler warnings.
    11 # pragma warning( disable : 4530 )
    12 #endif
    14 #include <string>
    15 #include <map>
    16 #include <vector>
    17 #include <stdlib.h>
    18 #include <stdio.h>
    19 #include <iostream>
    20 #include <fstream>
    22 #define MAX_COMMENT_LENGTH   500
    24 #if defined(XP_WIN32)
    26 #include <windows.h>
    28 #define UI_SNPRINTF _snprintf
    29 #define UI_DIR_SEPARATOR "\\"
    31 std::string WideToUTF8(const std::wstring& wide, bool* success = 0);
    33 #else
    35 #define UI_SNPRINTF snprintf
    36 #define UI_DIR_SEPARATOR "/"
    38 #endif
    40 typedef std::map<std::string, std::string> StringTable;
    42 #define ST_CRASHREPORTERTITLE        "CrashReporterTitle"
    43 #define ST_CRASHREPORTERVENDORTITLE  "CrashReporterVendorTitle"
    44 #define ST_CRASHREPORTERERROR        "CrashReporterErrorText"
    45 #define ST_CRASHREPORTERPRODUCTERROR "CrashReporterProductErrorText2"
    46 #define ST_CRASHREPORTERHEADER       "CrashReporterSorry"
    47 #define ST_CRASHREPORTERDESCRIPTION  "CrashReporterDescriptionText2"
    48 #define ST_CRASHREPORTERDEFAULT      "CrashReporterDefault"
    49 #define ST_VIEWREPORT                "Details"
    50 #define ST_VIEWREPORTTITLE           "ViewReportTitle"
    51 #define ST_COMMENTGRAYTEXT           "CommentGrayText"
    52 #define ST_EXTRAREPORTINFO           "ExtraReportInfo"
    53 #define ST_CHECKSUBMIT               "CheckSendReport"
    54 #define ST_CHECKURL                  "CheckIncludeURL"
    55 #define ST_CHECKEMAIL                "CheckAllowEmail"
    56 #define ST_EMAILGRAYTEXT             "EmailGrayText"
    57 #define ST_REPORTPRESUBMIT           "ReportPreSubmit2"
    58 #define ST_REPORTDURINGSUBMIT        "ReportDuringSubmit2"
    59 #define ST_REPORTSUBMITSUCCESS       "ReportSubmitSuccess"
    60 #define ST_SUBMITFAILED              "ReportSubmitFailed"
    61 #define ST_QUIT                      "Quit2"
    62 #define ST_RESTART                   "Restart"
    63 #define ST_OK                        "Ok"
    64 #define ST_CLOSE                     "Close"
    66 #define ST_ERROR_BADARGUMENTS        "ErrorBadArguments"
    67 #define ST_ERROR_EXTRAFILEEXISTS     "ErrorExtraFileExists"
    68 #define ST_ERROR_EXTRAFILEREAD       "ErrorExtraFileRead"
    69 #define ST_ERROR_EXTRAFILEMOVE       "ErrorExtraFileMove"
    70 #define ST_ERROR_DUMPFILEEXISTS      "ErrorDumpFileExists"
    71 #define ST_ERROR_DUMPFILEMOVE        "ErrorDumpFileMove"
    72 #define ST_ERROR_NOPRODUCTNAME       "ErrorNoProductName"
    73 #define ST_ERROR_NOSERVERURL         "ErrorNoServerURL"
    74 #define ST_ERROR_NOSETTINGSPATH      "ErrorNoSettingsPath"
    75 #define ST_ERROR_CREATEDUMPDIR       "ErrorCreateDumpDir"
    76 #define ST_ERROR_ENDOFLIFE           "ErrorEndOfLife"
    78 //=============================================================================
    79 // implemented in crashreporter.cpp
    80 //=============================================================================
    82 namespace CrashReporter {
    83   extern StringTable  gStrings;
    84   extern std::string  gSettingsPath;
    85   extern int          gArgc;
    86   extern char**       gArgv;
    88   void UIError(const std::string& message);
    90   // The UI finished sending the report
    91   void SendCompleted(bool success, const std::string& serverResponse);
    93   bool ReadStrings(std::istream& in,
    94                    StringTable& strings,
    95                    bool unescape);
    96   bool ReadStringsFromFile(const std::string& path,
    97                            StringTable& strings,
    98                            bool unescape);
    99   bool WriteStrings(std::ostream& out,
   100                     const std::string& header,
   101                     StringTable& strings,
   102                     bool escape);
   103   bool WriteStringsToFile(const std::string& path,
   104                           const std::string& header,
   105                           StringTable& strings,
   106                           bool escape);
   107   void LogMessage(const std::string& message);
   108   void DeleteDump();
   109   bool ShouldEnableSending();
   111   static const unsigned int kSaveCount = 10;
   112 }
   114 //=============================================================================
   115 // implemented in the platform-specific files
   116 //=============================================================================
   118 bool UIInit();
   119 void UIShutdown();
   121 // Run the UI for when the app was launched without a dump file
   122 void UIShowDefaultUI();
   124 // Run the UI for when the app was launched with a dump file
   125 // Return true if the user sent (or tried to send) the crash report,
   126 // false if they chose not to, and it should be deleted.
   127 bool UIShowCrashUI(const std::string& dumpfile,
   128                    const StringTable& queryParameters,
   129                    const std::string& sendURL,
   130                    const std::vector<std::string>& restartArgs);
   132 void UIError_impl(const std::string& message);
   134 bool UIGetIniPath(std::string& path);
   135 bool UIGetSettingsPath(const std::string& vendor,
   136                        const std::string& product,
   137                        std::string& settingsPath);
   138 bool UIEnsurePathExists(const std::string& path);
   139 bool UIFileExists(const std::string& path);
   140 bool UIMoveFile(const std::string& oldfile, const std::string& newfile);
   141 bool UIDeleteFile(const std::string& oldfile);
   142 std::ifstream* UIOpenRead(const std::string& filename);
   143 std::ofstream* UIOpenWrite(const std::string& filename, bool append=false);
   144 void UIPruneSavedDumps(const std::string& directory);
   146 #ifdef _MSC_VER
   147 # pragma warning( pop )
   148 #endif
   150 #endif

mercurial