OLD | NEW |
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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 208 } |
209 | 209 |
210 /** | 210 /** |
211 * @constructor | 211 * @constructor |
212 * @extends {WebInspector.SettingsTab} | 212 * @extends {WebInspector.SettingsTab} |
213 */ | 213 */ |
214 WebInspector.GenericSettingsTab = function() | 214 WebInspector.GenericSettingsTab = function() |
215 { | 215 { |
216 WebInspector.SettingsTab.call(this, WebInspector.UIString("General"), "gener
al-tab-content"); | 216 WebInspector.SettingsTab.call(this, WebInspector.UIString("General"), "gener
al-tab-content"); |
217 | 217 |
218 this._populateSectionsFromExtensions(); | 218 /** @const */ |
| 219 var explicitSectionOrder = ["", "Appearance", "Elements", "Sources", "Networ
k", "Profiler", "Console", "Extensions"]; |
| 220 /** @type {!Map<string, !Element>} */ |
| 221 this._nameToSection = new Map(); |
| 222 /** @type {!Map<string, !Element>} */ |
| 223 this._nameToSettingElement = new Map(); |
| 224 for (var sectionName of explicitSectionOrder) |
| 225 this._sectionElement(sectionName); |
| 226 self.runtime.extensions("setting").forEach(this._addSetting.bind(this)); |
| 227 self.runtime.extensions(WebInspector.SettingUI).forEach(this._addSettingUI.b
ind(this)); |
219 | 228 |
220 this._appendSection().appendChild(createTextButton(WebInspector.UIString("Re
store defaults and reload"), restoreAndReload)); | 229 this._appendSection().appendChild(createTextButton(WebInspector.UIString("Re
store defaults and reload"), restoreAndReload)); |
221 | 230 |
222 function restoreAndReload() | 231 function restoreAndReload() |
223 { | 232 { |
224 if (window.localStorage) | 233 if (window.localStorage) |
225 window.localStorage.clear(); | 234 window.localStorage.clear(); |
226 WebInspector.reload(); | 235 WebInspector.reload(); |
227 } | 236 } |
228 } | 237 } |
229 | 238 |
230 WebInspector.GenericSettingsTab.prototype = { | 239 WebInspector.GenericSettingsTab.prototype = { |
231 _populateSectionsFromExtensions: function() | 240 /** |
| 241 * @param {!Runtime.Extension} extension |
| 242 */ |
| 243 _addSetting: function(extension) |
232 { | 244 { |
233 /** @const */ | 245 var descriptor = extension.descriptor(); |
234 var explicitSectionOrder = ["", "Appearance", "Elements", "Sources", "Ne
twork", "Profiler", "Console", "Extensions"]; | 246 var sectionName = descriptor["category"] || ""; |
235 | 247 |
236 var allExtensions = self.runtime.extensions("ui-setting"); | 248 var settingName = descriptor["settingName"]; |
| 249 var setting = WebInspector.settings[settingName]; |
| 250 var uiTitle = WebInspector.UIString(extension.title(WebInspector.platfor
m())); |
237 | 251 |
238 /** @type {!Multimap.<string, !Runtime.Extension>} */ | 252 var sectionElement = this._sectionElement(sectionName); |
239 var extensionsBySectionId = new Multimap(); | 253 var parentSettingName = descriptor["parentSettingName"]; |
240 /** @type {!Multimap.<string, !Runtime.Extension>} */ | 254 var parentSettingElement = parentSettingName ? this._nameToSettingElemen
t.get(descriptor["parentSettingName"]) : null; |
241 var childSettingExtensionsByParentName = new Multimap(); | 255 var parentFieldset = null; |
| 256 if (parentSettingElement) { |
| 257 parentFieldset = parentSettingElement.__fieldset; |
| 258 if (!parentFieldset) { |
| 259 parentFieldset = WebInspector.SettingsUI.createSettingFieldset(W
ebInspector.settings[parentSettingName]); |
| 260 parentSettingElement.appendChild(parentFieldset); |
| 261 parentSettingElement.__fieldset = parentFieldset; |
| 262 } |
| 263 } |
242 | 264 |
243 allExtensions.forEach(function(extension) { | 265 var settingControl; |
244 var descriptor = extension.descriptor(); | 266 |
245 var sectionName = descriptor["section"] || ""; | 267 switch (descriptor["settingType"]) { |
246 if (!sectionName && descriptor["parentSettingName"]) { | 268 case "boolean": |
247 childSettingExtensionsByParentName.set(descriptor["parentSetting
Name"], extension); | 269 settingControl = WebInspector.SettingsUI.createSettingCheckbox(uiTit
le, setting); |
248 return; | 270 break; |
| 271 case "enum": |
| 272 var descriptorOptions = descriptor["options"]; |
| 273 var options = new Array(descriptorOptions.length); |
| 274 for (var i = 0; i < options.length; ++i) { |
| 275 // The third array item flags that the option name is "raw" (non
-i18n-izable). |
| 276 var optionName = descriptorOptions[i][2] ? descriptorOptions[i][
0] : WebInspector.UIString(descriptorOptions[i][0]); |
| 277 options[i] = [optionName, descriptorOptions[i][1]]; |
249 } | 278 } |
250 extensionsBySectionId.set(sectionName, extension); | 279 settingControl = this._createSelectSetting(uiTitle, options, setting
); |
251 }); | 280 break; |
| 281 default: |
| 282 console.error("Invalid setting type: " + descriptor["settingType"]); |
| 283 return; |
| 284 } |
| 285 this._nameToSettingElement.set(settingName, settingControl); |
| 286 (parentFieldset || sectionElement).appendChild(/** @type {!Element} */ (
settingControl)); |
| 287 }, |
252 | 288 |
253 var sectionIds = extensionsBySectionId.keysArray(); | 289 /** |
254 var explicitlyOrderedSections = explicitSectionOrder.keySet(); | 290 * @param {!Runtime.Extension} extension |
255 for (var i = 0; i < explicitSectionOrder.length; ++i) { | 291 */ |
256 var extensions = extensionsBySectionId.get(explicitSectionOrder[i]); | 292 _addSettingUI: function(extension) |
257 if (!extensions.size) | 293 { |
258 continue; | 294 var descriptor = extension.descriptor(); |
259 this._addSectionWithExtensionProvidedSettings(explicitSectionOrder[i
], extensions.valuesArray(), childSettingExtensionsByParentName); | 295 var sectionName = descriptor["category"] || ""; |
260 } | 296 extension.instancePromise().then(appendCustomSetting.bind(this)); |
261 for (var i = 0; i < sectionIds.length; ++i) { | 297 |
262 if (explicitlyOrderedSections[sectionIds[i]]) | 298 /** |
263 continue; | 299 * @param {!Object} object |
264 this._addSectionWithExtensionProvidedSettings(sectionIds[i], extensi
onsBySectionId.get(sectionIds[i]).valuesArray(), childSettingExtensionsByParentN
ame); | 300 * @this {WebInspector.GenericSettingsTab} |
| 301 */ |
| 302 function appendCustomSetting(object) |
| 303 { |
| 304 var settingUI = /** @type {!WebInspector.SettingUI} */ (object); |
| 305 var element = settingUI.settingElement(); |
| 306 if (element) |
| 307 this._sectionElement(sectionName).appendChild(element); |
265 } | 308 } |
266 }, | 309 }, |
267 | 310 |
268 /** | 311 /** |
269 * @param {string} sectionName | 312 * @param {string} sectionName |
270 * @param {!Array.<!Runtime.Extension>} extensions | 313 * @return {!Element} |
271 * @param {!Multimap.<string, !Runtime.Extension>} childSettingExtensionsByP
arentName | |
272 */ | 314 */ |
273 _addSectionWithExtensionProvidedSettings: function(sectionName, extensions,
childSettingExtensionsByParentName) | 315 _sectionElement: function(sectionName) |
274 { | 316 { |
275 var uiSectionName = sectionName && WebInspector.UIString(sectionName); | 317 var sectionElement = this._nameToSection.get(sectionName); |
276 var sectionElement = this._appendSection(uiSectionName); | 318 if (!sectionElement) { |
277 extensions.forEach(processSetting.bind(this, null)); | 319 var uiSectionName = sectionName && WebInspector.UIString(sectionName
); |
278 | 320 sectionElement = this._appendSection(uiSectionName); |
279 /** | 321 this._nameToSection.set(sectionName, sectionElement); |
280 * @param {?Element} parentFieldset | |
281 * @param {!Runtime.Extension} extension | |
282 * @this {WebInspector.GenericSettingsTab} | |
283 */ | |
284 function processSetting(parentFieldset, extension) | |
285 { | |
286 var descriptor = extension.descriptor(); | |
287 var experimentName = descriptor["experiment"]; | |
288 if (experimentName && !Runtime.experiments.isEnabled(experimentName)
) | |
289 return; | |
290 | |
291 if (descriptor["settingType"] === "custom") { | |
292 extension.instancePromise().then(appendCustomSetting); | |
293 return; | |
294 } | |
295 | |
296 var uiTitle = WebInspector.UIString(descriptor["title"]); | |
297 var settingName = descriptor["settingName"]; | |
298 var setting = WebInspector.settings[settingName]; | |
299 var settingControl = createSettingControl.call(this, uiTitle, settin
g, descriptor); | |
300 if (settingName) { | |
301 var childSettings = childSettingExtensionsByParentName.get(setti
ngName); | |
302 if (childSettings.size) { | |
303 var fieldSet = WebInspector.SettingsUI.createSettingFieldset
(setting); | |
304 settingControl.appendChild(fieldSet); | |
305 childSettings.valuesArray().forEach(function(item) { process
Setting.call(this, fieldSet, item); }, this); | |
306 } | |
307 } | |
308 appendAsChild(settingControl); | |
309 | |
310 /** | |
311 * @param {!Object} object | |
312 */ | |
313 function appendCustomSetting(object) | |
314 { | |
315 var uiSettingDelegate = /** @type {!WebInspector.UISettingDelega
te} */ (object); | |
316 var element = uiSettingDelegate.settingElement(); | |
317 if (element) | |
318 appendAsChild(element); | |
319 } | |
320 | |
321 /** | |
322 * @param {!Object} settingControl | |
323 */ | |
324 function appendAsChild(settingControl) | |
325 { | |
326 (parentFieldset || sectionElement).appendChild(/** @type {!Eleme
nt} */ (settingControl)); | |
327 } | |
328 } | 322 } |
329 | 323 return sectionElement; |
330 /** | |
331 * @param {string} uiTitle | |
332 * @param {!WebInspector.Setting} setting | |
333 * @param {!Object} descriptor | |
334 * @return {!Element} | |
335 * @this {WebInspector.GenericSettingsTab} | |
336 */ | |
337 function createSettingControl(uiTitle, setting, descriptor) | |
338 { | |
339 switch (descriptor["settingType"]) { | |
340 case "checkbox": | |
341 return WebInspector.SettingsUI.createSettingCheckbox(uiTitle, se
tting); | |
342 case "select": | |
343 var descriptorOptions = descriptor["options"]; | |
344 var options = new Array(descriptorOptions.length); | |
345 for (var i = 0; i < options.length; ++i) { | |
346 // The third array item flags that the option name is "raw"
(non-i18n-izable). | |
347 var optionName = descriptorOptions[i][2] ? descriptorOptions
[i][0] : WebInspector.UIString(descriptorOptions[i][0]); | |
348 options[i] = [optionName, descriptorOptions[i][1]]; | |
349 } | |
350 return this._createSelectSetting(uiTitle, options, setting); | |
351 default: | |
352 throw "Invalid setting type: " + descriptor["settingType"]; | |
353 } | |
354 } | |
355 }, | 324 }, |
356 | 325 |
357 __proto__: WebInspector.SettingsTab.prototype | 326 __proto__: WebInspector.SettingsTab.prototype |
358 } | 327 } |
359 | 328 |
360 /** | 329 /** |
361 * @constructor | 330 * @constructor |
362 * @extends {WebInspector.UISettingDelegate} | 331 * @implements {WebInspector.SettingUI} |
363 */ | 332 */ |
364 WebInspector.SettingsScreen.SkipStackFramePatternSettingDelegate = function() | 333 WebInspector.SettingsScreen.SkipStackFramePatternSettingUI = function() |
365 { | 334 { |
366 WebInspector.UISettingDelegate.call(this); | |
367 } | 335 } |
368 | 336 |
369 WebInspector.SettingsScreen.SkipStackFramePatternSettingDelegate.prototype = { | 337 WebInspector.SettingsScreen.SkipStackFramePatternSettingUI.prototype = { |
370 /** | 338 /** |
371 * @override | 339 * @override |
372 * @return {!Element} | 340 * @return {!Element} |
373 */ | 341 */ |
374 settingElement: function() | 342 settingElement: function() |
375 { | 343 { |
376 return createTextButton(WebInspector.manageBlackboxingButtonLabel(), thi
s._onManageButtonClick.bind(this), "", WebInspector.UIString("Skip stepping thro
ugh sources with particular names")); | 344 return createTextButton(WebInspector.manageBlackboxingButtonLabel(), thi
s._onManageButtonClick.bind(this), "", WebInspector.UIString("Skip stepping thro
ugh sources with particular names")); |
377 }, | 345 }, |
378 | 346 |
379 _onManageButtonClick: function() | 347 _onManageButtonClick: function() |
380 { | 348 { |
381 WebInspector.FrameworkBlackboxDialog.show(WebInspector.inspectorView.ele
ment); | 349 WebInspector.FrameworkBlackboxDialog.show(WebInspector.inspectorView.ele
ment); |
382 }, | 350 } |
383 | |
384 __proto__: WebInspector.UISettingDelegate.prototype | |
385 } | 351 } |
386 | 352 |
387 /** | 353 /** |
388 * @constructor | 354 * @constructor |
389 * @extends {WebInspector.SettingsTab} | 355 * @extends {WebInspector.SettingsTab} |
390 */ | 356 */ |
391 WebInspector.WorkspaceSettingsTab = function() | 357 WebInspector.WorkspaceSettingsTab = function() |
392 { | 358 { |
393 WebInspector.SettingsTab.call(this, WebInspector.UIString("Workspace"), "wor
kspace-tab-content"); | 359 WebInspector.SettingsTab.call(this, WebInspector.UIString("Workspace"), "wor
kspace-tab-content"); |
394 WebInspector.isolatedFileSystemManager.addEventListener(WebInspector.Isolate
dFileSystemManager.Events.FileSystemAdded, this._fileSystemAdded, this); | 360 WebInspector.isolatedFileSystemManager.addEventListener(WebInspector.Isolate
dFileSystemManager.Events.FileSystemAdded, this._fileSystemAdded, this); |
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1460 var columnId = columns[i]; | 1426 var columnId = columns[i]; |
1461 var editElement = this._addInputElements.get(columnId); | 1427 var editElement = this._addInputElements.get(columnId); |
1462 this._setEditElementValue(editElement, ""); | 1428 this._setEditElementValue(editElement, ""); |
1463 } | 1429 } |
1464 }, | 1430 }, |
1465 | 1431 |
1466 __proto__: WebInspector.SettingsList.prototype | 1432 __proto__: WebInspector.SettingsList.prototype |
1467 } | 1433 } |
1468 | 1434 |
1469 WebInspector._settingsController = new WebInspector.SettingsController(); | 1435 WebInspector._settingsController = new WebInspector.SettingsController(); |
OLD | NEW |