OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * This view displays information related to SDCH. | 6 * This view displays information related to SDCH. |
7 * | 7 * |
8 * Shows loaded dictionaries, blacklisted domains and SDCH errors. | 8 * Shows loaded dictionaries, blacklisted domains and SDCH errors. |
9 */ | 9 */ |
10 var SdchView = (function() { | 10 var SdchView = (function() { |
(...skipping 16 matching lines...) Expand all Loading... |
27 } | 27 } |
28 | 28 |
29 SdchView.TAB_ID = 'tab-handle-sdch'; | 29 SdchView.TAB_ID = 'tab-handle-sdch'; |
30 SdchView.TAB_NAME = 'SDCH'; | 30 SdchView.TAB_NAME = 'SDCH'; |
31 SdchView.TAB_HASH = '#sdch'; | 31 SdchView.TAB_HASH = '#sdch'; |
32 | 32 |
33 // IDs for special HTML elements in sdch_view.html | 33 // IDs for special HTML elements in sdch_view.html |
34 SdchView.MAIN_BOX_ID = 'sdch-view-tab-content'; | 34 SdchView.MAIN_BOX_ID = 'sdch-view-tab-content'; |
35 SdchView.SDCH_ENABLED_SPAN_ID = 'sdch-view-sdch-enabled'; | 35 SdchView.SDCH_ENABLED_SPAN_ID = 'sdch-view-sdch-enabled'; |
36 SdchView.SECURE_SCHEME_SUPPORT_SPAN_ID = 'sdch-view-secure-scheme-support'; | 36 SdchView.SECURE_SCHEME_SUPPORT_SPAN_ID = 'sdch-view-secure-scheme-support'; |
37 SdchView.BLACKLIST_TBODY_ID = 'sdch-view-blacklist-body'; | 37 SdchView.BLACKLIST_TBODY_ID = 'sdch-view-blacklist-tbody'; |
38 SdchView.DICTIONARIES_TBODY_ID = 'sdch-view-dictionaries-body'; | 38 SdchView.NUM_DICTIONARIES_LOADED_ID = 'sdch-view-num-dictionaries-loaded'; |
| 39 SdchView.DICTIONARIES_TBODY_ID = 'sdch-view-dictionaries-tbody'; |
39 | 40 |
40 cr.addSingletonGetter(SdchView); | 41 cr.addSingletonGetter(SdchView); |
41 | 42 |
42 SdchView.prototype = { | 43 SdchView.prototype = { |
43 // Inherit the superclass's methods. | 44 // Inherit the superclass's methods. |
44 __proto__: superClass.prototype, | 45 __proto__: superClass.prototype, |
45 | 46 |
46 onLoadLogFinish: function(data) { | 47 onLoadLogFinish: function(data) { |
47 return this.onSdchInfoChanged(data.sdchInfo); | 48 return this.onSdchInfoChanged(data.sdchInfo); |
48 }, | 49 }, |
49 | 50 |
50 onSdchInfoChanged: function(sdchInfo) { | 51 onSdchInfoChanged: function(sdchInfo) { |
51 if (!sdchInfo || typeof(sdchInfo.sdch_enabled) === 'undefined') | 52 if (!sdchInfo || typeof(sdchInfo.sdch_enabled) === 'undefined') |
52 return false; | 53 return false; |
53 // TODO(rayraymond): Update DOM without use of jstemplate. | 54 |
54 // var input = new JsEvalContext(sdchInfo); | 55 $(SdchView.SDCH_ENABLED_SPAN_ID).textContent = |
55 // jstProcess(input, $(SdchView.MAIN_BOX_ID)); | 56 !!sdchInfo.sdch_enabled; |
| 57 |
| 58 $(SdchView.NUM_DICTIONARIES_LOADED_ID).textContent = |
| 59 sdchInfo.dictionaries.length; |
| 60 |
| 61 var tbodyDictionaries = $(SdchView.DICTIONARIES_TBODY_ID); |
| 62 tbodyDictionaries.innerHTML = ''; |
| 63 |
| 64 // Fill in the dictionaries table. |
| 65 for (var i = 0; i < sdchInfo.dictionaries.length; ++i) { |
| 66 var d = sdchInfo.dictionaries[i]; |
| 67 var tr = addNode(tbodyDictionaries, 'tr'); |
| 68 |
| 69 addNodeWithText(tr, 'td', d.domain); |
| 70 addNodeWithText(tr, 'td', d.path); |
| 71 addNodeWithText(tr, 'td', |
| 72 d.ports ? d.ports.join(', ') : ''); |
| 73 addNodeWithText(tr, 'td', d.server_hash); |
| 74 addNodeWithText(tr, 'td', d.client_hash); |
| 75 addNodeWithText(tr, 'td', d.url); |
| 76 } |
| 77 |
| 78 var tbodyBlacklist = $(SdchView.BLACKLIST_TBODY_ID); |
| 79 tbodyBlacklist.innerHTML = ''; |
| 80 |
| 81 // Fill in the blacklisted table. |
| 82 for (var i = 0; i < sdchInfo.blacklisted.length; ++i) { |
| 83 var b = sdchInfo.blacklisted[i]; |
| 84 var tr = addNode(tbodyBlacklist, 'tr'); |
| 85 |
| 86 addNodeWithText(tr, 'td', d.domain); |
| 87 addNodeWithText(tr, 'td', d.sdchProblemCodeToString(reason)); |
| 88 addNodeWithText(tr, 'td', d.tries); |
| 89 } |
| 90 |
56 return true; | 91 return true; |
57 }, | 92 }, |
58 }; | 93 }; |
59 | 94 |
60 return SdchView; | 95 return SdchView; |
61 })(); | 96 })(); |
62 | 97 |
OLD | NEW |