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

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

Issue 2225753003: Revert of Add per-section clearing and dismissed suggestions to snippets-internals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 673c697fd5e2fa30e0b79631ab4eb76e14dfcd20..79c9ad1426bd5a717333a712def4f2a31f2e828f 100644
--- a/chrome/browser/resources/snippets_internals.js
+++ b/chrome/browser/resources/snippets_internals.js
@@ -5,8 +5,8 @@
cr.define('chrome.SnippetsInternals', function() {
'use strict';
- // Stores the list of suggestions we received in receiveContentSuggestions.
- var lastSuggestions = [];
+ // Stores the list of snippets we received in receiveSnippets.
+ var lastSnippets = [];
function initialize() {
$('submit-download').addEventListener('click', function(event) {
@@ -14,8 +14,13 @@
event.preventDefault();
});
+ $('submit-clear').addEventListener('click', function(event) {
+ chrome.send('clear');
+ event.preventDefault();
+ });
+
$('submit-dump').addEventListener('click', function(event) {
- downloadJson(JSON.stringify(lastSuggestions));
+ downloadJson(JSON.stringify(lastSnippets));
event.preventDefault();
});
@@ -25,6 +30,23 @@
$('last-json-dump').addEventListener('click', function(event) {
downloadJson($('last-json-text').innerText);
+ event.preventDefault();
+ });
+
+ $('dismissed-snippets-clear').addEventListener('click', function(event) {
+ chrome.send('clearDismissed');
+ event.preventDefault();
+ });
+
+ $('submit-clear-cached-suggestions')
+ .addEventListener('click', function(event) {
+ chrome.send('clearCachedSuggestions');
+ event.preventDefault();
+ });
+
+ $('submit-clear-dismissed-suggestions')
+ .addEventListener('click', function(event) {
+ chrome.send('clearDismissedSuggestions');
event.preventDefault();
});
@@ -52,34 +74,19 @@
function(host) { return host.url;}).join(' ');
}
- function receiveContentSuggestions(categoriesList) {
- lastSuggestions = categoriesList;
- displayList(categoriesList, 'content-suggestions',
- 'hidden-toggler');
-
- var clearCachedButtons =
- document.getElementsByClassName('submit-clear-cached-suggestions');
- for (var button of clearCachedButtons) {
- button.addEventListener('click', onClearCachedButtonClicked);
- }
-
- var clearDismissedButtons =
- document.getElementsByClassName('submit-clear-dismissed-suggestions');
- for (var button of clearDismissedButtons) {
- button.addEventListener('click', onClearDismissedButtonClicked);
- }
+ function receiveSnippets(snippets) {
+ lastSnippets = snippets;
+ displayList(snippets, 'snippets', 'snippet-title');
}
- function onClearCachedButtonClicked(event) {
- event.preventDefault();
- var id = parseInt(event.currentTarget.getAttribute('category-id'), 10);
- chrome.send('clearCachedSuggestions', [id]);
+ function receiveDismissedSnippets(dismissedSnippets) {
+ displayList(dismissedSnippets, 'dismissed-snippets',
+ 'dismissed-snippet-title');
}
- function onClearDismissedButtonClicked(event) {
- event.preventDefault();
- var id = parseInt(event.currentTarget.getAttribute('category-id'), 10);
- chrome.send('clearDismissedSuggestions', [id]);
+ function receiveContentSuggestions(categoriesList) {
+ displayList(categoriesList, 'content-suggestions',
+ 'content-suggestion-title');
}
function receiveJson(json) {
@@ -113,7 +120,7 @@
$(id).classList.toggle('hidden');
}
- function displayList(object, domId, toggleClass) {
+ function displayList(object, domId, titleClass) {
jstProcess(new JsEvalContext(object), $(domId));
var text;
@@ -130,7 +137,7 @@
if ($(domId + '-empty')) $(domId + '-empty').textContent = text;
if ($(domId + '-clear')) $(domId + '-clear').style.display = display;
- var links = document.getElementsByClassName(toggleClass);
+ var links = document.getElementsByClassName(titleClass);
for (var link of links) {
link.addEventListener('click', toggleHidden);
}
@@ -142,6 +149,8 @@
setHostRestricted: setHostRestricted,
receiveProperty: receiveProperty,
receiveHosts: receiveHosts,
+ receiveSnippets: receiveSnippets,
+ receiveDismissedSnippets: receiveDismissedSnippets,
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