Commit 168d4ea7 authored by Daniel Rubery's avatar Daniel Rubery Committed by Commit Bot

Add client_ checks to SafeBrowsingPrivateEventRouter

In a few cases, the preferences for realtime reporting are enabled, but
client_ is still null. For example, if the SafeBrowsingRealtimeReporting
feature is disabled. This can lead to crashes when trying to report events.

Bug: 1015849
Change-Id: I4ee0a042da4379ab4878c34ec8d726a3661c0aec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1869292Reviewed-by: default avatarBettina Dea <bdea@chromium.org>
Commit-Queue: Daniel Rubery <drubery@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707430}
parent d66ff74b
......@@ -120,7 +120,7 @@ void SafeBrowsingPrivateEventRouter::OnPolicySpecifiedPasswordReuseDetected(
event_router_->BroadcastEvent(std::move(extension_event));
}
if (IsRealtimeReportingEnabled()) {
if (IsRealtimeReportingEnabled() && client_) {
// Convert |params| to a real-time event dictionary and report it.
base::Value event(base::Value::Type::DICTIONARY);
event.SetStringKey(kKeyUrl, params.url);
......@@ -145,7 +145,7 @@ void SafeBrowsingPrivateEventRouter::OnPolicySpecifiedPasswordChanged(
event_router_->BroadcastEvent(std::move(extension_event));
}
if (IsRealtimeReportingEnabled()) {
if (IsRealtimeReportingEnabled() && client_) {
// Convert |params| to a real-time event dictionary and report it.
base::Value event(base::Value::Type::DICTIONARY);
event.SetStringKey(kKeyUserName, user_name);
......@@ -178,7 +178,7 @@ void SafeBrowsingPrivateEventRouter::OnDangerousDownloadOpened(
event_router_->BroadcastEvent(std::move(extension_event));
}
if (IsRealtimeReportingEnabled()) {
if (IsRealtimeReportingEnabled() && client_) {
// Convert |params| to a real-time event dictionary and report it.
base::Value event(base::Value::Type::DICTIONARY);
event.SetStringKey(kKeyUrl, params.url);
......@@ -220,7 +220,7 @@ void SafeBrowsingPrivateEventRouter::OnSecurityInterstitialShown(
event_router_->BroadcastEvent(std::move(extension_event));
}
if (IsRealtimeReportingEnabled()) {
if (IsRealtimeReportingEnabled() && client_) {
// Convert |params| to a real-time event dictionary and report it.
base::Value event(base::Value::Type::DICTIONARY);
event.SetStringKey(kKeyUrl, params.url);
......@@ -257,7 +257,7 @@ void SafeBrowsingPrivateEventRouter::OnSecurityInterstitialProceeded(
event_router_->BroadcastEvent(std::move(extension_event));
}
if (IsRealtimeReportingEnabled()) {
if (IsRealtimeReportingEnabled() && client_) {
// Convert |params| to a real-time event dictionary and report it.
base::Value event(base::Value::Type::DICTIONARY);
event.SetStringKey(kKeyUrl, params.url);
......@@ -277,7 +277,7 @@ void SafeBrowsingPrivateEventRouter::OnDangerousDeepScanningResult(
const std::string& mime_type,
const std::string& trigger,
const int64_t content_size) {
if (IsRealtimeReportingEnabled()) {
if (IsRealtimeReportingEnabled() && client_) {
// Create a real-time event dictionary from the arguments and report it.
base::Value event(base::Value::Type::DICTIONARY);
event.SetStringKey(kKeyUrl, url.spec());
......@@ -303,7 +303,7 @@ void SafeBrowsingPrivateEventRouter::OnSensitiveDataEvent(
const std::string& mime_type,
const std::string& trigger,
const int64_t content_size) {
if (IsRealtimeReportingEnabled()) {
if (IsRealtimeReportingEnabled() && client_) {
// Create a real-time event dictionary from the arguments and report it.
base::Value event(base::Value::Type::DICTIONARY);
event.SetStringKey(kKeyUrl, url.spec());
......@@ -333,7 +333,7 @@ void SafeBrowsingPrivateEventRouter::OnLargeUnscannedFileEvent(
const std::string& mime_type,
const std::string& trigger,
const int64_t content_size) {
if (IsRealtimeReportingEnabled()) {
if (IsRealtimeReportingEnabled() && client_) {
// Create a real-time event dictionary from the arguments and report it.
base::Value event(base::Value::Type::DICTIONARY);
event.SetStringKey(kKeyUrl, url.spec());
......@@ -357,7 +357,7 @@ void SafeBrowsingPrivateEventRouter::OnDangerousDownloadWarning(
const std::string& threat_type,
const std::string& mime_type,
const int64_t content_size) {
if (!IsRealtimeReportingEnabled())
if (!IsRealtimeReportingEnabled() || !client_)
return;
// Create a real-time event dictionary and report it.
......@@ -384,7 +384,7 @@ void SafeBrowsingPrivateEventRouter::OnDangerousDownloadWarningBypassed(
const std::string& threat_type,
const std::string& mime_type,
const int64_t content_size) {
if (!IsRealtimeReportingEnabled())
if (!IsRealtimeReportingEnabled() || !client_)
return;
// Create a real-time event dictionary and report it.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment