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

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

Issue 1962013002: Adding a parameter that will be used to request a transparent doodle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 16
17 namespace search_provider_logos { 17 namespace search_provider_logos {
18 18
19 namespace { 19 namespace {
20 const char kResponsePreamble[] = ")]}'"; 20 const char kResponsePreamble[] = ")]}'";
21 } 21 }
22 22
23 GURL GoogleAppendQueryparamsToLogoURL(const GURL& logo_url, 23 GURL GoogleAppendQueryparamsToLogoURL(const GURL& logo_url,
24 const std::string& fingerprint, 24 const std::string& fingerprint,
25 bool wants_cta) { 25 bool wants_cta,
26 bool transparent) {
26 // Note: we can't just use net::AppendQueryParameter() because it escapes 27 // Note: we can't just use net::AppendQueryParameter() because it escapes
27 // ":" to "%3A", but the server requires the colon not to be escaped. 28 // ":" to "%3A", but the server requires the colon not to be escaped.
28 // See: http://crbug.com/413845 29 // See: http://crbug.com/413845
29 30
30 // TODO(newt): Switch to using net::AppendQueryParameter once it no longer 31 // TODO(newt): Switch to using net::AppendQueryParameter once it no longer
31 // escapes ":" 32 // escapes ":"
32 if (!fingerprint.empty() || wants_cta) { 33 if (!fingerprint.empty() || wants_cta) {
33 std::string query(logo_url.query()); 34 std::string query(logo_url.query());
34 if (!query.empty()) 35 if (!query.empty())
35 query += "&"; 36 query += "&";
36 37
37 query += "async="; 38 query += "async=";
38 if (!fingerprint.empty()) { 39 std::vector<std::string> params;
39 query += "es_dfp:" + fingerprint; 40 if (!fingerprint.empty())
40 if (wants_cta) 41 params.push_back("es_dfp:" + fingerprint);
41 query += ","; 42
42 } 43 if (wants_cta)
43 if (wants_cta) { 44 params.push_back("cta:1");
44 query += "cta:1"; 45
45 } 46 if (transparent)
47 params.push_back("transp:1");
48
49 query += base::JoinString(params, ",");
46 GURL::Replacements replacements; 50 GURL::Replacements replacements;
47 replacements.SetQueryStr(query); 51 replacements.SetQueryStr(query);
48 return logo_url.ReplaceComponents(replacements); 52 return logo_url.ReplaceComponents(replacements);
49 } 53 }
50 54
51 return logo_url; 55 return logo_url;
52 } 56 }
53 57
54 std::unique_ptr<EncodedLogo> GoogleParseLogoResponse( 58 std::unique_ptr<EncodedLogo> GoogleParseLogoResponse(
55 const std::unique_ptr<std::string>& response, 59 const std::unique_ptr<std::string>& response,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 logo->metadata.can_show_after_expiration = true; 133 logo->metadata.can_show_after_expiration = true;
130 } 134 }
131 logo->metadata.expiration_time = response_time + time_to_live; 135 logo->metadata.expiration_time = response_time + time_to_live;
132 136
133 // If this point is reached, parsing has succeeded. 137 // If this point is reached, parsing has succeeded.
134 *parsing_failed = false; 138 *parsing_failed = false;
135 return logo; 139 return logo;
136 } 140 }
137 141
138 } // namespace search_provider_logos 142 } // namespace search_provider_logos
OLDNEW
« no previous file with comments | « components/search_provider_logos/google_logo_api.h ('k') | components/search_provider_logos/logo_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698