Allow the externalfile scheme to be whitelisted as an allowed scheme for component...
[chromium-blink-merge.git] / components / crash / app / crash_reporter_client.h
blob578cb872eaa419fdf9380ceb798b0620633b34bf
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_CRASH_APP_CRASH_REPORTER_CLIENT_H_
6 #define COMPONENTS_CRASH_APP_CRASH_REPORTER_CLIENT_H_
8 #include <string>
10 #include "base/strings/string16.h"
11 #include "build/build_config.h"
13 namespace base {
14 class FilePath;
17 #if defined(OS_MACOSX)
18 // We don't want to directly include
19 // breakpad/src/client/mac/Framework/Breakpad.h here, so we repeat the
20 // definition of BreakpadRef.
22 // On Mac, when compiling without breakpad support, a stub implementation is
23 // compiled in. Not having any includes of the breakpad library allows for
24 // reusing this header for the stub.
25 typedef void* BreakpadRef;
26 #endif
28 namespace crash_reporter {
30 class CrashReporterClient;
32 // Setter and getter for the client. The client should be set early, before any
33 // crash reporter code is called, and should stay alive throughout the entire
34 // runtime.
35 void SetCrashReporterClient(CrashReporterClient* client);
37 #if defined(CRASH_IMPLEMENTATION)
38 // The components's embedder API should only be used by the component.
39 CrashReporterClient* GetCrashReporterClient();
40 #endif
42 // Interface that the embedder implements.
43 class CrashReporterClient {
44 public:
45 CrashReporterClient();
46 virtual ~CrashReporterClient();
48 // Sets the crash reporting client ID, a unique identifier for the client
49 // that is sending crash reports. After it is set, it should not be changed.
50 // |client_guid| may either be a full GUID or a GUID that was already stripped
51 // from its dashes.
52 virtual void SetCrashReporterClientIdFromGUID(const std::string& client_guid);
54 #if defined(OS_WIN)
55 // Returns true if an alternative location to store the minidump files was
56 // specified. Returns true if |crash_dir| was set.
57 virtual bool GetAlternativeCrashDumpLocation(base::FilePath* crash_dir);
59 // Returns a textual description of the product type and version to include
60 // in the crash report.
61 virtual void GetProductNameAndVersion(const base::FilePath& exe_path,
62 base::string16* product_name,
63 base::string16* version,
64 base::string16* special_build,
65 base::string16* channel_name);
67 // Returns true if a restart dialog should be displayed. In that case,
68 // |message| and |title| are set to a message to display in a dialog box with
69 // the given title before restarting, and |is_rtl_locale| indicates whether
70 // to display the text as RTL.
71 virtual bool ShouldShowRestartDialog(base::string16* title,
72 base::string16* message,
73 bool* is_rtl_locale);
75 // Returns true if it is ok to restart the application. Invoked right before
76 // restarting after a crash.
77 virtual bool AboutToRestart();
79 // Returns true if the crash report uploader supports deferred uploads.
80 virtual bool GetDeferredUploadsSupported(bool is_per_user_install);
82 // Returns true if the running binary is a per-user installation.
83 virtual bool GetIsPerUserInstall(const base::FilePath& exe_path);
85 // Returns true if larger crash dumps should be dumped.
86 virtual bool GetShouldDumpLargerDumps(bool is_per_user_install);
88 // Returns the result code to return when breakpad failed to respawn a
89 // crashed process.
90 virtual int GetResultCodeRespawnFailed();
92 // Invoked when initializing the crash reporter in the browser process.
93 virtual void InitBrowserCrashDumpsRegKey();
95 // Invoked before attempting to write a minidump.
96 virtual void RecordCrashDumpAttempt(bool is_real_crash);
97 #endif
99 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_IOS)
100 // Returns a textual description of the product type and version to include
101 // in the crash report. Neither out parameter should be set to NULL.
102 virtual void GetProductNameAndVersion(const char** product_name,
103 const char** version);
105 virtual base::FilePath GetReporterLogFilename();
107 // Custom crash minidump handler after the minidump is generated.
108 // Returns true if the minidump is handled (client); otherwise, return false
109 // to fallback to default handler.
110 // WARNING: this handler runs in a compromised context. It may not call into
111 // libc nor allocate memory normally.
112 virtual bool HandleCrashDump(const char* crashdump_filename);
113 #endif
115 // The location where minidump files should be written. Returns true if
116 // |crash_dir| was set.
117 virtual bool GetCrashDumpLocation(base::FilePath* crash_dir);
119 // Register all of the potential crash keys that can be sent to the crash
120 // reporting server. Returns the size of the union of all keys.
121 virtual size_t RegisterCrashKeys();
123 // Returns true if running in unattended mode (for automated testing).
124 virtual bool IsRunningUnattended();
126 // Returns true if the user has given consent to collect stats.
127 virtual bool GetCollectStatsConsent();
129 #if defined(OS_WIN) || defined(OS_MACOSX)
130 // Returns true if crash reporting is enforced via management policies. In
131 // that case, |breakpad_enabled| is set to the value enforced by policies.
132 virtual bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled);
133 #endif
135 #if defined(OS_ANDROID)
136 // Returns the descriptor key of the android minidump global descriptor.
137 virtual int GetAndroidMinidumpDescriptor();
139 // Returns true if breakpad microdumps should be enabled. This orthogonal to
140 // the standard minidump uploader (which depends on the user consent).
141 virtual bool ShouldEnableBreakpadMicrodumps();
142 #endif
144 #if defined(OS_MACOSX)
145 // Install additional breakpad filter callbacks.
146 virtual void InstallAdditionalFilters(BreakpadRef breakpad);
147 #endif
149 // Returns true if breakpad should run in the given process type.
150 virtual bool EnableBreakpadForProcess(const std::string& process_type);
153 } // namespace crash_reporter
155 #endif // COMPONENTS_CRASH_APP_CRASH_REPORTER_CLIENT_H_