| 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 } | 171 } |
| 172 | 172 |
| 173 /** | 173 /** |
| 174 * Callback when requests are deleted. | 174 * Callback when requests are deleted. |
| 175 */ | 175 */ |
| 176 function requestsDeleted(status) { | 176 function requestsDeleted(status) { |
| 177 $('request-queue-actions-info').textContent = status; | 177 $('request-queue-actions-info').textContent = status; |
| 178 browserProxy.getRequestQueue().then(fillRequestQueue); | 178 browserProxy.getRequestQueue().then(fillRequestQueue); |
| 179 } | 179 } |
| 180 | 180 |
| 181 /** |
| 182 * Callback for prefetch actions. |
| 183 * @param {string} info The result of performing the prefetch actions. |
| 184 */ |
| 185 function setPrefetchResult(info) { |
| 186 $('prefetch-actions-info').textContent = info; |
| 187 } |
| 188 |
| 181 /** | 189 /** |
| 182 * Downloads all the stored page and request queue information into a file. | 190 * Downloads all the stored page and request queue information into a file. |
| 183 * TODO(chili): Create a CSV writer that can abstract out the line joining. | 191 * TODO(chili): Create a CSV writer that can abstract out the line joining. |
| 184 */ | 192 */ |
| 185 function download() { | 193 function download() { |
| 186 var json = JSON.stringify({ | 194 var json = JSON.stringify({ |
| 187 offlinePages: offlinePages, | 195 offlinePages: offlinePages, |
| 188 savePageRequests: savePageRequests | 196 savePageRequests: savePageRequests |
| 189 }, null, 2); | 197 }, null, 2); |
| 190 | 198 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 browserProxy.getRequestQueue().then(fillRequestQueue); | 318 browserProxy.getRequestQueue().then(fillRequestQueue); |
| 311 } | 319 } |
| 312 } else { | 320 } else { |
| 313 $('save-url-state').textContent += | 321 $('save-url-state').textContent += |
| 314 saveUrls[i] + ' failed to be added to queue.\n'; | 322 saveUrls[i] + ' failed to be added to queue.\n'; |
| 315 } | 323 } |
| 316 }); | 324 }); |
| 317 } | 325 } |
| 318 }; | 326 }; |
| 319 $('schedule-nwake').onclick = function() { | 327 $('schedule-nwake').onclick = function() { |
| 320 browserProxy.scheduleNwake(); | 328 browserProxy.scheduleNwake().then(setPrefetchResult); |
| 321 }; | 329 }; |
| 322 $('cancel-nwake').onclick = function() { | 330 $('cancel-nwake').onclick = function() { |
| 323 browserProxy.cancelNwake(); | 331 browserProxy.cancelNwake().then(setPrefetchResult); |
| 332 }; |
| 333 $('generate-page-bundle').onclick = function() { |
| 334 browserProxy.generatePageBundle($('generate-urls').value). |
| 335 then(setPrefetchResult); |
| 336 }; |
| 337 $('get-operation').onclick = function() { |
| 338 browserProxy.getOperation($('operation-name').value). |
| 339 then(setPrefetchResult); |
| 324 }; | 340 }; |
| 325 if (!incognito) | 341 if (!incognito) |
| 326 refreshAll(); | 342 refreshAll(); |
| 327 } | 343 } |
| 328 | 344 |
| 329 // Return an object with all of the exports. | 345 // Return an object with all of the exports. |
| 330 return { | 346 return { |
| 331 initialize: initialize, | 347 initialize: initialize, |
| 332 }; | 348 }; |
| 333 }); | 349 }); |
| 334 | 350 |
| 335 document.addEventListener('DOMContentLoaded', offlineInternals.initialize); | 351 document.addEventListener('DOMContentLoaded', offlineInternals.initialize); |
| OLD | NEW |