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

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: 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..c8a3593078939809ad3d60e17e0971d15a4bfe35 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 != '{}');
@@ -110,10 +127,10 @@ 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');
+ link.onclick = function(event) {
Marc Treib 2016/07/12 13:04:52 Forgive my ignorance, but is there any difference
Bernhard Bauer 2016/07/12 13:09:45 I would either use addEventListener everywhere or
Philipp Keck 2016/07/12 13:45:02 onclick allows for one, removal by ".onclick = nul
Marc Treib 2016/07/12 13:49:47 I'm moderately sure that it *was* actually an issu
jkrcal 2016/07/13 11:35:23 I can confirm that the toggle behaved weirdly some
+ var id = event.currentTarget.getAttribute('hidden-id');
$(id).classList.toggle('hidden');
- });
+ };
}
}
@@ -125,6 +142,7 @@ cr.define('chrome.SnippetsInternals', function() {
receiveHosts: receiveHosts,
receiveSnippets: receiveSnippets,
receiveDiscardedSnippets: receiveDiscardedSnippets,
+ receiveContentSuggestions: receiveContentSuggestions,
receiveJson: receiveJson,
};
});

Powered by Google App Engine
This is Rietveld 408576698