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

Side by Side Diff: Source/devtools/front_end/settings/SettingsScreen.js

Issue 1292673002: [DevTools] Group options in network presets select. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 __proto__: WebInspector.VBox.prototype 173 __proto__: WebInspector.VBox.prototype
174 } 174 }
175 175
176 /** 176 /**
177 * @constructor 177 * @constructor
178 * @extends {WebInspector.SettingsTab} 178 * @extends {WebInspector.SettingsTab}
179 */ 179 */
180 WebInspector.GenericSettingsTab = function() 180 WebInspector.GenericSettingsTab = function()
181 { 181 {
182 WebInspector.SettingsTab.call(this, WebInspector.UIString("General"), "gener al-tab-content"); 182 WebInspector.SettingsTab.call(this, WebInspector.UIString("General"), "gener al-tab-content");
183 WebInspector.GenericSettingsTab._instance = this;
183 184
184 /** @const */ 185 /** @const */
185 var explicitSectionOrder = ["", "Appearance", "Elements", "Sources", "Networ k", "Profiler", "Console", "Extensions"]; 186 var explicitSectionOrder = ["", "Appearance", "Elements", "Sources", "Networ k", "Profiler", "Console", "Extensions"];
186 /** @type {!Map<string, !Element>} */ 187 /** @type {!Map<string, !Element>} */
187 this._nameToSection = new Map(); 188 this._nameToSection = new Map();
188 /** @type {!Map<string, !Element>} */ 189 /** @type {!Map<string, !Element>} */
189 this._nameToSettingElement = new Map(); 190 this._nameToSettingElement = new Map();
190 for (var sectionName of explicitSectionOrder) 191 for (var sectionName of explicitSectionOrder)
191 this._sectionElement(sectionName); 192 this._sectionElement(sectionName);
192 self.runtime.extensions("setting").forEach(this._addSetting.bind(this)); 193 self.runtime.extensions("setting").forEach(this._addSetting.bind(this));
193 self.runtime.extensions(WebInspector.SettingUI).forEach(this._addSettingUI.b ind(this)); 194 self.runtime.extensions(WebInspector.SettingUI).forEach(this._addSettingUI.b ind(this));
194 195
195 this._appendSection().appendChild(createTextButton(WebInspector.UIString("Re store defaults and reload"), restoreAndReload)); 196 this._appendSection().appendChild(createTextButton(WebInspector.UIString("Re store defaults and reload"), restoreAndReload));
196 197
197 function restoreAndReload() 198 function restoreAndReload()
198 { 199 {
199 WebInspector.settings.clearAll(); 200 WebInspector.settings.clearAll();
200 WebInspector.reload(); 201 WebInspector.reload();
201 } 202 }
202 } 203 }
203 204
205 /** @type {?WebInspector.GenericSettingsTab} */
206 WebInspector.GenericSettingsTab._instance;
207
208 /**
209 * @param {!Runtime.Extension} extension
210 * @return {boolean}
211 */
212 WebInspector.GenericSettingsTab.isSettingVisible = function(extension)
213 {
214 var descriptor = extension.descriptor();
215 if (!("title" in descriptor))
216 return false;
217 if (!(("category" in descriptor) || ("parentSettingName" in descriptor)))
218 return false;
219 return true;
220 }
221
204 WebInspector.GenericSettingsTab.prototype = { 222 WebInspector.GenericSettingsTab.prototype = {
205 /** 223 /**
206 * @param {!Runtime.Extension} extension 224 * @param {!Runtime.Extension} extension
207 */ 225 */
208 _addSetting: function(extension) 226 _addSetting: function(extension)
209 { 227 {
228 if (!WebInspector.GenericSettingsTab.isSettingVisible(extension))
229 return;
210 var descriptor = extension.descriptor(); 230 var descriptor = extension.descriptor();
211 if (!("title" in descriptor))
212 return;
213 if (!(("category" in descriptor) || ("parentSettingName" in descriptor)) )
214 return;
215
216 var sectionName = descriptor["category"]; 231 var sectionName = descriptor["category"];
217 var settingName = descriptor["settingName"]; 232 var settingName = descriptor["settingName"];
218 var setting = WebInspector.moduleSetting(settingName); 233 var setting = WebInspector.moduleSetting(settingName);
219 var uiTitle = WebInspector.UIString(extension.title(WebInspector.platfor m())); 234 var uiTitle = WebInspector.UIString(extension.title(WebInspector.platfor m()));
220 235
221 var sectionElement = this._sectionElement(sectionName); 236 var sectionElement = this._sectionElement(sectionName);
222 var parentSettingName = descriptor["parentSettingName"]; 237 var parentSettingName = descriptor["parentSettingName"];
223 var parentSettingElement = parentSettingName ? this._nameToSettingElemen t.get(descriptor["parentSettingName"]) : null; 238 var parentSettingElement = parentSettingName ? this._nameToSettingElemen t.get(descriptor["parentSettingName"]) : null;
224 var parentFieldset = null; 239 var parentFieldset = null;
225 if (parentSettingElement) { 240 if (parentSettingElement) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 extension.instancePromise().then(appendCustomSetting.bind(this)); 280 extension.instancePromise().then(appendCustomSetting.bind(this));
266 281
267 /** 282 /**
268 * @param {!Object} object 283 * @param {!Object} object
269 * @this {WebInspector.GenericSettingsTab} 284 * @this {WebInspector.GenericSettingsTab}
270 */ 285 */
271 function appendCustomSetting(object) 286 function appendCustomSetting(object)
272 { 287 {
273 var settingUI = /** @type {!WebInspector.SettingUI} */ (object); 288 var settingUI = /** @type {!WebInspector.SettingUI} */ (object);
274 var element = settingUI.settingElement(); 289 var element = settingUI.settingElement();
275 if (element) 290 if (!element)
276 this._sectionElement(sectionName).appendChild(element); 291 return;
292 this._sectionElement(sectionName).appendChild(element);
293
294 var settingsList = descriptor["settings"];
295 if (!settingsList)
296 return;
297 for (var settingName of settingsList) {
298 this._nameToSettingElement.set(settingName, element);
299 if (settingName === this._highlightedSettingName)
300 this._highlight();
301 }
277 } 302 }
278 }, 303 },
279 304
280 /** 305 /**
281 * @param {string} sectionName 306 * @param {string} sectionName
282 * @return {!Element} 307 * @return {!Element}
283 */ 308 */
284 _sectionElement: function(sectionName) 309 _sectionElement: function(sectionName)
285 { 310 {
286 var sectionElement = this._nameToSection.get(sectionName); 311 var sectionElement = this._nameToSection.get(sectionName);
287 if (!sectionElement) { 312 if (!sectionElement) {
288 var uiSectionName = sectionName && WebInspector.UIString(sectionName ); 313 var uiSectionName = sectionName && WebInspector.UIString(sectionName );
289 sectionElement = this._appendSection(uiSectionName); 314 sectionElement = this._appendSection(uiSectionName);
290 this._nameToSection.set(sectionName, sectionElement); 315 this._nameToSection.set(sectionName, sectionElement);
291 } 316 }
292 return sectionElement; 317 return sectionElement;
293 }, 318 },
294 319
320 wasShown: function()
321 {
322 this._highlight();
323 },
324
325 willHide: function()
326 {
327 this._hideHighlight();
328 },
329
330 _hideHighlight: function()
331 {
332 var element = this._highlightedSettingElement();
333 if (element)
334 element.classList.remove("highlighted-setting");
335 delete this._highlightedSettingName;
336 },
337
338 /**
339 * @return {?Element}
340 */
341 _highlightedSettingElement: function()
342 {
343 return this._highlightedSettingName ? (this._nameToSettingElement.get(th is._highlightedSettingName) || null) : null;
344 },
345
346 _highlight: function()
347 {
348 var element = this._highlightedSettingElement();
349 if (element) {
350 element.classList.add("highlighted-setting");
351 element.scrollIntoView();
352 }
353 },
354
355 /**
356 * @param {!WebInspector.Setting} setting
357 */
358 highlightSetting: function(setting)
359 {
360 this._hideHighlight();
361 this._highlightedSettingName = setting.name;
pfeldman 2015/08/13 23:33:13 Lets highlight it when we know that it is on scree
362 this._highlight();
363 },
364
295 __proto__: WebInspector.SettingsTab.prototype 365 __proto__: WebInspector.SettingsTab.prototype
296 } 366 }
297 367
298 /** 368 /**
299 * @constructor 369 * @constructor
300 * @implements {WebInspector.SettingUI} 370 * @implements {WebInspector.SettingUI}
301 */ 371 */
302 WebInspector.SettingsScreen.SkipStackFramePatternSettingUI = function() 372 WebInspector.SettingsScreen.SkipStackFramePatternSettingUI = function()
303 { 373 {
304 } 374 }
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 WebInspector._settingsController.showSettingsScreen(); 671 WebInspector._settingsController.showSettingsScreen();
602 else if (actionId === "settings.help") 672 else if (actionId === "settings.help")
603 InspectorFrontendHost.openInNewTab("https://developers.google.com/we b/tools/chrome-devtools/"); 673 InspectorFrontendHost.openInNewTab("https://developers.google.com/we b/tools/chrome-devtools/");
604 else if (actionId === "settings.shortcuts") 674 else if (actionId === "settings.shortcuts")
605 WebInspector._settingsController.showSettingsScreen("shortcuts"); 675 WebInspector._settingsController.showSettingsScreen("shortcuts");
606 } 676 }
607 } 677 }
608 678
609 /** 679 /**
610 * @constructor 680 * @constructor
681 * @implements {WebInspector.Revealer}
682 */
683 WebInspector.SettingsController.Revealer = function() { }
684
685 WebInspector.SettingsController.Revealer.prototype = {
686 /**
687 * @override
688 * @param {!Object} object
689 * @param {number=} lineNumber
690 * @return {!Promise}
691 */
692 reveal: function(object, lineNumber)
693 {
694 console.assert(object instanceof WebInspector.Setting);
695 var setting = /** @type {!WebInspector.Setting} */ (object);
696 var success = false;
697
698 self.runtime.extensions("setting").forEach(revealModuleSetting);
699 self.runtime.extensions(WebInspector.SettingUI).forEach(revealSettingUI) ;
700 self.runtime.extensions("settings-view").forEach(revealSettingsView);
701
702 return success ? Promise.resolve() : Promise.reject();
703
704 /**
705 * @param {!Runtime.Extension} extension
706 */
707 function revealModuleSetting(extension)
708 {
709 if (!WebInspector.GenericSettingsTab.isSettingVisible(extension))
710 return;
711 if (extension.descriptor()["settingName"] === setting.name) {
712 WebInspector._settingsController.showSettingsScreen("general");
713 WebInspector.GenericSettingsTab._instance.highlightSetting(setti ng);
714 success = true;
715 }
716 }
717
718 /**
719 * @param {!Runtime.Extension} extension
720 */
721 function revealSettingUI(extension)
722 {
723 var settings = extension.descriptor()["settings"];
724 if (settings && settings.indexOf(setting.name) !== -1) {
725 WebInspector._settingsController.showSettingsScreen("general");
726 WebInspector.GenericSettingsTab._instance.highlightSetting(setti ng);
727 success = true;
728 }
729 }
730
731 /**
732 * @param {!Runtime.Extension} extension
733 */
734 function revealSettingsView(extension)
735 {
736 var settings = extension.descriptor()["settings"];
737 if (settings && settings.indexOf(setting.name) !== -1) {
738 WebInspector._settingsController.showSettingsScreen(extension.de scriptor()["name"]);
739 success = true;
740 }
741 }
742 }
743 }
744
745 /**
746 * @constructor
611 * @extends {WebInspector.Object} 747 * @extends {WebInspector.Object}
612 * @param {!Array.<{id: string, placeholder: (string|undefined), options: (!Arra y.<string>|undefined)}>} columns 748 * @param {!Array.<{id: string, placeholder: (string|undefined), options: (!Arra y.<string>|undefined)}>} columns
613 * @param {function(!Element, {id: string, placeholder: (string|undefined), opti ons: (!Array.<string>|undefined)}, ?string)} itemRenderer 749 * @param {function(!Element, {id: string, placeholder: (string|undefined), opti ons: (!Array.<string>|undefined)}, ?string)} itemRenderer
614 */ 750 */
615 WebInspector.SettingsList = function(columns, itemRenderer) 751 WebInspector.SettingsList = function(columns, itemRenderer)
616 { 752 {
617 this.element = createElementWithClass("div", "settings-list"); 753 this.element = createElementWithClass("div", "settings-list");
618 this.element.tabIndex = -1; 754 this.element.tabIndex = -1;
619 this._itemRenderer = itemRenderer; 755 this._itemRenderer = itemRenderer;
620 /** @type {!Map.<string, !Element>} */ 756 /** @type {!Map.<string, !Element>} */
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 var columnId = columns[i]; 1218 var columnId = columns[i];
1083 var editElement = this._addInputElements.get(columnId); 1219 var editElement = this._addInputElements.get(columnId);
1084 this._setEditElementValue(editElement, ""); 1220 this._setEditElementValue(editElement, "");
1085 } 1221 }
1086 }, 1222 },
1087 1223
1088 __proto__: WebInspector.SettingsList.prototype 1224 __proto__: WebInspector.SettingsList.prototype
1089 } 1225 }
1090 1226
1091 WebInspector._settingsController = new WebInspector.SettingsController(); 1227 WebInspector._settingsController = new WebInspector.SettingsController();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698