Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 return checkbox; | 129 return checkbox; |
| 130 }, | 130 }, |
| 131 | 131 |
| 132 /** | 132 /** |
| 133 * @return {Element} | 133 * @return {Element} |
| 134 */ | 134 */ |
| 135 _createUserAgentSelectRowElement: function() | 135 _createUserAgentSelectRowElement: function() |
| 136 { | 136 { |
| 137 var userAgent = WebInspector.settings.userAgent.get(); | 137 var userAgent = WebInspector.settings.userAgent.get(); |
| 138 | 138 |
| 139 // When present, the third element lists device metrics separated by 'x' : | 139 // When present, the third element lists device metrics separated by 'x' : |
|
skobes
2013/10/16 19:38:09
'x' sort of makes sense as a separator for width,
pfeldman
2013/10/17 16:31:16
It should all be converted into JSON. Parsing stri
| |
| 140 // - screen width, | 140 // - screen width, |
| 141 // - screen height, | 141 // - screen height, |
| 142 // - device scale factor. | 142 // - device scale factor, |
| 143 // - text autosizing. | |
| 143 const userAgents = [ | 144 const userAgents = [ |
| 144 ["Internet Explorer 10", "Mozilla/5.0 (compatible; MSIE 10.0; Window s NT 6.2; Trident/6.0)"], | 145 ["Internet Explorer 10", "Mozilla/5.0 (compatible; MSIE 10.0; Window s NT 6.2; Trident/6.0)"], |
| 145 ["Internet Explorer 9", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"], | 146 ["Internet Explorer 9", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"], |
| 146 ["Internet Explorer 8", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)"], | 147 ["Internet Explorer 8", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)"], |
| 147 ["Internet Explorer 7", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"], | 148 ["Internet Explorer 7", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"], |
| 148 | 149 |
| 149 ["Firefox 7 \u2014 Windows", "Mozilla/5.0 (Windows NT 6.1; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"], | 150 ["Firefox 7 \u2014 Windows", "Mozilla/5.0 (Windows NT 6.1; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"], |
| 150 ["Firefox 7 \u2014 Mac", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10. 6; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"], | 151 ["Firefox 7 \u2014 Mac", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10. 6; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"], |
| 151 ["Firefox 4 \u2014 Windows", "Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"], | 152 ["Firefox 4 \u2014 Windows", "Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"], |
| 152 ["Firefox 4 \u2014 Mac", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10. 6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"], | 153 ["Firefox 4 \u2014 Mac", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10. 6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"], |
| 153 ["Firefox 14 \u2014 Android Mobile", "Mozilla/5.0 (Android; Mobile; rv:14.0) Gecko/14.0 Firefox/14.0"], | 154 ["Firefox 14 \u2014 Android Mobile", "Mozilla/5.0 (Android; Mobile; rv:14.0) Gecko/14.0 Firefox/14.0"], |
| 154 ["Firefox 14 \u2014 Android Tablet", "Mozilla/5.0 (Android; Tablet; rv:14.0) Gecko/14.0 Firefox/14.0"], | 155 ["Firefox 14 \u2014 Android Tablet", "Mozilla/5.0 (Android; Tablet; rv:14.0) Gecko/14.0 Firefox/14.0"], |
| 155 | 156 |
| 156 ["Chrome \u2014 Android Mobile", "Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1 025.133 Mobile Safari/535.19", "720x1280x2"], | 157 ["Chrome \u2014 Android Mobile", "Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1 025.133 Mobile Safari/535.19", "720x1280x2x1"], |
| 157 ["Chrome \u2014 Android Tablet", "Mozilla/5.0 (Linux; Android 4.1.2; Nexus 7 Build/JZ054K) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.1 66 Safari/535.19", "1920x1200x2"], | 158 ["Chrome \u2014 Android Tablet", "Mozilla/5.0 (Linux; Android 4.1.2; Nexus 7 Build/JZ054K) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.1 66 Safari/535.19", "1920x1200x2x1"], |
| 158 | 159 |
| 159 ["iPhone \u2014 iOS 7", "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_2 li ke Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A4449 d Safari/9537.53", "640x1136x2"], | 160 ["iPhone \u2014 iOS 7", "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_2 li ke Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A4449 d Safari/9537.53", "640x1136x2x1"], |
| 160 ["iPhone \u2014 iOS 6", "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Sa fari/8536.25", "640x1136x2"], | 161 ["iPhone \u2014 iOS 6", "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Sa fari/8536.25", "640x1136x2x1"], |
| 161 ["iPad \u2014 iOS 7", "Mozilla/5.0 (iPad; CPU OS 7_0_2 like Mac OS X ) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A501 Safari/9537 .53", "2048x1536x2"], | 162 ["iPad \u2014 iOS 7", "Mozilla/5.0 (iPad; CPU OS 7_0_2 like Mac OS X ) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A501 Safari/9537 .53", "2048x1536x2x1"], |
| 162 ["iPad \u2014 iOS 6", "Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.2 5", "1024x768x1"], | 163 ["iPad \u2014 iOS 6", "Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.2 5", "1024x768x1x0"], |
| 163 | 164 |
| 164 ["Android 2.3 \u2014 Nexus S", "Mozilla/5.0 (Linux; U; Android 2.3.6 ; en-us; Nexus S Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1", "480x800x1.5"], | 165 ["Android 2.3 \u2014 Nexus S", "Mozilla/5.0 (Linux; U; Android 2.3.6 ; en-us; Nexus S Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1", "480x800x1.5x1"], |
| 165 ["Android 4.0.2 \u2014 Galaxy Nexus", "Mozilla/5.0 (Linux; U; Androi d 4.0.2; en-us; Galaxy Nexus Build/ICL53F) AppleWebKit/534.30 (KHTML, like Gecko ) Version/4.0 Mobile Safari/534.30", "720x1280x2"], | 166 ["Android 4.0.2 \u2014 Galaxy Nexus", "Mozilla/5.0 (Linux; U; Androi d 4.0.2; en-us; Galaxy Nexus Build/ICL53F) AppleWebKit/534.30 (KHTML, like Gecko ) Version/4.0 Mobile Safari/534.30", "720x1280x2x1"], |
| 166 | 167 |
| 167 ["BlackBerry \u2014 PlayBook 2.1", "Mozilla/5.0 (PlayBook; U; RIM Ta blet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML, like Gecko) Version/7.2.1.0 Saf ari/536.2+", "1024x600x1"], | 168 ["BlackBerry \u2014 PlayBook 2.1", "Mozilla/5.0 (PlayBook; U; RIM Ta blet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML, like Gecko) Version/7.2.1.0 Saf ari/536.2+", "1024x600x1x0"], |
| 168 ["BlackBerry \u2014 9900", "Mozilla/5.0 (BlackBerry; U; BlackBerry 9 900; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.187 Mobile Saf ari/534.11+", "640x480x1"], | 169 ["BlackBerry \u2014 9900", "Mozilla/5.0 (BlackBerry; U; BlackBerry 9 900; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.187 Mobile Saf ari/534.11+", "640x480x1x0"], |
| 169 ["BlackBerry \u2014 BB10", "Mozilla/5.0 (BB10; Touch) AppleWebKit/53 7.1+ (KHTML, like Gecko) Version/10.0.0.1337 Mobile Safari/537.1+", "768x1280x1" ], | 170 ["BlackBerry \u2014 BB10", "Mozilla/5.0 (BB10; Touch) AppleWebKit/53 7.1+ (KHTML, like Gecko) Version/10.0.0.1337 Mobile Safari/537.1+", "768x1280x1x 0"], |
| 170 | 171 |
| 171 ["MeeGo \u2014 Nokia N9", "Mozilla/5.0 (MeeGo; NokiaN9) AppleWebKit/ 534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13", "480x854x1" ], | 172 ["MeeGo \u2014 Nokia N9", "Mozilla/5.0 (MeeGo; NokiaN9) AppleWebKit/ 534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13", "480x854x1x 0"], |
| 172 | 173 |
| 173 [WebInspector.UIString("Other..."), "Other"] | 174 [WebInspector.UIString("Other..."), "Other"] |
| 174 ]; | 175 ]; |
| 175 | 176 |
| 176 var fieldsetElement = WebInspector.SettingsTab.createSettingFieldset(Web Inspector.settings.overrideUserAgent); | 177 var fieldsetElement = WebInspector.SettingsTab.createSettingFieldset(Web Inspector.settings.overrideUserAgent); |
| 177 var p = fieldsetElement.createChild("p"); | 178 var p = fieldsetElement.createChild("p"); |
| 178 this._selectElement = p.createChild("select"); | 179 this._selectElement = p.createChild("select"); |
| 179 this._otherUserAgentElement = p.createChild("input"); | 180 this._otherUserAgentElement = p.createChild("input"); |
| 180 this._otherUserAgentElement.type = "text"; | 181 this._otherUserAgentElement.type = "text"; |
| 181 this._otherUserAgentElement.value = userAgent; | 182 this._otherUserAgentElement.value = userAgent; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 * @param {boolean} enabled | 306 * @param {boolean} enabled |
| 306 */ | 307 */ |
| 307 _onMetricsCheckboxClicked: function(enabled) | 308 _onMetricsCheckboxClicked: function(enabled) |
| 308 { | 309 { |
| 309 if (enabled && !this._widthOverrideElement.value) | 310 if (enabled && !this._widthOverrideElement.value) |
| 310 this._widthOverrideElement.focus(); | 311 this._widthOverrideElement.focus(); |
| 311 }, | 312 }, |
| 312 | 313 |
| 313 _applyDeviceMetricsUserInput: function() | 314 _applyDeviceMetricsUserInput: function() |
| 314 { | 315 { |
| 315 this._setDeviceMetricsOverride(WebInspector.OverridesSupport.DeviceMetri cs.parseUserInput(this._widthOverrideElement.value.trim(), this._heightOverrideE lement.value.trim(), this._deviceScaleFactorOverrideElement.value.trim()), true) ; | 316 this._setDeviceMetricsOverride(WebInspector.OverridesSupport.DeviceMetri cs.parseUserInput(this._widthOverrideElement.value.trim(), this._heightOverrideE lement.value.trim(), this._deviceScaleFactorOverrideElement.value.trim(), this._ textAutosizingOverrideCheckbox.checked), true); |
| 316 }, | 317 }, |
| 317 | 318 |
| 318 /** | 319 /** |
| 319 * @param {?WebInspector.OverridesSupport.DeviceMetrics} metrics | 320 * @param {?WebInspector.OverridesSupport.DeviceMetrics} metrics |
| 320 * @param {boolean} userInputModified | 321 * @param {boolean} userInputModified |
| 321 */ | 322 */ |
| 322 _setDeviceMetricsOverride: function(metrics, userInputModified) | 323 _setDeviceMetricsOverride: function(metrics, userInputModified) |
| 323 { | 324 { |
| 324 function setValid(condition, element) | 325 function setValid(condition, element) |
| 325 { | 326 { |
| 326 if (condition) | 327 if (condition) |
| 327 element.removeStyleClass("error-input"); | 328 element.removeStyleClass("error-input"); |
| 328 else | 329 else |
| 329 element.addStyleClass("error-input"); | 330 element.addStyleClass("error-input"); |
| 330 } | 331 } |
| 331 | 332 |
| 332 setValid(metrics && metrics.isWidthValid(), this._widthOverrideElement); | 333 setValid(metrics && metrics.isWidthValid(), this._widthOverrideElement); |
| 333 setValid(metrics && metrics.isHeightValid(), this._heightOverrideElement ); | 334 setValid(metrics && metrics.isHeightValid(), this._heightOverrideElement ); |
| 334 setValid(metrics && metrics.isDeviceScaleFactorValid(), this._deviceScal eFactorOverrideElement); | 335 setValid(metrics && metrics.isDeviceScaleFactorValid(), this._deviceScal eFactorOverrideElement); |
| 336 setValid(metrics && metrics.isTextAutosizingValid(), this._textAutosizin gOverrideCheckbox); | |
| 335 | 337 |
| 336 if (!metrics) | 338 if (!metrics) |
| 337 return; | 339 return; |
| 338 | 340 |
| 339 if (!userInputModified) { | 341 if (!userInputModified) { |
| 340 this._widthOverrideElement.value = metrics.widthToInput(); | 342 this._widthOverrideElement.value = metrics.widthToInput(); |
| 341 this._heightOverrideElement.value = metrics.heightToInput(); | 343 this._heightOverrideElement.value = metrics.heightToInput(); |
| 342 this._deviceScaleFactorOverrideElement.value = metrics.deviceScaleFa ctorToInput(); | 344 this._deviceScaleFactorOverrideElement.value = metrics.deviceScaleFa ctorToInput(); |
| 345 this._textAutosizingOverrideCheckbox.checked = metrics.textAutosizin g; | |
| 343 } | 346 } |
| 344 | 347 |
| 345 if (metrics.isValid()) { | 348 if (metrics.isValid()) { |
| 346 var value = metrics.toSetting(); | 349 var value = metrics.toSetting(); |
| 347 if (value !== WebInspector.settings.deviceMetrics.get()) | 350 if (value !== WebInspector.settings.deviceMetrics.get()) |
| 348 WebInspector.settings.deviceMetrics.set(value); | 351 WebInspector.settings.deviceMetrics.set(value); |
| 349 } | 352 } |
| 350 }, | 353 }, |
| 351 | 354 |
| 352 /** | 355 /** |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 384 | 387 |
| 385 rowElement = tableElement.createChild("tr"); | 388 rowElement = tableElement.createChild("tr"); |
| 386 cellElement = rowElement.createChild("td"); | 389 cellElement = rowElement.createChild("td"); |
| 387 cellElement.appendChild(document.createTextNode(WebInspector.UIString("D evice scale factor:"))); | 390 cellElement.appendChild(document.createTextNode(WebInspector.UIString("D evice scale factor:"))); |
| 388 cellElement = rowElement.createChild("td"); | 391 cellElement = rowElement.createChild("td"); |
| 389 this._deviceScaleFactorOverrideElement = this._createInput(cellElement, "metrics-override-device-scale", String(metrics.deviceScaleFactor || 1), this._a pplyDeviceMetricsUserInput.bind(this), true); | 392 this._deviceScaleFactorOverrideElement = this._createInput(cellElement, "metrics-override-device-scale", String(metrics.deviceScaleFactor || 1), this._a pplyDeviceMetricsUserInput.bind(this), true); |
| 390 | 393 |
| 391 rowElement = tableElement.createChild("tr"); | 394 rowElement = tableElement.createChild("tr"); |
| 392 cellElement = rowElement.createChild("td"); | 395 cellElement = rowElement.createChild("td"); |
| 393 cellElement.colSpan = 2; | 396 cellElement.colSpan = 2; |
| 397 var textAutosizingOverrideElement = this._createNonPersistedCheckbox(Web Inspector.UIString("Text autosizing enabled"), this._applyDeviceMetricsUserInput .bind(this)); | |
| 398 this._textAutosizingOverrideCheckbox = textAutosizingOverrideElement.get ElementsByTagName("input")[0]; | |
| 399 this._textAutosizingOverrideCheckbox.checked = metrics.textAutosizing; | |
| 400 cellElement.appendChild(textAutosizingOverrideElement); | |
| 401 | |
| 402 rowElement = tableElement.createChild("tr"); | |
| 403 cellElement = rowElement.createChild("td"); | |
| 404 cellElement.colSpan = 2; | |
| 394 var checkbox = WebInspector.SettingsTab.createSettingCheckbox(WebInspect or.UIString("Fit in window"), WebInspector.settings.deviceFitWindow, true); | 405 var checkbox = WebInspector.SettingsTab.createSettingCheckbox(WebInspect or.UIString("Fit in window"), WebInspector.settings.deviceFitWindow, true); |
| 395 cellElement.appendChild(checkbox); | 406 cellElement.appendChild(checkbox); |
| 396 | 407 |
| 397 return fieldsetElement; | 408 return fieldsetElement; |
| 398 }, | 409 }, |
| 399 | 410 |
| 400 /** | 411 /** |
| 401 * @return {Element} | 412 * @return {Element} |
| 402 */ | 413 */ |
| 403 _createGeolocationOverrideControl: function() | 414 _createGeolocationOverrideControl: function() |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 }, | 591 }, |
| 581 | 592 |
| 582 _emulateMediaChanged: function(select) | 593 _emulateMediaChanged: function(select) |
| 583 { | 594 { |
| 584 var media = select.options[select.selectedIndex].value; | 595 var media = select.options[select.selectedIndex].value; |
| 585 WebInspector.settings.emulatedCSSMedia.set(media); | 596 WebInspector.settings.emulatedCSSMedia.set(media); |
| 586 }, | 597 }, |
| 587 | 598 |
| 588 __proto__: WebInspector.View.prototype | 599 __proto__: WebInspector.View.prototype |
| 589 } | 600 } |
| OLD | NEW |