| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 database_manager_->MatchCsdWhitelistUrl(url)) { | 170 database_manager_->MatchCsdWhitelistUrl(url)) { |
| 171 // We're done. There is no point in going back to the UI thread. | 171 // We're done. There is no point in going back to the UI thread. |
| 172 VLOG(1) << "Skipping phishing classification for URL: " << url | 172 VLOG(1) << "Skipping phishing classification for URL: " << url |
| 173 << " because it matches the csd whitelist"; | 173 << " because it matches the csd whitelist"; |
| 174 UMA_HISTOGRAM_ENUMERATION("SBClientPhishing.PreClassificationCheckFail", | 174 UMA_HISTOGRAM_ENUMERATION("SBClientPhishing.PreClassificationCheckFail", |
| 175 NO_CLASSIFY_MATCH_CSD_WHITELIST, | 175 NO_CLASSIFY_MATCH_CSD_WHITELIST, |
| 176 NO_CLASSIFY_MAX); | 176 NO_CLASSIFY_MAX); |
| 177 return; | 177 return; |
| 178 } | 178 } |
| 179 | 179 |
| 180 host_->malware_killswitch_on_ = database_manager_->MalwareKillSwitchOn(); |
| 181 |
| 180 BrowserThread::PostTask( | 182 BrowserThread::PostTask( |
| 181 BrowserThread::UI, | 183 BrowserThread::UI, |
| 182 FROM_HERE, | 184 FROM_HERE, |
| 183 base::Bind(&ShouldClassifyUrlRequest::CheckCache, this)); | 185 base::Bind(&ShouldClassifyUrlRequest::CheckCache, this)); |
| 184 } | 186 } |
| 185 | 187 |
| 186 void CheckCache() { | 188 void CheckCache() { |
| 187 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 189 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 188 if (canceled_) { | 190 if (canceled_) { |
| 189 return; | 191 return; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 ClientSideDetectionHost* ClientSideDetectionHost::Create( | 246 ClientSideDetectionHost* ClientSideDetectionHost::Create( |
| 245 WebContents* tab) { | 247 WebContents* tab) { |
| 246 return new ClientSideDetectionHost(tab); | 248 return new ClientSideDetectionHost(tab); |
| 247 } | 249 } |
| 248 | 250 |
| 249 ClientSideDetectionHost::ClientSideDetectionHost(WebContents* tab) | 251 ClientSideDetectionHost::ClientSideDetectionHost(WebContents* tab) |
| 250 : content::WebContentsObserver(tab), | 252 : content::WebContentsObserver(tab), |
| 251 csd_service_(NULL), | 253 csd_service_(NULL), |
| 252 weak_factory_(this), | 254 weak_factory_(this), |
| 253 unsafe_unique_page_id_(-1), | 255 unsafe_unique_page_id_(-1), |
| 256 malware_killswitch_on_(false), |
| 254 malware_report_enabled_(false) { | 257 malware_report_enabled_(false) { |
| 255 DCHECK(tab); | 258 DCHECK(tab); |
| 256 // Note: csd_service_ and sb_service will be NULL here in testing. | 259 // Note: csd_service_ and sb_service will be NULL here in testing. |
| 257 csd_service_ = g_browser_process->safe_browsing_detection_service(); | 260 csd_service_ = g_browser_process->safe_browsing_detection_service(); |
| 258 feature_extractor_.reset(new BrowserFeatureExtractor(tab, csd_service_)); | 261 feature_extractor_.reset(new BrowserFeatureExtractor(tab, csd_service_)); |
| 259 registrar_.Add(this, content::NOTIFICATION_RESOURCE_RESPONSE_STARTED, | 262 registrar_.Add(this, content::NOTIFICATION_RESOURCE_RESPONSE_STARTED, |
| 260 content::Source<WebContents>(tab)); | 263 content::Source<WebContents>(tab)); |
| 261 | 264 |
| 262 scoped_refptr<SafeBrowsingService> sb_service = | 265 scoped_refptr<SafeBrowsingService> sb_service = |
| 263 g_browser_process->safe_browsing_service(); | 266 g_browser_process->safe_browsing_service(); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 DCHECK(browse_info_.get()); | 385 DCHECK(browse_info_.get()); |
| 383 | 386 |
| 384 // We parse the protocol buffer here. If we're unable to parse it we won't | 387 // We parse the protocol buffer here. If we're unable to parse it we won't |
| 385 // send the verdict further. | 388 // send the verdict further. |
| 386 scoped_ptr<ClientPhishingRequest> verdict(new ClientPhishingRequest); | 389 scoped_ptr<ClientPhishingRequest> verdict(new ClientPhishingRequest); |
| 387 if (csd_service_ && | 390 if (csd_service_ && |
| 388 !weak_factory_.HasWeakPtrs() && | 391 !weak_factory_.HasWeakPtrs() && |
| 389 browse_info_.get() && | 392 browse_info_.get() && |
| 390 verdict->ParseFromString(verdict_str) && | 393 verdict->ParseFromString(verdict_str) && |
| 391 verdict->IsInitialized()) { | 394 verdict->IsInitialized()) { |
| 392 if (malware_report_enabled_) { | 395 // We do the malware IP matching and request sending if the feature |
| 396 // is enabled |
| 397 if (malware_report_enabled_ && !malware_killswitch_on_) { |
| 393 scoped_ptr<ClientMalwareRequest> malware_verdict( | 398 scoped_ptr<ClientMalwareRequest> malware_verdict( |
| 394 new ClientMalwareRequest); | 399 new ClientMalwareRequest); |
| 395 // Start browser-side malware feature extraction. Once we're done it will | 400 // Start browser-side malware feature extraction. Once we're done it will |
| 396 // send the malware client verdict request. | 401 // send the malware client verdict request. |
| 397 malware_verdict->set_url(verdict->url()); | 402 malware_verdict->set_url(verdict->url()); |
| 398 feature_extractor_->ExtractMalwareFeatures( | 403 feature_extractor_->ExtractMalwareFeatures( |
| 399 browse_info_.get(), | 404 browse_info_.get(), malware_verdict.get()); |
| 400 malware_verdict.get()); | |
| 401 MalwareFeatureExtractionDone(malware_verdict.Pass()); | 405 MalwareFeatureExtractionDone(malware_verdict.Pass()); |
| 402 } | 406 } |
| 403 | 407 |
| 404 // We only send phishing verdict to the server if the verdict is phishing or | 408 // We only send phishing verdict to the server if the verdict is phishing or |
| 405 // if a SafeBrowsing interstitial was already shown for this site. E.g., a | 409 // if a SafeBrowsing interstitial was already shown for this site. E.g., a |
| 406 // malware or phishing interstitial was shown but the user clicked | 410 // malware or phishing interstitial was shown but the user clicked |
| 407 // through. | 411 // through. |
| 408 if (verdict->is_phishing() || DidShowSBInterstitial()) { | 412 if (verdict->is_phishing() || DidShowSBInterstitial()) { |
| 409 if (DidShowSBInterstitial()) { | 413 if (DidShowSBInterstitial()) { |
| 410 browse_info_->unsafe_resource.reset(unsafe_resource_.release()); | 414 browse_info_->unsafe_resource.reset(unsafe_resource_.release()); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 ui_manager_->RemoveObserver(this); | 546 ui_manager_->RemoveObserver(this); |
| 543 | 547 |
| 544 ui_manager_ = ui_manager; | 548 ui_manager_ = ui_manager; |
| 545 if (ui_manager) | 549 if (ui_manager) |
| 546 ui_manager_->AddObserver(this); | 550 ui_manager_->AddObserver(this); |
| 547 | 551 |
| 548 database_manager_ = database_manager; | 552 database_manager_ = database_manager; |
| 549 } | 553 } |
| 550 | 554 |
| 551 } // namespace safe_browsing | 555 } // namespace safe_browsing |
| OLD | NEW |