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

Side by Side Diff: components/search_provider_logos/google_logo_api.cc

Issue 2695883003: Change uses of base::JoinString to pass StringPieces where possible. (Closed)
Patch Set: Remove dependency CL. Created 3 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/search_provider_logos/google_logo_api.h" 5 #include "components/search_provider_logos/google_logo_api.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "base/base64.h" 11 #include "base/base64.h"
12 #include "base/json/json_reader.h" 12 #include "base/json/json_reader.h"
13 #include "base/memory/ref_counted_memory.h" 13 #include "base/memory/ref_counted_memory.h"
14 #include "base/strings/string_piece.h"
14 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
15 #include "base/values.h" 16 #include "base/values.h"
16 17
17 namespace search_provider_logos { 18 namespace search_provider_logos {
18 19
19 namespace { 20 namespace {
20 const char kResponsePreamble[] = ")]}'"; 21 const char kResponsePreamble[] = ")]}'";
21 } 22 }
22 23
23 GURL GoogleAppendQueryparamsToLogoURL(const GURL& logo_url, 24 GURL GoogleAppendQueryparamsToLogoURL(const GURL& logo_url,
24 const std::string& fingerprint, 25 const std::string& fingerprint,
25 bool wants_cta, 26 bool wants_cta,
26 bool gray_background) { 27 bool gray_background) {
27 // Note: we can't just use net::AppendQueryParameter() because it escapes 28 // Note: we can't just use net::AppendQueryParameter() because it escapes
28 // ":" to "%3A", but the server requires the colon not to be escaped. 29 // ":" to "%3A", but the server requires the colon not to be escaped.
29 // See: http://crbug.com/413845 30 // See: http://crbug.com/413845
30 31
31 // TODO(newt): Switch to using net::AppendQueryParameter once it no longer 32 // TODO(newt): Switch to using net::AppendQueryParameter once it no longer
32 // escapes ":" 33 // escapes ":"
33 if (!fingerprint.empty() || wants_cta) { 34 if (!fingerprint.empty() || wants_cta) {
34 std::string query(logo_url.query()); 35 std::string query(logo_url.query());
35 if (!query.empty()) 36 if (!query.empty())
36 query += "&"; 37 query += "&";
37 38
38 query += "async="; 39 query += "async=";
39 std::vector<std::string> params; 40 std::vector<base::StringPiece> params;
40 if (!fingerprint.empty()) 41 std::string fingerprint_param;
41 params.push_back("es_dfp:" + fingerprint); 42 if (!fingerprint.empty()) {
43 fingerprint_param = "es_dfp:" + fingerprint;
44 params.push_back(fingerprint_param);
45 }
42 46
43 if (wants_cta) 47 if (wants_cta)
44 params.push_back("cta:1"); 48 params.push_back("cta:1");
45 49
46 if (gray_background) { 50 if (gray_background) {
47 params.push_back("transp:1"); 51 params.push_back("transp:1");
48 params.push_back("graybg:1"); 52 params.push_back("graybg:1");
49 } 53 }
50 54
51 query += base::JoinString(params, ","); 55 query += base::JoinString(params, ",");
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 logo->metadata.can_show_after_expiration = true; 147 logo->metadata.can_show_after_expiration = true;
144 } 148 }
145 logo->metadata.expiration_time = response_time + time_to_live; 149 logo->metadata.expiration_time = response_time + time_to_live;
146 150
147 // If this point is reached, parsing has succeeded. 151 // If this point is reached, parsing has succeeded.
148 *parsing_failed = false; 152 *parsing_failed = false;
149 return logo; 153 return logo;
150 } 154 }
151 155
152 } // namespace search_provider_logos 156 } // namespace search_provider_logos
OLDNEW
« no previous file with comments | « components/search_engines/keyword_table.cc ('k') | components/spellcheck/renderer/spellcheck_multilingual_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698