| OLD | NEW |
| 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_service.h" | 5 #include "chrome/browser/safe_browsing/client_side_detection_service.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 const base::TimeDelta ClientSideDetectionService::kReportsInterval = | 45 const base::TimeDelta ClientSideDetectionService::kReportsInterval = |
| 46 base::TimeDelta::FromDays(1); | 46 base::TimeDelta::FromDays(1); |
| 47 const base::TimeDelta ClientSideDetectionService::kNegativeCacheInterval = | 47 const base::TimeDelta ClientSideDetectionService::kNegativeCacheInterval = |
| 48 base::TimeDelta::FromDays(1); | 48 base::TimeDelta::FromDays(1); |
| 49 const base::TimeDelta ClientSideDetectionService::kPositiveCacheInterval = | 49 const base::TimeDelta ClientSideDetectionService::kPositiveCacheInterval = |
| 50 base::TimeDelta::FromMinutes(30); | 50 base::TimeDelta::FromMinutes(30); |
| 51 | 51 |
| 52 const char ClientSideDetectionService::kClientReportPhishingUrl[] = | 52 const char ClientSideDetectionService::kClientReportPhishingUrl[] = |
| 53 "https://sb-ssl.google.com/safebrowsing/clientreport/phishing"; | 53 "https://sb-ssl.google.com/safebrowsing/clientreport/phishing"; |
| 54 // Note: when updatng the model version, don't forget to change the filename | |
| 55 // in chrome/common/chrome_constants.cc as well, or else existing users won't | |
| 56 // download the new model. | |
| 57 const char ClientSideDetectionService::kClientModelUrl[] = | 54 const char ClientSideDetectionService::kClientModelUrl[] = |
| 58 "https://ssl.gstatic.com/safebrowsing/csd/client_model_v3.pb"; | 55 "https://ssl.gstatic.com/safebrowsing/csd/client_model_v4.pb"; |
| 59 | 56 |
| 60 struct ClientSideDetectionService::ClientReportInfo { | 57 struct ClientSideDetectionService::ClientReportInfo { |
| 61 scoped_ptr<ClientReportPhishingRequestCallback> callback; | 58 scoped_ptr<ClientReportPhishingRequestCallback> callback; |
| 62 GURL phishing_url; | 59 GURL phishing_url; |
| 63 }; | 60 }; |
| 64 | 61 |
| 65 ClientSideDetectionService::CacheState::CacheState(bool phish, base::Time time) | 62 ClientSideDetectionService::CacheState::CacheState(bool phish, base::Time time) |
| 66 : is_phishing(phish), | 63 : is_phishing(phish), |
| 67 timestamp(time) {} | 64 timestamp(time) {} |
| 68 | 65 |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 model.rule(i).feature(j) > max_index) { | 591 model.rule(i).feature(j) > max_index) { |
| 595 return false; | 592 return false; |
| 596 } | 593 } |
| 597 } | 594 } |
| 598 } | 595 } |
| 599 for (int i = 0; i < model.page_term_size(); ++i) { | 596 for (int i = 0; i < model.page_term_size(); ++i) { |
| 600 if (model.page_term(i) < 0 || model.page_term(i) > max_index) { | 597 if (model.page_term(i) < 0 || model.page_term(i) > max_index) { |
| 601 return false; | 598 return false; |
| 602 } | 599 } |
| 603 } | 600 } |
| 604 for (int i = 0; i < model.page_word_size(); ++i) { | |
| 605 if (model.page_word(i) < 0 || model.page_word(i) > max_index) { | |
| 606 return false; | |
| 607 } | |
| 608 } | |
| 609 return true; | 601 return true; |
| 610 } | 602 } |
| 611 | 603 |
| 612 // static | 604 // static |
| 613 bool ClientSideDetectionService::IsFalsePositiveResponse( | 605 bool ClientSideDetectionService::IsFalsePositiveResponse( |
| 614 const GURL& url, | 606 const GURL& url, |
| 615 const ClientPhishingResponse& response) { | 607 const ClientPhishingResponse& response) { |
| 616 if (!response.phishy() || response.whitelist_expression_size() == 0) { | 608 if (!response.phishy() || response.whitelist_expression_size() == 0) { |
| 617 return false; | 609 return false; |
| 618 } | 610 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 648 &whitelist_patterns); | 640 &whitelist_patterns); |
| 649 for (size_t j = 0; j < whitelist_patterns.size(); ++j) { | 641 for (size_t j = 0; j < whitelist_patterns.size(); ++j) { |
| 650 if (whitelist_patterns[j] == canonical_url_as_pattern) { | 642 if (whitelist_patterns[j] == canonical_url_as_pattern) { |
| 651 return true; | 643 return true; |
| 652 } | 644 } |
| 653 } | 645 } |
| 654 } | 646 } |
| 655 return false; | 647 return false; |
| 656 } | 648 } |
| 657 } // namespace safe_browsing | 649 } // namespace safe_browsing |
| OLD | NEW |