Index: chrome/browser/download/download_manager.cc |
=================================================================== |
--- chrome/browser/download/download_manager.cc (revision 86341) |
+++ chrome/browser/download/download_manager.cc (working copy) |
@@ -269,18 +269,37 @@ |
NewCallback(this, &DownloadManager::CheckDownloadUrlDone)); |
} |
+void DownloadManager::CheckVisitedBeforeDone(int32 download_id, |
+ bool visited_before) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ |
+ DownloadItem* download = GetActiveDownloadItem(download_id); |
+ if (download) { |
+ download->SetVisitedBefore(visited_before); |
+ HistoryAndSBChecksMaybeDone(download); |
+ } |
+} |
+ |
void DownloadManager::CheckDownloadUrlDone(int32 download_id, |
bool is_dangerous_url) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
DownloadItem* download = GetActiveDownloadItem(download_id); |
- if (!download) |
- return; |
+ if (download) { |
Randy Smith (Not in Mondays)
2011/05/24 18:28:25
It's a personal style preference (which probably m
|
+ download->SetUrlDangerous(is_dangerous_url); |
+ HistoryAndSBChecksMaybeDone(download); |
+ } |
+} |
- if (is_dangerous_url) |
- download->MarkUrlDangerous(); |
+void DownloadManager::HistoryAndSBChecksMaybeDone(DownloadItem* download) { |
Randy Smith (Not in Mondays)
2011/05/24 18:28:25
One of the biggest things we've done in the past c
|
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ DCHECK(download); |
+ // Only proceed once both the history and safe browsing checks have completed. |
DownloadStateInfo state = download->state_info(); |
+ if ((state.visited_referrer_before == DownloadStateInfo::UNKNOWN) || |
+ (state.is_dangerous_url == DownloadStateInfo::UNKNOWN)) |
+ return; |
// Check whether this download is for an extension install or not. |
// Allow extensions to be explicitly saved. |
@@ -343,7 +362,7 @@ |
NewRunnableMethod( |
this, |
&DownloadManager::CheckIfSuggestedPathExists, |
- download_id, |
+ download->id(), |
state, |
download_prefs()->download_path())); |
} |
@@ -497,6 +516,9 @@ |
DCHECK(!ContainsKey(active_downloads_, download_id)); |
downloads_.insert(download); |
active_downloads_[download_id] = download; |
+ |
+ download_history_->CheckVisitedReferrerBefore(download_id, info->referrer_url, |
+ NewCallback(this, &DownloadManager::CheckVisitedBeforeDone)); |
} |
void DownloadManager::ContinueDownloadWithPath(DownloadItem* download, |
@@ -1048,7 +1070,8 @@ |
return !(auto_open && state.has_user_gesture); |
if (danger_level == download_util::AllowOnUserGesture && |
- !state.has_user_gesture) |
+ (!state.has_user_gesture || |
+ state.visited_referrer_before != DownloadStateInfo::YES)) |
return true; |
if (state.is_extension_install) { |