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

Unified Diff: chrome/browser/resources/net_internals/hstsview.js

Issue 6500010: HSTS: add net-internals UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/net_internals/hstsview.js
diff --git a/chrome/browser/resources/net_internals/hstsview.js b/chrome/browser/resources/net_internals/hstsview.js
new file mode 100644
index 0000000000000000000000000000000000000000..ba0b88d5da9a1f40f3d8ddf89602ac7c98e03558
--- /dev/null
+++ b/chrome/browser/resources/net_internals/hstsview.js
@@ -0,0 +1,107 @@
+// Copyright (c) 2011 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.
+
+function HSTSView(mainBoxId, queryInputId, formId, queryOutputDivId,
eroman 2011/02/16 20:12:45 Please add a high level comment explaining what th
agl 2011/02/16 22:46:22 Done.
+ addInputId, addFormId, addCheckId,
+ deleteInputId, deleteFormId) {
+ DivView.call(this, mainBoxId);
+
+ this.queryInput_ = document.getElementById(queryInputId);
+ this.addCheck_ = document.getElementById(addCheckId);
+ this.addInput_ = document.getElementById(addInputId);
+ this.deleteInput_ = document.getElementById(deleteInputId);
+ this.queryOutputDiv_ = document.getElementById(queryOutputDivId);
+
+ var form = document.getElementById(formId);
+ form.addEventListener('submit', this.onSubmitQuery_.bind(this), false);
+ form = document.getElementById(addFormId);
+ form.addEventListener('submit', this.onSubmitAdd_.bind(this), false);
+ form = document.getElementById(deleteFormId);
+ form.addEventListener('submit', this.onSubmitDelete_.bind(this), false);
+
+ g_browser.hstsQueryCallback = this.onQueryCallback_.bind(this);
+}
+
+inherits(HSTSView, DivView);
+
+HSTSView.prototype.onSubmitQuery_ = function(event) {
+ g_browser.sendHSTSQuery(this.queryInput_.value);
+ event.preventDefault();
+};
+
+HSTSView.prototype.onSubmitAdd_ = function(event) {
+ g_browser.sendHSTSAdd(this.addInput_.value, this.addCheck_.checked);
+ g_browser.sendHSTSQuery(this.addInput_.value);
+ this.queryInput_.value = this.addInput_.value;
+ this.addCheck_.checked = false;
+ this.addInput_.value = '';
+ event.preventDefault();
+};
+
+HSTSView.prototype.onSubmitDelete_ = function(event) {
+ g_browser.sendHSTSDelete(this.deleteInput_.value);
+ this.deleteInput_.value = '';
+ event.preventDefault();
+};
+
+function hstsModeToString(m) {
+ if (m == 0) {
+ return 'STRICT';
+ } else if (m == 1) {
+ return 'OPPORTUNISTIC';
+ } else if (m == 2) {
+ return 'SPDY';
+ } else {
+ return 'UNKNOWN';
+ }
+}
+
+function yellowFade(element) {
+ element.style.webkitTransitionProperty = 'background-color';
+ element.style.webkitTransitionDuration = '0';
+ element.style.backgroundColor = '#fffccf';
+ setTimeout(function() {
+ element.style.webkitTransitionDuration = '1000ms';
+ element.style.backgroundColor = '#fff';
+ }, 0);
+}
+
+HSTSView.prototype.onQueryCallback_ = function(result) {
+ if (result.result == false) {
+ this.queryOutputDiv_.innerHTML = '<b>Not found</b>';
+ } else {
+ while (this.queryOutputDiv_.firstChild != null)
eroman 2011/02/16 20:12:45 Is the intent here to delete all children inside q
+ this.queryOutputDiv_.removeChild(this.queryOutputDiv_.firstChild);
+
+ s = document.createElement('span')
eroman 2011/02/16 20:12:45 There is also a convenience function to help with
mmenke 2011/02/16 20:22:49 nit: A number of these lines are missing semi-col
agl 2011/02/16 22:46:22 Done.
agl 2011/02/16 22:46:22 Done.
+ s.innerHTML = '<b>Found</b>: mode: '
+ this.queryOutputDiv_.appendChild(s)
+
+ t = document.createElement('tt')
+ t.innerText = hstsModeToString(result.mode);
+ this.queryOutputDiv_.appendChild(t)
+
+ t = document.createTextNode(' include_subdomains: ')
eroman 2011/02/16 20:12:45 We have a convenience method for this: addTextNod
agl 2011/02/16 22:46:22 Done.
+ this.queryOutputDiv_.appendChild(t)
+
+ t = document.createElement('tt')
+ t.innerText = result.subdomains;
+ this.queryOutputDiv_.appendChild(t)
+
+ t = document.createTextNode(' domain: ')
+ this.queryOutputDiv_.appendChild(t)
+
+ t = document.createElement('tt')
+ t.innerText = result.domain;
+ this.queryOutputDiv_.appendChild(t)
+
+ t = document.createTextNode(' is_preloaded: ')
+ this.queryOutputDiv_.appendChild(t)
+
+ t = document.createElement('tt')
+ t.innerText = result.preloaded;
+ this.queryOutputDiv_.appendChild(t)
+ }
+ yellowFade(this.queryOutputDiv_);
+}

Powered by Google App Engine
This is Rietveld 408576698