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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_service.cc

Issue 4822002: Send malware reports when a user opts-in from the safe browsing interstitial ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years 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
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/safe_browsing/safe_browsing_service.h" 5 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/browser_thread.h" 13 #include "chrome/browser/browser_thread.h"
14 #include "chrome/browser/metrics/metrics_service.h" 14 #include "chrome/browser/metrics/metrics_service.h"
15 #include "chrome/browser/prefs/pref_service.h" 15 #include "chrome/browser/prefs/pref_service.h"
16 #include "chrome/browser/profiles/profile_manager.h" 16 #include "chrome/browser/profiles/profile_manager.h"
17 #include "chrome/browser/safe_browsing/malware_details.h"
17 #include "chrome/browser/safe_browsing/protocol_manager.h" 18 #include "chrome/browser/safe_browsing/protocol_manager.h"
18 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" 19 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
19 #include "chrome/browser/safe_browsing/safe_browsing_database.h" 20 #include "chrome/browser/safe_browsing/safe_browsing_database.h"
20 #include "chrome/browser/tab_contents/tab_util.h" 21 #include "chrome/browser/tab_contents/tab_util.h"
21 #include "chrome/browser/tab_contents/tab_contents.h" 22 #include "chrome/browser/tab_contents/tab_contents.h"
22 #include "chrome/common/chrome_constants.h" 23 #include "chrome/common/chrome_constants.h"
23 #include "chrome/common/chrome_paths.h" 24 #include "chrome/common/chrome_paths.h"
24 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/net/url_request_context_getter.h" 26 #include "chrome/common/net/url_request_context_getter.h"
26 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
27 #include "chrome/common/url_constants.h" 28 #include "chrome/common/url_constants.h"
28 #include "net/base/registry_controlled_domain.h" 29 #include "net/base/registry_controlled_domain.h"
29 30
30 #if defined(OS_WIN) 31 #if defined(OS_WIN)
31 #include "chrome/installer/util/browser_distribution.h" 32 #include "chrome/installer/util/browser_distribution.h"
32 #endif 33 #endif
33 34
34 using base::Time; 35 using base::Time;
35 using base::TimeDelta; 36 using base::TimeDelta;
36 37
37 // The default URL prefix where browser fetches chunk updates, hashes, 38 // The default URL prefix where browser fetches chunk updates, hashes,
38 // and reports malware. 39 // and reports safe browsing hits.
39 static const char* const kSbDefaultInfoURLPrefix = 40 static const char* const kSbDefaultInfoURLPrefix =
40 "http://safebrowsing.clients.google.com/safebrowsing"; 41 "http://safebrowsing.clients.google.com/safebrowsing";
41 42
42 // The default URL prefix where browser fetches MAC client key. 43 // The default URL prefix where browser fetches MAC client key and reports
44 // malware details.
43 static const char* const kSbDefaultMacKeyURLPrefix = 45 static const char* const kSbDefaultMacKeyURLPrefix =
44 "https://sb-ssl.google.com/safebrowsing"; 46 "https://sb-ssl.google.com/safebrowsing";
45 47
46 static Profile* GetDefaultProfile() { 48 static Profile* GetDefaultProfile() {
47 FilePath user_data_dir; 49 FilePath user_data_dir;
48 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); 50 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
49 ProfileManager* profile_manager = g_browser_process->profile_manager(); 51 ProfileManager* profile_manager = g_browser_process->profile_manager();
50 return profile_manager->GetDefaultProfile(user_data_dir); 52 return profile_manager->GetDefaultProfile(user_data_dir);
51 } 53 }
52 54
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 resource.url, 840 resource.url,
839 page_url, 841 page_url,
840 referrer_url, 842 referrer_url,
841 is_subresource, 843 is_subresource,
842 resource.threat_type)); 844 resource.threat_type));
843 } 845 }
844 846
845 SafeBrowsingBlockingPage::ShowBlockingPage(this, resource); 847 SafeBrowsingBlockingPage::ShowBlockingPage(this, resource);
846 } 848 }
847 849
850 // A safebrowsing hit is sent right after we create a blocking page,
851 // only for UMA users.
848 void SafeBrowsingService::ReportSafeBrowsingHit( 852 void SafeBrowsingService::ReportSafeBrowsingHit(
849 const GURL& malicious_url, 853 const GURL& malicious_url,
850 const GURL& page_url, 854 const GURL& page_url,
851 const GURL& referrer_url, 855 const GURL& referrer_url,
852 bool is_subresource, 856 bool is_subresource,
853 SafeBrowsingService::UrlCheckResult threat_type) { 857 SafeBrowsingService::UrlCheckResult threat_type) {
854 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 858 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
855 if (!enabled_) 859 if (!enabled_)
856 return; 860 return;
857 861
858 DVLOG(1) << "ReportSafeBrowsingHit: " << malicious_url << " " << page_url 862 DVLOG(1) << "ReportSafeBrowsingHit: " << malicious_url << " " << page_url
859 << " " << referrer_url << " " << is_subresource << " " 863 << " " << referrer_url << " " << is_subresource << " "
860 << threat_type; 864 << threat_type;
861 protocol_manager_->ReportSafeBrowsingHit(malicious_url, page_url, 865 protocol_manager_->ReportSafeBrowsingHit(malicious_url, page_url,
862 referrer_url, is_subresource, 866 referrer_url, is_subresource,
863 threat_type); 867 threat_type);
864 } 868 }
869
870 // A MalwareDetails report is sent after the blocking page is going
871 // away, at which point we see if the user had opted-in using the
872 // checkbox on the blocking page.
873 void SafeBrowsingService::ReportMalwareDetails(
874 scoped_refptr<MalwareDetails> details) {
875 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
876 scoped_ptr<const std::string> serialized(details->GetSerializedReport());
877 if (!serialized->empty()) {
878 DVLOG(1) << "Sending serialized malware details.";
879 protocol_manager_->ReportMalwareDetails(*serialized);
880 }
881 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698