Index: components/safe_browsing/base_ping_manager.cc |
diff --git a/chrome/browser/safe_browsing/ping_manager.cc b/components/safe_browsing/base_ping_manager.cc |
similarity index 83% |
copy from chrome/browser/safe_browsing/ping_manager.cc |
copy to components/safe_browsing/base_ping_manager.cc |
index b223a15f2e44da561bb03974ddb00866de5dd54f..564385b621a6bd3d5379b858cf687492da0bcfec 100644 |
--- a/chrome/browser/safe_browsing/ping_manager.cc |
+++ b/components/safe_browsing/base_ping_manager.cc |
@@ -1,8 +1,8 @@ |
-// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2017 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/browser/safe_browsing/ping_manager.h" |
+#include "components/safe_browsing/base_ping_manager.h" |
#include <utility> |
@@ -12,20 +12,16 @@ |
#include "base/strings/string_util.h" |
#include "base/strings/stringprintf.h" |
#include "base/values.h" |
-#include "chrome/browser/safe_browsing/notification_image_reporter.h" |
-#include "chrome/browser/safe_browsing/permission_reporter.h" |
#include "components/data_use_measurement/core/data_use_user_data.h" |
#include "content/public/browser/browser_thread.h" |
#include "google_apis/google_api_keys.h" |
#include "net/base/escape.h" |
#include "net/base/load_flags.h" |
#include "net/log/net_log_source_type.h" |
-#include "net/ssl/ssl_info.h" |
#include "net/url_request/url_fetcher.h" |
#include "net/url_request/url_request_context.h" |
#include "net/url_request/url_request_context_getter.h" |
#include "net/url_request/url_request_status.h" |
-#include "third_party/skia/include/core/SkBitmap.h" |
#include "url/gurl.h" |
using content::BrowserThread; |
@@ -67,15 +63,15 @@ namespace safe_browsing { |
// SafeBrowsingPingManager implementation ---------------------------------- |
// static |
-std::unique_ptr<SafeBrowsingPingManager> SafeBrowsingPingManager::Create( |
+std::unique_ptr<BasePingManager> BasePingManager::Create( |
net::URLRequestContextGetter* request_context_getter, |
const SafeBrowsingProtocolConfig& config) { |
DCHECK_CURRENTLY_ON(BrowserThread::IO); |
return base::WrapUnique( |
- new SafeBrowsingPingManager(request_context_getter, config)); |
+ new BasePingManager(request_context_getter, config)); |
} |
-SafeBrowsingPingManager::SafeBrowsingPingManager( |
+BasePingManager::BasePingManager( |
net::URLRequestContextGetter* request_context_getter, |
const SafeBrowsingProtocolConfig& config) |
: client_name_(config.client_name), |
@@ -84,26 +80,21 @@ SafeBrowsingPingManager::SafeBrowsingPingManager( |
DCHECK(!url_prefix_.empty()); |
if (request_context_getter) { |
- permission_reporter_ = base::MakeUnique<PermissionReporter>( |
- request_context_getter->GetURLRequestContext()); |
- notification_image_reporter_ = base::MakeUnique<NotificationImageReporter>( |
- request_context_getter->GetURLRequestContext()); |
- |
net_log_ = net::NetLogWithSource::Make( |
request_context_getter->GetURLRequestContext()->net_log(), |
net::NetLogSourceType::SAFE_BROWSING); |
} |
- version_ = SafeBrowsingProtocolManagerHelper::Version(); |
+ version_ = Version(); |
} |
-SafeBrowsingPingManager::~SafeBrowsingPingManager() { |
+BasePingManager::~BasePingManager() { |
} |
// net::URLFetcherDelegate implementation ---------------------------------- |
// All SafeBrowsing request responses are handled here. |
-void SafeBrowsingPingManager::OnURLFetchComplete( |
+void BasePingManager::OnURLFetchComplete( |
const net::URLFetcher* source) { |
net_log_.EndEvent( |
net::NetLogEventType::SAFE_BROWSING_PING, |
@@ -118,7 +109,7 @@ void SafeBrowsingPingManager::OnURLFetchComplete( |
} |
// Sends a SafeBrowsing "hit" report. |
-void SafeBrowsingPingManager::ReportSafeBrowsingHit( |
+void BasePingManager::ReportSafeBrowsingHit( |
const safe_browsing::HitReport& hit_report) { |
GURL report_url = SafeBrowsingHitUrl(hit_report); |
std::unique_ptr<net::URLFetcher> report_ptr = net::URLFetcher::Create( |
@@ -146,7 +137,7 @@ void SafeBrowsingPingManager::ReportSafeBrowsingHit( |
} |
// Sends threat details for users who opt-in. |
-void SafeBrowsingPingManager::ReportThreatDetails(const std::string& report) { |
+void BasePingManager::ReportThreatDetails(const std::string& report) { |
GURL report_url = ThreatDetailsUrl(); |
std::unique_ptr<net::URLFetcher> fetcher = |
net::URLFetcher::Create(report_url, net::URLFetcher::POST, this); |
@@ -169,21 +160,7 @@ void SafeBrowsingPingManager::ReportThreatDetails(const std::string& report) { |
safebrowsing_reports_.insert(std::move(fetcher)); |
} |
-void SafeBrowsingPingManager::ReportPermissionAction( |
- const PermissionReportInfo& report_info) { |
- permission_reporter_->SendReport(report_info); |
-} |
- |
-void SafeBrowsingPingManager::ReportNotificationImage( |
- Profile* profile, |
- const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager, |
- const GURL& origin, |
- const SkBitmap& image) { |
- notification_image_reporter_->ReportNotificationImageOnIO( |
- profile, database_manager, origin, image); |
-} |
- |
-GURL SafeBrowsingPingManager::SafeBrowsingHitUrl( |
+GURL BasePingManager::SafeBrowsingHitUrl( |
const safe_browsing::HitReport& hit_report) const { |
DCHECK(hit_report.threat_type == SB_THREAT_TYPE_URL_MALWARE || |
hit_report.threat_type == SB_THREAT_TYPE_URL_PHISHING || |
@@ -191,7 +168,7 @@ GURL SafeBrowsingPingManager::SafeBrowsingHitUrl( |
hit_report.threat_type == SB_THREAT_TYPE_BINARY_MALWARE_URL || |
hit_report.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL || |
hit_report.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL); |
- std::string url = SafeBrowsingProtocolManagerHelper::ComposeUrl( |
+ std::string url = ComposeUrl( |
url_prefix_, "report", client_name_, version_, std::string(), |
hit_report.extended_reporting_level); |
@@ -265,7 +242,7 @@ GURL SafeBrowsingPingManager::SafeBrowsingHitUrl( |
hit_report.is_metrics_reporting_active, user_population_comp.c_str())); |
} |
-GURL SafeBrowsingPingManager::ThreatDetailsUrl() const { |
+GURL BasePingManager::ThreatDetailsUrl() const { |
std::string url = base::StringPrintf( |
"%s/clientreport/malware?client=%s&appver=%s&pver=1.0", |
url_prefix_.c_str(), |