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

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 if (!fingerprint.empty()) {
39 query += "es_dfp:" + fingerprint; 40 query += "es_dfp:" + fingerprint;
40 if (wants_cta) 41 if (wants_cta || transparent)
Marc Treib 2016/05/09 16:58:21 Hm, maybe it's time to push all the params into a
atanasova 2016/05/10 08:32:17 Done.
41 query += ","; 42 query += ",";
42 } 43 }
43 if (wants_cta) { 44 if (wants_cta) {
44 query += "cta:1"; 45 query += "cta:1";
46 if (transparent)
47 query += ",";
45 } 48 }
49 if (transparent)
50 query += "transp:1";
46 GURL::Replacements replacements; 51 GURL::Replacements replacements;
47 replacements.SetQueryStr(query); 52 replacements.SetQueryStr(query);
48 return logo_url.ReplaceComponents(replacements); 53 return logo_url.ReplaceComponents(replacements);
49 } 54 }
50 55
51 return logo_url; 56 return logo_url;
52 } 57 }
53 58
54 std::unique_ptr<EncodedLogo> GoogleParseLogoResponse( 59 std::unique_ptr<EncodedLogo> GoogleParseLogoResponse(
55 const std::unique_ptr<std::string>& response, 60 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; 134 logo->metadata.can_show_after_expiration = true;
130 } 135 }
131 logo->metadata.expiration_time = response_time + time_to_live; 136 logo->metadata.expiration_time = response_time + time_to_live;
132 137
133 // If this point is reached, parsing has succeeded. 138 // If this point is reached, parsing has succeeded.
134 *parsing_failed = false; 139 *parsing_failed = false;
135 return logo; 140 return logo;
136 } 141 }
137 142
138 } // namespace search_provider_logos 143 } // namespace search_provider_logos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698