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

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

Issue 7004007: iwyu: Include stringprintf.h where appropriate, part 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix 2. Created 9 years, 7 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/protocol_manager.h" 5 #include "chrome/browser/safe_browsing/protocol_manager.h"
6 6
7 #ifndef NDEBUG 7 #ifndef NDEBUG
8 #include "base/base64.h" 8 #include "base/base64.h"
9 #endif 9 #endif
10 #include "base/environment.h" 10 #include "base/environment.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/rand_util.h" 13 #include "base/rand_util.h"
14 #include "base/stl_util-inl.h" 14 #include "base/stl_util-inl.h"
15 #include "base/stringprintf.h"
15 #include "base/string_util.h" 16 #include "base/string_util.h"
16 #include "base/task.h" 17 #include "base/task.h"
17 #include "base/timer.h" 18 #include "base/timer.h"
18 #include "chrome/browser/safe_browsing/protocol_parser.h" 19 #include "chrome/browser/safe_browsing/protocol_parser.h"
19 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 20 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
20 #include "chrome/common/chrome_version_info.h" 21 #include "chrome/common/chrome_version_info.h"
21 #include "chrome/common/env_vars.h" 22 #include "chrome/common/env_vars.h"
22 #include "content/browser/browser_thread.h" 23 #include "content/browser/browser_thread.h"
23 #include "net/base/escape.h" 24 #include "net/base/escape.h"
24 #include "net/base/load_flags.h" 25 #include "net/base/load_flags.h"
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 update_size_ = 0; 719 update_size_ = 0;
719 sb_service_->UpdateFinished(success); 720 sb_service_->UpdateFinished(success);
720 } 721 }
721 722
722 std::string SafeBrowsingProtocolManager::ComposeUrl( 723 std::string SafeBrowsingProtocolManager::ComposeUrl(
723 const std::string& prefix, const std::string& method, 724 const std::string& prefix, const std::string& method,
724 const std::string& client_name, const std::string& version, 725 const std::string& client_name, const std::string& version,
725 const std::string& additional_query) { 726 const std::string& additional_query) {
726 DCHECK(!prefix.empty() && !method.empty() && 727 DCHECK(!prefix.empty() && !method.empty() &&
727 !client_name.empty() && !version.empty()); 728 !client_name.empty() && !version.empty());
728 std::string url = StringPrintf("%s/%s?client=%s&appver=%s&pver=2.2", 729 std::string url = base::StringPrintf("%s/%s?client=%s&appver=%s&pver=2.2",
729 prefix.c_str(), method.c_str(), 730 prefix.c_str(), method.c_str(),
730 client_name.c_str(), version.c_str()); 731 client_name.c_str(), version.c_str());
731 if (!additional_query.empty()) { 732 if (!additional_query.empty()) {
732 DCHECK(url.find("?") != std::string::npos); 733 DCHECK(url.find("?") != std::string::npos);
733 url.append("&"); 734 url.append("&");
734 url.append(additional_query); 735 url.append(additional_query);
735 } 736 }
736 return url; 737 return url;
737 } 738 }
738 739
739 GURL SafeBrowsingProtocolManager::UpdateUrl(bool use_mac) const { 740 GURL SafeBrowsingProtocolManager::UpdateUrl(bool use_mac) const {
740 std::string url = ComposeUrl(http_url_prefix_, "downloads", client_name_, 741 std::string url = ComposeUrl(http_url_prefix_, "downloads", client_name_,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 break; 783 break;
783 case SafeBrowsingService::BINARY_MALWARE_URL: 784 case SafeBrowsingService::BINARY_MALWARE_URL:
784 threat_list = "binurlhit"; 785 threat_list = "binurlhit";
785 break; 786 break;
786 case SafeBrowsingService::BINARY_MALWARE_HASH: 787 case SafeBrowsingService::BINARY_MALWARE_HASH:
787 threat_list = "binhashhit"; 788 threat_list = "binhashhit";
788 break; 789 break;
789 default: 790 default:
790 NOTREACHED(); 791 NOTREACHED();
791 } 792 }
792 return GURL(StringPrintf("%s&evts=%s&evtd=%s&evtr=%s&evhr=%s&evtb=%d", 793 return GURL(base::StringPrintf("%s&evts=%s&evtd=%s&evtr=%s&evhr=%s&evtb=%d",
793 url.c_str(), threat_list.c_str(), 794 url.c_str(), threat_list.c_str(),
794 EscapeQueryParamValue(malicious_url.spec(), true).c_str(), 795 EscapeQueryParamValue(malicious_url.spec(), true).c_str(),
795 EscapeQueryParamValue(page_url.spec(), true).c_str(), 796 EscapeQueryParamValue(page_url.spec(), true).c_str(),
796 EscapeQueryParamValue(referrer_url.spec(), true).c_str(), 797 EscapeQueryParamValue(referrer_url.spec(), true).c_str(),
797 is_subresource)); 798 is_subresource));
798 } 799 }
799 800
800 GURL SafeBrowsingProtocolManager::MalwareDetailsUrl() const { 801 GURL SafeBrowsingProtocolManager::MalwareDetailsUrl() const {
801 // The malware details go over HTTPS. 802 // The malware details go over HTTPS.
802 std::string url = StringPrintf( 803 std::string url = base::StringPrintf(
803 "%s/clientreport/malware?client=%s&appver=%s&pver=1.0", 804 "%s/clientreport/malware?client=%s&appver=%s&pver=1.0",
804 https_url_prefix_.c_str(), 805 https_url_prefix_.c_str(),
805 client_name_.c_str(), 806 client_name_.c_str(),
806 version_.c_str()); 807 version_.c_str());
807 return GURL(url); 808 return GURL(url);
808 } 809 }
809 810
810 GURL SafeBrowsingProtocolManager::NextChunkUrl(const std::string& url) const { 811 GURL SafeBrowsingProtocolManager::NextChunkUrl(const std::string& url) const {
811 std::string next_url; 812 std::string next_url;
812 if (!StartsWithASCII(url, "http://", false) && 813 if (!StartsWithASCII(url, "http://", false) &&
813 !StartsWithASCII(url, "https://", false)) { 814 !StartsWithASCII(url, "https://", false)) {
814 next_url.append("http://"); 815 next_url.append("http://");
815 next_url.append(url); 816 next_url.append(url);
816 } else { 817 } else {
817 next_url = url; 818 next_url = url;
818 } 819 }
819 if (!additional_query_.empty()) { 820 if (!additional_query_.empty()) {
820 if (next_url.find("?") != std::string::npos) { 821 if (next_url.find("?") != std::string::npos) {
821 next_url.append("&"); 822 next_url.append("&");
822 } else { 823 } else {
823 next_url.append("?"); 824 next_url.append("?");
824 } 825 }
825 next_url.append(additional_query_); 826 next_url.append(additional_query_);
826 } 827 }
827 return GURL(next_url); 828 return GURL(next_url);
828 } 829 }
OLDNEW
« no previous file with comments | « chrome/browser/process_singleton_linux.cc ('k') | chrome/browser/safe_browsing/protocol_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698