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

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

Issue 1978513002: Getting the personalization info in chrome://snippets-internals correct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: After code review #2 Created 4 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
« no previous file with comments | « chrome/browser/resources/snippets_internals.js ('k') | components/ntp_snippets/ntp_snippets_fetcher.h » ('j') | 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 efd0d5b6c2c1bc77551fd3bb67593b427d7275bc..1f1001a294ada5aeeea99aaa9ba4c1b1ab006b1f 100644
--- a/chrome/browser/ui/webui/snippets_internals_message_handler.cc
+++ b/chrome/browser/ui/webui/snippets_internals_message_handler.cc
@@ -71,11 +71,11 @@ void SnippetsInternalsMessageHandler::NTPSnippetsServiceLoaded() {
if (!dom_loaded_) return;
SendSnippets();
- SendDiscardedSnippets();
web_ui()->CallJavascriptFunction(
"chrome.SnippetsInternals.receiveJson",
- base::StringValue(ntp_snippets_service_->last_json()));
+ base::StringValue(
+ ntp_snippets_service_->snippets_fetcher()->last_json()));
}
void SnippetsInternalsMessageHandler::NTPSnippetsServiceCleared() {}
@@ -166,12 +166,23 @@ void SnippetsInternalsMessageHandler::SendInitialData() {
SendBoolean("flag-snippets", base::FeatureList::IsEnabled(
chrome::android::kNTPSnippetsFeature));
- bool restricted = !base::CommandLine::ForCurrentProcess()->HasSwitch(
- ntp_snippets::switches::kDontRestrict);
- SendBoolean("switch-restrict-to-hosts", restricted);
- const std::string help(restricted ? "(specify at least one host)" :
- "(unrestricted if no host is given)");
- SendString("hosts-help", help);
+ web_ui()->CallJavascriptFunction(
+ "chrome.SnippetsInternals.setHostRestricted",
+ base::FundamentalValue(
+ ntp_snippets_service_->snippets_fetcher()->UsesHostRestrictions()));
+
+ switch (ntp_snippets_service_->snippets_fetcher()->personalization()) {
+ case ntp_snippets::NTPSnippetsFetcher::Personalization::kPersonal:
+ SendString("switch-personalized", "Only personalized");
+ break;
+ case ntp_snippets::NTPSnippetsFetcher::Personalization::kBoth:
+ SendString("switch-personalized",
+ "Both personalized and non-personalized");
+ break;
+ case ntp_snippets::NTPSnippetsFetcher::Personalization::kNonPersonal:
+ SendString("switch-personalized", "Only non-personalized");
+ break;
+ }
SendSnippets();
SendDiscardedSnippets();
@@ -190,7 +201,8 @@ void SnippetsInternalsMessageHandler::SendSnippets() {
web_ui()->CallJavascriptFunction("chrome.SnippetsInternals.receiveSnippets",
result);
- const std::string& status = ntp_snippets_service_->last_status();
+ const std::string& status =
+ ntp_snippets_service_->snippets_fetcher()->last_status();
if (!status.empty())
SendString("hosts-status", "Finished: " + status);
}
« no previous file with comments | « chrome/browser/resources/snippets_internals.js ('k') | components/ntp_snippets/ntp_snippets_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698