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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 * @param {string} value | 263 * @param {string} value |
264 * @return {string} | 264 * @return {string} |
265 */ | 265 */ |
266 WebInspector.OverridesSupport.deviceScaleFactorValidator = function(value) | 266 WebInspector.OverridesSupport.deviceScaleFactorValidator = function(value) |
267 { | 267 { |
268 if (!value || (/^[\d]+(\.\d+)?|\.\d+$/.test(value) && value >= 0 && value <=
10)) | 268 if (!value || (/^[\d]+(\.\d+)?|\.\d+$/.test(value) && value >= 0 && value <=
10)) |
269 return ""; | 269 return ""; |
270 return WebInspector.UIString("Value must be non-negative float"); | 270 return WebInspector.UIString("Value must be non-negative float"); |
271 } | 271 } |
272 | 272 |
273 /** | |
274 * @param {string} value | |
275 * @return {string} | |
276 */ | |
277 WebInspector.OverridesSupport.networkDomainsValidator = function(value) | |
278 { | |
279 function test(s) | |
280 { | |
281 return /^[\w\-]+(\.[\w\-]+)*$/.test(s.trim()); | |
282 } | |
283 | |
284 if (!value.trim()) | |
285 return ""; | |
286 return value.split(",").every(test) ? "" : WebInspector.UIString("Value must
be a comma-separated list of domains"); | |
287 } | |
288 | |
289 // Second element is user agent value. | 273 // Second element is user agent value. |
290 // Third element lists device metrics separated by 'x': | 274 // Third element lists device metrics separated by 'x': |
291 // - screen width, | 275 // - screen width, |
292 // - screen height, | 276 // - screen height, |
293 // - device scale factor, | 277 // - device scale factor, |
294 // - touch (true by default if not present), | 278 // - touch (true by default if not present), |
295 // - viewport (true by default if not present). | 279 // - viewport (true by default if not present). |
296 WebInspector.OverridesSupport._phones = [ | 280 WebInspector.OverridesSupport._phones = [ |
297 ["Apple iPhone 3GS", | 281 ["Apple iPhone 3GS", |
298 "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) AppleWeb
Kit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5", | 282 "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) AppleWeb
Kit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5", |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 | 556 |
573 this.settings.emulationEnabled.addChangeListener(this._emulateTouchEvent
sChanged, this); | 557 this.settings.emulationEnabled.addChangeListener(this._emulateTouchEvent
sChanged, this); |
574 this.settings.emulateTouch.addChangeListener(this._emulateTouchEventsCha
nged, this); | 558 this.settings.emulateTouch.addChangeListener(this._emulateTouchEventsCha
nged, this); |
575 | 559 |
576 this.settings.emulationEnabled.addChangeListener(this._cssMediaChanged,
this); | 560 this.settings.emulationEnabled.addChangeListener(this._cssMediaChanged,
this); |
577 this.settings.overrideCSSMedia.addChangeListener(this._cssMediaChanged,
this); | 561 this.settings.overrideCSSMedia.addChangeListener(this._cssMediaChanged,
this); |
578 this.settings.emulatedCSSMedia.addChangeListener(this._cssMediaChanged,
this); | 562 this.settings.emulatedCSSMedia.addChangeListener(this._cssMediaChanged,
this); |
579 | 563 |
580 if (WebInspector.experimentsSettings.networkConditions.isEnabled()) { | 564 if (WebInspector.experimentsSettings.networkConditions.isEnabled()) { |
581 this.settings.emulationEnabled.addChangeListener(this._networkCondit
ionsChanged, this); | 565 this.settings.emulationEnabled.addChangeListener(this._networkCondit
ionsChanged, this); |
582 this.settings.networkConditionsDomains.addChangeListener(this._netwo
rkConditionsChanged, this); | |
583 this.settings.networkConditionsThroughput.addChangeListener(this._ne
tworkConditionsChanged, this); | 566 this.settings.networkConditionsThroughput.addChangeListener(this._ne
tworkConditionsChanged, this); |
584 } | 567 } |
585 | 568 |
586 WebInspector.settings.showMetricsRulers.addChangeListener(this._showRule
rsChanged, this); | 569 WebInspector.settings.showMetricsRulers.addChangeListener(this._showRule
rsChanged, this); |
587 this._showRulersChanged(); | 570 this._showRulersChanged(); |
588 | 571 |
589 if (!this.settings.emulationEnabled.get()) | 572 if (!this.settings.emulationEnabled.get()) |
590 return; | 573 return; |
591 | 574 |
592 if (this.settings.overrideDeviceOrientation.get()) | 575 if (this.settings.overrideDeviceOrientation.get()) |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 PageAgent.setEmulatedMedia(enabled ? this.settings.emulatedCSSMedia.get(
) : ""); | 753 PageAgent.setEmulatedMedia(enabled ? this.settings.emulatedCSSMedia.get(
) : ""); |
771 var targets = WebInspector.targetManager.targets(); | 754 var targets = WebInspector.targetManager.targets(); |
772 for (var i = 0; i < targets.length; ++i) | 755 for (var i = 0; i < targets.length; ++i) |
773 targets[i].cssModel.mediaQueryResultChanged(); | 756 targets[i].cssModel.mediaQueryResultChanged(); |
774 this.maybeHasActiveOverridesChanged(); | 757 this.maybeHasActiveOverridesChanged(); |
775 }, | 758 }, |
776 | 759 |
777 _networkConditionsChanged: function() | 760 _networkConditionsChanged: function() |
778 { | 761 { |
779 if (!this.settings.emulationEnabled.get() || !this.networkThroughputIsLi
mited()) { | 762 if (!this.settings.emulationEnabled.get() || !this.networkThroughputIsLi
mited()) { |
780 NetworkAgent.emulateNetworkConditions([], 0, false, 0, 0, 0); | 763 NetworkAgent.emulateNetworkConditions(false, 0, 0, 0); |
781 } else { | 764 } else { |
782 var domainsString = this.settings.networkConditionsDomains.get().tri
m(); | |
783 var domains = domainsString ? domainsString.split(",").map(function
(s) { return s.trim(); }) : []; | |
784 var throughput = this.settings.networkConditionsThroughput.get(); | 765 var throughput = this.settings.networkConditionsThroughput.get(); |
785 var offline = !throughput; | 766 var offline = !throughput; |
786 NetworkAgent.emulateNetworkConditions(domains, throughput, offline,
0, throughput, throughput); | 767 NetworkAgent.emulateNetworkConditions(offline, 0, throughput, throug
hput); |
787 } | 768 } |
788 this.maybeHasActiveOverridesChanged(); | 769 this.maybeHasActiveOverridesChanged(); |
789 }, | 770 }, |
790 | 771 |
791 /** | 772 /** |
792 * @return {boolean} | 773 * @return {boolean} |
793 */ | 774 */ |
794 showMetricsRulers: function() | 775 showMetricsRulers: function() |
795 { | 776 { |
796 var rulersInPageResizer = this._pageResizer && this.settings.emulationEn
abled.get(); | 777 var rulersInPageResizer = this._pageResizer && this.settings.emulationEn
abled.get(); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 | 870 |
890 this.settings.overrideGeolocation = WebInspector.settings.createSetting(
"overrideGeolocation", false); | 871 this.settings.overrideGeolocation = WebInspector.settings.createSetting(
"overrideGeolocation", false); |
891 this.settings.geolocationOverride = WebInspector.settings.createSetting(
"geolocationOverride", ""); | 872 this.settings.geolocationOverride = WebInspector.settings.createSetting(
"geolocationOverride", ""); |
892 | 873 |
893 this.settings.overrideDeviceOrientation = WebInspector.settings.createSe
tting("overrideDeviceOrientation", false); | 874 this.settings.overrideDeviceOrientation = WebInspector.settings.createSe
tting("overrideDeviceOrientation", false); |
894 this.settings.deviceOrientationOverride = WebInspector.settings.createSe
tting("deviceOrientationOverride", ""); | 875 this.settings.deviceOrientationOverride = WebInspector.settings.createSe
tting("deviceOrientationOverride", ""); |
895 | 876 |
896 this.settings.overrideCSSMedia = WebInspector.settings.createSetting("ov
errideCSSMedia", false); | 877 this.settings.overrideCSSMedia = WebInspector.settings.createSetting("ov
errideCSSMedia", false); |
897 this.settings.emulatedCSSMedia = WebInspector.settings.createSetting("em
ulatedCSSMedia", "print"); | 878 this.settings.emulatedCSSMedia = WebInspector.settings.createSetting("em
ulatedCSSMedia", "print"); |
898 | 879 |
899 this.settings.networkConditionsDomains = WebInspector.settings.createSet
ting("networkConditionsDomains", ""); | |
900 this.settings.networkConditionsThroughput = WebInspector.settings.create
Setting("networkConditionsThroughput", WebInspector.OverridesSupport._networkThr
oughputUnlimitedValue); | 880 this.settings.networkConditionsThroughput = WebInspector.settings.create
Setting("networkConditionsThroughput", WebInspector.OverridesSupport._networkThr
oughputUnlimitedValue); |
901 | 881 |
902 this.maybeHasActiveOverridesChanged(); | 882 this.maybeHasActiveOverridesChanged(); |
903 | 883 |
904 if (this._applyInitialOverridesOnTargetAdded) { | 884 if (this._applyInitialOverridesOnTargetAdded) { |
905 delete this._applyInitialOverridesOnTargetAdded; | 885 delete this._applyInitialOverridesOnTargetAdded; |
906 this.applyInitialOverrides(); | 886 this.applyInitialOverrides(); |
907 } | 887 } |
908 }, | 888 }, |
909 | 889 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 }, | 1091 }, |
1112 | 1092 |
1113 __proto__: WebInspector.Object.prototype | 1093 __proto__: WebInspector.Object.prototype |
1114 } | 1094 } |
1115 | 1095 |
1116 | 1096 |
1117 /** | 1097 /** |
1118 * @type {!WebInspector.OverridesSupport} | 1098 * @type {!WebInspector.OverridesSupport} |
1119 */ | 1099 */ |
1120 WebInspector.overridesSupport; | 1100 WebInspector.overridesSupport; |
OLD | NEW |