| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 the Alt-Svc mappings. | 6 * This view displays the Alt-Svc mappings. |
| 7 */ | 7 */ |
| 8 var AltSvcView = (function() { | 8 var AltSvcView = (function() { |
| 9 'use strict'; | 9 'use strict'; |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 } | 24 } |
| 25 | 25 |
| 26 AltSvcView.TAB_ID = 'tab-handle-alt-svc'; | 26 AltSvcView.TAB_ID = 'tab-handle-alt-svc'; |
| 27 AltSvcView.TAB_NAME = 'Alt-Svc'; | 27 AltSvcView.TAB_NAME = 'Alt-Svc'; |
| 28 AltSvcView.TAB_HASH = '#alt-svc'; | 28 AltSvcView.TAB_HASH = '#alt-svc'; |
| 29 | 29 |
| 30 // IDs for special HTML elements in alt_svc_view.html | 30 // IDs for special HTML elements in alt_svc_view.html |
| 31 AltSvcView.MAIN_BOX_ID = 'alt-svc-view-tab-content'; | 31 AltSvcView.MAIN_BOX_ID = 'alt-svc-view-tab-content'; |
| 32 AltSvcView.ALTERNATE_PROTOCOL_MAPPINGS_ID = | 32 AltSvcView.ALTERNATE_PROTOCOL_MAPPINGS_ID = |
| 33 'alt-svc-view-alternate-protocol-mappings'; | 33 'alt-svc-view-alternate-protocol-mappings'; |
| 34 AltSvcView.MAPPINGS_CONTENT_ID = |
| 35 'alt-svc-view-mappings-content'; |
| 36 AltSvcView.MAPPINGS_NO_CONTENT_ID = |
| 37 'alt-svc-view-mappings-no-content'; |
| 38 AltSvcView.MAPPINGS_TBODY_ID = 'alt-svc-view-mappings-tbody'; |
| 34 | 39 |
| 35 cr.addSingletonGetter(AltSvcView); | 40 cr.addSingletonGetter(AltSvcView); |
| 36 | 41 |
| 37 AltSvcView.prototype = { | 42 AltSvcView.prototype = { |
| 38 // Inherit the superclass's methods. | 43 // Inherit the superclass's methods. |
| 39 __proto__: superClass.prototype, | 44 __proto__: superClass.prototype, |
| 40 | 45 |
| 41 onLoadLogFinish: function(data) { | 46 onLoadLogFinish: function(data) { |
| 42 // TODO(rch): Remove the check for spdyAlternateProtocolMappings after | 47 // TODO(rch): Remove the check for spdyAlternateProtocolMappings after |
| 43 // M53 (It was renamed to altSvcMappings in M50). | 48 // M53 (It was renamed to altSvcMappings in M50). |
| 44 return this.onAltSvcMappingsChanged(data.altSvcMappings || | 49 return this.onAltSvcMappingsChanged(data.altSvcMappings || |
| 45 data.spdyAlternateProtocolMappings); | 50 data.spdyAlternateProtocolMappings); |
| 46 }, | 51 }, |
| 47 | 52 |
| 48 /** | 53 /** |
| 49 * Displays the alternate service mappings. | 54 * Displays the alternate service mappings. |
| 50 */ | 55 */ |
| 51 onAltSvcMappingsChanged: function(altSvcMappings) { | 56 onAltSvcMappingsChanged: function(altSvcMappings) { |
| 52 if (!altSvcMappings) | 57 if (!altSvcMappings) |
| 53 return false; | 58 return false; |
| 54 // TODO(rayraymond): Update DOM without use of jstemplate. | 59 |
| 55 // var input = new JsEvalContext({altSvcMappings: altSvcMappings}); | 60 var hasMappings = altSvcMappings && altSvcMappings.length > 0; |
| 56 // jstProcess(input, $(AltSvcView.ALTERNATE_PROTOCOL_MAPPINGS_ID)); | 61 |
| 62 setNodeDisplay($(AltSvcView.MAPPINGS_CONTENT_ID), hasMappings); |
| 63 setNodeDisplay($(AltSvcView.MAPPINGS_NO_CONTENT_ID), !hasMappings); |
| 64 |
| 65 var tbody = $(AltSvcView.MAPPINGS_TBODY_ID); |
| 66 tbody.innerHTML = ''; |
| 67 |
| 68 // Fill in the alternate service mappings table. |
| 69 for (var i = 0; i < altSvcMappings.length; ++i) { |
| 70 var a = altSvcMappings[i]; |
| 71 var tr = addNode(tbody, 'tr'); |
| 72 |
| 73 addNodeWithText(tr, 'td', a.server); |
| 74 addNodeWithText(tr, 'td', a.alternative_service); |
| 75 } |
| 76 |
| 57 return true; | 77 return true; |
| 58 } | 78 } |
| 59 }; | 79 }; |
| 60 | 80 |
| 61 return AltSvcView; | 81 return AltSvcView; |
| 62 })(); | 82 })(); |
| OLD | NEW |