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

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

Issue 1269773002: Cleanup VersionInfo after componentization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 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
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/protocol_manager_helper.h" 5 #include "chrome/browser/safe_browsing/protocol_manager_helper.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/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "chrome/common/chrome_version_info.h"
16 #include "chrome/common/env_vars.h" 15 #include "chrome/common/env_vars.h"
16 #include "components/version_info/version_info.h"
17 #include "google_apis/google_api_keys.h" 17 #include "google_apis/google_api_keys.h"
18 #include "net/base/escape.h" 18 #include "net/base/escape.h"
19 19
20 SafeBrowsingProtocolConfig::SafeBrowsingProtocolConfig() 20 SafeBrowsingProtocolConfig::SafeBrowsingProtocolConfig()
21 : disable_auto_update(false) 21 : disable_auto_update(false)
22 #if defined(OS_ANDROID) 22 #if defined(OS_ANDROID)
23 , disable_connection_check(false) 23 , disable_connection_check(false)
24 #endif 24 #endif
25 { 25 {
26 } 26 }
27 27
28 SafeBrowsingProtocolConfig::~SafeBrowsingProtocolConfig() { 28 SafeBrowsingProtocolConfig::~SafeBrowsingProtocolConfig() {
29 } 29 }
30 30
31 // static 31 // static
32 std::string SafeBrowsingProtocolManagerHelper::Version() { 32 std::string SafeBrowsingProtocolManagerHelper::Version() {
33 chrome::VersionInfo version_info; 33 if (version_info::GetVersionNumber().empty())
34 if (version_info.Version().empty())
35 return "0.1"; 34 return "0.1";
36 else 35 else
37 return version_info.Version(); 36 return version_info::GetVersionNumber();
38 } 37 }
39 38
40 // static 39 // static
41 std::string SafeBrowsingProtocolManagerHelper::ComposeUrl( 40 std::string SafeBrowsingProtocolManagerHelper::ComposeUrl(
42 const std::string& prefix, const std::string& method, 41 const std::string& prefix, const std::string& method,
43 const std::string& client_name, const std::string& version, 42 const std::string& client_name, const std::string& version,
44 const std::string& additional_query) { 43 const std::string& additional_query) {
45 DCHECK(!prefix.empty() && !method.empty() && 44 DCHECK(!prefix.empty() && !method.empty() &&
46 !client_name.empty() && !version.empty()); 45 !client_name.empty() && !version.empty());
47 std::string url = base::StringPrintf("%s/%s?client=%s&appver=%s&pver=3.0", 46 std::string url = base::StringPrintf("%s/%s?client=%s&appver=%s&pver=3.0",
48 prefix.c_str(), method.c_str(), 47 prefix.c_str(), method.c_str(),
49 client_name.c_str(), version.c_str()); 48 client_name.c_str(), version.c_str());
50 std::string api_key = google_apis::GetAPIKey(); 49 std::string api_key = google_apis::GetAPIKey();
51 if (!api_key.empty()) { 50 if (!api_key.empty()) {
52 base::StringAppendF(&url, "&key=%s", 51 base::StringAppendF(&url, "&key=%s",
53 net::EscapeQueryParamValue(api_key, true).c_str()); 52 net::EscapeQueryParamValue(api_key, true).c_str());
54 } 53 }
55 if (!additional_query.empty()) { 54 if (!additional_query.empty()) {
56 DCHECK(url.find("?") != std::string::npos); 55 DCHECK(url.find("?") != std::string::npos);
57 url.append("&"); 56 url.append("&");
58 url.append(additional_query); 57 url.append(additional_query);
59 } 58 }
60 return url; 59 return url;
61 } 60 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/protocol_manager.cc ('k') | chrome/browser/search_engines/ui_thread_search_terms_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698