| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('offlineInternals', function() { | 5 cr.define('offlineInternals', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** @type {!Array<OfflinePage>} */ | 8 /** @type {!Array<OfflinePage>} */ |
| 9 var offlinePages = []; | 9 var offlinePages = []; |
| 10 | 10 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 browserProxy_.getNetworkStatus().then(function(networkStatus) { | 121 browserProxy_.getNetworkStatus().then(function(networkStatus) { |
| 122 $('current-status').textContent = networkStatus; | 122 $('current-status').textContent = networkStatus; |
| 123 }); | 123 }); |
| 124 refreshLog(); | 124 refreshLog(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 /** | 127 /** |
| 128 * Delete all pages in the offline store. | 128 * Delete all pages in the offline store. |
| 129 */ | 129 */ |
| 130 function deleteAllPages() { | 130 function deleteAllPages() { |
| 131 browserProxy_.deleteAllPages().then(pagesDeleted); | 131 var checkboxes = document.getElementsByName('stored'); |
| 132 var selectedIds = []; |
| 133 |
| 134 for (var i = 0; i < checkboxes.length; i++) { |
| 135 selectedIds.push(checkboxes[i].value); |
| 136 } |
| 137 |
| 138 browserProxy_.deleteSelectedPages(selectedIds).then(pagesDeleted); |
| 132 } | 139 } |
| 133 | 140 |
| 134 /** | 141 /** |
| 135 * Delete all pending SavePageRequest items in the request queue. | 142 * Delete all pending SavePageRequest items in the request queue. |
| 136 */ | 143 */ |
| 137 function deleteAllRequests() { | 144 function deleteAllRequests() { |
| 138 browserProxy_.deleteAllRequests().then(requestsDeleted); | 145 var checkboxes = document.getElementsByName('requests'); |
| 146 var selectedIds = []; |
| 147 |
| 148 for (var i = 0; i < checkboxes.length; i++) { |
| 149 selectedIds.push(checkboxes[i].value); |
| 150 } |
| 151 |
| 152 browserProxy_.deleteSelectedRequests(selectedIds).then(requestsDeleted); |
| 139 } | 153 } |
| 140 | 154 |
| 141 /** | 155 /** |
| 142 * Callback when pages are deleted. | 156 * Callback when pages are deleted. |
| 143 * @param {string} status The status of the request. | 157 * @param {string} status The status of the request. |
| 144 */ | 158 */ |
| 145 function pagesDeleted(status) { | 159 function pagesDeleted(status) { |
| 146 $('page-actions-info').textContent = status; | 160 $('page-actions-info').textContent = status; |
| 147 browserProxy_.getStoredPages().then(fillStoredPages); | 161 browserProxy_.getStoredPages().then(fillStoredPages); |
| 148 } | 162 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 242 |
| 229 /** | 243 /** |
| 230 * @param {!boolean} enabled Whether to enable Logging. | 244 * @param {!boolean} enabled Whether to enable Logging. |
| 231 */ | 245 */ |
| 232 function toggleRequestQueueLog(enabled) { | 246 function toggleRequestQueueLog(enabled) { |
| 233 browserProxy_.setRecordRequestQueue(enabled); | 247 browserProxy_.setRecordRequestQueue(enabled); |
| 234 $('request-status').textContent = enabled ? 'On' : 'Off'; | 248 $('request-status').textContent = enabled ? 'On' : 'Off'; |
| 235 } | 249 } |
| 236 | 250 |
| 237 var incognito = loadTimeData.getBoolean('isIncognito'); | 251 var incognito = loadTimeData.getBoolean('isIncognito'); |
| 238 $('clear-all').disabled = incognito; | 252 $('delete-all-pages').disabled = incognito; |
| 239 $('clear-selected').disabled = incognito; | 253 $('delete-selected-pages').disabled = incognito; |
| 240 $('delete-all-requests').disabled = incognito; | 254 $('delete-all-requests').disabled = incognito; |
| 241 $('delete-selected-requests').disabled = incognito; | 255 $('delete-selected-requests').disabled = incognito; |
| 242 $('log-model-on').disabled = incognito; | 256 $('log-model-on').disabled = incognito; |
| 243 $('log-model-off').disabled = incognito; | 257 $('log-model-off').disabled = incognito; |
| 244 $('log-request-on').disabled = incognito; | 258 $('log-request-on').disabled = incognito; |
| 245 $('log-request-off').disabled = incognito; | 259 $('log-request-off').disabled = incognito; |
| 246 $('refresh').disabled = incognito; | 260 $('refresh').disabled = incognito; |
| 247 | 261 |
| 248 $('clear-all').onclick = deleteAllPages; | 262 $('delete-all-pages').onclick = deleteAllPages; |
| 249 $('clear-selected').onclick = deleteSelectedPages; | 263 $('delete-selected-pages').onclick = deleteSelectedPages; |
| 250 $('delete-all-requests').onclick = deleteAllRequests; | 264 $('delete-all-requests').onclick = deleteAllRequests; |
| 251 $('delete-selected-requests').onclick = deleteSelectedRequests; | 265 $('delete-selected-requests').onclick = deleteSelectedRequests; |
| 252 $('refresh').onclick = refreshAll; | 266 $('refresh').onclick = refreshAll; |
| 253 $('download').onclick = download; | 267 $('download').onclick = download; |
| 254 $('log-model-on').onclick = togglePageModelLog.bind(this, true); | 268 $('log-model-on').onclick = togglePageModelLog.bind(this, true); |
| 255 $('log-model-off').onclick = togglePageModelLog.bind(this, false); | 269 $('log-model-off').onclick = togglePageModelLog.bind(this, false); |
| 256 $('log-request-on').onclick = toggleRequestQueueLog.bind(this, true); | 270 $('log-request-on').onclick = toggleRequestQueueLog.bind(this, true); |
| 257 $('log-request-off').onclick = toggleRequestQueueLog.bind(this, false); | 271 $('log-request-off').onclick = toggleRequestQueueLog.bind(this, false); |
| 258 $('refresh-logs').onclick = refreshLog; | 272 $('refresh-logs').onclick = refreshLog; |
| 259 $('add-to-queue').onclick = function() { | 273 $('add-to-queue').onclick = function() { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 282 refreshAll(); | 296 refreshAll(); |
| 283 } | 297 } |
| 284 | 298 |
| 285 // Return an object with all of the exports. | 299 // Return an object with all of the exports. |
| 286 return { | 300 return { |
| 287 initialize: initialize, | 301 initialize: initialize, |
| 288 }; | 302 }; |
| 289 }); | 303 }); |
| 290 | 304 |
| 291 document.addEventListener('DOMContentLoaded', offlineInternals.initialize); | 305 document.addEventListener('DOMContentLoaded', offlineInternals.initialize); |
| OLD | NEW |