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

Unified Diff: chrome/browser/ui/webui/snippets_internals_message_handler.cc

Issue 2757663002: ntp-snippets-internals: add fields, indent JSON (Closed)
Patch Set: Make llx work Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/snippets_internals.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/snippets_internals_message_handler.cc
diff --git a/chrome/browser/ui/webui/snippets_internals_message_handler.cc b/chrome/browser/ui/webui/snippets_internals_message_handler.cc
index 3d78bada5ee070c3a65163bc88ef475bfd359f2c..b393b588a5eec393b420acfc99446eeb23eef2ff 100644
--- a/chrome/browser/ui/webui/snippets_internals_message_handler.cc
+++ b/chrome/browser/ui/webui/snippets_internals_message_handler.cc
@@ -19,6 +19,7 @@
#include "base/optional.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
+#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/android/chrome_feature_list.h"
@@ -56,8 +57,45 @@ std::unique_ptr<base::DictionaryValue> PrepareSuggestion(
entry->SetString("snippetText", suggestion.snippet_text());
entry->SetString("publishDate",
TimeFormatShortDateAndTime(suggestion.publish_date()));
+ entry->SetString("fetchDate",
+ TimeFormatShortDateAndTime(suggestion.fetch_date()));
entry->SetString("publisherName", suggestion.publisher_name());
entry->SetString("id", "content-suggestion-" + base::IntToString(index));
+ entry->SetDouble("score", suggestion.score());
+
+ if (suggestion.download_suggestion_extra()) {
+ const auto& extra = *suggestion.download_suggestion_extra();
+ auto value = base::MakeUnique<base::DictionaryValue>();
+ value->SetString("downloadGUID", extra.download_guid);
+ value->SetString("targetFilePath",
+ extra.target_file_path.LossyDisplayName());
+ value->SetString("mimeType", extra.mime_type);
+ value->SetString(
+ "offlinePageID",
+ base::StringPrintf("0x%016llx", static_cast<long long unsigned int>(
+ extra.offline_page_id)));
+ value->SetBoolean("isDownloadAsset", extra.is_download_asset);
+ entry->Set("downloadSuggestionExtra", std::move(value));
+ }
+
+ if (suggestion.recent_tab_suggestion_extra()) {
+ const auto& extra = *suggestion.recent_tab_suggestion_extra();
+ auto value = base::MakeUnique<base::DictionaryValue>();
+ value->SetInteger("tabID", extra.tab_id);
+ value->SetString(
+ "offlinePageID",
+ base::StringPrintf("0x%016llx", static_cast<long long unsigned int>(
+ extra.offline_page_id)));
+ entry->Set("recentTabSuggestionExtra", std::move(value));
+ }
+
+ if (suggestion.notification_extra()) {
+ const auto& extra = *suggestion.notification_extra();
+ auto value = base::MakeUnique<base::DictionaryValue>();
+ value->SetString("deadline", TimeFormatShortDateAndTime(extra.deadline));
+ entry->Set("notificationExtra", std::move(value));
+ }
+
return entry;
}
« no previous file with comments | « chrome/browser/resources/snippets_internals.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698