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

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,
6 addInputId, addFormId, addCheckId, deleteInputId, deleteFormId ) {
7 DivView.call(this, mainBoxId);
8
9 this.queryInput_ = document.getElementById(queryInputId);
10 this.addCheck_ = document.getElementById(addCheckId);
11 this.addInput_ = document.getElementById(addInputId);
12 this.deleteInput_ = document.getElementById(deleteInputId);
13 this.queryOutputDiv_ = document.getElementById(queryOutputDivId);
14
15 var form = document.getElementById(formId);
16 form.addEventListener('submit', this.onSubmitQuery_.bind(this), false);
17 form = document.getElementById(addFormId);
18 form.addEventListener('submit', this.onSubmitAdd_.bind(this), false);
19 form = document.getElementById(deleteFormId);
20 form.addEventListener('submit', this.onSubmitDelete_.bind(this), false);
21
22 g_browser.hstsQueryCallback = this.onQueryCallback_.bind(this);
23 }
24
25 inherits(HSTSView, DivView);
26
27 HSTSView.prototype.onSubmitQuery_ = function(event) {
28 g_browser.sendHSTSQuery(this.queryInput_.value);
29 event.preventDefault();
30 };
31
32 HSTSView.prototype.onSubmitAdd_ = function(event) {
33 g_browser.sendHSTSAdd(this.addInput_.value, this.addCheck_.checked);
34 g_browser.sendHSTSQuery(this.addInput_.value);
35 this.queryInput_.value = this.addInput_.value;
36 this.addCheck_.checked = false;
37 this.addInput_.value = "";
38 event.preventDefault();
39 };
40
41 HSTSView.prototype.onSubmitDelete_ = function(event) {
42 g_browser.sendHSTSDelete(this.deleteInput_.value);
43 this.deleteInput_.value = "";
44 event.preventDefault();
45 };
46
47 function hstsModeToString(m) {
48 if (m == 0) {
49 return "STRICT";
50 } else if (m == 1) {
51 return "OPPORTUNISTIC";
52 } else if (m == 2) {
53 return "SPDY";
54 } else {
55 return "UNKNOWN";
56 }
57 }
58
59 function yellowFade(element) {
60 element.style.webkitTransitionProperty = "background-color";
61 element.style.webkitTransitionDuration = "0";
62 element.style.backgroundColor = "#fffccf";
63 setTimeout(function() {
64 element.style.webkitTransitionDuration = "1000ms";
65 element.style.backgroundColor = "#fff";
66 }, 0);
67 }
68
69 HSTSView.prototype.onQueryCallback_ = function(result) {
70 if (result.result == false) {
71 this.queryOutputDiv_.innerHTML = "<b>Not found</b>";
72 } else {
73 this.queryOutputDiv_.innerHTML = "<b>Found</b>: mode: <tt>" +
74 hstsModeToString(result.mode) +
75 "</tt> include_subdomains: <tt>" +
76 result.subdomains +
77 "</tt> domain: <tt>" +
78 result.domain +
79 "</tt> is_preloaded: <tt>" +
80 result.preloaded +
81 "</tt>";
82 }
83 yellowFade(this.queryOutputDiv_);
84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698