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

Side by Side Diff: content/browser/resources/net/network_errors_listing.js

Issue 1421743002: Implement chrome://network-errors for direct access to network error interstitials (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix presubmit errors Created 5 years 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 cr.define('errorCodes', function() {
6 'use strict';
7
8 /**
9 * Generate the page content.
10 * @param {Array.<Object>} errorCodes Error codes array consisting of a
11 * numerical error ID and error code string.
12 */
13 function listErrorCodes(errorCodes) {
14 var errorPageUrl = 'chrome://network-error/';
15 var errorCodesList = document.createElement('ul');
16 for (var i = 0; i < errorCodes.length; i++) {
17 var listEl = document.createElement('li');
18 var errorCodeLinkEl = document.createElement('a');
19 errorCodeLinkEl.href = errorPageUrl + errorCodes[i].errorId;
20 errorCodeLinkEl.textContent = errorCodes[i].errorCode + ' (' +
21 errorCodes[i].errorId + ')';
22 listEl.appendChild(errorCodeLinkEl);
23 errorCodesList.appendChild(listEl);
24 }
25 $('pages').appendChild(errorCodesList);
26 }
27
28 function initialize() {
29 var xhr = new XMLHttpRequest();
30 xhr.open('GET', 'network-error-data.json');
31 xhr.addEventListener('load', function(e) {
32 if (xhr.status === 200) {
33 try {
34 var data = JSON.parse(xhr.responseText);
35 listErrorCodes(data['errorCodes']);
36 } catch (e) {
37 $('pages').innerText = 'Could not parse the error codes data. ' +
38 'Try reloading the page.';
39 }
40 }
41 });
42 xhr.send();
43 }
44
45 return {
46 initialize: initialize
47 };
48 });
49
50 document.addEventListener('DOMContentLoaded', errorCodes.initialize);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698