Chromium Code Reviews| 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 #include "chrome/browser/safe_browsing/client_side_detection_host.h" | 5 #include "chrome/browser/safe_browsing/client_side_detection_host.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 database_manager_->MatchCsdWhitelistUrl(url)) { | 169 database_manager_->MatchCsdWhitelistUrl(url)) { |
| 170 // We're done. There is no point in going back to the UI thread. | 170 // We're done. There is no point in going back to the UI thread. |
| 171 VLOG(1) << "Skipping phishing classification for URL: " << url | 171 VLOG(1) << "Skipping phishing classification for URL: " << url |
| 172 << " because it matches the csd whitelist"; | 172 << " because it matches the csd whitelist"; |
| 173 UMA_HISTOGRAM_ENUMERATION("SBClientPhishing.PreClassificationCheckFail", | 173 UMA_HISTOGRAM_ENUMERATION("SBClientPhishing.PreClassificationCheckFail", |
| 174 NO_CLASSIFY_MATCH_CSD_WHITELIST, | 174 NO_CLASSIFY_MATCH_CSD_WHITELIST, |
| 175 NO_CLASSIFY_MAX); | 175 NO_CLASSIFY_MAX); |
| 176 return; | 176 return; |
| 177 } | 177 } |
| 178 | 178 |
| 179 malware_killswitch_on_ = database_manager_->MalwareKillSwitchOn(); | |
| 180 | |
| 179 BrowserThread::PostTask( | 181 BrowserThread::PostTask( |
| 180 BrowserThread::UI, | 182 BrowserThread::UI, |
| 181 FROM_HERE, | 183 FROM_HERE, |
| 182 base::Bind(&ShouldClassifyUrlRequest::CheckCache, this)); | 184 base::Bind(&ShouldClassifyUrlRequest::CheckCache, this)); |
| 183 } | 185 } |
| 184 | 186 |
| 185 void CheckCache() { | 187 void CheckCache() { |
| 186 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 188 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 187 if (canceled_) { | 189 if (canceled_) { |
| 188 return; | 190 return; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 // static | 244 // static |
| 243 ClientSideDetectionHost* ClientSideDetectionHost::Create( | 245 ClientSideDetectionHost* ClientSideDetectionHost::Create( |
| 244 WebContents* tab) { | 246 WebContents* tab) { |
| 245 return new ClientSideDetectionHost(tab); | 247 return new ClientSideDetectionHost(tab); |
| 246 } | 248 } |
| 247 | 249 |
| 248 ClientSideDetectionHost::ClientSideDetectionHost(WebContents* tab) | 250 ClientSideDetectionHost::ClientSideDetectionHost(WebContents* tab) |
| 249 : content::WebContentsObserver(tab), | 251 : content::WebContentsObserver(tab), |
| 250 csd_service_(NULL), | 252 csd_service_(NULL), |
| 251 weak_factory_(this), | 253 weak_factory_(this), |
| 252 unsafe_unique_page_id_(-1) { | 254 unsafe_unique_page_id_(-1), |
| 255 malware_killswitch_on_(false) { | |
| 253 DCHECK(tab); | 256 DCHECK(tab); |
| 254 // Note: csd_service_ and sb_service will be NULL here in testing. | 257 // Note: csd_service_ and sb_service will be NULL here in testing. |
| 255 csd_service_ = g_browser_process->safe_browsing_detection_service(); | 258 csd_service_ = g_browser_process->safe_browsing_detection_service(); |
| 256 feature_extractor_.reset(new BrowserFeatureExtractor(tab, csd_service_)); | 259 feature_extractor_.reset(new BrowserFeatureExtractor(tab, csd_service_)); |
| 257 registrar_.Add(this, content::NOTIFICATION_RESOURCE_RESPONSE_STARTED, | 260 registrar_.Add(this, content::NOTIFICATION_RESOURCE_RESPONSE_STARTED, |
| 258 content::Source<WebContents>(tab)); | 261 content::Source<WebContents>(tab)); |
| 259 | 262 |
| 260 scoped_refptr<SafeBrowsingService> sb_service = | 263 scoped_refptr<SafeBrowsingService> sb_service = |
| 261 g_browser_process->safe_browsing_service(); | 264 g_browser_process->safe_browsing_service(); |
| 262 if (sb_service) { | 265 if (sb_service) { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 DCHECK(browse_info_.get()); | 376 DCHECK(browse_info_.get()); |
| 374 | 377 |
| 375 // We parse the protocol buffer here. If we're unable to parse it we won't | 378 // We parse the protocol buffer here. If we're unable to parse it we won't |
| 376 // send the verdict further. | 379 // send the verdict further. |
| 377 scoped_ptr<ClientPhishingRequest> verdict(new ClientPhishingRequest); | 380 scoped_ptr<ClientPhishingRequest> verdict(new ClientPhishingRequest); |
| 378 if (csd_service_ && | 381 if (csd_service_ && |
| 379 !weak_factory_.HasWeakPtrs() && | 382 !weak_factory_.HasWeakPtrs() && |
| 380 browse_info_.get() && | 383 browse_info_.get() && |
| 381 verdict->ParseFromString(verdict_str) && | 384 verdict->ParseFromString(verdict_str) && |
| 382 verdict->IsInitialized()) { | 385 verdict->IsInitialized()) { |
| 383 scoped_ptr<ClientMalwareRequest> malware_verdict(new ClientMalwareRequest); | 386 // We do the malware IP matching and request sending if the feature |
| 384 // Start browser-side malware feature extraction. Once we're done it will | 387 // is enabled |
| 385 // send the malware client verdict request. | 388 if (!malware_killswitch_on_) { |
|
mattm
2013/05/13 20:39:25
why not just do the database_manager_->MalwareKill
kewang
2013/05/14 08:21:41
I saw the above code where it access the database_
mattm
2013/05/15 07:12:37
Sorry, I think my above comment was incorrect, thi
kewang
2013/05/15 13:45:07
So I kept the code to check switch from database_m
| |
| 386 malware_verdict->set_url(verdict->url()); | 389 scoped_ptr<ClientMalwareRequest> malware_verdict( |
| 387 feature_extractor_->ExtractMalwareFeatures( | 390 new ClientMalwareRequest); |
| 388 browse_info_.get(), | 391 // Start browser-side malware feature extraction. Once we're done it will |
| 389 malware_verdict.get()); | 392 // send the malware client verdict request. |
| 390 MalwareFeatureExtractionDone(malware_verdict.Pass()); | 393 malware_verdict->set_url(verdict->url()); |
| 394 feature_extractor_->ExtractMalwareFeatures( | |
| 395 browse_info_.get(), malware_verdict.get()); | |
| 396 MalwareFeatureExtractionDone(malware_verdict.Pass()); | |
| 397 } | |
| 391 | 398 |
| 392 // We only send phishing verdict to the server if the verdict is phishing or | 399 // We only send phishing verdict to the server if the verdict is phishing or |
| 393 // if a SafeBrowsing interstitial was already shown for this site. E.g., a | 400 // if a SafeBrowsing interstitial was already shown for this site. E.g., a |
| 394 // malware or phishing interstitial was shown but the user clicked | 401 // malware or phishing interstitial was shown but the user clicked |
| 395 // through. | 402 // through. |
| 396 if (verdict->is_phishing() || DidShowSBInterstitial()) { | 403 if (verdict->is_phishing() || DidShowSBInterstitial()) { |
| 397 if (DidShowSBInterstitial()) { | 404 if (DidShowSBInterstitial()) { |
| 398 browse_info_->unsafe_resource.reset(unsafe_resource_.release()); | 405 browse_info_->unsafe_resource.reset(unsafe_resource_.release()); |
| 399 } | 406 } |
| 400 // Start browser-side feature extraction. Once we're done it will send | 407 // Start browser-side feature extraction. Once we're done it will send |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 ui_manager_->RemoveObserver(this); | 537 ui_manager_->RemoveObserver(this); |
| 531 | 538 |
| 532 ui_manager_ = ui_manager; | 539 ui_manager_ = ui_manager; |
| 533 if (ui_manager) | 540 if (ui_manager) |
| 534 ui_manager_->AddObserver(this); | 541 ui_manager_->AddObserver(this); |
| 535 | 542 |
| 536 database_manager_ = database_manager; | 543 database_manager_ = database_manager; |
| 537 } | 544 } |
| 538 | 545 |
| 539 } // namespace safe_browsing | 546 } // namespace safe_browsing |
| OLD | NEW |