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

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

Issue 7538009: Send back the URL that matched the SafeBrowsing list with the CSD ping. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Matt's comments. Created 9 years, 4 months 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 if (tab_contents() && 345 if (tab_contents() &&
346 tab_contents()->GetRenderProcessHost()->id() == 346 tab_contents()->GetRenderProcessHost()->id() ==
347 resource.render_process_host_id && 347 resource.render_process_host_id &&
348 tab_contents()->render_view_host()->routing_id() == 348 tab_contents()->render_view_host()->routing_id() ==
349 resource.render_view_id && 349 resource.render_view_id &&
350 (resource.threat_type == SafeBrowsingService::URL_PHISHING || 350 (resource.threat_type == SafeBrowsingService::URL_PHISHING ||
351 resource.threat_type == SafeBrowsingService::URL_MALWARE) && 351 resource.threat_type == SafeBrowsingService::URL_MALWARE) &&
352 tab_contents()->controller().GetActiveEntry()) { 352 tab_contents()->controller().GetActiveEntry()) {
353 unsafe_unique_page_id_ = 353 unsafe_unique_page_id_ =
354 tab_contents()->controller().GetActiveEntry()->unique_id(); 354 tab_contents()->controller().GetActiveEntry()->unique_id();
355 // We also keep the resource around in order to be able to send the
356 // malicious URL to the server.
357 unsafe_resource_.reset(new SafeBrowsingService::UnsafeResource(resource));
358 unsafe_resource_->client = NULL; // Make sure we don't do anything stupid.
355 } 359 }
356 } 360 }
357 361
358 void ClientSideDetectionHost::TabContentsDestroyed(TabContents* tab) { 362 void ClientSideDetectionHost::TabContentsDestroyed(TabContents* tab) {
359 DCHECK(tab); 363 DCHECK(tab);
360 // Tell any pending classification request that it is being canceled. 364 // Tell any pending classification request that it is being canceled.
361 if (classification_request_.get()) { 365 if (classification_request_.get()) {
362 classification_request_->Cancel(); 366 classification_request_->Cancel();
363 } 367 }
364 // Cancel all pending feature extractions. 368 // Cancel all pending feature extractions.
(...skipping 18 matching lines...) Expand all
383 if (csd_service_ && 387 if (csd_service_ &&
384 !cb_factory_.HasPendingCallbacks() && 388 !cb_factory_.HasPendingCallbacks() &&
385 browse_info_.get() && 389 browse_info_.get() &&
386 verdict->ParseFromString(verdict_str) && 390 verdict->ParseFromString(verdict_str) &&
387 verdict->IsInitialized() && 391 verdict->IsInitialized() &&
388 // We only send the verdict to the server if the verdict is phishing or if 392 // We only send the verdict to the server if the verdict is phishing or if
389 // a SafeBrowsing interstitial was already shown for this site. E.g., a 393 // a SafeBrowsing interstitial was already shown for this site. E.g., a
390 // malware or phishing interstitial was shown but the user clicked 394 // malware or phishing interstitial was shown but the user clicked
391 // through. 395 // through.
392 (verdict->is_phishing() || DidShowSBInterstitial())) { 396 (verdict->is_phishing() || DidShowSBInterstitial())) {
397 if (DidShowSBInterstitial()) {
398 browse_info_->unsafe_resource.reset(unsafe_resource_.release());
399 }
393 // Start browser-side feature extraction. Once we're done it will send 400 // Start browser-side feature extraction. Once we're done it will send
394 // the client verdict request. 401 // the client verdict request.
395 feature_extractor_->ExtractFeatures( 402 feature_extractor_->ExtractFeatures(
396 browse_info_.get(), 403 browse_info_.get(),
397 verdict.release(), 404 verdict.release(),
398 NewCallback(this, &ClientSideDetectionHost::FeatureExtractionDone)); 405 NewCallback(this, &ClientSideDetectionHost::FeatureExtractionDone));
399 } 406 }
400 browse_info_.reset(); 407 browse_info_.reset();
401 } 408 }
402 409
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 if (sb_service_) { 488 if (sb_service_) {
482 sb_service_->RemoveObserver(this); 489 sb_service_->RemoveObserver(this);
483 } 490 }
484 sb_service_ = service; 491 sb_service_ = service;
485 if (sb_service_) { 492 if (sb_service_) {
486 sb_service_->AddObserver(this); 493 sb_service_->AddObserver(this);
487 } 494 }
488 } 495 }
489 496
490 } // namespace safe_browsing 497 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698