Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are |
| 6 | * met: |
| 7 | * |
| 8 | * * Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * * Redistributions in binary form must reproduce the above |
| 11 | * copyright notice, this list of conditions and the following disclaimer |
| 12 | * in the documentation and/or other materials provided with the |
| 13 | * distribution. |
| 14 | * * Neither the name of Google Inc. nor the names of its |
| 15 | * contributors may be used to endorse or promote products derived from |
| 16 | * this software without specific prior written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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. |
| 29 | */ |
| 30 | /** |
| 31 | * @implements {UI.ViewLocationResolver} |
| 32 | * @unrestricted |
| 33 | */ |
Tim van der Lippe | 1ebfc50 | 2020-01-15 13:45:09 | [diff] [blame^] | 34 | export class SettingsScreen extends UI.VBox { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 35 | constructor() { |
| 36 | super(true); |
| 37 | this.registerRequiredCSS('settings/settingsScreen.css'); |
| 38 | |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 39 | this.contentElement.classList.add('settings-window-main'); |
| 40 | this.contentElement.classList.add('vbox'); |
| 41 | |
| 42 | const settingsLabelElement = createElement('div'); |
John Emau | b970e56 | 2019-06-05 01:17:27 | [diff] [blame] | 43 | const settingsTitleElement = UI.createShadowRootWithCoreStyles(settingsLabelElement, 'settings/settingsScreen.css') |
| 44 | .createChild('div', 'settings-window-title'); |
| 45 | |
| 46 | UI.ARIAUtils.markAsHeading(settingsTitleElement, 1); |
| 47 | settingsTitleElement.textContent = ls`Settings`; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 48 | |
| 49 | this._tabbedLocation = |
Paul Lewis | 5d4133e | 2019-11-27 13:06:01 | [diff] [blame] | 50 | UI.viewManager.createTabbedLocation(() => SettingsScreen._showSettingsScreen(), 'settings-view'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 51 | const tabbedPane = this._tabbedLocation.tabbedPane(); |
| 52 | tabbedPane.leftToolbar().appendToolbarItem(new UI.ToolbarItem(settingsLabelElement)); |
| 53 | tabbedPane.setShrinkableTabs(false); |
| 54 | tabbedPane.makeVerticalTabLayout(); |
John Emau | b970e56 | 2019-06-05 01:17:27 | [diff] [blame] | 55 | const shortcutsView = new UI.SimpleView(ls`Shortcuts`); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 56 | UI.shortcutsScreen.createShortcutsTabView().show(shortcutsView.element); |
| 57 | this._tabbedLocation.appendView(shortcutsView); |
| 58 | tabbedPane.show(this.contentElement); |
| 59 | |
| 60 | this.element.addEventListener('keydown', this._keyDown.bind(this), false); |
| 61 | this._developerModeCounter = 0; |
| 62 | this.setDefaultFocusedElement(this.contentElement); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * @param {string=} name |
| 67 | */ |
| 68 | static _showSettingsScreen(name) { |
| 69 | const settingsScreen = |
Tim van der Lippe | 1ebfc50 | 2020-01-15 13:45:09 | [diff] [blame^] | 70 | /** @type {!SettingsScreen} */ (self.runtime.sharedInstance(SettingsScreen)); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 71 | if (settingsScreen.isShowing()) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 72 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 73 | } |
John Emau | 8376364 | 2019-07-16 23:56:42 | [diff] [blame] | 74 | const dialog = new UI.Dialog(); |
Chandani Shrestha | 08469b8 | 2019-10-02 17:22:55 | [diff] [blame] | 75 | dialog.contentElement.tabIndex = -1; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 76 | dialog.addCloseButton(); |
Brian Cui | 8fdb148 | 2019-12-04 21:41:46 | [diff] [blame] | 77 | dialog.setOutsideClickCallback(() => {}); |
| 78 | dialog.setPointerEventsBehavior(UI.GlassPane.PointerEventsBehavior.PierceGlassPane); |
| 79 | dialog.setOutsideTabIndexBehavior(UI.Dialog.OutsideTabIndexBehavior.PreserveMainViewTabIndex); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 80 | settingsScreen.show(dialog.contentElement); |
| 81 | dialog.show(); |
| 82 | settingsScreen._selectTab(name || 'preferences'); |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * @override |
| 87 | * @param {string} locationName |
| 88 | * @return {?UI.ViewLocation} |
| 89 | */ |
| 90 | resolveLocation(locationName) { |
| 91 | return this._tabbedLocation; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * @param {string} name |
| 96 | */ |
| 97 | _selectTab(name) { |
| 98 | UI.viewManager.showView(name); |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * @param {!Event} event |
| 103 | */ |
| 104 | _keyDown(event) { |
| 105 | const shiftKeyCode = 16; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 106 | if (event.keyCode === shiftKeyCode && ++this._developerModeCounter > 5) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 107 | this.contentElement.classList.add('settings-developer-mode'); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 108 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 109 | } |
Paul Lewis | 5d4133e | 2019-11-27 13:06:01 | [diff] [blame] | 110 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 111 | |
| 112 | /** |
| 113 | * @unrestricted |
| 114 | */ |
Tim van der Lippe | c96ccd9 | 2019-11-29 16:23:54 | [diff] [blame] | 115 | class SettingsTab extends UI.VBox { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 116 | /** |
| 117 | * @param {string} name |
| 118 | * @param {string=} id |
| 119 | */ |
| 120 | constructor(name, id) { |
| 121 | super(); |
| 122 | this.element.classList.add('settings-tab-container'); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 123 | if (id) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 124 | this.element.id = id; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 125 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 126 | const header = this.element.createChild('header'); |
Chandani Shrestha | 83bd7c9 | 2019-06-11 21:21:59 | [diff] [blame] | 127 | header.createChild('h1').createTextChild(name); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 128 | this.containerElement = this.element.createChild('div', 'settings-container-wrapper') |
| 129 | .createChild('div', 'settings-tab settings-content settings-container'); |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * @param {string=} name |
| 134 | * @return {!Element} |
| 135 | */ |
| 136 | _appendSection(name) { |
| 137 | const block = this.containerElement.createChild('div', 'settings-block'); |
Chandani Shrestha | 83bd7c9 | 2019-06-11 21:21:59 | [diff] [blame] | 138 | if (name) { |
| 139 | UI.ARIAUtils.markAsGroup(block); |
| 140 | const title = block.createChild('div', 'settings-section-title'); |
| 141 | title.textContent = name; |
| 142 | UI.ARIAUtils.markAsHeading(title, 2); |
Joel Einbinder | eaef616 | 2019-07-15 17:42:55 | [diff] [blame] | 143 | UI.ARIAUtils.setAccessibleName(block, name); |
Chandani Shrestha | 83bd7c9 | 2019-06-11 21:21:59 | [diff] [blame] | 144 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 145 | return block; |
| 146 | } |
Paul Lewis | 5d4133e | 2019-11-27 13:06:01 | [diff] [blame] | 147 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 148 | |
| 149 | /** |
| 150 | * @unrestricted |
| 151 | */ |
Paul Lewis | 5d4133e | 2019-11-27 13:06:01 | [diff] [blame] | 152 | export class GenericSettingsTab extends SettingsTab { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 153 | constructor() { |
| 154 | super(Common.UIString('Preferences'), 'preferences-tab-content'); |
| 155 | |
| 156 | /** @const */ |
| 157 | const explicitSectionOrder = |
| 158 | ['', 'Appearance', 'Sources', 'Elements', 'Network', 'Performance', 'Console', 'Extensions']; |
| 159 | /** @type {!Map<string, !Element>} */ |
| 160 | this._nameToSection = new Map(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 161 | for (const sectionName of explicitSectionOrder) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 162 | this._sectionElement(sectionName); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 163 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 164 | self.runtime.extensions('setting').forEach(this._addSetting.bind(this)); |
| 165 | self.runtime.extensions(UI.SettingUI).forEach(this._addSettingUI.bind(this)); |
| 166 | |
| 167 | this._appendSection().appendChild( |
| 168 | UI.createTextButton(Common.UIString('Restore defaults and reload'), restoreAndReload)); |
| 169 | |
| 170 | function restoreAndReload() { |
| 171 | Common.settings.clearAll(); |
| 172 | Components.reload(); |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | /** |
Tim van der Lippe | 99e59b8 | 2019-09-30 20:00:59 | [diff] [blame] | 177 | * @param {!Root.Runtime.Extension} extension |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 178 | * @return {boolean} |
| 179 | */ |
| 180 | static isSettingVisible(extension) { |
| 181 | const descriptor = extension.descriptor(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 182 | if (!('title' in descriptor)) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 183 | return false; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 184 | } |
| 185 | if (!('category' in descriptor)) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 186 | return false; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 187 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 188 | return true; |
| 189 | } |
| 190 | |
| 191 | /** |
Tim van der Lippe | 99e59b8 | 2019-09-30 20:00:59 | [diff] [blame] | 192 | * @param {!Root.Runtime.Extension} extension |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 193 | */ |
| 194 | _addSetting(extension) { |
Paul Lewis | 5d4133e | 2019-11-27 13:06:01 | [diff] [blame] | 195 | if (!GenericSettingsTab.isSettingVisible(extension)) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 196 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 197 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 198 | const sectionElement = this._sectionElement(extension.descriptor()['category']); |
| 199 | const setting = Common.moduleSetting(extension.descriptor()['settingName']); |
| 200 | const settingControl = UI.SettingsUI.createControlForSetting(setting); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 201 | if (settingControl) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 202 | sectionElement.appendChild(settingControl); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 203 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | /** |
Tim van der Lippe | 99e59b8 | 2019-09-30 20:00:59 | [diff] [blame] | 207 | * @param {!Root.Runtime.Extension} extension |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 208 | */ |
| 209 | _addSettingUI(extension) { |
| 210 | const descriptor = extension.descriptor(); |
| 211 | const sectionName = descriptor['category'] || ''; |
| 212 | extension.instance().then(appendCustomSetting.bind(this)); |
| 213 | |
| 214 | /** |
| 215 | * @param {!Object} object |
Tim van der Lippe | 1ebfc50 | 2020-01-15 13:45:09 | [diff] [blame^] | 216 | * @this {GenericSettingsTab} |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 217 | */ |
| 218 | function appendCustomSetting(object) { |
| 219 | const settingUI = /** @type {!UI.SettingUI} */ (object); |
| 220 | const element = settingUI.settingElement(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 221 | if (element) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 222 | this._sectionElement(sectionName).appendChild(element); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 223 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 224 | } |
| 225 | } |
| 226 | |
| 227 | /** |
| 228 | * @param {string} sectionName |
| 229 | * @return {!Element} |
| 230 | */ |
| 231 | _sectionElement(sectionName) { |
| 232 | let sectionElement = this._nameToSection.get(sectionName); |
| 233 | if (!sectionElement) { |
| 234 | const uiSectionName = sectionName && Common.UIString(sectionName); |
| 235 | sectionElement = this._appendSection(uiSectionName); |
| 236 | this._nameToSection.set(sectionName, sectionElement); |
| 237 | } |
| 238 | return sectionElement; |
| 239 | } |
Paul Lewis | 5d4133e | 2019-11-27 13:06:01 | [diff] [blame] | 240 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 241 | |
| 242 | /** |
| 243 | * @unrestricted |
| 244 | */ |
Paul Lewis | 5d4133e | 2019-11-27 13:06:01 | [diff] [blame] | 245 | export class ExperimentsSettingsTab extends SettingsTab { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 246 | constructor() { |
| 247 | super(Common.UIString('Experiments'), 'experiments-tab-content'); |
| 248 | |
Tim van der Lippe | 99e59b8 | 2019-09-30 20:00:59 | [diff] [blame] | 249 | const experiments = Root.Runtime.experiments.allConfigurableExperiments(); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 250 | if (experiments.length) { |
| 251 | const experimentsSection = this._appendSection(); |
| 252 | experimentsSection.appendChild(this._createExperimentsWarningSubsection()); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 253 | for (let i = 0; i < experiments.length; ++i) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 254 | experimentsSection.appendChild(this._createExperimentCheckbox(experiments[i])); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 255 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 256 | } |
| 257 | } |
| 258 | |
| 259 | /** |
| 260 | * @return {!Element} element |
| 261 | */ |
| 262 | _createExperimentsWarningSubsection() { |
| 263 | const subsection = createElement('div'); |
| 264 | const warning = subsection.createChild('span', 'settings-experiments-warning-subsection-warning'); |
| 265 | warning.textContent = Common.UIString('WARNING:'); |
| 266 | subsection.createTextChild(' '); |
| 267 | const message = subsection.createChild('span', 'settings-experiments-warning-subsection-message'); |
| 268 | message.textContent = Common.UIString('These experiments could be dangerous and may require restart.'); |
| 269 | return subsection; |
| 270 | } |
| 271 | |
| 272 | _createExperimentCheckbox(experiment) { |
| 273 | const label = UI.CheckboxLabel.create(Common.UIString(experiment.title), experiment.isEnabled()); |
| 274 | const input = label.checkboxElement; |
| 275 | input.name = experiment.name; |
| 276 | function listener() { |
| 277 | experiment.setEnabled(input.checked); |
| 278 | } |
| 279 | input.addEventListener('click', listener, false); |
| 280 | |
| 281 | const p = createElement('p'); |
| 282 | p.className = experiment.hidden && !experiment.isEnabled() ? 'settings-experiment-hidden' : ''; |
| 283 | p.appendChild(label); |
| 284 | return p; |
| 285 | } |
Paul Lewis | 5d4133e | 2019-11-27 13:06:01 | [diff] [blame] | 286 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 287 | |
| 288 | /** |
| 289 | * @implements {UI.ActionDelegate} |
| 290 | * @unrestricted |
| 291 | */ |
Paul Lewis | 5d4133e | 2019-11-27 13:06:01 | [diff] [blame] | 292 | export class ActionDelegate { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 293 | /** |
| 294 | * @override |
| 295 | * @param {!UI.Context} context |
| 296 | * @param {string} actionId |
| 297 | * @return {boolean} |
| 298 | */ |
| 299 | handleAction(context, actionId) { |
| 300 | switch (actionId) { |
| 301 | case 'settings.show': |
Paul Lewis | 5d4133e | 2019-11-27 13:06:01 | [diff] [blame] | 302 | SettingsScreen._showSettingsScreen(); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 303 | return true; |
| 304 | case 'settings.documentation': |
Tim van der Lippe | 50cfa9b | 2019-10-01 10:40:58 | [diff] [blame] | 305 | Host.InspectorFrontendHost.openInNewTab('https://developers.google.com/web/tools/chrome-devtools/'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 306 | return true; |
| 307 | case 'settings.shortcuts': |
Paul Lewis | 5d4133e | 2019-11-27 13:06:01 | [diff] [blame] | 308 | SettingsScreen._showSettingsScreen(Common.UIString('Shortcuts')); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 309 | return true; |
| 310 | } |
| 311 | return false; |
| 312 | } |
Paul Lewis | 5d4133e | 2019-11-27 13:06:01 | [diff] [blame] | 313 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 314 | |
| 315 | /** |
| 316 | * @implements {Common.Revealer} |
| 317 | * @unrestricted |
| 318 | */ |
Paul Lewis | 5d4133e | 2019-11-27 13:06:01 | [diff] [blame] | 319 | export class Revealer { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 320 | /** |
| 321 | * @override |
| 322 | * @param {!Object} object |
| 323 | * @return {!Promise} |
| 324 | */ |
| 325 | reveal(object) { |
| 326 | console.assert(object instanceof Common.Setting); |
| 327 | const setting = /** @type {!Common.Setting} */ (object); |
| 328 | let success = false; |
| 329 | |
| 330 | self.runtime.extensions('setting').forEach(revealModuleSetting); |
| 331 | self.runtime.extensions(UI.SettingUI).forEach(revealSettingUI); |
| 332 | self.runtime.extensions('view').forEach(revealSettingsView); |
| 333 | |
| 334 | return success ? Promise.resolve() : Promise.reject(); |
| 335 | |
| 336 | /** |
Tim van der Lippe | 99e59b8 | 2019-09-30 20:00:59 | [diff] [blame] | 337 | * @param {!Root.Runtime.Extension} extension |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 338 | */ |
| 339 | function revealModuleSetting(extension) { |
Paul Lewis | 5d4133e | 2019-11-27 13:06:01 | [diff] [blame] | 340 | if (!GenericSettingsTab.isSettingVisible(extension)) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 341 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 342 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 343 | if (extension.descriptor()['settingName'] === setting.name) { |
Tim van der Lippe | 50cfa9b | 2019-10-01 10:40:58 | [diff] [blame] | 344 | Host.InspectorFrontendHost.bringToFront(); |
Paul Lewis | 5d4133e | 2019-11-27 13:06:01 | [diff] [blame] | 345 | SettingsScreen._showSettingsScreen(); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 346 | success = true; |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | /** |
Tim van der Lippe | 99e59b8 | 2019-09-30 20:00:59 | [diff] [blame] | 351 | * @param {!Root.Runtime.Extension} extension |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 352 | */ |
| 353 | function revealSettingUI(extension) { |
| 354 | const settings = extension.descriptor()['settings']; |
| 355 | if (settings && settings.indexOf(setting.name) !== -1) { |
Tim van der Lippe | 50cfa9b | 2019-10-01 10:40:58 | [diff] [blame] | 356 | Host.InspectorFrontendHost.bringToFront(); |
Paul Lewis | 5d4133e | 2019-11-27 13:06:01 | [diff] [blame] | 357 | SettingsScreen._showSettingsScreen(); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 358 | success = true; |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | /** |
Tim van der Lippe | 99e59b8 | 2019-09-30 20:00:59 | [diff] [blame] | 363 | * @param {!Root.Runtime.Extension} extension |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 364 | */ |
| 365 | function revealSettingsView(extension) { |
| 366 | const location = extension.descriptor()['location']; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 367 | if (location !== 'settings-view') { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 368 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 369 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 370 | const settings = extension.descriptor()['settings']; |
| 371 | if (settings && settings.indexOf(setting.name) !== -1) { |
Tim van der Lippe | 50cfa9b | 2019-10-01 10:40:58 | [diff] [blame] | 372 | Host.InspectorFrontendHost.bringToFront(); |
Paul Lewis | 5d4133e | 2019-11-27 13:06:01 | [diff] [blame] | 373 | SettingsScreen._showSettingsScreen(extension.descriptor()['id']); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 374 | success = true; |
| 375 | } |
| 376 | } |
| 377 | } |
Paul Lewis | 5d4133e | 2019-11-27 13:06:01 | [diff] [blame] | 378 | } |