diff options
author | lzheng@chromium.org <lzheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-13 23:26:28 +0000 |
---|---|---|
committer | lzheng@chromium.org <lzheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-13 23:26:28 +0000 |
commit | 42930de46c386ff5104138d003486bd12a78c45f (patch) | |
tree | 2859aeaab1dabfabacb32a2799eed0657b1a5bcf /chrome/browser/safe_browsing | |
parent | 869b5b6f67e9dbf02392ab941ff80f959329ea80 (diff) | |
download | chromium_src-42930de46c386ff5104138d003486bd12a78c45f.zip chromium_src-42930de46c386ff5104138d003486bd12a78c45f.tar.gz chromium_src-42930de46c386ff5104138d003486bd12a78c45f.tar.bz2 |
Add support to sha256 hash the downloaded file.
BUG=60822
TEST=base_file_unittest.cc
Review URL: http://codereview.chromium.org/6023006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71379 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/safe_browsing')
-rw-r--r-- | chrome/browser/safe_browsing/safe_browsing_service.cc | 15 | ||||
-rw-r--r-- | chrome/browser/safe_browsing/safe_browsing_service.h | 8 |
2 files changed, 23 insertions, 0 deletions
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc index c4e8eff..a0f8384 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service.cc +++ b/chrome/browser/safe_browsing/safe_browsing_service.cc @@ -47,6 +47,7 @@ const char* const kSbDefaultInfoURLPrefix = const char* const kSbDefaultMacKeyURLPrefix = "https://sb-ssl.google.com/safebrowsing"; +// TODO(lzheng): Replace this with Profile* ProfileManager::GetDefaultProfile(). Profile* GetDefaultProfile() { FilePath user_data_dir; PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); @@ -154,6 +155,20 @@ bool SafeBrowsingService::CanCheckUrl(const GURL& url) const { url.SchemeIs(chrome::kHttpsScheme); } +// Only report SafeBrowsing related stats when UMA is enabled and +// safe browsing is enabled. +bool SafeBrowsingService::CanReportStats() const { + const MetricsService* metrics = g_browser_process->metrics_service(); + const PrefService* pref_service = GetDefaultProfile()->GetPrefs(); + return metrics && metrics->reporting_active() && + pref_service && pref_service->GetBoolean(prefs::kSafeBrowsingEnabled); +} + +// Binhash verification is only enabled for UMA users for now. +bool SafeBrowsingService::DownloadBinHashNeeded() const { + return enable_download_protection_ && CanReportStats(); +} + void SafeBrowsingService::CheckDownloadUrlDone( SafeBrowsingCheck* check, UrlCheckResult result) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); diff --git a/chrome/browser/safe_browsing/safe_browsing_service.h b/chrome/browser/safe_browsing/safe_browsing_service.h index 73eb201..28f74de 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service.h +++ b/chrome/browser/safe_browsing/safe_browsing_service.h @@ -117,6 +117,10 @@ class SafeBrowsingService // Create an instance of the safe browsing service. static SafeBrowsingService* CreateSafeBrowsingService(); + // Called on UI thread to decide if safe browsing related stats + // could be reported. + bool CanReportStats() const; + // Called on the UI thread to initialize the service. void Initialize(); @@ -126,6 +130,10 @@ class SafeBrowsingService // Returns true if the url's scheme can be checked. bool CanCheckUrl(const GURL& url) const; + // Called on UI thread to decide if the download file's sha256 hash + // should be calculated for safebrowsing. + bool DownloadBinHashNeeded() const; + // Called on the IO thread to check if the given url is safe or not. If we // can synchronously determine that the url is safe, CheckUrl returns true. // Otherwise it returns false, and "client" is called asynchronously with the |