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

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

Issue 2839413002: DevTools: add rendering overlay options to command menu (Closed)
Patch Set: ac Created 3 years, 7 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
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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 */ 139 */
140 Settings.GenericSettingsTab = class extends Settings.SettingsTab { 140 Settings.GenericSettingsTab = class extends Settings.SettingsTab {
141 constructor() { 141 constructor() {
142 super(Common.UIString('Preferences'), 'preferences-tab-content'); 142 super(Common.UIString('Preferences'), 'preferences-tab-content');
143 143
144 /** @const */ 144 /** @const */
145 var explicitSectionOrder = 145 var explicitSectionOrder =
146 ['', 'Appearance', 'Elements', 'Sources', 'Network', 'Profiler', 'Consol e', 'Extensions']; 146 ['', 'Appearance', 'Elements', 'Sources', 'Network', 'Profiler', 'Consol e', 'Extensions'];
147 /** @type {!Map<string, !Element>} */ 147 /** @type {!Map<string, !Element>} */
148 this._nameToSection = new Map(); 148 this._nameToSection = new Map();
149 /** @type {!Map<string, !Element>} */
150 this._nameToSettingElement = new Map();
151 for (var sectionName of explicitSectionOrder) 149 for (var sectionName of explicitSectionOrder)
152 this._sectionElement(sectionName); 150 this._sectionElement(sectionName);
153 self.runtime.extensions('setting').forEach(this._addSetting.bind(this)); 151 self.runtime.extensions('setting').forEach(this._addSetting.bind(this));
154 self.runtime.extensions(UI.SettingUI).forEach(this._addSettingUI.bind(this)) ; 152 self.runtime.extensions(UI.SettingUI).forEach(this._addSettingUI.bind(this)) ;
155 153
156 this._appendSection().appendChild( 154 this._appendSection().appendChild(
157 UI.createTextButton(Common.UIString('Restore defaults and reload'), rest oreAndReload)); 155 UI.createTextButton(Common.UIString('Restore defaults and reload'), rest oreAndReload));
158 156
159 function restoreAndReload() { 157 function restoreAndReload() {
160 Common.settings.clearAll(); 158 Common.settings.clearAll();
(...skipping 13 matching lines...) Expand all
174 return false; 172 return false;
175 return true; 173 return true;
176 } 174 }
177 175
178 /** 176 /**
179 * @param {!Runtime.Extension} extension 177 * @param {!Runtime.Extension} extension
180 */ 178 */
181 _addSetting(extension) { 179 _addSetting(extension) {
182 if (!Settings.GenericSettingsTab.isSettingVisible(extension)) 180 if (!Settings.GenericSettingsTab.isSettingVisible(extension))
183 return; 181 return;
184 var descriptor = extension.descriptor(); 182 var sectionElement = this._sectionElement(extension.descriptor()['category'] );
185 var sectionName = descriptor['category']; 183 var settingControl = UI.SettingsUI.settingExtensionToControl(extension);
186 var settingName = descriptor['settingName']; 184 if (settingControl)
187 var setting = Common.moduleSetting(settingName); 185 sectionElement.appendChild(settingControl);
188 var uiTitle = Common.UIString(extension.title());
189
190 var sectionElement = this._sectionElement(sectionName);
191 var settingControl;
192
193 switch (descriptor['settingType']) {
194 case 'boolean':
195 settingControl = UI.SettingsUI.createSettingCheckbox(uiTitle, setting);
196 break;
197 case 'enum':
198 settingControl = UI.SettingsUI.createSettingSelect(uiTitle, descriptor[' options'], setting);
199 break;
200 default:
201 console.error('Invalid setting type: ' + descriptor['settingType']);
202 return;
203 }
204 this._nameToSettingElement.set(settingName, settingControl);
205 sectionElement.appendChild(/** @type {!Element} */ (settingControl));
206 } 186 }
207 187
208 /** 188 /**
209 * @param {!Runtime.Extension} extension 189 * @param {!Runtime.Extension} extension
210 */ 190 */
211 _addSettingUI(extension) { 191 _addSettingUI(extension) {
212 var descriptor = extension.descriptor(); 192 var descriptor = extension.descriptor();
213 var sectionName = descriptor['category'] || ''; 193 var sectionName = descriptor['category'] || '';
214 extension.instance().then(appendCustomSetting.bind(this)); 194 extension.instance().then(appendCustomSetting.bind(this));
215 195
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 return; 347 return;
368 var settings = extension.descriptor()['settings']; 348 var settings = extension.descriptor()['settings'];
369 if (settings && settings.indexOf(setting.name) !== -1) { 349 if (settings && settings.indexOf(setting.name) !== -1) {
370 InspectorFrontendHost.bringToFront(); 350 InspectorFrontendHost.bringToFront();
371 Settings.SettingsScreen._showSettingsScreen(extension.descriptor()['id'] ); 351 Settings.SettingsScreen._showSettingsScreen(extension.descriptor()['id'] );
372 success = true; 352 success = true;
373 } 353 }
374 } 354 }
375 } 355 }
376 }; 356 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698