OLD | NEW |
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> |
| 8 |
7 #include <algorithm> | 9 #include <algorithm> |
8 | 10 |
9 #include "base/base64.h" | 11 #include "base/base64.h" |
10 #include "base/json/json_reader.h" | 12 #include "base/json/json_reader.h" |
11 #include "base/memory/ref_counted_memory.h" | 13 #include "base/memory/ref_counted_memory.h" |
12 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
13 #include "base/values.h" | 15 #include "base/values.h" |
14 | 16 |
15 namespace search_provider_logos { | 17 namespace search_provider_logos { |
16 | 18 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 logo_dict->GetString("alt", &logo->metadata.alt_text); | 113 logo_dict->GetString("alt", &logo->metadata.alt_text); |
112 | 114 |
113 // Existance of url indicates |data| is a call to action image for an | 115 // Existance of url indicates |data| is a call to action image for an |
114 // animated doodle. |url| points to that animated doodle. | 116 // animated doodle. |url| points to that animated doodle. |
115 logo_dict->GetString("url", &logo->metadata.animated_url); | 117 logo_dict->GetString("url", &logo->metadata.animated_url); |
116 | 118 |
117 base::TimeDelta time_to_live; | 119 base::TimeDelta time_to_live; |
118 int time_to_live_ms; | 120 int time_to_live_ms; |
119 if (logo_dict->GetInteger("time_to_live", &time_to_live_ms)) { | 121 if (logo_dict->GetInteger("time_to_live", &time_to_live_ms)) { |
120 time_to_live = base::TimeDelta::FromMilliseconds( | 122 time_to_live = base::TimeDelta::FromMilliseconds( |
121 std::min(static_cast<int64>(time_to_live_ms), kMaxTimeToLiveMS)); | 123 std::min(static_cast<int64_t>(time_to_live_ms), kMaxTimeToLiveMS)); |
122 logo->metadata.can_show_after_expiration = false; | 124 logo->metadata.can_show_after_expiration = false; |
123 } else { | 125 } else { |
124 time_to_live = base::TimeDelta::FromMilliseconds(kMaxTimeToLiveMS); | 126 time_to_live = base::TimeDelta::FromMilliseconds(kMaxTimeToLiveMS); |
125 logo->metadata.can_show_after_expiration = true; | 127 logo->metadata.can_show_after_expiration = true; |
126 } | 128 } |
127 logo->metadata.expiration_time = response_time + time_to_live; | 129 logo->metadata.expiration_time = response_time + time_to_live; |
128 | 130 |
129 // If this point is reached, parsing has succeeded. | 131 // If this point is reached, parsing has succeeded. |
130 *parsing_failed = false; | 132 *parsing_failed = false; |
131 return logo.Pass(); | 133 return logo.Pass(); |
132 } | 134 } |
133 | 135 |
134 } // namespace search_provider_logos | 136 } // namespace search_provider_logos |
OLD | NEW |