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

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

Issue 1488923002: Remove unused DidPageReceiveSafeBrowsingMatch code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
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 27 matching lines...) Expand all
38 using content::NavigationEntry; 38 using content::NavigationEntry;
39 using content::ResourceRequestDetails; 39 using content::ResourceRequestDetails;
40 using content::ResourceType; 40 using content::ResourceType;
41 using content::WebContents; 41 using content::WebContents;
42 42
43 namespace safe_browsing { 43 namespace safe_browsing {
44 44
45 const size_t ClientSideDetectionHost::kMaxUrlsPerIP = 20; 45 const size_t ClientSideDetectionHost::kMaxUrlsPerIP = 20;
46 const size_t ClientSideDetectionHost::kMaxIPsPerBrowse = 200; 46 const size_t ClientSideDetectionHost::kMaxIPsPerBrowse = 200;
47 47
48 const char kSafeBrowsingMatchKey[] = "safe_browsing_match";
49
50 typedef base::Callback<void(bool)> ShouldClassifyUrlCallback; 48 typedef base::Callback<void(bool)> ShouldClassifyUrlCallback;
51 49
52 // This class is instantiated each time a new toplevel URL loads, and 50 // This class is instantiated each time a new toplevel URL loads, and
53 // asynchronously checks whether the malware and phishing classifiers should run 51 // asynchronously checks whether the malware and phishing classifiers should run
54 // for this URL. If so, it notifies the host class by calling the provided 52 // for this URL. If so, it notifies the host class by calling the provided
55 // callback form the UI thread. Objects of this class are ref-counted and will 53 // callback form the UI thread. Objects of this class are ref-counted and will
56 // be destroyed once nobody uses it anymore. If |web_contents|, |csd_service| 54 // be destroyed once nobody uses it anymore. If |web_contents|, |csd_service|
57 // or |host| go away you need to call Cancel(). We keep the |database_manager| 55 // or |host| go away you need to call Cancel(). We keep the |database_manager|
58 // alive in a ref pointer for as long as it takes. 56 // alive in a ref pointer for as long as it takes.
59 class ClientSideDetectionHost::ShouldClassifyUrlRequest 57 class ClientSideDetectionHost::ShouldClassifyUrlRequest
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 // Store the unique page ID for later. 423 // Store the unique page ID for later.
426 unsafe_unique_page_id_ = 424 unsafe_unique_page_id_ =
427 web_contents()->GetController().GetActiveEntry()->GetUniqueID(); 425 web_contents()->GetController().GetActiveEntry()->GetUniqueID();
428 426
429 // We also keep the resource around in order to be able to send the 427 // We also keep the resource around in order to be able to send the
430 // malicious URL to the server. 428 // malicious URL to the server.
431 unsafe_resource_.reset(new SafeBrowsingUIManager::UnsafeResource(resource)); 429 unsafe_resource_.reset(new SafeBrowsingUIManager::UnsafeResource(resource));
432 unsafe_resource_->callback.Reset(); // Don't do anything stupid. 430 unsafe_resource_->callback.Reset(); // Don't do anything stupid.
433 } 431 }
434 432
435 void ClientSideDetectionHost::OnSafeBrowsingMatch( 433 void ClientSideDetectionHost::OnSafeBrowsingMatch(
Nathan Parker 2015/12/03 17:21:20 Can this method be removed altogether (from the ob
mattm 2015/12/03 20:38:36 Yeah, it could be. I'll do that in a separate CL s
436 const SafeBrowsingUIManager::UnsafeResource& resource) { 434 const SafeBrowsingUIManager::UnsafeResource& resource) {}
437 if (!web_contents() || !web_contents()->GetController().GetActiveEntry())
438 return;
439
440 // Check that this notification is really for us.
441 content::RenderViewHost* hit_rvh = content::RenderViewHost::FromID(
442 resource.render_process_host_id, resource.render_view_id);
443 if (!hit_rvh ||
444 web_contents() != content::WebContents::FromRenderViewHost(hit_rvh))
445 return;
446
447 web_contents()->GetController().GetActiveEntry()->SetExtraData(
448 kSafeBrowsingMatchKey, base::ASCIIToUTF16("1"));
449 }
450 435
451 scoped_refptr<SafeBrowsingDatabaseManager> 436 scoped_refptr<SafeBrowsingDatabaseManager>
452 ClientSideDetectionHost::database_manager() { 437 ClientSideDetectionHost::database_manager() {
453 return database_manager_; 438 return database_manager_;
454 } 439 }
455 440
456 bool ClientSideDetectionHost::DidPageReceiveSafeBrowsingMatch() const {
457 if (!web_contents() || !web_contents()->GetController().GetVisibleEntry())
458 return false;
459
460 // If an interstitial page is showing, GetVisibleEntry will return the
461 // transient NavigationEntry for the interstitial. The transient entry
462 // will not have the flag set, so use the pending entry instead if there
463 // is one.
464 NavigationEntry* entry = web_contents()->GetController().GetPendingEntry();
465 if (!entry) {
466 entry = web_contents()->GetController().GetVisibleEntry();
467 if (entry->GetPageType() == content::PAGE_TYPE_INTERSTITIAL)
468 entry = web_contents()->GetController().GetLastCommittedEntry();
469 if (!entry)
470 return false;
471 }
472
473 base::string16 value;
474 return entry->GetExtraData(kSafeBrowsingMatchKey, &value);
475 }
476
477 void ClientSideDetectionHost::WebContentsDestroyed() { 441 void ClientSideDetectionHost::WebContentsDestroyed() {
478 // Tell any pending classification request that it is being canceled. 442 // Tell any pending classification request that it is being canceled.
479 if (classification_request_.get()) { 443 if (classification_request_.get()) {
480 classification_request_->Cancel(); 444 classification_request_->Cancel();
481 } 445 }
482 // Cancel all pending feature extractions. 446 // Cancel all pending feature extractions.
483 feature_extractor_.reset(); 447 feature_extractor_.reset();
484 } 448 }
485 449
486 void ClientSideDetectionHost::OnPhishingPreClassificationDone( 450 void ClientSideDetectionHost::OnPhishingPreClassificationDone(
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 ui_manager_->RemoveObserver(this); 693 ui_manager_->RemoveObserver(this);
730 694
731 ui_manager_ = ui_manager; 695 ui_manager_ = ui_manager;
732 if (ui_manager) 696 if (ui_manager)
733 ui_manager_->AddObserver(this); 697 ui_manager_->AddObserver(this);
734 698
735 database_manager_ = database_manager; 699 database_manager_ = database_manager;
736 } 700 }
737 701
738 } // namespace safe_browsing 702 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698