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 <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
16 #include "chrome/browser/history/history_service.h" | 16 #include "chrome/browser/history/history_service.h" |
17 #include "chrome/browser/history/history_service_factory.h" | 17 #include "chrome/browser/history/history_service_factory.h" |
18 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
19 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
20 #include "chrome/common/safe_browsing/csd.pb.h" | 20 #include "chrome/common/safe_browsing/csd.pb.h" |
21 #include "chrome/common/safe_browsing/download_protection_util.h" | 21 #include "chrome/common/safe_browsing/download_protection_util.h" |
22 #include "content/public/browser/download_item.h" | 22 #include "components/history/core/browser/download_constants.h" |
23 #include "content/public/browser/notification_details.h" | 23 #include "content/public/browser/notification_details.h" |
24 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
25 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
26 | 26 |
27 namespace safe_browsing { | 27 namespace safe_browsing { |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 // The following functions are overloaded for the two object types that | 31 // The following functions are overloaded for the two object types that |
32 // represent the metadata for a download: history::DownloadRow and | 32 // represent the metadata for a download: history::DownloadRow and |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 (HasBeenOpened(first) && !HasBeenOpened(second))); | 78 (HasBeenOpened(first) && !HasBeenOpened(second))); |
79 } | 79 } |
80 | 80 |
81 // Returns a pointer to the most interesting completed download in |downloads|. | 81 // Returns a pointer to the most interesting completed download in |downloads|. |
82 const history::DownloadRow* FindMostInteresting( | 82 const history::DownloadRow* FindMostInteresting( |
83 const std::vector<history::DownloadRow>& downloads) { | 83 const std::vector<history::DownloadRow>& downloads) { |
84 const history::DownloadRow* most_recent_row = NULL; | 84 const history::DownloadRow* most_recent_row = NULL; |
85 for (size_t i = 0; i < downloads.size(); ++i) { | 85 for (size_t i = 0; i < downloads.size(); ++i) { |
86 const history::DownloadRow& row = downloads[i]; | 86 const history::DownloadRow& row = downloads[i]; |
87 // Ignore incomplete downloads. | 87 // Ignore incomplete downloads. |
88 if (row.state != content::DownloadItem::COMPLETE) | 88 if (row.state != history::DownloadState::COMPLETE) |
89 continue; | 89 continue; |
90 if (!most_recent_row || IsMoreInterestingThan(row, *most_recent_row)) | 90 if (!most_recent_row || IsMoreInterestingThan(row, *most_recent_row)) |
91 most_recent_row = &row; | 91 most_recent_row = &row; |
92 } | 92 } |
93 return most_recent_row; | 93 return most_recent_row; |
94 } | 94 } |
95 | 95 |
96 // Returns true if |candidate| is more interesting than whichever of |details| | 96 // Returns true if |candidate| is more interesting than whichever of |details| |
97 // or |best_row| is present. | 97 // or |best_row| is present. |
98 template <class D> | 98 template <class D> |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 } | 338 } |
339 } | 339 } |
340 } | 340 } |
341 | 341 |
342 void LastDownloadFinder::HistoryServiceBeingDeleted( | 342 void LastDownloadFinder::HistoryServiceBeingDeleted( |
343 HistoryService* history_service) { | 343 HistoryService* history_service) { |
344 history_service_observer_.Remove(history_service); | 344 history_service_observer_.Remove(history_service); |
345 } | 345 } |
346 | 346 |
347 } // namespace safe_browsing | 347 } // namespace safe_browsing |
OLD | NEW |