| OLD | NEW |
| 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 // Helper class which handles communication with the SafeBrowsing servers for | 5 // Helper class which handles communication with the SafeBrowsing servers for |
| 6 // improved binary download protection. | 6 // improved binary download protection. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ | 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ |
| 9 #define CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ | 9 #define CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ |
| 10 | 10 |
| 11 #include <stdint.h> | 11 #include <stdint.h> |
| 12 | 12 |
| 13 #include <memory> | 13 #include <memory> |
| 14 #include <set> | 14 #include <set> |
| 15 #include <string> | 15 #include <string> |
| 16 #include <unordered_map> | 16 #include <unordered_map> |
| 17 #include <vector> | 17 #include <vector> |
| 18 | 18 |
| 19 #include "base/callback.h" | 19 #include "base/callback.h" |
| 20 #include "base/callback_list.h" | 20 #include "base/callback_list.h" |
| 21 #include "base/files/file_path.h" | 21 #include "base/files/file_path.h" |
| 22 #include "base/gtest_prod_util.h" | 22 #include "base/gtest_prod_util.h" |
| 23 #include "base/macros.h" | 23 #include "base/macros.h" |
| 24 #include "base/memory/ref_counted.h" | 24 #include "base/memory/ref_counted.h" |
| 25 #include "base/supports_user_data.h" | 25 #include "base/supports_user_data.h" |
| 26 #include "chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager
.h" |
| 26 #include "chrome/browser/safe_browsing/ui_manager.h" | 27 #include "chrome/browser/safe_browsing/ui_manager.h" |
| 27 #include "components/safe_browsing_db/database_manager.h" | 28 #include "components/safe_browsing_db/database_manager.h" |
| 28 #include "net/url_request/url_request_context_getter.h" | 29 #include "net/url_request/url_request_context_getter.h" |
| 29 #include "url/gurl.h" | 30 #include "url/gurl.h" |
| 30 | 31 |
| 31 | 32 |
| 32 namespace content { | 33 namespace content { |
| 33 class DownloadItem; | 34 class DownloadItem; |
| 34 class PageNavigator; | 35 class PageNavigator; |
| 35 } | 36 } |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 // list of strings that need to be checked against the download whitelist to | 281 // list of strings that need to be checked against the download whitelist to |
| 281 // determine whether the certificate is whitelisted. | 282 // determine whether the certificate is whitelisted. |
| 282 static void GetCertificateWhitelistStrings( | 283 static void GetCertificateWhitelistStrings( |
| 283 const net::X509Certificate& certificate, | 284 const net::X509Certificate& certificate, |
| 284 const net::X509Certificate& issuer, | 285 const net::X509Certificate& issuer, |
| 285 std::vector<std::string>* whitelist_strings); | 286 std::vector<std::string>* whitelist_strings); |
| 286 | 287 |
| 287 // Returns the URL that will be used for download requests. | 288 // Returns the URL that will be used for download requests. |
| 288 static GURL GetDownloadRequestUrl(); | 289 static GURL GetDownloadRequestUrl(); |
| 289 | 290 |
| 291 // If kDownloadAttribution feature is enabled, identify and add referrer chain |
| 292 // info of a download to ClientDownloadRequest proto. This function also |
| 293 // records UMA stats of download attribution result. |
| 294 void AddReferrerChainToClientDownloadRequest( |
| 295 const GURL& download_url, |
| 296 content::WebContents* web_contents, |
| 297 ClientDownloadRequest* out_request); |
| 298 |
| 290 // These pointers may be NULL if SafeBrowsing is disabled. | 299 // These pointers may be NULL if SafeBrowsing is disabled. |
| 291 scoped_refptr<SafeBrowsingUIManager> ui_manager_; | 300 scoped_refptr<SafeBrowsingUIManager> ui_manager_; |
| 292 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; | 301 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; |
| 302 scoped_refptr<SafeBrowsingNavigationObserverManager> |
| 303 navigation_observer_manager_; |
| 293 | 304 |
| 294 // The context we use to issue network requests. | 305 // The context we use to issue network requests. |
| 295 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 306 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
| 296 | 307 |
| 297 // Set of pending server requests for DownloadManager mediated downloads. | 308 // Set of pending server requests for DownloadManager mediated downloads. |
| 298 std::set<scoped_refptr<CheckClientDownloadRequest>> download_requests_; | 309 std::set<scoped_refptr<CheckClientDownloadRequest>> download_requests_; |
| 299 | 310 |
| 300 // Set of pending server requests for PPAPI mediated downloads. Using a map | 311 // Set of pending server requests for PPAPI mediated downloads. Using a map |
| 301 // because heterogeneous lookups aren't available yet in std::unordered_map. | 312 // because heterogeneous lookups aren't available yet in std::unordered_map. |
| 302 std::unordered_map<PPAPIDownloadRequest*, | 313 std::unordered_map<PPAPIDownloadRequest*, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 326 std::set<std::string> manual_blacklist_hashes_; | 337 std::set<std::string> manual_blacklist_hashes_; |
| 327 | 338 |
| 328 // Rate of whitelisted downloads we sample to send out download ping. | 339 // Rate of whitelisted downloads we sample to send out download ping. |
| 329 double whitelist_sample_rate_; | 340 double whitelist_sample_rate_; |
| 330 | 341 |
| 331 DISALLOW_COPY_AND_ASSIGN(DownloadProtectionService); | 342 DISALLOW_COPY_AND_ASSIGN(DownloadProtectionService); |
| 332 }; | 343 }; |
| 333 } // namespace safe_browsing | 344 } // namespace safe_browsing |
| 334 | 345 |
| 335 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ | 346 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ |
| OLD | NEW |