Chromium Code Reviews| Index: chrome/browser/safe_browsing/client_side_detection_host.cc |
| diff --git a/chrome/browser/safe_browsing/client_side_detection_host.cc b/chrome/browser/safe_browsing/client_side_detection_host.cc |
| index 6eeb6f7d60d378e3f65a3ec079a2dce0472dd0cd..114715b426603a6bbce3a004e6ae6f1ead54582b 100644 |
| --- a/chrome/browser/safe_browsing/client_side_detection_host.cc |
| +++ b/chrome/browser/safe_browsing/client_side_detection_host.cc |
| @@ -12,6 +12,7 @@ |
| #include "base/metrics/histogram.h" |
| #include "base/prefs/pref_service.h" |
| #include "base/sequenced_task_runner_helpers.h" |
| +#include "base/strings/utf_string_conversions.h" |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/safe_browsing/browser_feature_extractor.h" |
| @@ -47,6 +48,8 @@ namespace safe_browsing { |
| const int ClientSideDetectionHost::kMaxUrlsPerIP = 20; |
| const int ClientSideDetectionHost::kMaxIPsPerBrowse = 200; |
| +const char kSafeBrowsingHitKey[] = "safe_browsing_hit"; |
|
mattm
2013/12/14 00:09:49
s/hit/match/
Greg Billock
2013/12/14 18:35:34
Done.
|
| + |
| // This class is instantiated each time a new toplevel URL loads, and |
| // asynchronously checks whether the phishing classifier should run for this |
| // URL. If so, it notifies the renderer with a StartPhishingDetection IPC. |
| @@ -248,8 +251,7 @@ ClientSideDetectionHost::ClientSideDetectionHost(WebContents* tab) |
| weak_factory_(this), |
| unsafe_unique_page_id_(-1), |
| malware_killswitch_on_(false), |
| - malware_report_enabled_(false), |
| - malware_or_phishing_match_(false) { |
| + malware_report_enabled_(false) { |
| DCHECK(tab); |
| // Note: csd_service_ and sb_service will be NULL here in testing. |
| csd_service_ = g_browser_process->safe_browsing_detection_service(); |
| @@ -291,8 +293,6 @@ bool ClientSideDetectionHost::OnMessageReceived(const IPC::Message& message) { |
| void ClientSideDetectionHost::DidNavigateMainFrame( |
| const content::LoadCommittedDetails& details, |
| const content::FrameNavigateParams& params) { |
| - malware_or_phishing_match_ = false; |
| - |
| // TODO(noelutz): move this DCHECK to WebContents and fix all the unit tests |
| // that don't call this method on the UI thread. |
| // DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| @@ -355,6 +355,9 @@ void ClientSideDetectionHost::OnSafeBrowsingHit( |
| // Store the unique page ID for later. |
| unsafe_unique_page_id_ = |
| web_contents()->GetController().GetActiveEntry()->GetUniqueID(); |
| + web_contents()->GetController().GetActiveEntry()->SetExtraData( |
| + kSafeBrowsingHitKey, base::ASCIIToUTF16("1")); |
|
mattm
2013/12/14 00:09:49
This shouldn't be necessary (OnSafeBrowsingMatch s
Greg Billock
2013/12/14 18:35:34
Done.
|
| + |
| // We also keep the resource around in order to be able to send the |
| // malicious URL to the server. |
| unsafe_resource_.reset(new SafeBrowsingUIManager::UnsafeResource(resource)); |
| @@ -363,7 +366,8 @@ void ClientSideDetectionHost::OnSafeBrowsingHit( |
| void ClientSideDetectionHost::OnSafeBrowsingMatch( |
| const SafeBrowsingUIManager::UnsafeResource& resource) { |
|
mattm
2013/12/14 00:09:49
derp. Doesn't this function also need to do the ch
Greg Billock
2013/12/14 18:35:34
Looks like we should do if (!web_contents || !wc..
mattm
2013/12/16 22:36:11
OnSafeBrowsingMatch and OnSafeBrowsingHit are both
Greg Billock
2013/12/16 23:00:21
Ah, I see what you mean. OK, done.
|
| - malware_or_phishing_match_ = true; |
| + web_contents()->GetController().GetActiveEntry()->SetExtraData( |
|
mattm
2013/12/14 00:09:49
also do null checks like OnSafeBrowsingHit does
Greg Billock
2013/12/14 18:35:34
Done.
|
| + kSafeBrowsingHitKey, base::ASCIIToUTF16("1")); |
| } |
| scoped_refptr<SafeBrowsingDatabaseManager> |
| @@ -372,7 +376,16 @@ ClientSideDetectionHost::database_manager() { |
| } |
| bool ClientSideDetectionHost::DidPageReceiveSafeBrowsingMatch() const { |
|
mattm
2013/12/14 00:09:49
nit: probably would be cleaner if it first just go
mattm
2013/12/14 00:09:49
null checks here too.
Greg Billock
2013/12/14 18:35:34
Done.
Greg Billock
2013/12/14 18:35:34
Done.
|
| - return malware_or_phishing_match_ || DidShowSBInterstitial(); |
| + if (web_contents()->GetController().GetPendingEntry()) { |
|
mattm
2013/12/14 00:09:49
GetActiveEntry will already return the pending ent
Greg Billock
2013/12/14 18:35:34
Yes, the transient entries are the reason for this
mattm
2013/12/16 22:36:11
Yeah, I didn't understand the comment. Maybe somet
Greg Billock
2013/12/16 23:00:21
I think I always want to check Pending if there is
mattm
2013/12/16 23:28:51
Sorry, my comment neglected a point. In the case I
Greg Billock
2013/12/16 23:59:42
Are there any such cases? That is, can we basicall
mattm
2013/12/17 00:09:19
Yeah, a safebrowsing match can occur either on a p
Greg Billock
2013/12/17 00:18:32
Cool. Yeah, I added a test for that case. Thanks!
|
| + // Check the pending entry if we are displaying an interstitial page. |
|
mattm
2013/12/14 00:09:49
Comment is a little confusing as it might not actu
Greg Billock
2013/12/14 18:35:34
Yeah, this is for the other case -- that case shou
|
| + base::string16 value; |
| + return web_contents()->GetController().GetPendingEntry()->GetExtraData( |
| + kSafeBrowsingHitKey, &value); |
| + } |
| + |
| + base::string16 value; |
| + return web_contents()->GetController().GetActiveEntry()->GetExtraData( |
| + kSafeBrowsingHitKey, &value); |
| } |
| void ClientSideDetectionHost::WebContentsDestroyed(WebContents* tab) { |