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

Unified Diff: chrome/browser/resources/offline_pages/offline_internals.js

Issue 2328973003: Adds a delete button to chrome:offline-internals (Closed)
Patch Set: CR feedback per BauerB Created 4 years, 3 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/offline_pages/offline_internals.js
diff --git a/chrome/browser/resources/offline_pages/offline_internals.js b/chrome/browser/resources/offline_pages/offline_internals.js
index baa0d181feaf049c62c42c543222fd0c0d8cd627..e746c39df7ea0627c570eecdac1a2e474027d62a 100644
--- a/chrome/browser/resources/offline_pages/offline_internals.js
+++ b/chrome/browser/resources/offline_pages/offline_internals.js
@@ -72,6 +72,15 @@ cr.define('offlineInternals', function() {
for (var i = 0; i < requests.length; i++) {
var row = document.createElement('tr');
+ var checkboxCell = document.createElement('td');
+ var checkbox = document.createElement('input');
+ checkbox.setAttribute('type', 'checkbox');
+ checkbox.setAttribute('name', 'requests');
+ checkbox.setAttribute('value', requests[i].id);
+
+ checkboxCell.appendChild(checkbox);
+ row.appendChild(checkboxCell);
+
var cell = document.createElement('td');
cell.textContent = requests[i].onlineUrl;
row.appendChild(cell);
@@ -123,6 +132,13 @@ cr.define('offlineInternals', function() {
}
/**
+ * Delete all pending SavePageRequest items in the request queue.
+ */
+ function deleteAllRequests() {
+ browserProxy_.deleteAllRequests().then(requestsDeleted);
+ }
+
+ /**
* Callback when pages are deleted.
* @param {string} status The status of the request.
*/
@@ -132,6 +148,14 @@ cr.define('offlineInternals', function() {
}
/**
+ * Callback when requests are deleted.
+ */
+ function requestsDeleted(status) {
+ $('request-queue-actions-info').textContent = status;
+ browserProxy_.getRequestQueue().then(fillRequestQueue);
+ }
+
+ /**
* 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.
*/
@@ -171,6 +195,21 @@ cr.define('offlineInternals', function() {
}
/**
+ * Delete selected SavePageRequest items from the request queue.
+ */
+ function deleteSelectedRequests() {
+ var checkboxes = document.getElementsByName('requests');
+ var selectedIds = [];
+
+ for (var i = 0; i < checkboxes.length; i++) {
+ if (checkboxes[i].checked)
+ selectedIds.push(checkboxes[i].value);
+ }
+
+ browserProxy_.deleteSelectedRequests(selectedIds).then(requestsDeleted);
+ }
+
+ /**
* Refreshes the logs.
*/
function refreshLog() {
@@ -198,6 +237,8 @@ cr.define('offlineInternals', function() {
var incognito = loadTimeData.getBoolean('isIncognito');
$('clear-all').disabled = incognito;
$('clear-selected').disabled = incognito;
+ $('delete-all-requests').disabled = incognito;
+ $('delete-selected-requests').disabled = incognito;
$('log-model-on').disabled = incognito;
$('log-model-off').disabled = incognito;
$('log-request-on').disabled = incognito;
@@ -206,6 +247,8 @@ cr.define('offlineInternals', function() {
$('clear-all').onclick = deleteAllPages;
$('clear-selected').onclick = deleteSelectedPages;
+ $('delete-all-requests').onclick = deleteAllRequests;
+ $('delete-selected-requests').onclick = deleteSelectedRequests;
$('refresh').onclick = refreshAll;
$('download').onclick = download;
$('log-model-on').onclick = togglePageModelLog.bind(this, true);

Powered by Google App Engine
This is Rietveld 408576698