| 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 f06d83e50a3228999b86ca6a74ab37be1dc0c2e4..761bad9674211e3f3b2e68e8a39aa98de73725fa 100644
|
| --- a/chrome/browser/ui/webui/snippets_internals_message_handler.cc
|
| +++ b/chrome/browser/ui/webui/snippets_internals_message_handler.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include <memory>
|
| #include <set>
|
| +#include <utility>
|
| #include <vector>
|
|
|
| #include "base/bind.h"
|
| @@ -32,6 +33,7 @@ using ntp_snippets::Category;
|
| using ntp_snippets::CategoryInfo;
|
| using ntp_snippets::CategoryStatus;
|
| using ntp_snippets::KnownCategories;
|
| +using ntp_snippets::UserClassifier;
|
|
|
| namespace {
|
|
|
| @@ -73,7 +75,7 @@ std::string GetCategoryStatusName(CategoryStatus status) {
|
| return std::string();
|
| }
|
|
|
| -} // namespace
|
| +} // namespace
|
|
|
| SnippetsInternalsMessageHandler::SnippetsInternalsMessageHandler()
|
| : content_suggestions_service_observer_(this),
|
| @@ -119,6 +121,12 @@ void SnippetsInternalsMessageHandler::RegisterMessages() {
|
| base::Bind(
|
| &SnippetsInternalsMessageHandler::HandleToggleDismissedSuggestions,
|
| base::Unretained(this)));
|
| +
|
| + web_ui()->RegisterMessageCallback(
|
| + "clearClassification",
|
| + base::Bind(
|
| + &SnippetsInternalsMessageHandler::ClearClassification,
|
| + base::Unretained(this)));
|
| }
|
|
|
| void SnippetsInternalsMessageHandler::OnNewSuggestions(Category category) {
|
| @@ -245,6 +253,14 @@ void SnippetsInternalsMessageHandler::HandleToggleDismissedSuggestions(
|
| }
|
| }
|
|
|
| +void SnippetsInternalsMessageHandler::ClearClassification(
|
| + const base::ListValue* args) {
|
| + DCHECK_EQ(0u, args->GetSize());
|
| + content_suggestions_service_->user_classifier()
|
| + ->ClearClassificationForDebugging();
|
| + SendClassification();
|
| +}
|
| +
|
| void SnippetsInternalsMessageHandler::SendAllContent() {
|
| SendHosts();
|
|
|
| @@ -264,6 +280,8 @@ void SnippetsInternalsMessageHandler::SendAllContent() {
|
| base::FeatureList::IsEnabled(
|
| ntp_snippets::kPhysicalWebPageSuggestionsFeature));
|
|
|
| + SendClassification();
|
| +
|
| web_ui()->CallJavascriptFunctionUnsafe(
|
| "chrome.SnippetsInternals.setHostRestricted",
|
| base::FundamentalValue(
|
| @@ -292,6 +310,22 @@ void SnippetsInternalsMessageHandler::SendAllContent() {
|
| SendContentSuggestions();
|
| }
|
|
|
| +void SnippetsInternalsMessageHandler::SendClassification() {
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| + "chrome.SnippetsInternals.receiveClassification",
|
| + base::StringValue(content_suggestions_service_->user_classifier()
|
| + ->GetUserClassDescriptionForDebugging()),
|
| + base::FundamentalValue(
|
| + content_suggestions_service_->user_classifier()->GetEstimatedAvgTime(
|
| + UserClassifier::Metric::NTP_OPENED)),
|
| + base::FundamentalValue(
|
| + content_suggestions_service_->user_classifier()->GetEstimatedAvgTime(
|
| + UserClassifier::Metric::SUGGESTIONS_SHOWN)),
|
| + base::FundamentalValue(
|
| + content_suggestions_service_->user_classifier()->GetEstimatedAvgTime(
|
| + UserClassifier::Metric::SUGGESTIONS_USED)));
|
| +}
|
| +
|
| void SnippetsInternalsMessageHandler::SendHosts() {
|
| std::unique_ptr<base::ListValue> hosts_list(new base::ListValue);
|
|
|
|
|