Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: chrome/browser/safe_browsing/ping_manager.cc

Issue 2047253002: Add hooks to permission layer for permission action reporting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permission-reporter-implementation
Patch Set: Use PRIORITY_PREFERENCE instead of PREFERENCE sync Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/safe_browsing/ping_manager.h" 5 #include "chrome/browser/safe_browsing/ping_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "chrome/browser/safe_browsing/permission_reporter.h"
13 #include "components/certificate_reporting/error_reporter.h" 14 #include "components/certificate_reporting/error_reporter.h"
14 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
15 #include "google_apis/google_api_keys.h" 16 #include "google_apis/google_api_keys.h"
16 #include "net/base/escape.h" 17 #include "net/base/escape.h"
17 #include "net/base/load_flags.h" 18 #include "net/base/load_flags.h"
18 #include "net/ssl/ssl_info.h" 19 #include "net/ssl/ssl_info.h"
19 #include "net/url_request/report_sender.h" 20 #include "net/url_request/report_sender.h"
20 #include "net/url_request/url_fetcher.h" 21 #include "net/url_request/url_fetcher.h"
21 #include "net/url_request/url_request_context_getter.h" 22 #include "net/url_request/url_request_context_getter.h"
22 #include "net/url_request/url_request_status.h" 23 #include "net/url_request/url_request_status.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 56
56 if (request_context_getter) { 57 if (request_context_getter) {
57 net::ReportSender::CookiesPreference cookies_preference; 58 net::ReportSender::CookiesPreference cookies_preference;
58 GURL certificate_upload_url; 59 GURL certificate_upload_url;
59 cookies_preference = net::ReportSender::DO_NOT_SEND_COOKIES; 60 cookies_preference = net::ReportSender::DO_NOT_SEND_COOKIES;
60 certificate_upload_url = GURL(kExtendedReportingUploadUrlInsecure); 61 certificate_upload_url = GURL(kExtendedReportingUploadUrlInsecure);
61 62
62 certificate_error_reporter_.reset(new certificate_reporting::ErrorReporter( 63 certificate_error_reporter_.reset(new certificate_reporting::ErrorReporter(
63 request_context_getter->GetURLRequestContext(), certificate_upload_url, 64 request_context_getter->GetURLRequestContext(), certificate_upload_url,
64 cookies_preference)); 65 cookies_preference));
66
67 permission_reporter_.reset(
68 new PermissionReporter(request_context_getter->GetURLRequestContext()));
65 } 69 }
66 70
67 version_ = SafeBrowsingProtocolManagerHelper::Version(); 71 version_ = SafeBrowsingProtocolManagerHelper::Version();
68 } 72 }
69 73
70 SafeBrowsingPingManager::~SafeBrowsingPingManager() { 74 SafeBrowsingPingManager::~SafeBrowsingPingManager() {
71 // Delete in-progress safebrowsing reports (hits and details). 75 // Delete in-progress safebrowsing reports (hits and details).
72 STLDeleteContainerPointers(safebrowsing_reports_.begin(), 76 STLDeleteContainerPointers(safebrowsing_reports_.begin(),
73 safebrowsing_reports_.end()); 77 safebrowsing_reports_.end());
74 } 78 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 DCHECK(certificate_error_reporter_); 126 DCHECK(certificate_error_reporter_);
123 certificate_error_reporter_->SendExtendedReportingReport(serialized_report); 127 certificate_error_reporter_->SendExtendedReportingReport(serialized_report);
124 } 128 }
125 129
126 void SafeBrowsingPingManager::SetCertificateErrorReporterForTesting( 130 void SafeBrowsingPingManager::SetCertificateErrorReporterForTesting(
127 std::unique_ptr<certificate_reporting::ErrorReporter> 131 std::unique_ptr<certificate_reporting::ErrorReporter>
128 certificate_error_reporter) { 132 certificate_error_reporter) {
129 certificate_error_reporter_ = std::move(certificate_error_reporter); 133 certificate_error_reporter_ = std::move(certificate_error_reporter);
130 } 134 }
131 135
136 void SafeBrowsingPingManager::ReportPermissionAction(
137 const GURL& origin,
138 content::PermissionType permission,
139 PermissionAction action) {
140 permission_reporter_->SendReport(origin, permission, action);
141 }
142
132 GURL SafeBrowsingPingManager::SafeBrowsingHitUrl( 143 GURL SafeBrowsingPingManager::SafeBrowsingHitUrl(
133 const safe_browsing::HitReport& hit_report) const { 144 const safe_browsing::HitReport& hit_report) const {
134 DCHECK(hit_report.threat_type == SB_THREAT_TYPE_URL_MALWARE || 145 DCHECK(hit_report.threat_type == SB_THREAT_TYPE_URL_MALWARE ||
135 hit_report.threat_type == SB_THREAT_TYPE_URL_PHISHING || 146 hit_report.threat_type == SB_THREAT_TYPE_URL_PHISHING ||
136 hit_report.threat_type == SB_THREAT_TYPE_URL_UNWANTED || 147 hit_report.threat_type == SB_THREAT_TYPE_URL_UNWANTED ||
137 hit_report.threat_type == SB_THREAT_TYPE_BINARY_MALWARE_URL || 148 hit_report.threat_type == SB_THREAT_TYPE_BINARY_MALWARE_URL ||
138 hit_report.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL || 149 hit_report.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL ||
139 hit_report.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL); 150 hit_report.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL);
140 std::string url = SafeBrowsingProtocolManagerHelper::ComposeUrl( 151 std::string url = SafeBrowsingProtocolManagerHelper::ComposeUrl(
141 url_prefix_, "report", client_name_, version_, std::string(), 152 url_prefix_, "report", client_name_, version_, std::string(),
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 version_.c_str()); 230 version_.c_str());
220 std::string api_key = google_apis::GetAPIKey(); 231 std::string api_key = google_apis::GetAPIKey();
221 if (!api_key.empty()) { 232 if (!api_key.empty()) {
222 base::StringAppendF(&url, "&key=%s", 233 base::StringAppendF(&url, "&key=%s",
223 net::EscapeQueryParamValue(api_key, true).c_str()); 234 net::EscapeQueryParamValue(api_key, true).c_str());
224 } 235 }
225 return GURL(url); 236 return GURL(url);
226 } 237 }
227 238
228 } // namespace safe_browsing 239 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698