Skip to content

Commit

Permalink
[M116] Add InterstitialInteractionMap parameter to CSBRR functions
Browse files Browse the repository at this point in the history
As part of implementing interaction lists for CSBRRs, we must add a
parameter to the trigger manager's FinishCollectingThreatDetails method
that allows us to access the list of interstitial interactions. Once we
submit this, we will submit a CL that adds the actual interaction list
to CSBRRs.

(cherry picked from commit fb73314)

Bug: 1439670
Change-Id: Ifd31cbd57f6edd5fa6b0dbb248685c5d812ca546
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4621748
Commit-Queue: Sarah Krakowiak <skrakowi@chromium.org>
Reviewed-by: Daniel Rubery <drubery@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1161399}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4645789
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/branch-heads/5845@{#104}
Cr-Branched-From: 5a5dff6-refs/heads/main@{#1160321}
  • Loading branch information
Sarah Krakowiak authored and Chromium LUCI CQ committed Jun 26, 2023
1 parent 38fb9b0 commit 7e984c5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ bool TriggerManager::StartCollectingThreatDetailsWithReason(
return true;
}

void TriggerManager::SetInterstitialInteractions(
std::unique_ptr<security_interstitials::InterstitialInteractionMap>
interstitial_interactions) {
interstitial_interactions_ = std::move(interstitial_interactions);
}

bool TriggerManager::FinishCollectingThreatDetails(
const TriggerType trigger_type,
WebContentsKey web_contents_key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ class TriggerManager {
ReferrerChainProvider* referrer_chain_provider,
const SBErrorOptions& error_display_options);

// Store map of security interstitial interactions that should be sent in the
// threat report.
void SetInterstitialInteractions(
std::unique_ptr<security_interstitials::InterstitialInteractionMap>
interstitial_interactions);

// Completes the collection of a ThreatDetails report for the specified
// |web_contents_key| (derived from a WebContents*) and sends the
// report. |delay| can be used to wait a period of time before finishing the
Expand Down Expand Up @@ -195,6 +201,10 @@ class TriggerManager {
// Keeps track of how often triggers fire and throttles them when needed.
std::unique_ptr<TriggerThrottler> trigger_throttler_;

// Keeps track of user interactions with a security interstitial.
std::unique_ptr<security_interstitials::InterstitialInteractionMap>
interstitial_interactions_;

base::WeakPtrFactory<TriggerManager> weak_factory_{this};
// WeakPtrFactory should be last, don't add any members below it.
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#ifndef COMPONENTS_SECURITY_INTERSTITIALS_CORE_BASE_SAFE_BROWSING_ERROR_UI_H_
#define COMPONENTS_SECURITY_INTERSTITIALS_CORE_BASE_SAFE_BROWSING_ERROR_UI_H_

#include <map>

#include "base/memory/raw_ptr.h"
#include "base/time/time.h"
#include "base/values.h"
Expand All @@ -13,6 +15,18 @@

namespace security_interstitials {

struct InterstitialInteractionDetails {
InterstitialInteractionDetails(int occurrence_count,
int64_t first_timestamp,
int64_t last_timestamp);
int occurrence_count;
int64_t first_timestamp;
int64_t last_timestamp;
};

using InterstitialInteractionMap =
std::map<SecurityInterstitialCommand, InterstitialInteractionDetails>;

// A base class for quiet vs loud versions of the safe browsing interstitial.
// This class displays UI for Safe Browsing errors that block page loads. This
// class is purely about visual display; it does not do any error-handling logic
Expand Down

0 comments on commit 7e984c5

Please sign in to comment.