Chromium Code Reviews| 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..61938133d886573829778fc2ffab95cdac9d5a57 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" |
| @@ -73,7 +74,7 @@ std::string GetCategoryStatusName(CategoryStatus status) { |
| return std::string(); |
| } |
| -} // namespace |
| +} // namespace |
| SnippetsInternalsMessageHandler::SnippetsInternalsMessageHandler() |
| : content_suggestions_service_observer_(this), |
| @@ -119,6 +120,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 +252,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 +279,8 @@ void SnippetsInternalsMessageHandler::SendAllContent() { |
| base::FeatureList::IsEnabled( |
| ntp_snippets::kPhysicalWebPageSuggestionsFeature)); |
| + SendClassification(); |
| + |
| web_ui()->CallJavascriptFunctionUnsafe( |
| "chrome.SnippetsInternals.setHostRestricted", |
| base::FundamentalValue( |
| @@ -292,6 +309,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( |
| + ntp_snippets::UserClassifier::Metric::NTP_OPENED)), |
|
Marc Treib
2016/09/20 13:26:52
optional: You could add a "using ntp_snippets::Use
jkrcal
2016/09/20 13:46:39
Done.
|
| + base::FundamentalValue( |
| + content_suggestions_service_->user_classifier()->GetEstimatedAvgTime( |
| + ntp_snippets::UserClassifier::Metric::SUGGESTIONS_SHOWN)), |
| + base::FundamentalValue( |
| + content_suggestions_service_->user_classifier()->GetEstimatedAvgTime( |
| + ntp_snippets::UserClassifier::Metric::SUGGESTIONS_USED))); |
| +} |
| + |
| void SnippetsInternalsMessageHandler::SendHosts() { |
| std::unique_ptr<base::ListValue> hosts_list(new base::ListValue); |