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

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

Issue 2889153003: [NTP::SectionOrder] Add ranker section to snippets internals. (Closed)
Patch Set: jkrcal@ nit. Created 3 years, 7 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
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 9b3d770447bb1d81ebf1a370f5383de575646072..703d28073dcfd8202e4592891b653d0c0e1418b2 100644
--- a/chrome/browser/ui/webui/snippets_internals_message_handler.cc
+++ b/chrome/browser/ui/webui/snippets_internals_message_handler.cc
@@ -30,6 +30,7 @@
#include "chrome/common/chrome_features.h"
#include "components/ntp_snippets/category.h"
#include "components/ntp_snippets/category_info.h"
+#include "components/ntp_snippets/category_rankers/category_ranker.h"
#include "components/ntp_snippets/features.h"
#include "components/ntp_snippets/pref_names.h"
#include "components/ntp_snippets/remote/remote_suggestions_fetcher.h"
@@ -375,6 +376,7 @@ void SnippetsInternalsMessageHandler::SendAllContent() {
chrome::android::kPhysicalWebFeature));
SendClassification();
+ SendRankerDebugData();
SendLastRemoteSuggestionsBackgroundFetchTime();
if (remote_suggestions_provider_) {
@@ -412,6 +414,24 @@ void SnippetsInternalsMessageHandler::SendClassification() {
UserClassifier::Metric::SUGGESTIONS_USED)));
}
+void SnippetsInternalsMessageHandler::SendRankerDebugData() {
+ std::vector<ntp_snippets::CategoryRanker::DebugDataItem> data =
+ content_suggestions_service_->category_ranker()->GetDebugData();
+
+ std::unique_ptr<base::ListValue> items_list(new base::ListValue);
+ for (const auto& item : data) {
+ auto entry = base::MakeUnique<base::DictionaryValue>();
+ entry->SetString("label", item.label);
+ entry->SetString("content", item.content);
+ items_list->Append(std::move(entry));
+ }
+
+ base::DictionaryValue result;
+ result.Set("list", std::move(items_list));
+ web_ui()->CallJavascriptFunctionUnsafe(
+ "chrome.SnippetsInternals.receiveRankerDebugData", result);
+}
+
void SnippetsInternalsMessageHandler::
SendLastRemoteSuggestionsBackgroundFetchTime() {
base::Time time = base::Time::FromInternalValue(pref_service_->GetInt64(

Powered by Google App Engine
This is Rietveld 408576698