Commit e0462d08 authored by Xinghui Lu's avatar Xinghui Lu Committed by Commit Bot

[Reland]Add a metric to track what resource type triggers SB blocking page.

Fix: Initialize the resource_type field with a default value kMainFrame.

We'd like to know for each safe browsing blocking page created, what
is the resource type that triggers the page. This information
can help us decide the priority of resource types that should be
checked in real time.

Metrics added in this CL:
SafeBrowsing.BlockingPage.ResourceType

Bug: 1065137
Change-Id: I38f2b0b4787fb1c04ee515e08856d4ab8b00aa07
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2133115Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Reviewed-by: default avatarDaniel Rubery <drubery@chromium.org>
Commit-Queue: Xinghui Lu <xinghuilu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756914}
parent 5d2bf76a
......@@ -10,6 +10,7 @@
#include "base/feature_list.h"
#include "base/lazy_instance.h"
#include "base/metrics/histogram_macros.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/interstitials/enterprise_util.h"
......@@ -246,6 +247,8 @@ SafeBrowsingBlockingPage* SafeBrowsingBlockingPage::CreateBlockingPage(
const GURL& main_frame_url,
const UnsafeResource& unsafe_resource,
bool should_trigger_reporting) {
UMA_HISTOGRAM_ENUMERATION("SafeBrowsing.BlockingPage.ResourceType",
unsafe_resource.resource_type);
const UnsafeResourceList resources{unsafe_resource};
// Set up the factory if this has not been done already (tests do that
// before this method is called).
......
......@@ -154,6 +154,7 @@ SafeBrowsingUrlCheckerImpl::MakeUnsafeResource(const GURL& url,
resource.is_subframe = resource_type_ == ResourceType::kSubFrame;
resource.threat_type = threat_type;
resource.threat_metadata = metadata;
resource.resource_type = resource_type_;
resource.callback =
base::BindRepeating(&SafeBrowsingUrlCheckerImpl::OnBlockingPageComplete,
weak_factory_.GetWeakPtr());
......
......@@ -4,6 +4,7 @@ include_rules = [
"+components/metrics",
"+components/prefs",
"+components/rappor",
"+components/safe_browsing/core/common",
"+components/safe_browsing/core/db",
"+components/ssl_errors",
"+components/strings/grit/components_strings.h",
......
......@@ -72,6 +72,7 @@ static_library("unsafe_resource") {
deps = [
"//base",
"//components/safe_browsing/core/common:common",
"//components/safe_browsing/core/db:hit_report",
"//components/safe_browsing/core/db:util",
"//net",
......
......@@ -12,6 +12,7 @@ UnsafeResource::UnsafeResource()
: is_subresource(false),
is_subframe(false),
threat_type(safe_browsing::SB_THREAT_TYPE_SAFE),
resource_type(safe_browsing::ResourceType::kMainFrame),
threat_source(safe_browsing::ThreatSource::UNKNOWN),
is_delayed_warning(false) {}
......
......@@ -10,6 +10,7 @@
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "base/single_thread_task_runner.h"
#include "components/safe_browsing/core/common/safebrowsing_constants.h"
#include "components/safe_browsing/core/db/hit_report.h"
#include "url/gurl.h"
......@@ -52,6 +53,7 @@ struct UnsafeResource {
bool is_subframe;
safe_browsing::SBThreatType threat_type;
safe_browsing::ThreatMetadata threat_metadata;
safe_browsing::ResourceType resource_type;
UrlCheckCallback callback; // This is called back on |callback_thread|.
scoped_refptr<base::SingleThreadTaskRunner> callback_thread;
base::RepeatingCallback<content::WebContents*(void)> web_contents_getter;
......
......@@ -135939,6 +135939,19 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary>
</histogram>
<histogram name="SafeBrowsing.BlockingPage.ResourceType"
enum="ContentResourceType2" expires_after="2021-03-27">
<owner>xinghuilu@chromium.org</owner>
<owner>chrome-safebrowsing-alerts@google.com</owner>
<summary>
Logs the resource type that triggers the safe browsing blocking page. Logged
each time a safe browsing blocking page is created. This metric is useful to
show the priority of checking each resource type in real time. Note that
this metric may be bias towards mainframe, because the default resource type
is set to mainframe.
</summary>
</histogram>
<histogram name="SafeBrowsing.CheckBrowseUrl.HasLocalMatch"
enum="BooleanMatched" expires_after="2020-08-05">
<owner>vakh@chromium.org</owner>
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