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

Side by Side Diff: chrome/browser/resources/offline_pages/offline_internals.js

Issue 2939273002: DO NOT SUBMIT: what chrome/browser/resources/ could eventually look like with clang-format (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
OLDNEW
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
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 /** 181 /**
182 * Callback for prefetch actions. 182 * Callback for prefetch actions.
183 * @param {string} info The result of performing the prefetch actions. 183 * @param {string} info The result of performing the prefetch actions.
184 */ 184 */
185 function setPrefetchResult(info) { 185 function setPrefetchResult(info) {
186 $('prefetch-actions-info').textContent = info; 186 $('prefetch-actions-info').textContent = info;
187 } 187 }
188 188
189 /** 189 /**
190 * 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.
191 * 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.
192 */ 192 */
193 function download() { 193 function download() {
194 var json = JSON.stringify({ 194 var json = JSON.stringify(
195 offlinePages: offlinePages, 195 {offlinePages: offlinePages, savePageRequests: savePageRequests}, null,
196 savePageRequests: savePageRequests 196 2);
197 }, null, 2);
198 197
199 window.open( 198 window.open(
200 'data:application/json,' + encodeURIComponent(json), 199 'data:application/json,' + encodeURIComponent(json), 'dump.json');
201 'dump.json');
202 } 200 }
203 201
204 /** 202 /**
205 * Updates the status strings. 203 * Updates the status strings.
206 * @param {!IsLogging} logStatus Status of logging. 204 * @param {!IsLogging} logStatus Status of logging.
207 */ 205 */
208 function updateLogStatus(logStatus) { 206 function updateLogStatus(logStatus) {
209 $('model-status').textContent = getTextLabel(logStatus.modelIsLogging); 207 $('model-status').textContent = getTextLabel(logStatus.modelIsLogging);
210 $('request-status').textContent = getTextLabel(logStatus.queueIsLogging); 208 $('request-status').textContent = getTextLabel(logStatus.queueIsLogging);
211 $('prefetch-status').textContent = 209 $('prefetch-status').textContent =
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 $('log-request-on').onclick = toggleRequestQueueLog.bind(this, true); 298 $('log-request-on').onclick = toggleRequestQueueLog.bind(this, true);
301 $('log-request-off').onclick = toggleRequestQueueLog.bind(this, false); 299 $('log-request-off').onclick = toggleRequestQueueLog.bind(this, false);
302 $('log-prefetch-on').onclick = togglePrefetchServiceLog.bind(this, true); 300 $('log-prefetch-on').onclick = togglePrefetchServiceLog.bind(this, true);
303 $('log-prefetch-off').onclick = togglePrefetchServiceLog.bind(this, false); 301 $('log-prefetch-off').onclick = togglePrefetchServiceLog.bind(this, false);
304 $('refresh-logs').onclick = refreshLog; 302 $('refresh-logs').onclick = refreshLog;
305 $('add-to-queue').onclick = function() { 303 $('add-to-queue').onclick = function() {
306 var saveUrls = $('url').value.split(','); 304 var saveUrls = $('url').value.split(',');
307 var counter = saveUrls.length; 305 var counter = saveUrls.length;
308 $('save-url-state').textContent = ''; 306 $('save-url-state').textContent = '';
309 for (let i = 0; i < saveUrls.length; i++) { 307 for (let i = 0; i < saveUrls.length; i++) {
310 browserProxy.addToRequestQueue(saveUrls[i]) 308 browserProxy.addToRequestQueue(saveUrls[i]).then(function(state) {
311 .then(function(state) { 309 if (state) {
312 if (state) { 310 $('save-url-state').textContent +=
313 $('save-url-state').textContent += 311 saveUrls[i] + ' has been added to queue.\n';
314 saveUrls[i] + ' has been added to queue.\n'; 312 $('url').value = '';
315 $('url').value = ''; 313 counter--;
316 counter--; 314 if (counter == 0) {
317 if (counter == 0) { 315 browserProxy.getRequestQueue().then(fillRequestQueue);
318 browserProxy.getRequestQueue().then(fillRequestQueue); 316 }
319 } 317 } else {
320 } else { 318 $('save-url-state').textContent +=
321 $('save-url-state').textContent += 319 saveUrls[i] + ' failed to be added to queue.\n';
322 saveUrls[i] + ' failed to be added to queue.\n'; 320 }
323 } 321 });
324 });
325 } 322 }
326 }; 323 };
327 $('schedule-nwake').onclick = function() { 324 $('schedule-nwake').onclick = function() {
328 browserProxy.scheduleNwake().then(setPrefetchResult); 325 browserProxy.scheduleNwake().then(setPrefetchResult);
329 }; 326 };
330 $('cancel-nwake').onclick = function() { 327 $('cancel-nwake').onclick = function() {
331 browserProxy.cancelNwake().then(setPrefetchResult); 328 browserProxy.cancelNwake().then(setPrefetchResult);
332 }; 329 };
333 $('generate-page-bundle').onclick = function() { 330 $('generate-page-bundle').onclick = function() {
334 browserProxy.generatePageBundle($('generate-urls').value). 331 browserProxy.generatePageBundle($('generate-urls').value)
335 then(setPrefetchResult); 332 .then(setPrefetchResult);
336 }; 333 };
337 $('get-operation').onclick = function() { 334 $('get-operation').onclick = function() {
338 browserProxy.getOperation($('operation-name').value). 335 browserProxy.getOperation($('operation-name').value)
339 then(setPrefetchResult); 336 .then(setPrefetchResult);
340 }; 337 };
341 if (!incognito) 338 if (!incognito)
342 refreshAll(); 339 refreshAll();
343 } 340 }
344 341
345 // Return an object with all of the exports. 342 // Return an object with all of the exports.
346 return { 343 return {
347 initialize: initialize, 344 initialize: initialize,
348 }; 345 };
349 }); 346 });
350 347
351 document.addEventListener('DOMContentLoaded', offlineInternals.initialize); 348 document.addEventListener('DOMContentLoaded', offlineInternals.initialize);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698