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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 /** | 260 /** |
| 261 * @param {string} value | 261 * @param {string} value |
| 262 */ | 262 */ |
| 263 WebInspector.OverridesSupport.inputValidator = function(value) | 263 WebInspector.OverridesSupport.inputValidator = function(value) |
| 264 { | 264 { |
| 265 if (value >= 0 && value <= 10000) | 265 if (value >= 0 && value <= 10000) |
| 266 return ""; | 266 return ""; |
| 267 return WebInspector.UIString("Value must be non-negative integer"); | 267 return WebInspector.UIString("Value must be non-negative integer"); |
| 268 } | 268 } |
| 269 | 269 |
| 270 /** | |
| 271 * @param {string} value | |
|
eustas
2014/06/05 15:06:51
please specify return type.
| |
| 272 */ | |
| 273 WebInspector.OverridesSupport.networkDomainsValidator = function(value) | |
| 274 { | |
| 275 function test(s) | |
| 276 { | |
| 277 return /^[\w\-]+(\.[\w\-]+)*$/.test(s.trim()); | |
| 278 } | |
| 279 | |
| 280 if (!value.trim()) | |
| 281 return ""; | |
| 282 return value.split(",").every(test) ? "" : WebInspector.UIString("Value must be a comma-separated list of domains"); | |
| 283 } | |
| 284 | |
| 270 // Third element lists device metrics separated by 'x': | 285 // Third element lists device metrics separated by 'x': |
| 271 // - screen width, | 286 // - screen width, |
| 272 // - screen height, | 287 // - screen height, |
| 273 // - device scale factor, | 288 // - device scale factor, |
| 274 WebInspector.OverridesSupport._phones = [ | 289 WebInspector.OverridesSupport._phones = [ |
| 275 ["Apple iPhone 3GS", | 290 ["Apple iPhone 3GS", |
| 276 "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", | 291 "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", |
| 277 "320x480x1"], | 292 "320x480x1"], |
| 278 ["Apple iPhone 4", | 293 ["Apple iPhone 4", |
| 279 "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", | 294 "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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 526 | 541 |
| 527 if (this.settings.overrideCSSMedia.get()) | 542 if (this.settings.overrideCSSMedia.get()) |
| 528 this._cssMediaChanged(); | 543 this._cssMediaChanged(); |
| 529 | 544 |
| 530 if (this.settings.overrideDeviceResolution.get() || this.settings.emulat eViewport.get()) | 545 if (this.settings.overrideDeviceResolution.get() || this.settings.emulat eViewport.get()) |
| 531 this._deviceMetricsChanged(); | 546 this._deviceMetricsChanged(); |
| 532 | 547 |
| 533 if (this.settings.overrideUserAgent.get()) | 548 if (this.settings.overrideUserAgent.get()) |
| 534 this._userAgentChanged(); | 549 this._userAgentChanged(); |
| 535 | 550 |
| 551 if (this.settings.emulateNetworkConditions.get()) | |
| 552 this._networkConditionsChanged(); | |
| 553 | |
| 536 this._showRulersChanged(); | 554 this._showRulersChanged(); |
| 537 }, | 555 }, |
| 538 | 556 |
| 539 _userAgentChanged: function() | 557 _userAgentChanged: function() |
| 540 { | 558 { |
| 541 if (this._userAgentChangedListenerMuted) | 559 if (this._userAgentChangedListenerMuted) |
| 542 return; | 560 return; |
| 543 var userAgent = this.settings.overrideUserAgent.get() ? this.settings.us erAgent.get() : ""; | 561 var userAgent = this.settings.overrideUserAgent.get() ? this.settings.us erAgent.get() : ""; |
| 544 NetworkAgent.setUserAgentOverride(userAgent); | 562 NetworkAgent.setUserAgentOverride(userAgent); |
| 545 if (this._userAgent !== userAgent) | 563 if (this._userAgent !== userAgent) |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 701 if (this.isInspectingDevice() && this.settings.overrideCSSMedia.get()) | 719 if (this.isInspectingDevice() && this.settings.overrideCSSMedia.get()) |
| 702 return; | 720 return; |
| 703 | 721 |
| 704 PageAgent.setEmulatedMedia(this.settings.overrideCSSMedia.get() ? this.s ettings.emulatedCSSMedia.get() : ""); | 722 PageAgent.setEmulatedMedia(this.settings.overrideCSSMedia.get() ? this.s ettings.emulatedCSSMedia.get() : ""); |
| 705 var targets = WebInspector.targetManager.targets(); | 723 var targets = WebInspector.targetManager.targets(); |
| 706 for (var i = 0; i < targets.length; ++i) | 724 for (var i = 0; i < targets.length; ++i) |
| 707 targets[i].cssModel.mediaQueryResultChanged(); | 725 targets[i].cssModel.mediaQueryResultChanged(); |
| 708 this.maybeHasActiveOverridesChanged(); | 726 this.maybeHasActiveOverridesChanged(); |
| 709 }, | 727 }, |
| 710 | 728 |
| 729 _networkConditionsChanged: function() | |
| 730 { | |
| 731 var domainsString = this.settings.networkDomains.get().trim(); | |
| 732 var domains = domainsString ? domainsString.split(",").map(function (s) { return s.trim(); }) : []; | |
| 733 NetworkAgent.emulateNetworkConditions(domains, 0, this.settings.emulateN etworkConditions.get()); | |
| 734 this.maybeHasActiveOverridesChanged(); | |
| 735 }, | |
| 736 | |
| 711 /** | 737 /** |
| 712 * @return {boolean} | 738 * @return {boolean} |
| 713 */ | 739 */ |
| 714 showMetricsRulers: function() | 740 showMetricsRulers: function() |
| 715 { | 741 { |
| 716 var rulersInPageResizer = this._pageResizer && this.settings.overrideDev iceResolution.get(); | 742 var rulersInPageResizer = this._pageResizer && this.settings.overrideDev iceResolution.get(); |
| 717 return WebInspector.settings.showMetricsRulers.get() && !rulersInPageRes izer; | 743 return WebInspector.settings.showMetricsRulers.get() && !rulersInPageRes izer; |
| 718 }, | 744 }, |
| 719 | 745 |
| 720 _showRulersChanged: function() | 746 _showRulersChanged: function() |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 804 this.settings.emulateViewport = WebInspector.settings.createSetting("emu lateViewport", false); | 830 this.settings.emulateViewport = WebInspector.settings.createSetting("emu lateViewport", false); |
| 805 this.settings.emulateTouchEvents = WebInspector.settings.createSetting(" emulateTouchEvents", false); | 831 this.settings.emulateTouchEvents = WebInspector.settings.createSetting(" emulateTouchEvents", false); |
| 806 this.settings.overrideGeolocation = WebInspector.settings.createSetting( "overrideGeolocation", false); | 832 this.settings.overrideGeolocation = WebInspector.settings.createSetting( "overrideGeolocation", false); |
| 807 this.settings.geolocationOverride = WebInspector.settings.createSetting( "geolocationOverride", ""); | 833 this.settings.geolocationOverride = WebInspector.settings.createSetting( "geolocationOverride", ""); |
| 808 this.settings.overrideDeviceOrientation = WebInspector.settings.createSe tting("overrideDeviceOrientation", false); | 834 this.settings.overrideDeviceOrientation = WebInspector.settings.createSe tting("overrideDeviceOrientation", false); |
| 809 this.settings.deviceOrientationOverride = WebInspector.settings.createSe tting("deviceOrientationOverride", ""); | 835 this.settings.deviceOrientationOverride = WebInspector.settings.createSe tting("deviceOrientationOverride", ""); |
| 810 this.settings.overrideCSSMedia = WebInspector.settings.createSetting("ov errideCSSMedia", false); | 836 this.settings.overrideCSSMedia = WebInspector.settings.createSetting("ov errideCSSMedia", false); |
| 811 this.settings.emulatedCSSMedia = WebInspector.settings.createSetting("em ulatedCSSMedia", "print"); | 837 this.settings.emulatedCSSMedia = WebInspector.settings.createSetting("em ulatedCSSMedia", "print"); |
| 812 this.settings.emulatedDevice = WebInspector.settings.createSetting("emul atedDevice", "Google Nexus 5"); | 838 this.settings.emulatedDevice = WebInspector.settings.createSetting("emul atedDevice", "Google Nexus 5"); |
| 813 | 839 |
| 840 this.settings.emulateNetworkConditions = WebInspector.settings.createSet ting("emulateNetworkConditions", false); | |
| 841 this.settings.networkDomains = WebInspector.settings.createSetting("netw orkDomains", ""); | |
| 842 | |
|
pfeldman
2014/06/05 15:13:43
networkOfflineDomains?
| |
| 814 this.maybeHasActiveOverridesChanged(); | 843 this.maybeHasActiveOverridesChanged(); |
| 815 | 844 |
| 816 this.settings.overrideUserAgent.addChangeListener(this._userAgentChanged , this); | 845 this.settings.overrideUserAgent.addChangeListener(this._userAgentChanged , this); |
| 817 this.settings.userAgent.addChangeListener(this._userAgentChanged, this); | 846 this.settings.userAgent.addChangeListener(this._userAgentChanged, this); |
| 818 | 847 |
| 819 this.settings.overrideDeviceResolution.addChangeListener(this._deviceMet ricsChanged, this); | 848 this.settings.overrideDeviceResolution.addChangeListener(this._deviceMet ricsChanged, this); |
| 820 this.settings.deviceWidth.addChangeListener(this._deviceMetricsChanged, this); | 849 this.settings.deviceWidth.addChangeListener(this._deviceMetricsChanged, this); |
| 821 this.settings.deviceHeight.addChangeListener(this._deviceMetricsChanged, this); | 850 this.settings.deviceHeight.addChangeListener(this._deviceMetricsChanged, this); |
| 822 this.settings.deviceScaleFactor.addChangeListener(this._deviceMetricsCha nged, this); | 851 this.settings.deviceScaleFactor.addChangeListener(this._deviceMetricsCha nged, this); |
| 823 this.settings.deviceTextAutosizing.addChangeListener(this._deviceMetrics Changed, this); | 852 this.settings.deviceTextAutosizing.addChangeListener(this._deviceMetrics Changed, this); |
| 824 this.settings.emulateViewport.addChangeListener(this._deviceMetricsChang ed, this); | 853 this.settings.emulateViewport.addChangeListener(this._deviceMetricsChang ed, this); |
| 825 this.settings.deviceFitWindow.addChangeListener(this._deviceMetricsChang ed, this); | 854 this.settings.deviceFitWindow.addChangeListener(this._deviceMetricsChang ed, this); |
| 826 | 855 |
| 827 this.settings.overrideGeolocation.addChangeListener(this._geolocationPos itionChanged, this); | 856 this.settings.overrideGeolocation.addChangeListener(this._geolocationPos itionChanged, this); |
| 828 this.settings.geolocationOverride.addChangeListener(this._geolocationPos itionChanged, this); | 857 this.settings.geolocationOverride.addChangeListener(this._geolocationPos itionChanged, this); |
| 829 | 858 |
| 830 this.settings.overrideDeviceOrientation.addChangeListener(this._deviceOr ientationChanged, this); | 859 this.settings.overrideDeviceOrientation.addChangeListener(this._deviceOr ientationChanged, this); |
| 831 this.settings.deviceOrientationOverride.addChangeListener(this._deviceOr ientationChanged, this); | 860 this.settings.deviceOrientationOverride.addChangeListener(this._deviceOr ientationChanged, this); |
| 832 | 861 |
| 833 this.settings.emulateTouchEvents.addChangeListener(this._emulateTouchEve ntsChanged, this); | 862 this.settings.emulateTouchEvents.addChangeListener(this._emulateTouchEve ntsChanged, this); |
| 834 | 863 |
| 835 this.settings.overrideCSSMedia.addChangeListener(this._cssMediaChanged, this); | 864 this.settings.overrideCSSMedia.addChangeListener(this._cssMediaChanged, this); |
| 836 this.settings.emulatedCSSMedia.addChangeListener(this._cssMediaChanged, this); | 865 this.settings.emulatedCSSMedia.addChangeListener(this._cssMediaChanged, this); |
| 837 | 866 |
| 867 this.settings.emulateNetworkConditions.addChangeListener(this._networkCo nditionsChanged, this); | |
| 868 this.settings.networkDomains.addChangeListener(this._networkConditionsCh anged, this); | |
| 869 | |
| 838 WebInspector.settings.showMetricsRulers.addChangeListener(this._showRule rsChanged, this); | 870 WebInspector.settings.showMetricsRulers.addChangeListener(this._showRule rsChanged, this); |
| 839 | 871 |
| 840 if (this._applyInitialOverridesOnTargetAdded) { | 872 if (this._applyInitialOverridesOnTargetAdded) { |
| 841 delete this._applyInitialOverridesOnTargetAdded; | 873 delete this._applyInitialOverridesOnTargetAdded; |
| 842 this.applyInitialOverrides(); | 874 this.applyInitialOverrides(); |
| 843 } | 875 } |
| 844 }, | 876 }, |
| 845 | 877 |
| 846 swapDimensions: function() | 878 swapDimensions: function() |
| 847 { | 879 { |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1060 }, | 1092 }, |
| 1061 | 1093 |
| 1062 __proto__: WebInspector.Object.prototype | 1094 __proto__: WebInspector.Object.prototype |
| 1063 } | 1095 } |
| 1064 | 1096 |
| 1065 | 1097 |
| 1066 /** | 1098 /** |
| 1067 * @type {!WebInspector.OverridesSupport} | 1099 * @type {!WebInspector.OverridesSupport} |
| 1068 */ | 1100 */ |
| 1069 WebInspector.overridesSupport; | 1101 WebInspector.overridesSupport; |
| OLD | NEW |