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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 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.
6 addInputId, addFormId, addCheckId,
7 deleteInputId, deleteFormId) {
8 DivView.call(this, mainBoxId);
9
10 this.queryInput_ = document.getElementById(queryInputId);
11 this.addCheck_ = document.getElementById(addCheckId);
12 this.addInput_ = document.getElementById(addInputId);
13 this.deleteInput_ = document.getElementById(deleteInputId);
14 this.queryOutputDiv_ = document.getElementById(queryOutputDivId);
15
16 var form = document.getElementById(formId);
17 form.addEventListener('submit', this.onSubmitQuery_.bind(this), false);
18 form = document.getElementById(addFormId);
19 form.addEventListener('submit', this.onSubmitAdd_.bind(this), false);
20 form = document.getElementById(deleteFormId);
21 form.addEventListener('submit', this.onSubmitDelete_.bind(this), false);
22
23 g_browser.hstsQueryCallback = this.onQueryCallback_.bind(this);
24 }
25
26 inherits(HSTSView, DivView);
27
28 HSTSView.prototype.onSubmitQuery_ = function(event) {
29 g_browser.sendHSTSQuery(this.queryInput_.value);
30 event.preventDefault();
31 };
32
33 HSTSView.prototype.onSubmitAdd_ = function(event) {
34 g_browser.sendHSTSAdd(this.addInput_.value, this.addCheck_.checked);
35 g_browser.sendHSTSQuery(this.addInput_.value);
36 this.queryInput_.value = this.addInput_.value;
37 this.addCheck_.checked = false;
38 this.addInput_.value = '';
39 event.preventDefault();
40 };
41
42 HSTSView.prototype.onSubmitDelete_ = function(event) {
43 g_browser.sendHSTSDelete(this.deleteInput_.value);
44 this.deleteInput_.value = '';
45 event.preventDefault();
46 };
47
48 function hstsModeToString(m) {
49 if (m == 0) {
50 return 'STRICT';
51 } else if (m == 1) {
52 return 'OPPORTUNISTIC';
53 } else if (m == 2) {
54 return 'SPDY';
55 } else {
56 return 'UNKNOWN';
57 }
58 }
59
60 function yellowFade(element) {
61 element.style.webkitTransitionProperty = 'background-color';
62 element.style.webkitTransitionDuration = '0';
63 element.style.backgroundColor = '#fffccf';
64 setTimeout(function() {
65 element.style.webkitTransitionDuration = '1000ms';
66 element.style.backgroundColor = '#fff';
67 }, 0);
68 }
69
70 HSTSView.prototype.onQueryCallback_ = function(result) {
71 if (result.result == false) {
72 this.queryOutputDiv_.innerHTML = '<b>Not found</b>';
73 } else {
74 while (this.queryOutputDiv_.firstChild != null)
eroman 2011/02/16 20:12:45 Is the intent here to delete all children inside q
75 this.queryOutputDiv_.removeChild(this.queryOutputDiv_.firstChild);
76
77 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.
78 s.innerHTML = '<b>Found</b>: mode: '
79 this.queryOutputDiv_.appendChild(s)
80
81 t = document.createElement('tt')
82 t.innerText = hstsModeToString(result.mode);
83 this.queryOutputDiv_.appendChild(t)
84
85 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.
86 this.queryOutputDiv_.appendChild(t)
87
88 t = document.createElement('tt')
89 t.innerText = result.subdomains;
90 this.queryOutputDiv_.appendChild(t)
91
92 t = document.createTextNode(' domain: ')
93 this.queryOutputDiv_.appendChild(t)
94
95 t = document.createElement('tt')
96 t.innerText = result.domain;
97 this.queryOutputDiv_.appendChild(t)
98
99 t = document.createTextNode(' is_preloaded: ')
100 this.queryOutputDiv_.appendChild(t)
101
102 t = document.createElement('tt')
103 t.innerText = result.preloaded;
104 this.queryOutputDiv_.appendChild(t)
105 }
106 yellowFade(this.queryOutputDiv_);
107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698