Chromium Code Reviews| 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 13 matching lines...) Expand all Loading... | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 33 * @extends {WebInspector.VBox} | 33 * @extends {WebInspector.VBox} |
| 34 * @implements {WebInspector.ViewLocationResolver} | |
| 34 */ | 35 */ |
| 35 WebInspector.SettingsScreen = function() | 36 WebInspector.SettingsScreen = function() |
| 36 { | 37 { |
| 37 WebInspector.VBox.call(this, true); | 38 WebInspector.VBox.call(this, true); |
| 38 this.registerRequiredCSS("settings/settingsScreen.css"); | 39 this.registerRequiredCSS("settings/settingsScreen.css"); |
| 39 | 40 |
| 40 this.contentElement.tabIndex = 0; | 41 this.contentElement.tabIndex = 0; |
| 41 this.contentElement.classList.add("help-window-main"); | 42 this.contentElement.classList.add("help-window-main"); |
| 42 this.contentElement.classList.add("vbox"); | 43 this.contentElement.classList.add("vbox"); |
| 43 var settingsLabelElement = createElementWithClass("div", "help-window-label" ); | 44 var settingsLabelElement = createElementWithClass("div", "help-window-label" ); |
| 44 settingsLabelElement.createTextChild(WebInspector.UIString("Settings")); | 45 settingsLabelElement.createTextChild(WebInspector.UIString("Settings")); |
| 45 | 46 |
| 46 this._extensibleTabbedPane = new WebInspector.ExtensibleTabbedPane("settings -view"); | 47 this._extensibleTabbedPane = new WebInspector.ExtensibleTabbedPane("settings -view"); |
| 47 var tabbedPane = this._extensibleTabbedPane.tabbedPane(); | 48 var tabbedPane = this._extensibleTabbedPane.tabbedPane(); |
| 48 tabbedPane.insertBeforeTabStrip(settingsLabelElement); | 49 tabbedPane.insertBeforeTabStrip(settingsLabelElement); |
| 49 tabbedPane.setShrinkableTabs(false); | 50 tabbedPane.setShrinkableTabs(false); |
| 50 tabbedPane.setVerticalTabLayout(true); | 51 tabbedPane.setVerticalTabLayout(true); |
| 51 tabbedPane.appendTab("shortcuts", WebInspector.UIString("Shortcuts"), WebIns pector.shortcutsScreen.createShortcutsTabView()); | 52 tabbedPane.appendTab("shortcuts", WebInspector.UIString("Shortcuts"), WebIns pector.shortcutsScreen.createShortcutsTabView()); |
| 52 this._extensibleTabbedPane.show(this.contentElement); | 53 this._extensibleTabbedPane.show(this.contentElement); |
| 53 | 54 |
| 54 this.element.addEventListener("keydown", this._keyDown.bind(this), false); | 55 this.element.addEventListener("keydown", this._keyDown.bind(this), false); |
| 55 this._developerModeCounter = 0; | 56 this._developerModeCounter = 0; |
| 56 this.setDefaultFocusedElement(this.contentElement); | 57 this.setDefaultFocusedElement(this.contentElement); |
| 57 } | 58 } |
| 58 | 59 |
| 60 /** | |
| 61 * @param {string=} name | |
| 62 */ | |
| 63 WebInspector.SettingsScreen._showSettingsScreen = function(name) | |
| 64 { | |
| 65 var settingsScreen = /** @type {!WebInspector.SettingsScreen} */ (self.runti me.sharedInstance(WebInspector.SettingsScreen)); | |
| 66 var dialog = new WebInspector.Dialog(); | |
| 67 dialog.addCloseButton(); | |
| 68 settingsScreen.show(dialog.element); | |
| 69 settingsScreen.selectTab(name || "preferences"); | |
| 70 dialog.show(); | |
| 71 } | |
| 72 | |
| 59 WebInspector.SettingsScreen.prototype = { | 73 WebInspector.SettingsScreen.prototype = { |
| 74 | |
| 75 /** | |
| 76 * @override | |
| 77 * @param {string} locationName | |
| 78 * @return {?WebInspector.ViewLocation} | |
| 79 */ | |
| 80 resolveLocation: function(locationName) | |
|
dgozman
2016/08/03 19:18:18
I thought we agreed on revealLocation.
pfeldman
2016/08/03 21:52:18
I'll follow up in the subsequent patch.
| |
| 81 { | |
| 82 WebInspector.SettingsScreen._showSettingsScreen(); | |
| 83 return this._extensibleTabbedPane; | |
| 84 }, | |
| 85 | |
| 60 /** | 86 /** |
| 61 * @param {string} name | 87 * @param {string} name |
| 62 */ | 88 */ |
| 63 selectTab: function(name) | 89 selectTab: function(name) |
| 64 { | 90 { |
| 65 this._extensibleTabbedPane.showTab(name); | 91 this._extensibleTabbedPane.showView(name); |
| 66 }, | 92 }, |
| 67 | 93 |
| 68 /** | 94 /** |
| 69 * @param {!Event} event | 95 * @param {!Event} event |
| 70 */ | 96 */ |
| 71 _keyDown: function(event) | 97 _keyDown: function(event) |
| 72 { | 98 { |
| 73 var shiftKeyCode = 16; | 99 var shiftKeyCode = 16; |
| 74 if (event.keyCode === shiftKeyCode && ++this._developerModeCounter > 5) | 100 if (event.keyCode === shiftKeyCode && ++this._developerModeCounter > 5) |
| 75 this.contentElement.classList.add("settings-developer-mode"); | 101 this.contentElement.classList.add("settings-developer-mode"); |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 449 p.className = experiment.hidden && !experiment.isEnabled() ? "settings-e xperiment-hidden" : ""; | 475 p.className = experiment.hidden && !experiment.isEnabled() ? "settings-e xperiment-hidden" : ""; |
| 450 p.appendChild(label); | 476 p.appendChild(label); |
| 451 return p; | 477 return p; |
| 452 }, | 478 }, |
| 453 | 479 |
| 454 __proto__: WebInspector.SettingsTab.prototype | 480 __proto__: WebInspector.SettingsTab.prototype |
| 455 } | 481 } |
| 456 | 482 |
| 457 /** | 483 /** |
| 458 * @constructor | 484 * @constructor |
| 459 */ | |
| 460 WebInspector.SettingsController = function() | |
| 461 { | |
| 462 /** @type {?WebInspector.SettingsScreen} */ | |
| 463 this._settingsScreen; | |
| 464 } | |
| 465 | |
| 466 WebInspector.SettingsController.prototype = { | |
| 467 /** | |
| 468 * @param {string=} name | |
| 469 */ | |
| 470 showSettingsScreen: function(name) | |
| 471 { | |
| 472 if (!this._settingsScreen) | |
| 473 this._settingsScreen = new WebInspector.SettingsScreen(); | |
| 474 | |
| 475 var dialog = new WebInspector.Dialog(); | |
| 476 dialog.addCloseButton(); | |
| 477 this._settingsScreen.show(dialog.element); | |
| 478 this._settingsScreen.selectTab(name || "preferences"); | |
| 479 dialog.show(); | |
| 480 } | |
| 481 } | |
| 482 | |
| 483 /** | |
| 484 * @constructor | |
| 485 * @implements {WebInspector.ActionDelegate} | 485 * @implements {WebInspector.ActionDelegate} |
| 486 */ | 486 */ |
| 487 WebInspector.SettingsController.ActionDelegate = function() { } | 487 WebInspector.SettingsScreen.ActionDelegate = function() { } |
| 488 | 488 |
| 489 WebInspector.SettingsController.ActionDelegate.prototype = { | 489 WebInspector.SettingsScreen.ActionDelegate.prototype = { |
| 490 /** | 490 /** |
| 491 * @override | 491 * @override |
| 492 * @param {!WebInspector.Context} context | 492 * @param {!WebInspector.Context} context |
| 493 * @param {string} actionId | 493 * @param {string} actionId |
| 494 * @return {boolean} | 494 * @return {boolean} |
| 495 */ | 495 */ |
| 496 handleAction: function(context, actionId) | 496 handleAction: function(context, actionId) |
| 497 { | 497 { |
| 498 switch (actionId) { | 498 switch (actionId) { |
| 499 case "settings.show": | 499 case "settings.show": |
| 500 WebInspector._settingsController.showSettingsScreen(); | 500 WebInspector.SettingsScreen._showSettingsScreen(); |
| 501 return true; | 501 return true; |
| 502 case "settings.help": | 502 case "settings.help": |
| 503 InspectorFrontendHost.openInNewTab("https://developers.google.com/we b/tools/chrome-devtools/"); | 503 InspectorFrontendHost.openInNewTab("https://developers.google.com/we b/tools/chrome-devtools/"); |
| 504 return true; | 504 return true; |
| 505 case "settings.shortcuts": | 505 case "settings.shortcuts": |
| 506 WebInspector._settingsController.showSettingsScreen("shortcuts"); | 506 WebInspector.SettingsScreen._showSettingsScreen("shortcuts"); |
| 507 return true; | 507 return true; |
| 508 } | 508 } |
| 509 return false; | 509 return false; |
| 510 } | 510 } |
| 511 } | 511 } |
| 512 | 512 |
| 513 /** | 513 /** |
| 514 * @constructor | 514 * @constructor |
| 515 * @implements {WebInspector.Revealer} | 515 * @implements {WebInspector.Revealer} |
| 516 */ | 516 */ |
| 517 WebInspector.SettingsController.Revealer = function() { } | 517 WebInspector.SettingsScreen.Revealer = function() { } |
| 518 | 518 |
| 519 WebInspector.SettingsController.Revealer.prototype = { | 519 WebInspector.SettingsScreen.Revealer.prototype = { |
| 520 /** | 520 /** |
| 521 * @override | 521 * @override |
| 522 * @param {!Object} object | 522 * @param {!Object} object |
| 523 * @return {!Promise} | 523 * @return {!Promise} |
| 524 */ | 524 */ |
| 525 reveal: function(object) | 525 reveal: function(object) |
| 526 { | 526 { |
| 527 console.assert(object instanceof WebInspector.Setting); | 527 console.assert(object instanceof WebInspector.Setting); |
| 528 var setting = /** @type {!WebInspector.Setting} */ (object); | 528 var setting = /** @type {!WebInspector.Setting} */ (object); |
| 529 var success = false; | 529 var success = false; |
| 530 | 530 |
| 531 self.runtime.extensions("setting").forEach(revealModuleSetting); | 531 self.runtime.extensions("setting").forEach(revealModuleSetting); |
| 532 self.runtime.extensions(WebInspector.SettingUI).forEach(revealSettingUI) ; | 532 self.runtime.extensions(WebInspector.SettingUI).forEach(revealSettingUI) ; |
| 533 self.runtime.extensions("view").forEach(revealSettingsView); | 533 self.runtime.extensions("view").forEach(revealSettingsView); |
| 534 | 534 |
| 535 return success ? Promise.resolve() : Promise.reject(); | 535 return success ? Promise.resolve() : Promise.reject(); |
| 536 | 536 |
| 537 /** | 537 /** |
| 538 * @param {!Runtime.Extension} extension | 538 * @param {!Runtime.Extension} extension |
| 539 */ | 539 */ |
| 540 function revealModuleSetting(extension) | 540 function revealModuleSetting(extension) |
| 541 { | 541 { |
| 542 if (!WebInspector.GenericSettingsTab.isSettingVisible(extension)) | 542 if (!WebInspector.GenericSettingsTab.isSettingVisible(extension)) |
| 543 return; | 543 return; |
| 544 if (extension.descriptor()["settingName"] === setting.name) { | 544 if (extension.descriptor()["settingName"] === setting.name) { |
| 545 InspectorFrontendHost.bringToFront(); | 545 InspectorFrontendHost.bringToFront(); |
| 546 WebInspector._settingsController.showSettingsScreen("preferences "); | 546 WebInspector.SettingsScreen._showSettingsScreen(); |
| 547 success = true; | 547 success = true; |
| 548 } | 548 } |
| 549 } | 549 } |
| 550 | 550 |
| 551 /** | 551 /** |
| 552 * @param {!Runtime.Extension} extension | 552 * @param {!Runtime.Extension} extension |
| 553 */ | 553 */ |
| 554 function revealSettingUI(extension) | 554 function revealSettingUI(extension) |
| 555 { | 555 { |
| 556 var settings = extension.descriptor()["settings"]; | 556 var settings = extension.descriptor()["settings"]; |
| 557 if (settings && settings.indexOf(setting.name) !== -1) { | 557 if (settings && settings.indexOf(setting.name) !== -1) { |
| 558 InspectorFrontendHost.bringToFront(); | 558 InspectorFrontendHost.bringToFront(); |
| 559 WebInspector._settingsController.showSettingsScreen("preferences "); | 559 WebInspector.SettingsScreen._showSettingsScreen(); |
| 560 success = true; | 560 success = true; |
| 561 } | 561 } |
| 562 } | 562 } |
| 563 | 563 |
| 564 /** | 564 /** |
| 565 * @param {!Runtime.Extension} extension | 565 * @param {!Runtime.Extension} extension |
| 566 */ | 566 */ |
| 567 function revealSettingsView(extension) | 567 function revealSettingsView(extension) |
| 568 { | 568 { |
| 569 var location = extension.descriptor()["location"]; | 569 var location = extension.descriptor()["location"]; |
| 570 if (location !== "settings-view") | 570 if (location !== "settings-view") |
| 571 return; | 571 return; |
| 572 var settings = extension.descriptor()["settings"]; | 572 var settings = extension.descriptor()["settings"]; |
| 573 if (settings && settings.indexOf(setting.name) !== -1) { | 573 if (settings && settings.indexOf(setting.name) !== -1) { |
| 574 InspectorFrontendHost.bringToFront(); | 574 InspectorFrontendHost.bringToFront(); |
| 575 WebInspector._settingsController.showSettingsScreen(extension.de scriptor()["name"]); | 575 WebInspector.SettingsScreen._showSettingsScreen(extension.descri ptor()["id"]); |
| 576 success = true; | 576 success = true; |
| 577 } | 577 } |
| 578 } | 578 } |
| 579 } | 579 } |
| 580 } | 580 } |
| 581 | |
| 582 WebInspector._settingsController = new WebInspector.SettingsController(); | |
| OLD | NEW |