Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: chrome/browser/download/chrome_download_manager_delegate.h

Issue 8536041: This CL integrates the new SafeBrowsing download service class (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: fix unit-tests Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ 5 #ifndef CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_
6 #define CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ 6 #define CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 private: 94 private:
95 friend class base::RefCountedThreadSafe<ChromeDownloadManagerDelegate>; 95 friend class base::RefCountedThreadSafe<ChromeDownloadManagerDelegate>;
96 96
97 // content::NotificationObserver implementation. 97 // content::NotificationObserver implementation.
98 virtual void Observe(int type, 98 virtual void Observe(int type,
99 const content::NotificationSource& source, 99 const content::NotificationSource& source,
100 const content::NotificationDetails& details) OVERRIDE; 100 const content::NotificationDetails& details) OVERRIDE;
101 101
102 // Callback function after url is checked with safebrowsing service. 102 // Callback function after url is checked with safebrowsing service.
103 void CheckDownloadUrlDone(int32 download_id, bool is_dangerous_url); 103 void CheckDownloadUrlDone(
104 int32 download_id,
105 safe_browsing::DownloadProtectionService::DownloadCheckResult result);
106
107 // Callback function after the DownloadProtectionService completes.
108 void CheckClientDownloadDone(
109 int32 download_id,
110 safe_browsing::DownloadProtectionService::DownloadCheckResult result);
104 111
105 // Callback function after we check whether the referrer URL has been visited 112 // Callback function after we check whether the referrer URL has been visited
106 // before today. 113 // before today.
107 void CheckVisitedReferrerBeforeDone(int32 download_id, 114 void CheckVisitedReferrerBeforeDone(int32 download_id,
108 bool visited_referrer_before); 115 bool visited_referrer_before);
109 116
110 // Called on the download thread to check whether the suggested file path 117 // Called on the download thread to check whether the suggested file path
111 // exists. We don't check if the file exists on the UI thread to avoid UI 118 // exists. We don't check if the file exists on the UI thread to avoid UI
112 // stalls from interacting with the file system. 119 // stalls from interacting with the file system.
113 void CheckIfSuggestedPathExists(int32 download_id, 120 void CheckIfSuggestedPathExists(int32 download_id,
114 DownloadStateInfo state, 121 DownloadStateInfo state,
115 const FilePath& default_path); 122 const FilePath& default_path);
116 123
117 // Called on the UI thread once it's determined whether the suggested file 124 // Called on the UI thread once it's determined whether the suggested file
118 // path exists. 125 // path exists.
119 void OnPathExistenceAvailable(int32 download_id, 126 void OnPathExistenceAvailable(int32 download_id,
120 const DownloadStateInfo& new_state); 127 const DownloadStateInfo& new_state);
121 128
122 // Returns true if this download should show the "dangerous file" warning. 129 // Returns true if this download should show the "dangerous file" warning.
123 // Various factors are considered, such as the type of the file, whether a 130 // Various factors are considered, such as the type of the file, whether a
124 // user action initiated the download, and whether the user has explicitly 131 // user action initiated the download, and whether the user has explicitly
125 // marked the file type as "auto open". 132 // marked the file type as "auto open".
126 bool IsDangerousFile(const DownloadItem& download, 133 bool IsDangerousFile(const DownloadItem& download,
127 const DownloadStateInfo& state, 134 const DownloadStateInfo& state,
128 bool visited_referrer_before); 135 bool visited_referrer_before);
129 136
130 // Callback from history system. 137 // Callback from history system.
131 void OnItemAddedToPersistentStore(int32 download_id, int64 db_handle); 138 void OnItemAddedToPersistentStore(int32 download_id, int64 db_handle);
132 139
133 // Callback function after download file hash is checked with safebrowsing
134 // service.
135 void CheckDownloadHashDone(int32 download_id, bool is_dangerous_hash);
136
137 // Callback function after the DownloadProtectionService completes.
138 void CheckClientDownloadDone(
139 int32 download_id,
140 safe_browsing::DownloadProtectionService::DownloadCheckResult result);
141
142 Profile* profile_; 140 Profile* profile_;
143 scoped_ptr<DownloadPrefs> download_prefs_; 141 scoped_ptr<DownloadPrefs> download_prefs_;
144 scoped_ptr<DownloadHistory> download_history_; 142 scoped_ptr<DownloadHistory> download_history_;
145 143
146 // Maps from pending extension installations to DownloadItem IDs. 144 // Maps from pending extension installations to DownloadItem IDs.
147 typedef base::hash_map<CrxInstaller*, int> CrxInstallerMap; 145 typedef base::hash_map<CrxInstaller*, int> CrxInstallerMap;
148 CrxInstallerMap crx_installers_; 146 CrxInstallerMap crx_installers_;
149 147
148 // Maps the SafeBrowsing download check state to a DownloadItem ID.
149 struct SafeBrowsingState {
150 // If true the SafeBrowsing check is not done yet.
151 bool pending;
152 // The verdict that we got from calling CheckClientDownload.
153 safe_browsing::DownloadProtectionService::DownloadCheckResult verdict;
154 };
155 typedef base::hash_map<int, SafeBrowsingState> SafeBrowsingStateMap;
156 SafeBrowsingStateMap safe_browsing_state_;
157
150 content::NotificationRegistrar registrar_; 158 content::NotificationRegistrar registrar_;
151 159
152 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate); 160 DISALLOW_COPY_AND_ASSIGN(ChromeDownloadManagerDelegate);
153 }; 161 };
154 162
155 #endif // CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_ 163 #endif // CHROME_BROWSER_DOWNLOAD_CHROME_DOWNLOAD_MANAGER_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698