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

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

Issue 2276933003: Add data usage tracking for safe browsing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 2 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 | « no previous file | chrome/browser/safe_browsing/client_side_model_loader.cc » ('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/client_side_detection_service.h" 5 #include "chrome/browser/safe_browsing/client_side_detection_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
15 #include "base/metrics/sparse_histogram.h" 15 #include "base/metrics/sparse_histogram.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/stl_util.h" 17 #include "base/stl_util.h"
18 #include "base/threading/thread_task_runner_handle.h" 18 #include "base/threading/thread_task_runner_handle.h"
19 #include "base/time/time.h" 19 #include "base/time/time.h"
20 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
23 #include "chrome/common/safe_browsing/client_model.pb.h" 23 #include "chrome/common/safe_browsing/client_model.pb.h"
24 #include "chrome/common/safe_browsing/csd.pb.h" 24 #include "chrome/common/safe_browsing/csd.pb.h"
25 #include "chrome/common/safe_browsing/safebrowsing_messages.h" 25 #include "chrome/common/safe_browsing/safebrowsing_messages.h"
26 #include "components/data_use_measurement/core/data_use_user_data.h"
26 #include "components/prefs/pref_service.h" 27 #include "components/prefs/pref_service.h"
27 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
29 #include "content/public/browser/notification_types.h" 30 #include "content/public/browser/notification_types.h"
30 #include "content/public/browser/render_process_host.h" 31 #include "content/public/browser/render_process_host.h"
31 #include "crypto/sha2.h" 32 #include "crypto/sha2.h"
32 #include "google_apis/google_api_keys.h" 33 #include "google_apis/google_api_keys.h"
33 #include "net/base/escape.h" 34 #include "net/base/escape.h"
34 #include "net/base/ip_address.h" 35 #include "net/base/ip_address.h"
35 #include "net/base/load_flags.h" 36 #include "net/base/load_flags.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 if (!callback.is_null()) 284 if (!callback.is_null())
284 callback.Run(GURL(request->url()), false); 285 callback.Run(GURL(request->url()), false);
285 return; 286 return;
286 } 287 }
287 288
288 std::unique_ptr<net::URLFetcher> fetcher( 289 std::unique_ptr<net::URLFetcher> fetcher(
289 net::URLFetcher::Create(0 /* ID used for testing */, 290 net::URLFetcher::Create(0 /* ID used for testing */,
290 GetClientReportUrl(kClientReportPhishingUrl), 291 GetClientReportUrl(kClientReportPhishingUrl),
291 net::URLFetcher::POST, this)); 292 net::URLFetcher::POST, this));
292 net::URLFetcher* fetcher_ptr = fetcher.get(); 293 net::URLFetcher* fetcher_ptr = fetcher.get();
294 data_use_measurement::DataUseUserData::AttachToFetcher(
295 fetcher_ptr, data_use_measurement::DataUseUserData::SAFE_BROWSING);
293 296
294 // Remember which callback and URL correspond to the current fetcher object. 297 // Remember which callback and URL correspond to the current fetcher object.
295 std::unique_ptr<ClientPhishingReportInfo> info(new ClientPhishingReportInfo); 298 std::unique_ptr<ClientPhishingReportInfo> info(new ClientPhishingReportInfo);
296 info->fetcher = std::move(fetcher); 299 info->fetcher = std::move(fetcher);
297 info->callback = callback; 300 info->callback = callback;
298 info->phishing_url = GURL(request->url()); 301 info->phishing_url = GURL(request->url());
299 client_phishing_reports_[fetcher_ptr] = std::move(info); 302 client_phishing_reports_[fetcher_ptr] = std::move(info);
300 303
301 fetcher_ptr->SetLoadFlags(net::LOAD_DISABLE_CACHE); 304 fetcher_ptr->SetLoadFlags(net::LOAD_DISABLE_CACHE);
302 fetcher_ptr->SetRequestContext(request_context_getter_.get()); 305 fetcher_ptr->SetRequestContext(request_context_getter_.get());
(...skipping 23 matching lines...) Expand all
326 if (!callback.is_null()) 329 if (!callback.is_null())
327 callback.Run(GURL(request->url()), GURL(request->url()), false); 330 callback.Run(GURL(request->url()), GURL(request->url()), false);
328 return; 331 return;
329 } 332 }
330 333
331 std::unique_ptr<net::URLFetcher> fetcher( 334 std::unique_ptr<net::URLFetcher> fetcher(
332 net::URLFetcher::Create(0 /* ID used for testing */, 335 net::URLFetcher::Create(0 /* ID used for testing */,
333 GetClientReportUrl(kClientReportMalwareUrl), 336 GetClientReportUrl(kClientReportMalwareUrl),
334 net::URLFetcher::POST, this)); 337 net::URLFetcher::POST, this));
335 net::URLFetcher* fetcher_ptr = fetcher.get(); 338 net::URLFetcher* fetcher_ptr = fetcher.get();
339 data_use_measurement::DataUseUserData::AttachToFetcher(
340 fetcher_ptr, data_use_measurement::DataUseUserData::SAFE_BROWSING);
336 341
337 // Remember which callback and URL correspond to the current fetcher object. 342 // Remember which callback and URL correspond to the current fetcher object.
338 std::unique_ptr<ClientMalwareReportInfo> info(new ClientMalwareReportInfo); 343 std::unique_ptr<ClientMalwareReportInfo> info(new ClientMalwareReportInfo);
339 info->fetcher = std::move(fetcher); 344 info->fetcher = std::move(fetcher);
340 info->callback = callback; 345 info->callback = callback;
341 info->original_url = GURL(request->url()); 346 info->original_url = GURL(request->url());
342 client_malware_reports_[fetcher_ptr] = std::move(info); 347 client_malware_reports_[fetcher_ptr] = std::move(info);
343 348
344 fetcher_ptr->SetLoadFlags(net::LOAD_DISABLE_CACHE); 349 fetcher_ptr->SetLoadFlags(net::LOAD_DISABLE_CACHE);
345 fetcher_ptr->SetRequestContext(request_context_getter_.get()); 350 fetcher_ptr->SetRequestContext(request_context_getter_.get());
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 const std::string& report_url) { 517 const std::string& report_url) {
513 GURL url(report_url); 518 GURL url(report_url);
514 std::string api_key = google_apis::GetAPIKey(); 519 std::string api_key = google_apis::GetAPIKey();
515 if (!api_key.empty()) 520 if (!api_key.empty())
516 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); 521 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true));
517 522
518 return url; 523 return url;
519 } 524 }
520 525
521 } // namespace safe_browsing 526 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/client_side_model_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698