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

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

Issue 2624193004: Submit a sample of notification images to Safe Browsing (Closed)
Patch Set: Report net_error codes to UMA Created 3 years, 11 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
« no previous file with comments | « chrome/browser/safe_browsing/ping_manager.h ('k') | chrome/common/safe_browsing/csd.proto » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/base64.h" 9 #include "base/base64.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/safe_browsing/notification_image_reporter.h"
15 #include "chrome/browser/safe_browsing/permission_reporter.h" 16 #include "chrome/browser/safe_browsing/permission_reporter.h"
16 #include "components/data_use_measurement/core/data_use_user_data.h" 17 #include "components/data_use_measurement/core/data_use_user_data.h"
17 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
18 #include "google_apis/google_api_keys.h" 19 #include "google_apis/google_api_keys.h"
19 #include "net/base/escape.h" 20 #include "net/base/escape.h"
20 #include "net/base/load_flags.h" 21 #include "net/base/load_flags.h"
21 #include "net/log/net_log_source_type.h" 22 #include "net/log/net_log_source_type.h"
22 #include "net/ssl/ssl_info.h" 23 #include "net/ssl/ssl_info.h"
23 #include "net/url_request/url_fetcher.h" 24 #include "net/url_request/url_fetcher.h"
24 #include "net/url_request/url_request_context.h" 25 #include "net/url_request/url_request_context.h"
25 #include "net/url_request/url_request_context_getter.h" 26 #include "net/url_request/url_request_context_getter.h"
26 #include "net/url_request/url_request_status.h" 27 #include "net/url_request/url_request_status.h"
28 #include "third_party/skia/include/core/SkBitmap.h"
27 #include "url/gurl.h" 29 #include "url/gurl.h"
28 30
29 using content::BrowserThread; 31 using content::BrowserThread;
30 32
31 namespace { 33 namespace {
32 // Returns a dictionary with "url"=|url-spec| and "data"=|payload| for 34 // Returns a dictionary with "url"=|url-spec| and "data"=|payload| for
33 // netlogging the start phase of a ping. 35 // netlogging the start phase of a ping.
34 std::unique_ptr<base::Value> NetLogPingStartCallback( 36 std::unique_ptr<base::Value> NetLogPingStartCallback(
35 const net::NetLogWithSource& net_log, 37 const net::NetLogWithSource& net_log,
36 const GURL& url, 38 const GURL& url,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 77
76 SafeBrowsingPingManager::SafeBrowsingPingManager( 78 SafeBrowsingPingManager::SafeBrowsingPingManager(
77 net::URLRequestContextGetter* request_context_getter, 79 net::URLRequestContextGetter* request_context_getter,
78 const SafeBrowsingProtocolConfig& config) 80 const SafeBrowsingProtocolConfig& config)
79 : client_name_(config.client_name), 81 : client_name_(config.client_name),
80 request_context_getter_(request_context_getter), 82 request_context_getter_(request_context_getter),
81 url_prefix_(config.url_prefix) { 83 url_prefix_(config.url_prefix) {
82 DCHECK(!url_prefix_.empty()); 84 DCHECK(!url_prefix_.empty());
83 85
84 if (request_context_getter) { 86 if (request_context_getter) {
85 permission_reporter_.reset( 87 permission_reporter_ = base::MakeUnique<PermissionReporter>(
86 new PermissionReporter(request_context_getter->GetURLRequestContext())); 88 request_context_getter->GetURLRequestContext());
89 notification_image_reporter_ = base::MakeUnique<NotificationImageReporter>(
90 request_context_getter->GetURLRequestContext());
87 91
88 net_log_ = net::NetLogWithSource::Make( 92 net_log_ = net::NetLogWithSource::Make(
89 request_context_getter->GetURLRequestContext()->net_log(), 93 request_context_getter->GetURLRequestContext()->net_log(),
90 net::NetLogSourceType::SAFE_BROWSING); 94 net::NetLogSourceType::SAFE_BROWSING);
91 } 95 }
92 96
93 version_ = SafeBrowsingProtocolManagerHelper::Version(); 97 version_ = SafeBrowsingProtocolManagerHelper::Version();
94 } 98 }
95 99
96 SafeBrowsingPingManager::~SafeBrowsingPingManager() { 100 SafeBrowsingPingManager::~SafeBrowsingPingManager() {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 167
164 fetcher->Start(); 168 fetcher->Start();
165 safebrowsing_reports_.insert(std::move(fetcher)); 169 safebrowsing_reports_.insert(std::move(fetcher));
166 } 170 }
167 171
168 void SafeBrowsingPingManager::ReportPermissionAction( 172 void SafeBrowsingPingManager::ReportPermissionAction(
169 const PermissionReportInfo& report_info) { 173 const PermissionReportInfo& report_info) {
170 permission_reporter_->SendReport(report_info); 174 permission_reporter_->SendReport(report_info);
171 } 175 }
172 176
177 void SafeBrowsingPingManager::ReportNotificationImage(
178 Profile* profile,
179 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager,
180 const GURL& origin,
181 const SkBitmap& image) {
182 notification_image_reporter_->ReportNotificationImageOnIO(
183 profile, database_manager, origin, image);
184 }
185
173 GURL SafeBrowsingPingManager::SafeBrowsingHitUrl( 186 GURL SafeBrowsingPingManager::SafeBrowsingHitUrl(
174 const safe_browsing::HitReport& hit_report) const { 187 const safe_browsing::HitReport& hit_report) const {
175 DCHECK(hit_report.threat_type == SB_THREAT_TYPE_URL_MALWARE || 188 DCHECK(hit_report.threat_type == SB_THREAT_TYPE_URL_MALWARE ||
176 hit_report.threat_type == SB_THREAT_TYPE_URL_PHISHING || 189 hit_report.threat_type == SB_THREAT_TYPE_URL_PHISHING ||
177 hit_report.threat_type == SB_THREAT_TYPE_URL_UNWANTED || 190 hit_report.threat_type == SB_THREAT_TYPE_URL_UNWANTED ||
178 hit_report.threat_type == SB_THREAT_TYPE_BINARY_MALWARE_URL || 191 hit_report.threat_type == SB_THREAT_TYPE_BINARY_MALWARE_URL ||
179 hit_report.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL || 192 hit_report.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL ||
180 hit_report.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL); 193 hit_report.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL);
181 std::string url = SafeBrowsingProtocolManagerHelper::ComposeUrl( 194 std::string url = SafeBrowsingProtocolManagerHelper::ComposeUrl(
182 url_prefix_, "report", client_name_, version_, std::string(), 195 url_prefix_, "report", client_name_, version_, std::string(),
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 version_.c_str()); 273 version_.c_str());
261 std::string api_key = google_apis::GetAPIKey(); 274 std::string api_key = google_apis::GetAPIKey();
262 if (!api_key.empty()) { 275 if (!api_key.empty()) {
263 base::StringAppendF(&url, "&key=%s", 276 base::StringAppendF(&url, "&key=%s",
264 net::EscapeQueryParamValue(api_key, true).c_str()); 277 net::EscapeQueryParamValue(api_key, true).c_str());
265 } 278 }
266 return GURL(url); 279 return GURL(url);
267 } 280 }
268 281
269 } // namespace safe_browsing 282 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/ping_manager.h ('k') | chrome/common/safe_browsing/csd.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698