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/last_download_finder.h" | 5 #include "chrome/browser/safe_browsing/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 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } | 138 } |
139 | 139 |
140 void LastDownloadFinder::SearchInProfile(Profile* profile) { | 140 void LastDownloadFinder::SearchInProfile(Profile* profile) { |
141 // Do not look in OTR profiles or in profiles that do not participate in | 141 // Do not look in OTR profiles or in profiles that do not participate in |
142 // safe browsing. | 142 // safe browsing. |
143 if (profile->IsOffTheRecord() || | 143 if (profile->IsOffTheRecord() || |
144 !profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) { | 144 !profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) { |
145 return; | 145 return; |
146 } | 146 } |
147 | 147 |
| 148 // Exit early if already processing this profile. This could happen if, for |
| 149 // example, NOTIFICATION_PROFILE_ADDED arrives after construction while |
| 150 // waiting for NOTIFICATION_HISTORY_LOADED. |
| 151 if (std::find(profiles_.begin(), profiles_.end(), profile) != |
| 152 profiles_.end()) { |
| 153 return; |
| 154 } |
| 155 |
148 HistoryService* history_service = | 156 HistoryService* history_service = |
149 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); | 157 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); |
150 // No history service is returned for profiles that do not save history. | 158 // No history service is returned for profiles that do not save history. |
151 if (!history_service) | 159 if (!history_service) |
152 return; | 160 return; |
153 | 161 |
154 profiles_.push_back(profile); | 162 profiles_.push_back(profile); |
155 if (history_service->BackendLoaded()) { | 163 if (history_service->BackendLoaded()) { |
156 history_service->QueryDownloads( | 164 history_service->QueryDownloads( |
157 base::Bind(&LastDownloadFinder::OnDownloadQuery, | 165 base::Bind(&LastDownloadFinder::OnDownloadQuery, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 break; | 248 break; |
241 case chrome::NOTIFICATION_PROFILE_DESTROYED: | 249 case chrome::NOTIFICATION_PROFILE_DESTROYED: |
242 AbandonSearchInProfile(content::Source<Profile>(source).ptr()); | 250 AbandonSearchInProfile(content::Source<Profile>(source).ptr()); |
243 break; | 251 break; |
244 default: | 252 default: |
245 break; | 253 break; |
246 } | 254 } |
247 } | 255 } |
248 | 256 |
249 } // namespace safe_browsing | 257 } // namespace safe_browsing |
OLD | NEW |