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

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

Issue 587943003: Fix doodle verification URL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated test Created 6 years, 2 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
« no previous file with comments | « no previous file | components/search_provider_logos/logo_tracker_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "net/base/url_util.h"
13 12
14 namespace search_provider_logos { 13 namespace search_provider_logos {
15 14
16 namespace { 15 namespace {
17 const char kResponsePreamble[] = ")]}'"; 16 const char kResponsePreamble[] = ")]}'";
18 } 17 }
19 18
20 GURL GoogleAppendFingerprintToLogoURL(const GURL& logo_url, 19 GURL GoogleAppendFingerprintToLogoURL(const GURL& logo_url,
21 const std::string& fingerprint) { 20 const std::string& fingerprint) {
22 return net::AppendQueryParameter(logo_url, "async", "es_dfp:" + fingerprint); 21 // 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 // See: http://crbug.com/413845
mmenke 2014/09/24 19:48:58 nit: Could you add something like: TODO(newt): S
newt (away) 2014/09/24 19:56:10 Done.
24
25 std::string query(logo_url.query());
26 if (!query.empty())
27 query += "&";
28
29 query += "async=es_dfp:";
30 query += fingerprint;
31 GURL::Replacements replacements;
32 replacements.SetQueryStr(query);
33 return logo_url.ReplaceComponents(replacements);
23 } 34 }
24 35
25 scoped_ptr<EncodedLogo> GoogleParseLogoResponse( 36 scoped_ptr<EncodedLogo> GoogleParseLogoResponse(
26 const scoped_ptr<std::string>& response, 37 const scoped_ptr<std::string>& response,
27 base::Time response_time) { 38 base::Time response_time) {
28 // Google doodles are sent as JSON with a prefix. Example: 39 // Google doodles are sent as JSON with a prefix. Example:
29 // )]}' {"update":{"logo":{ 40 // )]}' {"update":{"logo":{
30 // "data": "/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/...", 41 // "data": "/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/...",
31 // "mime_type": "image/png", 42 // "mime_type": "image/png",
32 // "fingerprint": "db063e32", 43 // "fingerprint": "db063e32",
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } else { 95 } else {
85 time_to_live = base::TimeDelta::FromMilliseconds(kMaxTimeToLiveMS); 96 time_to_live = base::TimeDelta::FromMilliseconds(kMaxTimeToLiveMS);
86 logo->metadata.can_show_after_expiration = true; 97 logo->metadata.can_show_after_expiration = true;
87 } 98 }
88 logo->metadata.expiration_time = response_time + time_to_live; 99 logo->metadata.expiration_time = response_time + time_to_live;
89 100
90 return logo.Pass(); 101 return logo.Pass();
91 } 102 }
92 103
93 } // namespace search_provider_logos 104 } // namespace search_provider_logos
OLDNEW
« no previous file with comments | « no previous file | components/search_provider_logos/logo_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698