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 "chrome/browser/search/suggestions/suggestions_source.h" | 5 #include "chrome/browser/search/suggestions/suggestions_source.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include <vector> | 10 #include <vector> |
8 | 11 |
9 #include "base/barrier_closure.h" | 12 #include "base/barrier_closure.h" |
10 #include "base/base64.h" | 13 #include "base/base64.h" |
11 #include "base/bind.h" | 14 #include "base/bind.h" |
12 #include "base/memory/ref_counted_memory.h" | 15 #include "base/memory/ref_counted_memory.h" |
13 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
14 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/string_piece.h" | 18 #include "base/strings/string_piece.h" |
16 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
(...skipping 24 matching lines...) Expand all Loading... |
41 | 44 |
42 // Fills |output| with the HTML needed to display the suggestions. | 45 // Fills |output| with the HTML needed to display the suggestions. |
43 void RenderOutputHtml(const SuggestionsProfile& profile, | 46 void RenderOutputHtml(const SuggestionsProfile& profile, |
44 const std::map<GURL, std::string>& base64_encoded_pngs, | 47 const std::map<GURL, std::string>& base64_encoded_pngs, |
45 std::string* output) { | 48 std::string* output) { |
46 std::vector<std::string> out; | 49 std::vector<std::string> out; |
47 out.push_back(kHtmlHeader); | 50 out.push_back(kHtmlHeader); |
48 out.push_back(kHtmlBody); | 51 out.push_back(kHtmlBody); |
49 out.push_back("<h1>Suggestions</h1>\n<ul>"); | 52 out.push_back("<h1>Suggestions</h1>\n<ul>"); |
50 | 53 |
51 int64 now = (base::Time::NowFromSystemTime() - base::Time::UnixEpoch()) | 54 int64_t now = (base::Time::NowFromSystemTime() - base::Time::UnixEpoch()) |
52 .ToInternalValue(); | 55 .ToInternalValue(); |
53 size_t size = profile.suggestions_size(); | 56 size_t size = profile.suggestions_size(); |
54 for (size_t i = 0; i < size; ++i) { | 57 for (size_t i = 0; i < size; ++i) { |
55 const ChromeSuggestion& suggestion = profile.suggestions(i); | 58 const ChromeSuggestion& suggestion = profile.suggestions(i); |
56 base::TimeDelta remaining_time = base::TimeDelta::FromMicroseconds( | 59 base::TimeDelta remaining_time = base::TimeDelta::FromMicroseconds( |
57 suggestion.expiry_ts() - now); | 60 suggestion.expiry_ts() - now); |
58 base::string16 remaining_time_formatted = ui::TimeFormat::Detailed( | 61 base::string16 remaining_time_formatted = ui::TimeFormat::Detailed( |
59 ui::TimeFormat::Format::FORMAT_DURATION, | 62 ui::TimeFormat::Format::FORMAT_DURATION, |
60 ui::TimeFormat::Length::LENGTH_LONG, | 63 ui::TimeFormat::Length::LENGTH_LONG, |
61 -1, remaining_time); | 64 -1, remaining_time); |
62 std::string line; | 65 std::string line; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 std::string encoded_output; | 193 std::string encoded_output; |
191 base::Base64Encode(std::string(output.begin(), output.end()), | 194 base::Base64Encode(std::string(output.begin(), output.end()), |
192 &encoded_output); | 195 &encoded_output); |
193 context->base64_encoded_pngs[url] = "data:image/png;base64,"; | 196 context->base64_encoded_pngs[url] = "data:image/png;base64,"; |
194 context->base64_encoded_pngs[url] += encoded_output; | 197 context->base64_encoded_pngs[url] += encoded_output; |
195 } | 198 } |
196 barrier.Run(); | 199 barrier.Run(); |
197 } | 200 } |
198 | 201 |
199 } // namespace suggestions | 202 } // namespace suggestions |
OLD | NEW |