| 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 // Helper class which handles communication with the SafeBrowsing servers for | 5 // Helper class which handles communication with the SafeBrowsing servers for |
| 6 // improved binary download protection. | 6 // improved binary download protection. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ | 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ |
| 9 #define CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ | 9 #define CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ |
| 10 | 10 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 const CheckDownloadCallback& callback); | 122 const CheckDownloadCallback& callback); |
| 123 | 123 |
| 124 // Returns true iff the download specified by |info| should be scanned by | 124 // Returns true iff the download specified by |info| should be scanned by |
| 125 // CheckClientDownload() for malicious content. | 125 // CheckClientDownload() for malicious content. |
| 126 virtual bool IsSupportedDownload( | 126 virtual bool IsSupportedDownload( |
| 127 const content::DownloadItem& item, | 127 const content::DownloadItem& item, |
| 128 const base::FilePath& target_path) const; | 128 const base::FilePath& target_path) const; |
| 129 | 129 |
| 130 virtual void CheckPPAPIDownloadRequest( | 130 virtual void CheckPPAPIDownloadRequest( |
| 131 const GURL& requestor_url, | 131 const GURL& requestor_url, |
| 132 const GURL& initiating_frame_url, |
| 133 content::WebContents* web_contents, |
| 132 const base::FilePath& default_file_path, | 134 const base::FilePath& default_file_path, |
| 133 const std::vector<base::FilePath::StringType>& alternate_extensions, | 135 const std::vector<base::FilePath::StringType>& alternate_extensions, |
| 134 Profile* profile, | 136 Profile* profile, |
| 135 const CheckDownloadCallback& callback); | 137 const CheckDownloadCallback& callback); |
| 136 | 138 |
| 137 // Display more information to the user regarding the download specified by | 139 // Display more information to the user regarding the download specified by |
| 138 // |info|. This method is invoked when the user requests more information | 140 // |info|. This method is invoked when the user requests more information |
| 139 // about a download that was marked as malicious. | 141 // about a download that was marked as malicious. |
| 140 void ShowDetailsForDownload(const content::DownloadItem& item, | 142 void ShowDetailsForDownload(const content::DownloadItem& item, |
| 141 content::PageNavigator* navigator); | 143 content::PageNavigator* navigator); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 166 | 168 |
| 167 // Registers a callback that will be run when a PPAPI ClientDownloadRequest | 169 // Registers a callback that will be run when a PPAPI ClientDownloadRequest |
| 168 // has been formed. | 170 // has been formed. |
| 169 PPAPIDownloadRequestSubscription RegisterPPAPIDownloadRequestCallback( | 171 PPAPIDownloadRequestSubscription RegisterPPAPIDownloadRequestCallback( |
| 170 const PPAPIDownloadRequestCallback& callback); | 172 const PPAPIDownloadRequestCallback& callback); |
| 171 | 173 |
| 172 double whitelist_sample_rate() const { | 174 double whitelist_sample_rate() const { |
| 173 return whitelist_sample_rate_; | 175 return whitelist_sample_rate_; |
| 174 } | 176 } |
| 175 | 177 |
| 178 scoped_refptr<SafeBrowsingNavigationObserverManager> |
| 179 navigation_observer_manager() { |
| 180 return navigation_observer_manager_; |
| 181 } |
| 182 |
| 176 static void SetDownloadPingToken(content::DownloadItem* item, | 183 static void SetDownloadPingToken(content::DownloadItem* item, |
| 177 const std::string& token); | 184 const std::string& token); |
| 178 | 185 |
| 179 static std::string GetDownloadPingToken(const content::DownloadItem* item); | 186 static std::string GetDownloadPingToken(const content::DownloadItem* item); |
| 180 | 187 |
| 181 protected: | 188 protected: |
| 182 // Enum to keep track why a particular download verdict was chosen. | 189 // Enum to keep track why a particular download verdict was chosen. |
| 183 // Used for UMA metrics. Do not reorder. | 190 // Used for UMA metrics. Do not reorder. |
| 184 enum DownloadCheckResultReason { | 191 enum DownloadCheckResultReason { |
| 185 REASON_INVALID_URL = 0, | 192 REASON_INVALID_URL = 0, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 static GURL GetDownloadRequestUrl(); | 296 static GURL GetDownloadRequestUrl(); |
| 290 | 297 |
| 291 // If kDownloadAttribution feature is enabled, identify and add referrer chain | 298 // If kDownloadAttribution feature is enabled, identify and add referrer chain |
| 292 // info of a download to ClientDownloadRequest proto. This function also | 299 // info of a download to ClientDownloadRequest proto. This function also |
| 293 // records UMA stats of download attribution result. | 300 // records UMA stats of download attribution result. |
| 294 void AddReferrerChainToClientDownloadRequest( | 301 void AddReferrerChainToClientDownloadRequest( |
| 295 const GURL& download_url, | 302 const GURL& download_url, |
| 296 content::WebContents* web_contents, | 303 content::WebContents* web_contents, |
| 297 ClientDownloadRequest* out_request); | 304 ClientDownloadRequest* out_request); |
| 298 | 305 |
| 306 // If kDownloadAttribution feature is enabled, identify referrer chain of the |
| 307 // PPAPI download based on the frame URL where the download is initiated. |
| 308 // Then add referrer chain info to ClientDownloadRequest proto. This function |
| 309 // also records UMA stats of download attribution result. |
| 310 void AddReferrerChainToPPAPIClientDownloadRequest( |
| 311 const GURL& initiating_frame_url, |
| 312 int tab_id, |
| 313 bool has_user_gesture, |
| 314 ClientDownloadRequest* out_request); |
| 315 |
| 299 // These pointers may be NULL if SafeBrowsing is disabled. | 316 // These pointers may be NULL if SafeBrowsing is disabled. |
| 300 scoped_refptr<SafeBrowsingUIManager> ui_manager_; | 317 scoped_refptr<SafeBrowsingUIManager> ui_manager_; |
| 301 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; | 318 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; |
| 302 scoped_refptr<SafeBrowsingNavigationObserverManager> | 319 scoped_refptr<SafeBrowsingNavigationObserverManager> |
| 303 navigation_observer_manager_; | 320 navigation_observer_manager_; |
| 304 | 321 |
| 305 // The context we use to issue network requests. | 322 // The context we use to issue network requests. |
| 306 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 323 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
| 307 | 324 |
| 308 // Set of pending server requests for DownloadManager mediated downloads. | 325 // Set of pending server requests for DownloadManager mediated downloads. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 337 std::set<std::string> manual_blacklist_hashes_; | 354 std::set<std::string> manual_blacklist_hashes_; |
| 338 | 355 |
| 339 // Rate of whitelisted downloads we sample to send out download ping. | 356 // Rate of whitelisted downloads we sample to send out download ping. |
| 340 double whitelist_sample_rate_; | 357 double whitelist_sample_rate_; |
| 341 | 358 |
| 342 DISALLOW_COPY_AND_ASSIGN(DownloadProtectionService); | 359 DISALLOW_COPY_AND_ASSIGN(DownloadProtectionService); |
| 343 }; | 360 }; |
| 344 } // namespace safe_browsing | 361 } // namespace safe_browsing |
| 345 | 362 |
| 346 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ | 363 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ |
| OLD | NEW |