| 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/protocol_manager.h" | 5 #include "chrome/browser/safe_browsing/protocol_manager.h" |
| 6 | 6 |
| 7 #include "base/environment.h" | 7 #include "base/environment.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| 11 #include "base/metrics/sparse_histogram.h" | 11 #include "base/metrics/sparse_histogram.h" |
| 12 #include "base/profiler/scoped_tracker.h" | 12 #include "base/profiler/scoped_tracker.h" |
| 13 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
| 14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 18 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
| 19 #include "chrome/browser/safe_browsing/protocol_parser.h" | 19 #include "chrome/browser/safe_browsing/protocol_parser.h" |
| 20 #include "chrome/common/env_vars.h" | 20 #include "chrome/common/env_vars.h" |
| 21 #include "components/safe_browsing_db/util.h" | |
| 22 #include "components/variations/variations_associated_data.h" | 21 #include "components/variations/variations_associated_data.h" |
| 23 #include "google_apis/google_api_keys.h" | 22 #include "google_apis/google_api_keys.h" |
| 24 #include "net/base/escape.h" | 23 #include "net/base/escape.h" |
| 25 #include "net/base/load_flags.h" | 24 #include "net/base/load_flags.h" |
| 26 #include "net/base/net_errors.h" | 25 #include "net/base/net_errors.h" |
| 27 #include "net/http/http_response_headers.h" | 26 #include "net/http/http_response_headers.h" |
| 28 #include "net/http/http_status_code.h" | 27 #include "net/http/http_status_code.h" |
| 29 #include "net/url_request/url_fetcher.h" | 28 #include "net/url_request/url_fetcher.h" |
| 30 #include "net/url_request/url_request_context_getter.h" | 29 #include "net/url_request/url_request_context_getter.h" |
| 31 #include "net/url_request/url_request_status.h" | 30 #include "net/url_request/url_request_status.h" |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 // The update was not successful, but don't back off. | 624 // The update was not successful, but don't back off. |
| 626 UpdateFinished(false, false); | 625 UpdateFinished(false, false); |
| 627 return; | 626 return; |
| 628 } | 627 } |
| 629 | 628 |
| 630 // Format our stored chunks: | 629 // Format our stored chunks: |
| 631 bool found_malware = false; | 630 bool found_malware = false; |
| 632 bool found_phishing = false; | 631 bool found_phishing = false; |
| 633 for (size_t i = 0; i < lists.size(); ++i) { | 632 for (size_t i = 0; i < lists.size(); ++i) { |
| 634 update_list_data_.append(safe_browsing::FormatList(lists[i])); | 633 update_list_data_.append(safe_browsing::FormatList(lists[i])); |
| 635 if (lists[i].name == safe_browsing::kPhishingList) | 634 if (lists[i].name == safe_browsing_util::kPhishingList) |
| 636 found_phishing = true; | 635 found_phishing = true; |
| 637 | 636 |
| 638 if (lists[i].name == safe_browsing::kMalwareList) | 637 if (lists[i].name == safe_browsing_util::kMalwareList) |
| 639 found_malware = true; | 638 found_malware = true; |
| 640 } | 639 } |
| 641 | 640 |
| 642 // If we have an empty database, let the server know we want data for these | 641 // If we have an empty database, let the server know we want data for these |
| 643 // lists. | 642 // lists. |
| 644 // TODO(shess): These cases never happen because the database fills in the | 643 // TODO(shess): These cases never happen because the database fills in the |
| 645 // lists in GetChunks(). Refactor the unit tests so that this code can be | 644 // lists in GetChunks(). Refactor the unit tests so that this code can be |
| 646 // removed. | 645 // removed. |
| 647 if (!found_phishing) { | 646 if (!found_phishing) { |
| 648 update_list_data_.append(safe_browsing::FormatList( | 647 update_list_data_.append(safe_browsing::FormatList( |
| 649 SBListChunkRanges(safe_browsing::kPhishingList))); | 648 SBListChunkRanges(safe_browsing_util::kPhishingList))); |
| 650 } | 649 } |
| 651 if (!found_malware) { | 650 if (!found_malware) { |
| 652 update_list_data_.append(safe_browsing::FormatList( | 651 update_list_data_.append(safe_browsing::FormatList( |
| 653 SBListChunkRanges(safe_browsing::kMalwareList))); | 652 SBListChunkRanges(safe_browsing_util::kMalwareList))); |
| 654 } | 653 } |
| 655 | 654 |
| 656 // Large requests are (probably) a sign of database corruption. | 655 // Large requests are (probably) a sign of database corruption. |
| 657 // Record stats to inform decisions about whether to automate | 656 // Record stats to inform decisions about whether to automate |
| 658 // deletion of such databases. http://crbug.com/120219 | 657 // deletion of such databases. http://crbug.com/120219 |
| 659 UMA_HISTOGRAM_COUNTS("SB2.UpdateRequestSize", update_list_data_.size()); | 658 UMA_HISTOGRAM_COUNTS("SB2.UpdateRequestSize", update_list_data_.size()); |
| 660 | 659 |
| 661 GURL update_url = UpdateUrl(is_extended_reporting); | 660 GURL update_url = UpdateUrl(is_extended_reporting); |
| 662 request_ = net::URLFetcher::Create(url_fetcher_id_++, update_url, | 661 request_ = net::URLFetcher::Create(url_fetcher_id_++, update_url, |
| 663 net::URLFetcher::POST, this); | 662 net::URLFetcher::POST, this); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 FullHashCallback callback, bool is_download) | 792 FullHashCallback callback, bool is_download) |
| 794 : callback(callback), | 793 : callback(callback), |
| 795 is_download(is_download) { | 794 is_download(is_download) { |
| 796 } | 795 } |
| 797 | 796 |
| 798 SafeBrowsingProtocolManager::FullHashDetails::~FullHashDetails() { | 797 SafeBrowsingProtocolManager::FullHashDetails::~FullHashDetails() { |
| 799 } | 798 } |
| 800 | 799 |
| 801 SafeBrowsingProtocolManagerDelegate::~SafeBrowsingProtocolManagerDelegate() { | 800 SafeBrowsingProtocolManagerDelegate::~SafeBrowsingProtocolManagerDelegate() { |
| 802 } | 801 } |
| OLD | NEW |