| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 20 matching lines...) Expand all Loading... |
| 31 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 33 * @extends {WebInspector.Object} | 33 * @extends {WebInspector.Object} |
| 34 */ | 34 */ |
| 35 WebInspector.HandlerRegistry = function(setting) | 35 WebInspector.HandlerRegistry = function(setting) |
| 36 { | 36 { |
| 37 WebInspector.Object.call(this); | 37 WebInspector.Object.call(this); |
| 38 this._handlers = {}; | 38 this._handlers = {}; |
| 39 this._setting = setting; | 39 this._setting = setting; |
| 40 this._activeHandler = this._setting.get(); | 40 this._activeHandler = this._setting.get(); |
| 41 } | 41 }; |
| 42 | 42 |
| 43 WebInspector.HandlerRegistry.prototype = { | 43 WebInspector.HandlerRegistry.prototype = { |
| 44 get handlerNames() | 44 get handlerNames() |
| 45 { | 45 { |
| 46 return Object.getOwnPropertyNames(this._handlers); | 46 return Object.getOwnPropertyNames(this._handlers); |
| 47 }, | 47 }, |
| 48 | 48 |
| 49 get activeHandler() | 49 get activeHandler() |
| 50 { | 50 { |
| 51 return this._activeHandler; | 51 return this._activeHandler; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 InspectorFrontendHost.openInNewTab(resourceURL); | 204 InspectorFrontendHost.openInNewTab(resourceURL); |
| 205 } | 205 } |
| 206 if (!targetNode.enclosingNodeOrSelfWithClassList(["resources", "panel"])
&& WebInspector.resourceForURL(resourceURL)) | 206 if (!targetNode.enclosingNodeOrSelfWithClassList(["resources", "panel"])
&& WebInspector.resourceForURL(resourceURL)) |
| 207 contextMenu.appendItem(WebInspector.UIString.capitalize("Open ^link
in Application ^panel"), openInResourcesPanel.bind(null, resourceURL)); | 207 contextMenu.appendItem(WebInspector.UIString.capitalize("Open ^link
in Application ^panel"), openInResourcesPanel.bind(null, resourceURL)); |
| 208 | 208 |
| 209 | 209 |
| 210 contextMenu.appendItem(WebInspector.copyLinkAddressLabel(), InspectorFro
ntendHost.copyText.bind(InspectorFrontendHost, resourceURL)); | 210 contextMenu.appendItem(WebInspector.copyLinkAddressLabel(), InspectorFro
ntendHost.copyText.bind(InspectorFrontendHost, resourceURL)); |
| 211 }, | 211 }, |
| 212 | 212 |
| 213 __proto__: WebInspector.Object.prototype | 213 __proto__: WebInspector.Object.prototype |
| 214 } | 214 }; |
| 215 | 215 |
| 216 /** @enum {symbol} */ | 216 /** @enum {symbol} */ |
| 217 WebInspector.HandlerRegistry.Events = { | 217 WebInspector.HandlerRegistry.Events = { |
| 218 HandlersUpdated: Symbol("HandlersUpdated") | 218 HandlersUpdated: Symbol("HandlersUpdated") |
| 219 } | 219 }; |
| 220 | 220 |
| 221 /** | 221 /** |
| 222 * @constructor | 222 * @constructor |
| 223 */ | 223 */ |
| 224 WebInspector.HandlerSelector = function(handlerRegistry) | 224 WebInspector.HandlerSelector = function(handlerRegistry) |
| 225 { | 225 { |
| 226 this._handlerRegistry = handlerRegistry; | 226 this._handlerRegistry = handlerRegistry; |
| 227 this.element = createElementWithClass("select", "chrome-select"); | 227 this.element = createElementWithClass("select", "chrome-select"); |
| 228 this.element.addEventListener("change", this._onChange.bind(this), false); | 228 this.element.addEventListener("change", this._onChange.bind(this), false); |
| 229 this._update(); | 229 this._update(); |
| 230 this._handlerRegistry.addEventListener(WebInspector.HandlerRegistry.Events.H
andlersUpdated, this._update.bind(this)); | 230 this._handlerRegistry.addEventListener(WebInspector.HandlerRegistry.Events.H
andlersUpdated, this._update.bind(this)); |
| 231 } | 231 }; |
| 232 | 232 |
| 233 WebInspector.HandlerSelector.prototype = | 233 WebInspector.HandlerSelector.prototype = |
| 234 { | 234 { |
| 235 _update: function() | 235 _update: function() |
| 236 { | 236 { |
| 237 this.element.removeChildren(); | 237 this.element.removeChildren(); |
| 238 var names = this._handlerRegistry.handlerNames; | 238 var names = this._handlerRegistry.handlerNames; |
| 239 var activeHandler = this._handlerRegistry.activeHandler; | 239 var activeHandler = this._handlerRegistry.activeHandler; |
| 240 | 240 |
| 241 for (var i = 0; i < names.length; ++i) { | 241 for (var i = 0; i < names.length; ++i) { |
| 242 var option = createElement("option"); | 242 var option = createElement("option"); |
| 243 option.textContent = names[i]; | 243 option.textContent = names[i]; |
| 244 option.selected = activeHandler === names[i]; | 244 option.selected = activeHandler === names[i]; |
| 245 this.element.appendChild(option); | 245 this.element.appendChild(option); |
| 246 } | 246 } |
| 247 this.element.disabled = names.length <= 1; | 247 this.element.disabled = names.length <= 1; |
| 248 }, | 248 }, |
| 249 | 249 |
| 250 _onChange: function(event) | 250 _onChange: function(event) |
| 251 { | 251 { |
| 252 var value = event.target.value; | 252 var value = event.target.value; |
| 253 this._handlerRegistry.activeHandler = value; | 253 this._handlerRegistry.activeHandler = value; |
| 254 } | 254 } |
| 255 } | 255 }; |
| 256 | 256 |
| 257 /** | 257 /** |
| 258 * @constructor | 258 * @constructor |
| 259 * @implements {WebInspector.ContextMenu.Provider} | 259 * @implements {WebInspector.ContextMenu.Provider} |
| 260 */ | 260 */ |
| 261 WebInspector.HandlerRegistry.ContextMenuProvider = function() | 261 WebInspector.HandlerRegistry.ContextMenuProvider = function() |
| 262 { | 262 { |
| 263 } | 263 }; |
| 264 | 264 |
| 265 WebInspector.HandlerRegistry.ContextMenuProvider.prototype = { | 265 WebInspector.HandlerRegistry.ContextMenuProvider.prototype = { |
| 266 /** | 266 /** |
| 267 * @override | 267 * @override |
| 268 * @param {!Event} event | 268 * @param {!Event} event |
| 269 * @param {!WebInspector.ContextMenu} contextMenu | 269 * @param {!WebInspector.ContextMenu} contextMenu |
| 270 * @param {!Object} target | 270 * @param {!Object} target |
| 271 */ | 271 */ |
| 272 appendApplicableItems: function(event, contextMenu, target) | 272 appendApplicableItems: function(event, contextMenu, target) |
| 273 { | 273 { |
| 274 WebInspector.openAnchorLocationRegistry._appendContentProviderItems(cont
extMenu, target); | 274 WebInspector.openAnchorLocationRegistry._appendContentProviderItems(cont
extMenu, target); |
| 275 WebInspector.openAnchorLocationRegistry._appendHrefItems(contextMenu, ta
rget); | 275 WebInspector.openAnchorLocationRegistry._appendHrefItems(contextMenu, ta
rget); |
| 276 } | 276 } |
| 277 } | 277 }; |
| 278 | 278 |
| 279 /** | 279 /** |
| 280 * @constructor | 280 * @constructor |
| 281 * @implements {WebInspector.Linkifier.LinkHandler} | 281 * @implements {WebInspector.Linkifier.LinkHandler} |
| 282 */ | 282 */ |
| 283 WebInspector.HandlerRegistry.LinkHandler = function() | 283 WebInspector.HandlerRegistry.LinkHandler = function() |
| 284 { | 284 { |
| 285 } | 285 }; |
| 286 | 286 |
| 287 WebInspector.HandlerRegistry.LinkHandler.prototype = { | 287 WebInspector.HandlerRegistry.LinkHandler.prototype = { |
| 288 /** | 288 /** |
| 289 * @override | 289 * @override |
| 290 * @param {string} url | 290 * @param {string} url |
| 291 * @param {number=} lineNumber | 291 * @param {number=} lineNumber |
| 292 * @return {boolean} | 292 * @return {boolean} |
| 293 */ | 293 */ |
| 294 handleLink: function(url, lineNumber) | 294 handleLink: function(url, lineNumber) |
| 295 { | 295 { |
| 296 return WebInspector.openAnchorLocationRegistry.dispatch({ url: url, line
Number: lineNumber}); | 296 return WebInspector.openAnchorLocationRegistry.dispatch({ url: url, line
Number: lineNumber}); |
| 297 } | 297 } |
| 298 } | 298 }; |
| 299 | 299 |
| 300 /** | 300 /** |
| 301 * @constructor | 301 * @constructor |
| 302 * @implements {WebInspector.SettingUI} | 302 * @implements {WebInspector.SettingUI} |
| 303 */ | 303 */ |
| 304 WebInspector.HandlerRegistry.OpenAnchorLocationSettingUI = function() | 304 WebInspector.HandlerRegistry.OpenAnchorLocationSettingUI = function() |
| 305 { | 305 { |
| 306 } | 306 }; |
| 307 | 307 |
| 308 WebInspector.HandlerRegistry.OpenAnchorLocationSettingUI.prototype = { | 308 WebInspector.HandlerRegistry.OpenAnchorLocationSettingUI.prototype = { |
| 309 /** | 309 /** |
| 310 * @override | 310 * @override |
| 311 * @return {?Element} | 311 * @return {?Element} |
| 312 */ | 312 */ |
| 313 settingElement: function() | 313 settingElement: function() |
| 314 { | 314 { |
| 315 if (!WebInspector.openAnchorLocationRegistry.handlerNames.length) | 315 if (!WebInspector.openAnchorLocationRegistry.handlerNames.length) |
| 316 return null; | 316 return null; |
| 317 | 317 |
| 318 var handlerSelector = new WebInspector.HandlerSelector(WebInspector.open
AnchorLocationRegistry); | 318 var handlerSelector = new WebInspector.HandlerSelector(WebInspector.open
AnchorLocationRegistry); |
| 319 return WebInspector.SettingsUI.createCustomSetting(WebInspector.UIString
("Link handling:"), handlerSelector.element); | 319 return WebInspector.SettingsUI.createCustomSetting(WebInspector.UIString
("Link handling:"), handlerSelector.element); |
| 320 } | 320 } |
| 321 } | 321 }; |
| 322 | 322 |
| 323 /** | 323 /** |
| 324 * @type {!WebInspector.HandlerRegistry} | 324 * @type {!WebInspector.HandlerRegistry} |
| 325 */ | 325 */ |
| 326 WebInspector.openAnchorLocationRegistry; | 326 WebInspector.openAnchorLocationRegistry; |
| OLD | NEW |