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

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

Issue 1927993002: Allow dumping raw json fetched from the server. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: After code review #2 Created 4 years, 8 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 84164bba9684fc9e2013b3b563081822383f2ceb..b66c94100c5e26522bed565ea0ac1d327d46c858 100644
--- a/chrome/browser/resources/snippets_internals.js
+++ b/chrome/browser/resources/snippets_internals.js
@@ -21,6 +21,15 @@ cr.define('chrome.SnippetsInternals', function() {
event.preventDefault();
});
+ $('last-json-button').addEventListener('click', function(event) {
+ $('last-json-container').classList.toggle('hidden');
+ });
+
+ $('last-json-dump').addEventListener('click', function(event) {
+ receiveJsonToDownload($('last-json-text').innerText);
+ event.preventDefault();
+ });
+
$('discarded-snippets-clear').addEventListener('click', function(event) {
chrome.send('clearDiscarded');
event.preventDefault();
@@ -50,6 +59,15 @@ cr.define('chrome.SnippetsInternals', function() {
}
function receiveJson(json) {
+ receiveProperty('last-json-text', json);
+ if (json) {
+ $('last-json').classList.remove('hidden');
+ } else {
+ $('last-json').classList.add('hidden');
+ }
+ }
+
+ function receiveJsonToDownload(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.)
@@ -80,8 +98,7 @@ cr.define('chrome.SnippetsInternals', function() {
for (var link of links) {
link.addEventListener('click', function(event) {
var id = event.currentTarget.getAttribute('snippet-id');
- $(id).classList.toggle('snippet-hidden');
- event.preventDefault();
+ $(id).classList.toggle('hidden');
});
}
}
@@ -94,6 +111,7 @@ cr.define('chrome.SnippetsInternals', function() {
receiveSnippets: receiveSnippets,
receiveDiscardedSnippets: receiveDiscardedSnippets,
receiveJson: receiveJson,
+ receiveJsonToDownload: receiveJsonToDownload,
};
});
« 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