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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/resources/net/network_errors_listing.js
diff --git a/content/browser/resources/net/network_errors_listing.js b/content/browser/resources/net/network_errors_listing.js
new file mode 100644
index 0000000000000000000000000000000000000000..04bb8c22ca00270953fe8a0d8c2185dc5537f1d6
--- /dev/null
+++ b/content/browser/resources/net/network_errors_listing.js
@@ -0,0 +1,50 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+cr.define('errorCodes', function() {
+ 'use strict';
+
+ /**
+ * Generate the page content.
+ * @param {Array.<Object>} errorCodes Error codes array consisting of a
+ * numerical error ID and error code string.
+ */
+ function listErrorCodes(errorCodes) {
+ var errorPageUrl = 'chrome://network-error/';
+ var errorCodesList = document.createElement('ul');
+ for (var i = 0; i < errorCodes.length; i++) {
+ var listEl = document.createElement('li');
+ var errorCodeLinkEl = document.createElement('a');
+ errorCodeLinkEl.href = errorPageUrl + errorCodes[i].errorId;
+ errorCodeLinkEl.textContent = errorCodes[i].errorCode + ' (' +
+ errorCodes[i].errorId + ')';
+ listEl.appendChild(errorCodeLinkEl);
+ errorCodesList.appendChild(listEl);
+ }
+ $('pages').appendChild(errorCodesList);
+ }
+
+ function initialize() {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', 'network-error-data.json');
+ xhr.addEventListener('load', function(e) {
+ if (xhr.status === 200) {
+ try {
+ var data = JSON.parse(xhr.responseText);
+ listErrorCodes(data['errorCodes']);
+ } catch (e) {
+ $('pages').innerText = 'Could not parse the error codes data. ' +
+ 'Try reloading the page.';
+ }
+ }
+ });
+ xhr.send();
+ }
+
+ return {
+ initialize: initialize
+ };
+});
+
+document.addEventListener('DOMContentLoaded', errorCodes.initialize);

Powered by Google App Engine
This is Rietveld 408576698