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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/network/NetworkManageCustomHeadersView.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright 2016 The Chromium Authors. All rights reserved. 2 * Copyright 2016 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 /** 6 /**
7 * @implements {WebInspector.ListWidget.Delegate} 7 * @implements {UI.ListWidget.Delegate}
8 * @unrestricted 8 * @unrestricted
9 */ 9 */
10 WebInspector.NetworkManageCustomHeadersView = class extends WebInspector.VBox { 10 Network.NetworkManageCustomHeadersView = class extends UI.VBox {
11 /** 11 /**
12 * @param {!Array.<!{title: string, editable: boolean}>} columnData 12 * @param {!Array.<!{title: string, editable: boolean}>} columnData
13 * @param {function(string) : boolean} addHeaderColumnCallback 13 * @param {function(string) : boolean} addHeaderColumnCallback
14 * @param {function(string, string) : boolean} changeHeaderColumnCallback 14 * @param {function(string, string) : boolean} changeHeaderColumnCallback
15 * @param {function(string) : boolean} removeHeaderColumnCallback 15 * @param {function(string) : boolean} removeHeaderColumnCallback
16 */ 16 */
17 constructor(columnData, addHeaderColumnCallback, changeHeaderColumnCallback, r emoveHeaderColumnCallback) { 17 constructor(columnData, addHeaderColumnCallback, changeHeaderColumnCallback, r emoveHeaderColumnCallback) {
18 super(true); 18 super(true);
19 this.registerRequiredCSS('network/networkManageCustomHeadersView.css'); 19 this.registerRequiredCSS('network/networkManageCustomHeadersView.css');
20 20
21 this.contentElement.classList.add('custom-headers-wrapper'); 21 this.contentElement.classList.add('custom-headers-wrapper');
22 this.contentElement.createChild('div', 'header').textContent = WebInspector. UIString('Manage Header Columns'); 22 this.contentElement.createChild('div', 'header').textContent = Common.UIStri ng('Manage Header Columns');
23 23
24 this._list = new WebInspector.ListWidget(this); 24 this._list = new UI.ListWidget(this);
25 this._list.element.classList.add('custom-headers-list'); 25 this._list.element.classList.add('custom-headers-list');
26 this._list.registerRequiredCSS('network/networkManageCustomHeadersView.css') ; 26 this._list.registerRequiredCSS('network/networkManageCustomHeadersView.css') ;
27 27
28 var placeholder = createElementWithClass('div', 'custom-headers-list-list-em pty'); 28 var placeholder = createElementWithClass('div', 'custom-headers-list-list-em pty');
29 placeholder.textContent = WebInspector.UIString('No custom headers'); 29 placeholder.textContent = Common.UIString('No custom headers');
30 this._list.setEmptyPlaceholder(placeholder); 30 this._list.setEmptyPlaceholder(placeholder);
31 this._list.show(this.contentElement); 31 this._list.show(this.contentElement);
32 this.contentElement.appendChild(createTextButton( 32 this.contentElement.appendChild(createTextButton(
33 WebInspector.UIString('Add custom header\u2026'), this._addButtonClicked .bind(this), 'add-button')); 33 Common.UIString('Add custom header\u2026'), this._addButtonClicked.bind( this), 'add-button'));
34 34
35 /** @type {!Map.<string, !{title: string, editable: boolean}>} */ 35 /** @type {!Map.<string, !{title: string, editable: boolean}>} */
36 this._columnConfigs = new Map(); 36 this._columnConfigs = new Map();
37 columnData.forEach(columnData => this._columnConfigs.set(columnData.title.to LowerCase(), columnData)); 37 columnData.forEach(columnData => this._columnConfigs.set(columnData.title.to LowerCase(), columnData));
38 38
39 this._addHeaderColumnCallback = addHeaderColumnCallback; 39 this._addHeaderColumnCallback = addHeaderColumnCallback;
40 this._changeHeaderColumnCallback = changeHeaderColumnCallback; 40 this._changeHeaderColumnCallback = changeHeaderColumnCallback;
41 this._removeHeaderColumnCallback = removeHeaderColumnCallback; 41 this._removeHeaderColumnCallback = removeHeaderColumnCallback;
42 42
43 this.contentElement.tabIndex = 0; 43 this.contentElement.tabIndex = 0;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 */ 80 */
81 removeItemRequested(item, index) { 81 removeItemRequested(item, index) {
82 this._removeHeaderColumnCallback(item.header); 82 this._removeHeaderColumnCallback(item.header);
83 this._columnConfigs.delete(item.header.toLowerCase()); 83 this._columnConfigs.delete(item.header.toLowerCase());
84 this._headersUpdated(); 84 this._headersUpdated();
85 } 85 }
86 86
87 /** 87 /**
88 * @override 88 * @override
89 * @param {*} item 89 * @param {*} item
90 * @param {!WebInspector.ListWidget.Editor} editor 90 * @param {!UI.ListWidget.Editor} editor
91 * @param {boolean} isNew 91 * @param {boolean} isNew
92 */ 92 */
93 commitEdit(item, editor, isNew) { 93 commitEdit(item, editor, isNew) {
94 var headerId = editor.control('header').value.trim(); 94 var headerId = editor.control('header').value.trim();
95 var success; 95 var success;
96 if (isNew) 96 if (isNew)
97 success = this._addHeaderColumnCallback(headerId); 97 success = this._addHeaderColumnCallback(headerId);
98 else 98 else
99 success = this._changeHeaderColumnCallback(item.header, headerId); 99 success = this._changeHeaderColumnCallback(item.header, headerId);
100 100
101 if (success && !isNew) 101 if (success && !isNew)
102 this._columnConfigs.delete(item.header.toLowerCase()); 102 this._columnConfigs.delete(item.header.toLowerCase());
103 if (success) 103 if (success)
104 this._columnConfigs.set(headerId.toLowerCase(), {title: headerId, editable : true}); 104 this._columnConfigs.set(headerId.toLowerCase(), {title: headerId, editable : true});
105 105
106 this._headersUpdated(); 106 this._headersUpdated();
107 } 107 }
108 108
109 /** 109 /**
110 * @override 110 * @override
111 * @param {*} item 111 * @param {*} item
112 * @return {!WebInspector.ListWidget.Editor} 112 * @return {!UI.ListWidget.Editor}
113 */ 113 */
114 beginEdit(item) { 114 beginEdit(item) {
115 var editor = this._createEditor(); 115 var editor = this._createEditor();
116 editor.control('header').value = item.header; 116 editor.control('header').value = item.header;
117 return editor; 117 return editor;
118 } 118 }
119 119
120 /** 120 /**
121 * @return {!WebInspector.ListWidget.Editor} 121 * @return {!UI.ListWidget.Editor}
122 */ 122 */
123 _createEditor() { 123 _createEditor() {
124 if (this._editor) 124 if (this._editor)
125 return this._editor; 125 return this._editor;
126 126
127 var editor = new WebInspector.ListWidget.Editor(); 127 var editor = new UI.ListWidget.Editor();
128 this._editor = editor; 128 this._editor = editor;
129 var content = editor.contentElement(); 129 var content = editor.contentElement();
130 130
131 var titles = content.createChild('div', 'custom-headers-edit-row'); 131 var titles = content.createChild('div', 'custom-headers-edit-row');
132 titles.createChild('div', 'custom-headers-header').textContent = WebInspecto r.UIString('Header Name'); 132 titles.createChild('div', 'custom-headers-header').textContent = Common.UISt ring('Header Name');
133 133
134 var fields = content.createChild('div', 'custom-headers-edit-row'); 134 var fields = content.createChild('div', 'custom-headers-edit-row');
135 fields.createChild('div', 'custom-headers-header') 135 fields.createChild('div', 'custom-headers-header')
136 .appendChild(editor.createInput('header', 'text', 'x-custom-header', val idateHeader.bind(this))); 136 .appendChild(editor.createInput('header', 'text', 'x-custom-header', val idateHeader.bind(this)));
137 137
138 return editor; 138 return editor;
139 139
140 /** 140 /**
141 * @param {*} item 141 * @param {*} item
142 * @param {number} index 142 * @param {number} index
143 * @param {!HTMLInputElement|!HTMLSelectElement} input 143 * @param {!HTMLInputElement|!HTMLSelectElement} input
144 * @this {WebInspector.NetworkManageCustomHeadersView} 144 * @this {Network.NetworkManageCustomHeadersView}
145 * @return {boolean} 145 * @return {boolean}
146 */ 146 */
147 function validateHeader(item, index, input) { 147 function validateHeader(item, index, input) {
148 var headerId = editor.control('header').value.trim().toLowerCase(); 148 var headerId = editor.control('header').value.trim().toLowerCase();
149 if (this._columnConfigs.has(headerId) && item.header !== headerId) 149 if (this._columnConfigs.has(headerId) && item.header !== headerId)
150 return false; 150 return false;
151 return true; 151 return true;
152 } 152 }
153 } 153 }
154 }; 154 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698