diff --git a/atom/common/api/atom_api_crash_reporter.cc b/atom/common/api/atom_api_crash_reporter.cc index 6820e7a792..0edd787e55 100644 --- a/atom/common/api/atom_api_crash_reporter.cc +++ b/atom/common/api/atom_api_crash_reporter.cc @@ -31,14 +31,21 @@ struct Converter { namespace { +void SetExtraParameter(const std::string& key, mate::Arguments* args) { + std::string value; + if (args->GetNext(&value)) + CrashReporter::GetInstance()->SetExtraParameter(key, value); + else + CrashReporter::GetInstance()->RemoveExtraParameter(key); +} + void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { mate::Dictionary dict(context->GetIsolate(), exports); auto reporter = base::Unretained(CrashReporter::GetInstance()); dict.SetMethod("start", base::Bind(&CrashReporter::Start, reporter)); - dict.SetMethod("setExtraParameter", - base::Bind(&CrashReporter::SetExtraParameter, reporter)); + dict.SetMethod("setExtraParameter", &SetExtraParameter); dict.SetMethod("getUploadedReports", base::Bind(&CrashReporter::GetUploadedReports, reporter)); dict.SetMethod("setUploadToServer", diff --git a/atom/common/crash_reporter/crash_reporter.cc b/atom/common/crash_reporter/crash_reporter.cc index bc3176275f..d901f83fa4 100644 --- a/atom/common/crash_reporter/crash_reporter.cc +++ b/atom/common/crash_reporter/crash_reporter.cc @@ -90,6 +90,9 @@ void CrashReporter::SetExtraParameter(const std::string& key, const std::string& value) { } +void CrashReporter::RemoveExtraParameter(const std::string& key) { +} + #if defined(OS_MACOSX) && defined(MAS_BUILD) // static CrashReporter* CrashReporter::GetInstance() { diff --git a/atom/common/crash_reporter/crash_reporter.h b/atom/common/crash_reporter/crash_reporter.h index cd93f171c0..2bdcd9b02d 100644 --- a/atom/common/crash_reporter/crash_reporter.h +++ b/atom/common/crash_reporter/crash_reporter.h @@ -39,6 +39,7 @@ class CrashReporter { virtual bool GetUploadToServer(); virtual void SetExtraParameter(const std::string& key, const std::string& value); + virtual void RemoveExtraParameter(const std::string& key); protected: CrashReporter(); diff --git a/atom/common/crash_reporter/crash_reporter_mac.h b/atom/common/crash_reporter/crash_reporter_mac.h index 8d1b1d0de1..583c99a86e 100644 --- a/atom/common/crash_reporter/crash_reporter_mac.h +++ b/atom/common/crash_reporter/crash_reporter_mac.h @@ -36,6 +36,7 @@ class CrashReporterMac : public CrashReporter { bool GetUploadToServer() override; void SetExtraParameter(const std::string& key, const std::string& value) override; + void RemoveExtraParameter(const std::string& key) override; private: friend struct base::DefaultSingletonTraits; diff --git a/atom/common/crash_reporter/crash_reporter_mac.mm b/atom/common/crash_reporter/crash_reporter_mac.mm index 0e9b20d6f6..4b59be5dfc 100644 --- a/atom/common/crash_reporter/crash_reporter_mac.mm +++ b/atom/common/crash_reporter/crash_reporter_mac.mm @@ -108,6 +108,13 @@ void CrashReporterMac::SetExtraParameter(const std::string& key, upload_parameters_[key] = value; } +void CrashReporterMac::RemoveExtraParameter(const std::string& key) { + if (simple_string_dictionary_) + simple_string_dictionary_->RemoveKey(key.data()); + else + upload_parameters_.erase(key); +} + std::vector CrashReporterMac::GetUploadedReports(const base::FilePath& crashes_dir) { std::vector uploaded_reports; diff --git a/docs/api/crash-reporter.md b/docs/api/crash-reporter.md index 096276a3ff..f4ed2d2ce0 100644 --- a/docs/api/crash-reporter.md +++ b/docs/api/crash-reporter.md @@ -118,7 +118,8 @@ called before `start` is called. ### `crashReporter.setExtraParameter(key, value)` _macOS_ * `key` String - Parameter key. -* `value` String - Parameter value. +* `value` String - Parameter value. Specifying `null` or `undefined` will + remove the key from the extra parameters. Set an extra data to set be sent with the crash report. The values specified here will be sent in addition to any values set via the `extra` option to