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

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: Add guard to permission reporting Created 4 years, 6 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 cookies_preference = net::ReportSender::DO_NOT_SEND_COOKIES; 68 cookies_preference = net::ReportSender::DO_NOT_SEND_COOKIES;
68 certificate_upload_url = GURL(kExtendedReportingUploadUrlInsecure); 69 certificate_upload_url = GURL(kExtendedReportingUploadUrlInsecure);
69 } else { 70 } else {
70 cookies_preference = net::ReportSender::SEND_COOKIES; 71 cookies_preference = net::ReportSender::SEND_COOKIES;
71 certificate_upload_url = GURL(kExtendedReportingUploadUrlSecure); 72 certificate_upload_url = GURL(kExtendedReportingUploadUrlSecure);
72 } 73 }
73 74
74 certificate_error_reporter_.reset(new certificate_reporting::ErrorReporter( 75 certificate_error_reporter_.reset(new certificate_reporting::ErrorReporter(
75 request_context_getter->GetURLRequestContext(), certificate_upload_url, 76 request_context_getter->GetURLRequestContext(), certificate_upload_url,
76 cookies_preference)); 77 cookies_preference));
78
79 permission_reporter_.reset(
80 new PermissionReporter(request_context_getter->GetURLRequestContext()));
77 } 81 }
78 82
79 version_ = SafeBrowsingProtocolManagerHelper::Version(); 83 version_ = SafeBrowsingProtocolManagerHelper::Version();
80 } 84 }
81 85
82 SafeBrowsingPingManager::~SafeBrowsingPingManager() { 86 SafeBrowsingPingManager::~SafeBrowsingPingManager() {
83 // Delete in-progress safebrowsing reports (hits and details). 87 // Delete in-progress safebrowsing reports (hits and details).
84 STLDeleteContainerPointers(safebrowsing_reports_.begin(), 88 STLDeleteContainerPointers(safebrowsing_reports_.begin(),
85 safebrowsing_reports_.end()); 89 safebrowsing_reports_.end());
86 } 90 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 DCHECK(certificate_error_reporter_); 138 DCHECK(certificate_error_reporter_);
135 certificate_error_reporter_->SendExtendedReportingReport(serialized_report); 139 certificate_error_reporter_->SendExtendedReportingReport(serialized_report);
136 } 140 }
137 141
138 void SafeBrowsingPingManager::SetCertificateErrorReporterForTesting( 142 void SafeBrowsingPingManager::SetCertificateErrorReporterForTesting(
139 std::unique_ptr<certificate_reporting::ErrorReporter> 143 std::unique_ptr<certificate_reporting::ErrorReporter>
140 certificate_error_reporter) { 144 certificate_error_reporter) {
141 certificate_error_reporter_ = std::move(certificate_error_reporter); 145 certificate_error_reporter_ = std::move(certificate_error_reporter);
142 } 146 }
143 147
148 PermissionReporter* SafeBrowsingPingManager::permission_reporter() {
149 DCHECK(permission_reporter_);
raymes 2016/06/14 02:47:11 nit: this isn't needed DCHECKs for null often are
stefanocs 2016/06/14 03:37:37 Done.
150 return permission_reporter_.get();
151 }
152
144 GURL SafeBrowsingPingManager::SafeBrowsingHitUrl( 153 GURL SafeBrowsingPingManager::SafeBrowsingHitUrl(
145 const safe_browsing::HitReport& hit_report) const { 154 const safe_browsing::HitReport& hit_report) const {
146 DCHECK(hit_report.threat_type == SB_THREAT_TYPE_URL_MALWARE || 155 DCHECK(hit_report.threat_type == SB_THREAT_TYPE_URL_MALWARE ||
147 hit_report.threat_type == SB_THREAT_TYPE_URL_PHISHING || 156 hit_report.threat_type == SB_THREAT_TYPE_URL_PHISHING ||
148 hit_report.threat_type == SB_THREAT_TYPE_URL_UNWANTED || 157 hit_report.threat_type == SB_THREAT_TYPE_URL_UNWANTED ||
149 hit_report.threat_type == SB_THREAT_TYPE_BINARY_MALWARE_URL || 158 hit_report.threat_type == SB_THREAT_TYPE_BINARY_MALWARE_URL ||
150 hit_report.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL || 159 hit_report.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL ||
151 hit_report.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL); 160 hit_report.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL);
152 std::string url = SafeBrowsingProtocolManagerHelper::ComposeUrl( 161 std::string url = SafeBrowsingProtocolManagerHelper::ComposeUrl(
153 url_prefix_, "report", client_name_, version_, std::string(), 162 url_prefix_, "report", client_name_, version_, std::string(),
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 version_.c_str()); 240 version_.c_str());
232 std::string api_key = google_apis::GetAPIKey(); 241 std::string api_key = google_apis::GetAPIKey();
233 if (!api_key.empty()) { 242 if (!api_key.empty()) {
234 base::StringAppendF(&url, "&key=%s", 243 base::StringAppendF(&url, "&key=%s",
235 net::EscapeQueryParamValue(api_key, true).c_str()); 244 net::EscapeQueryParamValue(api_key, true).c_str());
236 } 245 }
237 return GURL(url); 246 return GURL(url);
238 } 247 }
239 248
240 } // namespace safe_browsing 249 } // namespace safe_browsing
OLDNEW
« chrome/browser/safe_browsing/ping_manager.h ('K') | « chrome/browser/safe_browsing/ping_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698