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.

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

mercurial