Chromium Code Reviews| Index: chrome/browser/search/suggestions/suggestions_source.cc |
| diff --git a/chrome/browser/search/suggestions/suggestions_source.cc b/chrome/browser/search/suggestions/suggestions_source.cc |
| index cb0e17e3f798953121fa0a182c1efc7573b26710..299a6f4a2507a1fb70be57f362c3d3e1ffd6e0ba 100644 |
| --- a/chrome/browser/search/suggestions/suggestions_source.cc |
| +++ b/chrome/browser/search/suggestions/suggestions_source.cc |
| @@ -11,13 +11,18 @@ |
| #include "base/bind.h" |
| #include "base/memory/ref_counted_memory.h" |
| #include "base/strings/string16.h" |
| +#include "base/strings/string_number_conversions.h" |
| #include "base/strings/string_piece.h" |
| #include "base/strings/string_util.h" |
| +#include "base/strings/stringprintf.h" |
| +#include "base/strings/utf_string_conversions.h" |
| +#include "base/time/time.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/search/suggestions/suggestions_service_factory.h" |
| #include "chrome/common/url_constants.h" |
| #include "components/suggestions/suggestions_service.h" |
| #include "net/base/escape.h" |
| +#include "ui/base/l10n/time_format.h" |
| #include "ui/gfx/codec/png_codec.h" |
| #include "ui/gfx/image/image_skia.h" |
| #include "url/gurl.h" |
| @@ -42,9 +47,17 @@ void RenderOutputHtml(const SuggestionsProfile& profile, |
| out.push_back(kHtmlBody); |
| out.push_back("<h1>Suggestions</h1>\n<ul>"); |
| + int64 now = (base::Time::NowFromSystemTime() - base::Time::UnixEpoch()) |
| + .ToInternalValue(); |
| size_t size = profile.suggestions_size(); |
| for (size_t i = 0; i < size; ++i) { |
| const ChromeSuggestion& suggestion = profile.suggestions(i); |
| + base::TimeDelta td = base::TimeDelta::FromMicroseconds( |
|
manzagop (departed)
2014/08/06 19:11:18
td isn't self-explanatory. Can you find better? eg
gayane -on leave until 09-2017
2014/08/06 21:12:20
renamed as remaining_time
|
| + suggestion.expiry_ts() - now); |
| + base::string16 formatted = ui::TimeFormat::Detailed( |
|
manzagop (departed)
2014/08/06 19:11:18
Perhaps td_formatted so it's clear what this?
gayane -on leave until 09-2017
2014/08/06 21:12:20
renamed as remaining_time_formatted
|
| + ui::TimeFormat::Format::FORMAT_DURATION, |
| + ui::TimeFormat::Length::LENGTH_LONG, |
| + -1, td); |
| std::string line; |
| line += "<li><a href=\""; |
| line += net::EscapeForHTML(suggestion.url()); |
| @@ -57,7 +70,9 @@ void RenderOutputHtml(const SuggestionsProfile& profile, |
| line += it->second; |
| line += "'>"; |
| } |
| - line += "</a></li>\n"; |
| + line += "</a> Expires in "; |
| + line += base::UTF16ToUTF8(formatted); |
| + line += "</li>\n"; |
| out.push_back(line); |
| } |
| out.push_back("</ul>"); |