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

Unified Diff: chrome/browser/resources/snippets_internals.js

Issue 2145563002: Add ContentSuggestionsService to SnippetsInternals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@articleprovider2
Patch Set: Refactor NTPSnippetsService::UpdateStateForStatus switch statement Created 4 years, 5 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/resources/snippets_internals.js
diff --git a/chrome/browser/resources/snippets_internals.js b/chrome/browser/resources/snippets_internals.js
index b44905c2733359c1f4844acdc4d86eefd9ff411d..0969dc45794273bb6947942b6926d6c074778a5b 100644
--- a/chrome/browser/resources/snippets_internals.js
+++ b/chrome/browser/resources/snippets_internals.js
@@ -38,6 +38,18 @@ cr.define('chrome.SnippetsInternals', function() {
event.preventDefault();
});
+ $('submit-clear-cached-suggestions')
+ .addEventListener('click', function(event) {
+ chrome.send('clearCachedSuggestions');
+ event.preventDefault();
+ });
+
+ $('submit-clear-discarded-suggestions')
+ .addEventListener('click', function(event) {
+ chrome.send('clearDiscardedSuggestions');
+ event.preventDefault();
+ });
+
chrome.send('loaded');
}
@@ -69,6 +81,11 @@ cr.define('chrome.SnippetsInternals', function() {
'discarded-snippet-title');
}
+ function receiveContentSuggestions(categoriesList) {
+ displayList(categoriesList, 'content-suggestions',
+ 'content-suggestion-title');
+ }
+
function receiveJson(json) {
var trimmed = json.trim();
var hasContent = (trimmed && trimmed != '{}');
@@ -91,6 +108,11 @@ cr.define('chrome.SnippetsInternals', function() {
link.click();
}
+ function toggleHidden(event) {
+ var id = event.currentTarget.getAttribute('hidden-id');
+ $(id).classList.toggle('hidden');
+ }
+
function displayList(object, domId, titleClass) {
jstProcess(new JsEvalContext(object), $(domId));
@@ -110,10 +132,7 @@ cr.define('chrome.SnippetsInternals', function() {
var links = document.getElementsByClassName(titleClass);
for (var link of links) {
- link.addEventListener('click', function(event) {
- var id = event.currentTarget.getAttribute('snippet-id');
- $(id).classList.toggle('hidden');
- });
+ link.addEventListener('click', toggleHidden);
}
}
@@ -125,6 +144,7 @@ cr.define('chrome.SnippetsInternals', function() {
receiveHosts: receiveHosts,
receiveSnippets: receiveSnippets,
receiveDiscardedSnippets: receiveDiscardedSnippets,
+ receiveContentSuggestions: receiveContentSuggestions,
receiveJson: receiveJson,
};
});
« no previous file with comments | « chrome/browser/resources/snippets_internals.html ('k') | chrome/browser/ui/webui/snippets_internals_message_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698