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

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

Issue 1987333003: [NTP Snippets] Persist snippets in a LevelDB instead of prefs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test memleaks 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
Index: chrome/browser/resources/snippets_internals.js
diff --git a/chrome/browser/resources/snippets_internals.js b/chrome/browser/resources/snippets_internals.js
index a9f7b57141ccf56d7e4987516aa520836b08eccf..b44905c2733359c1f4844acdc4d86eefd9ff411d 100644
--- a/chrome/browser/resources/snippets_internals.js
+++ b/chrome/browser/resources/snippets_internals.js
@@ -5,6 +5,9 @@
cr.define('chrome.SnippetsInternals', function() {
'use strict';
+ // Stores the list of snippets we received in receiveSnippets.
+ var lastSnippets = [];
+
function initialize() {
$('submit-download').addEventListener('click', function(event) {
chrome.send('download', [$('hosts-input').value]);
@@ -17,7 +20,7 @@ cr.define('chrome.SnippetsInternals', function() {
});
$('submit-dump').addEventListener('click', function(event) {
- chrome.send('dump');
+ downloadJson(JSON.stringify(lastSnippets));
event.preventDefault();
});
@@ -26,7 +29,7 @@ cr.define('chrome.SnippetsInternals', function() {
});
$('last-json-dump').addEventListener('click', function(event) {
- receiveJsonToDownload($('last-json-text').innerText);
+ downloadJson($('last-json-text').innerText);
event.preventDefault();
});
@@ -57,6 +60,7 @@ cr.define('chrome.SnippetsInternals', function() {
}
function receiveSnippets(snippets) {
+ lastSnippets = snippets;
displayList(snippets, 'snippets', 'snippet-title');
}
@@ -77,7 +81,7 @@ cr.define('chrome.SnippetsInternals', function() {
}
}
- function receiveJsonToDownload(json) {
+ function downloadJson(json) {
// Redirect the browser to download data in |json| as a file "snippets.json"
// (Setting Content-Disposition: attachment via a data: URL is not possible;
// create a link with download attribute and simulate a click, instead.)
@@ -122,7 +126,6 @@ cr.define('chrome.SnippetsInternals', function() {
receiveSnippets: receiveSnippets,
receiveDiscardedSnippets: receiveDiscardedSnippets,
receiveJson: receiveJson,
- receiveJsonToDownload: receiveJsonToDownload,
};
});

Powered by Google App Engine
This is Rietveld 408576698