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 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 5 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 int32 download_id, | 322 int32 download_id, |
323 DownloadProtectionService::DownloadCheckResult result) { | 323 DownloadProtectionService::DownloadCheckResult result) { |
324 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 324 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
325 DownloadItem* download = | 325 DownloadItem* download = |
326 download_manager_->GetActiveDownloadItem(download_id); | 326 download_manager_->GetActiveDownloadItem(download_id); |
327 if (!download) | 327 if (!download) |
328 return; | 328 return; |
329 | 329 |
330 VLOG(2) << __FUNCTION__ << "() download = " << download->DebugString(false) | 330 VLOG(2) << __FUNCTION__ << "() download = " << download->DebugString(false) |
331 << " verdict = " << result; | 331 << " verdict = " << result; |
332 if (result == DownloadProtectionService::DANGEROUS) | 332 if (result != DownloadProtectionService::SAFE) |
333 download->SetDangerType(content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL); | 333 download->SetDangerType(content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL); |
334 | 334 |
335 download_history_->CheckVisitedReferrerBefore( | 335 download_history_->CheckVisitedReferrerBefore( |
336 download_id, download->GetReferrerUrl(), | 336 download_id, download->GetReferrerUrl(), |
337 base::Bind(&ChromeDownloadManagerDelegate::CheckVisitedReferrerBeforeDone, | 337 base::Bind(&ChromeDownloadManagerDelegate::CheckVisitedReferrerBeforeDone, |
338 base::Unretained(this))); | 338 base::Unretained(this))); |
339 } | 339 } |
340 | 340 |
341 void ChromeDownloadManagerDelegate::CheckClientDownloadDone( | 341 void ChromeDownloadManagerDelegate::CheckClientDownloadDone( |
342 int32 download_id, | 342 int32 download_id, |
343 DownloadProtectionService::DownloadCheckResult result) { | 343 DownloadProtectionService::DownloadCheckResult result) { |
344 DownloadItem* item = download_manager_->GetActiveDownloadItem(download_id); | 344 DownloadItem* item = download_manager_->GetActiveDownloadItem(download_id); |
345 if (!item) | 345 if (!item) |
346 return; | 346 return; |
347 | 347 |
348 VLOG(2) << __FUNCTION__ << "() download = " << item->DebugString(false) | 348 VLOG(2) << __FUNCTION__ << "() download = " << item->DebugString(false) |
349 << " verdict = " << result; | 349 << " verdict = " << result; |
350 // We only mark the content as being dangerous if the download's safety state | 350 // We only mark the content as being dangerous if the download's safety state |
351 // has not been set to DANGEROUS yet. We don't want to show two warnings. | 351 // has not been set to DANGEROUS yet. We don't want to show two warnings. |
352 if (result == DownloadProtectionService::DANGEROUS && | 352 if (item->GetSafetyState() == DownloadItem::SAFE) { |
353 item->GetSafetyState() == DownloadItem::SAFE) | 353 switch (result) { |
354 item->SetDangerType(content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT); | 354 case DownloadProtectionService::SAFE: |
| 355 // Do nothing. |
| 356 break; |
| 357 case DownloadProtectionService::DANGEROUS: |
| 358 item->SetDangerType(content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT); |
| 359 break; |
| 360 case DownloadProtectionService::UNCOMMON: |
| 361 item->SetDangerType(content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT); |
| 362 break; |
| 363 } |
| 364 } |
355 | 365 |
356 SafeBrowsingState* state = static_cast<SafeBrowsingState*>( | 366 SafeBrowsingState* state = static_cast<SafeBrowsingState*>( |
357 item->GetExternalData(&safe_browsing_id)); | 367 item->GetExternalData(&safe_browsing_id)); |
358 DCHECK(state); | 368 DCHECK(state); |
359 if (state) { | 369 if (state) { |
360 state->pending = false; | 370 state->pending = false; |
361 state->verdict = result; | 371 state->verdict = result; |
362 } | 372 } |
363 item->MaybeCompleteDownload(); | 373 item->MaybeCompleteDownload(); |
364 } | 374 } |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 int32 download_id, int64 db_handle) { | 615 int32 download_id, int64 db_handle) { |
606 // It's not immediately obvious, but HistoryBackend::CreateDownload() can | 616 // It's not immediately obvious, but HistoryBackend::CreateDownload() can |
607 // call this function with an invalid |db_handle|. For instance, this can | 617 // call this function with an invalid |db_handle|. For instance, this can |
608 // happen when the history database is offline. We cannot have multiple | 618 // happen when the history database is offline. We cannot have multiple |
609 // DownloadItems with the same invalid db_handle, so we need to assign a | 619 // DownloadItems with the same invalid db_handle, so we need to assign a |
610 // unique |db_handle| here. | 620 // unique |db_handle| here. |
611 if (db_handle == DownloadItem::kUninitializedHandle) | 621 if (db_handle == DownloadItem::kUninitializedHandle) |
612 db_handle = download_history_->GetNextFakeDbHandle(); | 622 db_handle = download_history_->GetNextFakeDbHandle(); |
613 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); | 623 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); |
614 } | 624 } |
OLD | NEW |