Use GetUploadsEnabled to return GetShouldUpload

This commit is contained in:
Samuel Attard 2016-11-08 13:39:11 +13:00 committed by Kevin Sawicki
parent 5a1a2616aa
commit 285a36f9de
7 changed files with 31 additions and 7 deletions

View file

@ -42,6 +42,8 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
base::Bind(&CrashReporter::GetUploadedReports, report));
dict.SetMethod("_setShouldUpload",
base::Bind(&CrashReporter::SetShouldUpload, report));
dict.SetMethod("_getShouldUpload",
base::Bind(&CrashReporter::GetShouldUpload, report));
}
} // namespace

View file

@ -47,6 +47,10 @@ void CrashReporter::SetShouldUpload(const bool should_upload) {
}
bool CrashReporter::GetShouldUpload() {
return true;
}
std::vector<CrashReporter::UploadReportResult>
CrashReporter::GetUploadedReports(const base::FilePath& crashes_dir) {
std::string file_content;

View file

@ -34,6 +34,7 @@ class CrashReporter {
const base::FilePath& crashes_dir);
virtual void SetShouldUpload(bool should_upload);
virtual bool GetShouldUpload();
protected:
CrashReporter();

View file

@ -33,6 +33,7 @@ class CrashReporterMac : public CrashReporter {
bool skip_system_crash_handler) override;
void SetUploadParameters() override;
void SetShouldUpload(bool should_upload) override;
bool GetShouldUpload() override;
private:
friend struct base::DefaultSingletonTraits<CrashReporterMac>;

View file

@ -75,12 +75,18 @@ void CrashReporterMac::InitBreakpad(const std::string& product_name,
if (is_browser_) {
database_ =
crashpad::CrashReportDatabase::Initialize(crashes_dir);
if (database_) {
database_->GetSettings()->SetUploadsEnabled(should_upload);
}
SetShouldUpload(should_upload);
}
}
bool CrashReporterMac::GetShouldUpload() {
bool enabled = true;
if (database_) {
database_->GetSettings()->GetUploadsEnabled(&enabled);
}
return enabled;
}
void CrashReporterMac::SetShouldUpload(const bool should_upload) {
if (database_) {
database_->GetSettings()->SetUploadsEnabled(should_upload);

View file

@ -75,12 +75,16 @@ ID.
Returns `Boolean` - Whether reports should be submitted to the server. Set through
the `start` method or `setShouldUpload`.
**NOTE:** This API can only be used from the main process
### `crashReporter.setShouldUpload(shouldUpload)` _macOS_
* `shouldUpload` Boolean _macOS_ - Whether reports should be submitted to the server
This would normally be controlled by user preferences.
**NOTE:** This API can only be used from the main process
## Crash Report Payload
The crash reporter will send the following data to the `submitURL` as

View file

@ -62,7 +62,6 @@ class CrashReporter {
})
}
this._shouldUpload = shouldUpload
binding.start(this.getProductName(), companyName, submitURL, this.getCrashesDirectory(), shouldUpload, ignoreSystemCrashHandler, extra)
}
@ -104,12 +103,19 @@ class CrashReporter {
}
getShouldUpload() {
return this._shouldUpload
if (process.type === 'browser') {
return binding._getShouldUpload()
} else {
throw new Error('getShouldUpload can only be called from the main process')
}
}
setShouldUpload(shouldUpload) {
this._shouldUpload = shouldUpload
return binding._setShouldUpload(shouldUpload)
if (process.type === 'browser') {
return binding._setShouldUpload(shouldUpload)
} else {
throw new Error('setShouldUpload can only be called from the main process')
}
}
}