Commit 11fbeaad authored by Colin Blundell's avatar Colin Blundell Committed by Commit Bot

[SSL Interstitials] Componentize ChromeMetricsHelper

This CL componentizes ChromeMetricsHelper and renames it to
ContentMetricsHelper, as it is now specific only to //content embedders
that use //components/security_interstitials, rather than being specific
to //chrome as it was previously. The motivation is to reuse this class
in WebLayer (which will happen in an upcoming CL).

Bug: 812808, 1030692
Change-Id: I48e533fe7d56bba84bf16c877148aa98a5779ec5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2041625
Commit-Queue: Colin Blundell <blundell@chromium.org>
Reviewed-by: default avatarCarlos IL <carlosil@chromium.org>
Cr-Commit-Position: refs/heads/master@{#739412}
parent 82649862
......@@ -631,8 +631,6 @@ jumbo_static_library("browser") {
"installable/installable_task_queue.h",
"internal_auth.cc",
"internal_auth.h",
"interstitials/chrome_metrics_helper.cc",
"interstitials/chrome_metrics_helper.h",
"interstitials/enterprise_util.cc",
"interstitials/enterprise_util.h",
"intranet_redirect_detector.cc",
......
......@@ -12,7 +12,6 @@
#include "base/lazy_instance.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/interstitials/chrome_metrics_helper.h"
#include "chrome/browser/interstitials/enterprise_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_preferences_util.h"
......@@ -24,6 +23,7 @@
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/safe_browsing/core/features.h"
#include "components/safe_browsing/core/triggers/trigger_manager.h"
#include "components/security_interstitials/content/content_metrics_helper.h"
#include "components/security_interstitials/content/security_interstitial_controller_client.h"
#include "components/security_interstitials/content/unsafe_resource_util.h"
#include "components/security_interstitials/core/controller_client.h"
......@@ -295,8 +295,8 @@ SafeBrowsingBlockingPage::CreateControllerClient(
web_contents->GetBrowserContext());
DCHECK(profile);
std::unique_ptr<ChromeMetricsHelper> metrics_helper =
std::make_unique<ChromeMetricsHelper>(
std::unique_ptr<ContentMetricsHelper> metrics_helper =
std::make_unique<ContentMetricsHelper>(
HistoryServiceFactory::GetForProfile(
Profile::FromBrowserContext(web_contents->GetBrowserContext()),
ServiceAccessType::EXPLICIT_ACCESS),
......
......@@ -9,7 +9,6 @@
#include "base/time/time.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/interstitials/chrome_metrics_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_preferences_util.h"
#include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
......@@ -17,6 +16,7 @@
#include "chrome/browser/ssl/ssl_error_controller_client.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/url_constants.h"
#include "components/security_interstitials/content/content_metrics_helper.h"
#include "components/security_interstitials/content/ssl_blocking_page.h"
#include "components/security_interstitials/core/controller_client.h"
#include "components/security_interstitials/core/metrics_helper.h"
......@@ -106,15 +106,15 @@ void OpenLoginPage(content::WebContents* web_contents) {
#endif // !BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION)
}
std::unique_ptr<ChromeMetricsHelper> CreateMetricsHelperWithRecording(
std::unique_ptr<ContentMetricsHelper> CreateMetricsHelperWithRecording(
content::WebContents* web_contents,
const GURL& request_url,
const std::string& metric_prefix,
bool overridable) {
security_interstitials::MetricsHelper::ReportDetails reporting_info;
reporting_info.metric_prefix = metric_prefix;
std::unique_ptr<ChromeMetricsHelper> metrics_helper =
std::make_unique<ChromeMetricsHelper>(
std::unique_ptr<ContentMetricsHelper> metrics_helper =
std::make_unique<ContentMetricsHelper>(
HistoryServiceFactory::GetForProfile(
Profile::FromBrowserContext(web_contents->GetBrowserContext()),
ServiceAccessType::EXPLICIT_ACCESS),
......@@ -141,7 +141,7 @@ ChromeSecurityBlockingPageFactory::CreateSSLPage(
const GURL& support_url,
std::unique_ptr<SSLCertReporter> ssl_cert_reporter) {
bool overridable = SSLBlockingPage::IsOverridable(options_mask);
std::unique_ptr<ChromeMetricsHelper> metrics_helper(
std::unique_ptr<ContentMetricsHelper> metrics_helper(
CreateMetricsHelperWithRecording(
web_contents, request_url,
overridable ? "ssl_overridable" : "ssl_nonoverridable", overridable));
......
......@@ -14,7 +14,6 @@
#include "base/task/post_task.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/interstitials/chrome_metrics_helper.h"
#include "chrome/browser/interstitials/enterprise_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
......@@ -23,6 +22,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/security_interstitials/content/content_metrics_helper.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
......
......@@ -24,6 +24,8 @@ static_library("security_interstitial_page") {
"common_name_mismatch_handler.h",
"connection_help_ui.cc",
"connection_help_ui.h",
"content_metrics_helper.cc",
"content_metrics_helper.h",
"known_interception_disclosure_ui.cc",
"known_interception_disclosure_ui.h",
"legacy_tls_blocking_page.cc",
......@@ -68,6 +70,7 @@ static_library("security_interstitial_page") {
"//base",
"//build:branding_buildflags",
"//components/captive_portal/core",
"//components/history/core/browser",
"//components/network_time",
"//components/prefs:prefs",
"//components/resources",
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/interstitials/chrome_metrics_helper.h"
#include "components/security_interstitials/content/content_metrics_helper.h"
#include "components/captive_portal/core/buildflags.h"
#include "components/history/core/browser/history_service.h"
......@@ -12,7 +12,7 @@
#include "components/security_interstitials/content/captive_portal_metrics_recorder.h"
#endif
ChromeMetricsHelper::ChromeMetricsHelper(
ContentMetricsHelper::ContentMetricsHelper(
history::HistoryService* history_service,
const GURL& request_url,
const security_interstitials::MetricsHelper::ReportDetails settings)
......@@ -20,10 +20,10 @@ ChromeMetricsHelper::ChromeMetricsHelper(
settings,
history_service) {}
ChromeMetricsHelper::~ChromeMetricsHelper() = default;
ContentMetricsHelper::~ContentMetricsHelper() = default;
#if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION)
void ChromeMetricsHelper::StartRecordingCaptivePortalMetrics(
void ContentMetricsHelper::StartRecordingCaptivePortalMetrics(
captive_portal::CaptivePortalService* captive_portal_service,
bool overridable) {
captive_portal_recorder_.reset(
......@@ -31,7 +31,7 @@ void ChromeMetricsHelper::StartRecordingCaptivePortalMetrics(
}
#endif
void ChromeMetricsHelper::RecordExtraShutdownMetrics() {
void ContentMetricsHelper::RecordExtraShutdownMetrics() {
#if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION)
// The captive portal metrics should be recorded when the interstitial is
// closing (or destructing).
......@@ -39,4 +39,3 @@ void ChromeMetricsHelper::RecordExtraShutdownMetrics() {
captive_portal_recorder_->RecordCaptivePortalUMAStatistics();
#endif
}
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_INTERSTITIALS_CHROME_METRICS_HELPER_H_
#define CHROME_BROWSER_INTERSTITIALS_CHROME_METRICS_HELPER_H_
#ifndef COMPONENTS_SECURITY_INTERSTITIALS_CONTENT_CONTENT_METRICS_HELPER_H_
#define COMPONENTS_SECURITY_INTERSTITIALS_CONTENT_CONTENT_METRICS_HELPER_H_
#include <string>
......@@ -22,18 +22,18 @@ class HistoryService;
class CaptivePortalMetricsRecorder;
// This class adds desktop-Chrome-specific metrics to the
// This class adds metrics specific to the usage of CaptivePortalService to the
// security_interstitials::MetricsHelper.
// TODO(crbug.com/812808): Refactor out the use of this class if possible.
// This class is meant to be used on the UI thread for captive portal metrics.
class ChromeMetricsHelper : public security_interstitials::MetricsHelper {
class ContentMetricsHelper : public security_interstitials::MetricsHelper {
public:
ChromeMetricsHelper(
ContentMetricsHelper(
history::HistoryService* history_service,
const GURL& url,
const security_interstitials::MetricsHelper::ReportDetails settings);
~ChromeMetricsHelper() override;
~ContentMetricsHelper() override;
#if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION)
void StartRecordingCaptivePortalMetrics(
......@@ -50,7 +50,7 @@ class ChromeMetricsHelper : public security_interstitials::MetricsHelper {
std::unique_ptr<CaptivePortalMetricsRecorder> captive_portal_recorder_;
#endif
DISALLOW_COPY_AND_ASSIGN(ChromeMetricsHelper);
DISALLOW_COPY_AND_ASSIGN(ContentMetricsHelper);
};
#endif // CHROME_BROWSER_INTERSTITIALS_CHROME_METRICS_HELPER_H_
#endif // COMPONENTS_SECURITY_INTERSTITIALS_CONTENT_CONTENT_METRICS_HELPER_H_
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