Commit 46dd8d1d authored by Cathy Li's avatar Cathy Li Committed by Commit Bot

[Offline pages][Internals] Update internal page download to not use dataurl

Data urls are disabled from top-level navigations as of Chrome 60. This will
display the JSON in a floating textarea instead.

Bug: 775599
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I6a66eaf19f005cbf75640db146ea4ca4acf26277
Reviewed-on: https://chromium-review.googlesource.com/724236
Commit-Queue: Cathy Li <chili@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarJustin DeWitt <dewittj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#513234}
parent 41a2423f
...@@ -47,6 +47,10 @@ li:nth-child(2n) { ...@@ -47,6 +47,10 @@ li:nth-child(2n) {
background-color: lavender; background-color: lavender;
} }
dialog {
border: none;
}
#current-status { #current-status {
font-size: 15px; font-size: 15px;
} }
...@@ -55,3 +59,10 @@ li:nth-child(2n) { ...@@ -55,3 +59,10 @@ li:nth-child(2n) {
font-family: monospace; font-family: monospace;
white-space: pre-wrap; white-space: pre-wrap;
} }
#dump-box {
box-sizing: border-box;
display: block;
resize: none;
width: 100%;
}
...@@ -19,8 +19,15 @@ ...@@ -19,8 +19,15 @@
<div> <div>
<span id="current-status"></span> <span id="current-status"></span>
<button id="refresh">Refresh page</button> <button id="refresh">Refresh page</button>
<button id="download">Dump</button> <button id="dump">Dump</button>
</div> </div>
<dialog id="dump">
<textarea id="dump-box" name="json-box" rows="10" cols="40" readonly>
</textarea>
<button id="copy-to-clipboard">Copy</button>
<button id="close-dump">Close</button>
<span id="dump-info"></span>
</dialog>
<h2>Event Logs</h2> <h2>Event Logs</h2>
<div> <div>
......
...@@ -173,13 +173,26 @@ cr.define('offlineInternals', function() { ...@@ -173,13 +173,26 @@ cr.define('offlineInternals', function() {
* Downloads all the stored page and request queue information into a file. * Downloads all the stored page and request queue information into a file.
* TODO(chili): Create a CSV writer that can abstract out the line joining. * TODO(chili): Create a CSV writer that can abstract out the line joining.
*/ */
function download() { function dumpAsJson() {
var json = JSON.stringify( var json = JSON.stringify(
{offlinePages: offlinePages, savePageRequests: savePageRequests}, null, {offlinePages: offlinePages, savePageRequests: savePageRequests}, null,
2); 2);
window.open( $('dump-box').value = json;
'data:application/json,' + encodeURIComponent(json), 'dump.json'); $('dump-info').textContent = '';
$('dump').showModal();
$('dump-box').select();
}
function closeDump() {
$('dump').close();
$('dump-box').value = '';
}
function copyDump() {
$('dump-box').select();
document.execCommand('copy');
$('dump-info').textContent = 'Copied to clipboard!';
} }
/** /**
...@@ -260,22 +273,19 @@ cr.define('offlineInternals', function() { ...@@ -260,22 +273,19 @@ cr.define('offlineInternals', function() {
} }
var incognito = loadTimeData.getBoolean('isIncognito'); var incognito = loadTimeData.getBoolean('isIncognito');
$('delete-all-pages').disabled = incognito; ['delete-all-pages', 'delete-selected-pages', 'delete-all-requests',
$('delete-selected-pages').disabled = incognito; 'delete-selected-requests', 'log-model-on', 'log-model-off',
$('delete-all-requests').disabled = incognito; 'log-request-on', 'log-request-off', 'refresh']
$('delete-selected-requests').disabled = incognito; .forEach(el => $(el).disabled = incognito);
$('log-model-on').disabled = incognito;
$('log-model-off').disabled = incognito;
$('log-request-on').disabled = incognito;
$('log-request-off').disabled = incognito;
$('refresh').disabled = incognito;
$('delete-all-pages').onclick = deleteAllPages; $('delete-all-pages').onclick = deleteAllPages;
$('delete-selected-pages').onclick = deleteSelectedPages; $('delete-selected-pages').onclick = deleteSelectedPages;
$('delete-all-requests').onclick = deleteAllRequests; $('delete-all-requests').onclick = deleteAllRequests;
$('delete-selected-requests').onclick = deleteSelectedRequests; $('delete-selected-requests').onclick = deleteSelectedRequests;
$('refresh').onclick = refreshAll; $('refresh').onclick = refreshAll;
$('download').onclick = download; $('dump').onclick = dumpAsJson;
$('close-dump').onclick = closeDump;
$('copy-to-clipboard').onclick = copyDump;
$('log-model-on').onclick = togglePageModelLog.bind(this, true); $('log-model-on').onclick = togglePageModelLog.bind(this, true);
$('log-model-off').onclick = togglePageModelLog.bind(this, false); $('log-model-off').onclick = togglePageModelLog.bind(this, false);
$('log-request-on').onclick = toggleRequestQueueLog.bind(this, true); $('log-request-on').onclick = toggleRequestQueueLog.bind(this, true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment