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

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

Issue 1066923002: [LogoTracker] Correct fingerprint append in async parameter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change append_fingerprint_func_ to append_queryparams_func_. Created 5 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 "base/base64.h" 7 #include "base/base64.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/memory/ref_counted_memory.h" 9 #include "base/memory/ref_counted_memory.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 12
13 namespace search_provider_logos { 13 namespace search_provider_logos {
14 14
15 namespace { 15 namespace {
16 const char kResponsePreamble[] = ")]}'"; 16 const char kResponsePreamble[] = ")]}'";
17 } 17 }
18 18
19 GURL GoogleAppendFingerprintToLogoURL(const GURL& logo_url, 19 GURL GoogleAppendQueryparamsToLogoURL(const GURL& logo_url,
20 const std::string& fingerprint) { 20 const std::string& fingerprint,
21 bool wants_cta) {
21 // Note: we can't just use net::AppendQueryParameter() because it escapes 22 // Note: we can't just use net::AppendQueryParameter() because it escapes
22 // ":" to "%3A", but the server requires the colon not to be escaped. 23 // ":" to "%3A", but the server requires the colon not to be escaped.
23 // See: http://crbug.com/413845 24 // See: http://crbug.com/413845
24 25
25 // TODO(newt): Switch to using net::AppendQueryParameter once it no longer 26 // TODO(newt): Switch to using net::AppendQueryParameter once it no longer
26 // escapes ":" 27 // escapes ":"
28 if (!fingerprint.empty() || wants_cta) {
29 std::string query(logo_url.query());
30 if (!query.empty())
31 query += "&";
27 32
28 std::string query(logo_url.query()); 33 query += "async=";
29 if (!query.empty()) 34 if (!fingerprint.empty()) {
30 query += "&"; 35 query += "es_dfp:" + fingerprint + ",";
36 }
37 if (wants_cta) {
38 query += "cta:1";
39 }
40 GURL::Replacements replacements;
41 replacements.SetQueryStr(query);
42 return logo_url.ReplaceComponents(replacements);
43 }
31 44
32 query += "async=es_dfp:"; 45 return logo_url;
33 query += fingerprint;
34 GURL::Replacements replacements;
35 replacements.SetQueryStr(query);
36 return logo_url.ReplaceComponents(replacements);
37 } 46 }
38 47
39 scoped_ptr<EncodedLogo> GoogleParseLogoResponse( 48 scoped_ptr<EncodedLogo> GoogleParseLogoResponse(
40 const scoped_ptr<std::string>& response, 49 const scoped_ptr<std::string>& response,
41 base::Time response_time) { 50 base::Time response_time) {
42 // Google doodles are sent as JSON with a prefix. Example: 51 // Google doodles are sent as JSON with a prefix. Example:
43 // )]}' {"update":{"logo":{ 52 // )]}' {"update":{"logo":{
44 // "data": "/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/...", 53 // "data": "/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/...",
45 // "mime_type": "image/png", 54 // "mime_type": "image/png",
46 // "fingerprint": "db063e32", 55 // "fingerprint": "db063e32",
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } else { 112 } else {
104 time_to_live = base::TimeDelta::FromMilliseconds(kMaxTimeToLiveMS); 113 time_to_live = base::TimeDelta::FromMilliseconds(kMaxTimeToLiveMS);
105 logo->metadata.can_show_after_expiration = true; 114 logo->metadata.can_show_after_expiration = true;
106 } 115 }
107 logo->metadata.expiration_time = response_time + time_to_live; 116 logo->metadata.expiration_time = response_time + time_to_live;
108 117
109 return logo.Pass(); 118 return logo.Pass();
110 } 119 }
111 120
112 } // namespace search_provider_logos 121 } // namespace search_provider_logos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698