| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/incident_reporting/last_download_finder.h
" | 5 #include "chrome/browser/safe_browsing/incident_reporting/last_download_finder.h
" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
| 7 #include <algorithm> | 10 #include <algorithm> |
| 8 #include <functional> | 11 #include <functional> |
| 9 #include <utility> | 12 #include <utility> |
| 10 | 13 |
| 11 #include "base/bind.h" | 14 #include "base/bind.h" |
| 12 #include "base/macros.h" | 15 #include "base/macros.h" |
| 13 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
| 14 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "build/build_config.h" |
| 16 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/chrome_notification_types.h" | 21 #include "chrome/browser/chrome_notification_types.h" |
| 18 #include "chrome/browser/history/history_service_factory.h" | 22 #include "chrome/browser/history/history_service_factory.h" |
| 19 #include "chrome/browser/profiles/profile_manager.h" | 23 #include "chrome/browser/profiles/profile_manager.h" |
| 20 #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_ser
vice.h" | 24 #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_ser
vice.h" |
| 21 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 22 #include "chrome/common/safe_browsing/csd.pb.h" | 26 #include "chrome/common/safe_browsing/csd.pb.h" |
| 23 #include "chrome/common/safe_browsing/download_protection_util.h" | 27 #include "chrome/common/safe_browsing/download_protection_util.h" |
| 24 #include "components/history/core/browser/download_constants.h" | 28 #include "components/history/core/browser/download_constants.h" |
| 25 #include "components/history/core/browser/history_service.h" | 29 #include "components/history/core/browser/history_service.h" |
| 26 #include "content/public/browser/notification_details.h" | 30 #include "content/public/browser/notification_details.h" |
| 27 #include "content/public/browser/notification_service.h" | 31 #include "content/public/browser/notification_service.h" |
| 28 #include "content/public/browser/notification_source.h" | 32 #include "content/public/browser/notification_source.h" |
| 29 #include "crypto/sha2.h" | 33 #include "crypto/sha2.h" |
| 30 | 34 |
| 31 namespace safe_browsing { | 35 namespace safe_browsing { |
| 32 | 36 |
| 33 namespace { | 37 namespace { |
| 34 | 38 |
| 35 // The following functions are overloaded for the two object types that | 39 // The following functions are overloaded for the two object types that |
| 36 // represent the metadata for a download: history::DownloadRow and | 40 // represent the metadata for a download: history::DownloadRow and |
| 37 // ClientIncidentReport_DownloadDetails. These are used by the template | 41 // ClientIncidentReport_DownloadDetails. These are used by the template |
| 38 // functions that follow. | 42 // functions that follow. |
| 39 | 43 |
| 40 // Returns the end time of a download represented by a DownloadRow. | 44 // Returns the end time of a download represented by a DownloadRow. |
| 41 int64 GetEndTime(const history::DownloadRow& row) { | 45 int64_t GetEndTime(const history::DownloadRow& row) { |
| 42 return row.end_time.ToJavaTime(); | 46 return row.end_time.ToJavaTime(); |
| 43 } | 47 } |
| 44 | 48 |
| 45 // Returns the end time of a download represented by a DownloadDetails. | 49 // Returns the end time of a download represented by a DownloadDetails. |
| 46 int64 GetEndTime(const ClientIncidentReport_DownloadDetails& details) { | 50 int64_t GetEndTime(const ClientIncidentReport_DownloadDetails& details) { |
| 47 return details.download_time_msec(); | 51 return details.download_time_msec(); |
| 48 } | 52 } |
| 49 | 53 |
| 50 bool IsBinaryDownloadForCurrentOS( | 54 bool IsBinaryDownloadForCurrentOS( |
| 51 ClientDownloadRequest::DownloadType download_type) { | 55 ClientDownloadRequest::DownloadType download_type) { |
| 52 static_assert(ClientDownloadRequest::DownloadType_MAX == | 56 static_assert(ClientDownloadRequest::DownloadType_MAX == |
| 53 ClientDownloadRequest::INVALID_MAC_ARCHIVE, | 57 ClientDownloadRequest::INVALID_MAC_ARCHIVE, |
| 54 "Update logic below"); | 58 "Update logic below"); |
| 55 | 59 |
| 56 // Platform-specific types are relevant only for their own platforms. | 60 // Platform-specific types are relevant only for their own platforms. |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 } | 436 } |
| 433 } | 437 } |
| 434 } | 438 } |
| 435 | 439 |
| 436 void LastDownloadFinder::HistoryServiceBeingDeleted( | 440 void LastDownloadFinder::HistoryServiceBeingDeleted( |
| 437 history::HistoryService* history_service) { | 441 history::HistoryService* history_service) { |
| 438 history_service_observer_.Remove(history_service); | 442 history_service_observer_.Remove(history_service); |
| 439 } | 443 } |
| 440 | 444 |
| 441 } // namespace safe_browsing | 445 } // namespace safe_browsing |
| OLD | NEW |