| 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 33 * @implements {WebInspector.TargetManager.Observer} | 33 * @implements {WebInspector.TargetManager.Observer} |
| 34 * @extends {WebInspector.Object} | 34 * @extends {WebInspector.Object} |
| 35 * @param {boolean} responsiveDesignAvailable | 35 * @param {boolean} responsiveDesignAvailable |
| 36 */ | 36 */ |
| 37 WebInspector.OverridesSupport = function(responsiveDesignAvailable) | 37 WebInspector.OverridesSupport = function(responsiveDesignAvailable) |
| 38 { | 38 { |
| 39 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeMod
el.EventTypes.MainFrameNavigated, this._onMainFrameNavigated.bind(this), this); | |
| 40 this._touchEmulationSuspended = false; | 39 this._touchEmulationSuspended = false; |
| 41 this._emulateMobileEnabled = false; | 40 this._emulateMobileEnabled = false; |
| 42 this._userAgent = ""; | 41 this._userAgent = ""; |
| 43 this._pageResizer = null; | 42 this._pageResizer = null; |
| 44 this._deviceScale = 1; | 43 this._deviceScale = 1; |
| 45 this._fixedDeviceScale = false; | 44 this._fixedDeviceScale = false; |
| 46 this._initialized = false; | 45 this._initialized = false; |
| 47 this._deviceMetricsThrottler = new WebInspector.Throttler(0); | 46 this._deviceMetricsThrottler = new WebInspector.Throttler(0); |
| 48 this._responsiveDesignAvailable = responsiveDesignAvailable; | 47 this._responsiveDesignAvailable = responsiveDesignAvailable; |
| 48 |
| 49 this.settings = {}; |
| 50 this.settings._emulationEnabled = WebInspector.settings.createSetting("emula
tionEnabled", false); |
| 51 |
| 52 this.settings.userAgent = WebInspector.settings.createSetting("userAgent", "
"); |
| 53 |
| 54 this.settings.emulateResolution = WebInspector.settings.createSetting("emula
teResolution", true); |
| 55 this.settings.deviceWidth = WebInspector.settings.createSetting("deviceWidth
", 360); |
| 56 this.settings.deviceHeight = WebInspector.settings.createSetting("deviceHeig
ht", 640); |
| 57 this.settings.deviceScaleFactor = WebInspector.settings.createSetting("devic
eScaleFactor", 0); |
| 58 this.settings.deviceFitWindow = WebInspector.settings.createSetting("deviceF
itWindow", true); |
| 59 this.settings.emulateMobile = WebInspector.settings.createSetting("emulateMo
bile", false); |
| 60 this.settings.customDevicePresets = WebInspector.settings.createSetting("cus
tomDevicePresets", []); |
| 61 |
| 62 this.settings.emulateTouch = WebInspector.settings.createSetting("emulateTou
ch", false); |
| 63 |
| 64 this.settings.overrideGeolocation = WebInspector.settings.createSetting("ove
rrideGeolocation", false); |
| 65 this.settings.geolocationOverride = WebInspector.settings.createSetting("geo
locationOverride", ""); |
| 66 |
| 67 this.settings.overrideDeviceOrientation = WebInspector.settings.createSettin
g("overrideDeviceOrientation", false); |
| 68 this.settings.deviceOrientationOverride = WebInspector.settings.createSettin
g("deviceOrientationOverride", ""); |
| 69 |
| 70 this.settings.overrideCSSMedia = WebInspector.settings.createSetting("overri
deCSSMedia", false); |
| 71 this.settings.emulatedCSSMedia = WebInspector.settings.createSetting("emulat
edCSSMedia", "print"); |
| 72 |
| 73 this.settings.networkConditions = WebInspector.settings.createSetting("netwo
rkConditions", {throughput: WebInspector.OverridesSupport.NetworkThroughputUnlim
itedValue, latency: 0}); |
| 74 |
| 49 WebInspector.targetManager.observeTargets(this); | 75 WebInspector.targetManager.observeTargets(this); |
| 50 } | 76 } |
| 51 | 77 |
| 52 WebInspector.OverridesSupport.Events = { | 78 WebInspector.OverridesSupport.Events = { |
| 53 OverridesWarningUpdated: "OverridesWarningUpdated", | 79 OverridesWarningUpdated: "OverridesWarningUpdated", |
| 54 EmulationStateChanged: "EmulationStateChanged" | 80 EmulationStateChanged: "EmulationStateChanged" |
| 55 } | 81 } |
| 56 | 82 |
| 57 WebInspector.OverridesSupport.MaxDeviceSize = 3000; | 83 WebInspector.OverridesSupport.MaxDeviceSize = 3000; |
| 58 | 84 |
| (...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 | 769 |
| 744 /** | 770 /** |
| 745 * @param {!WebInspector.Target} target | 771 * @param {!WebInspector.Target} target |
| 746 */ | 772 */ |
| 747 targetAdded: function(target) | 773 targetAdded: function(target) |
| 748 { | 774 { |
| 749 // FIXME: adapt this to multiple targets. | 775 // FIXME: adapt this to multiple targets. |
| 750 if (this._target) | 776 if (this._target) |
| 751 return; | 777 return; |
| 752 this._target = target; | 778 this._target = target; |
| 753 | 779 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel
.EventTypes.MainFrameNavigated, this._onMainFrameNavigated, this); |
| 754 this.settings = {}; | |
| 755 this.settings._emulationEnabled = WebInspector.settings.createSetting("e
mulationEnabled", false); | |
| 756 | |
| 757 this.settings.userAgent = WebInspector.settings.createSetting("userAgent
", ""); | |
| 758 | |
| 759 this.settings.emulateResolution = WebInspector.settings.createSetting("e
mulateResolution", true); | |
| 760 this.settings.deviceWidth = WebInspector.settings.createSetting("deviceW
idth", 360); | |
| 761 this.settings.deviceHeight = WebInspector.settings.createSetting("device
Height", 640); | |
| 762 this.settings.deviceScaleFactor = WebInspector.settings.createSetting("d
eviceScaleFactor", 0); | |
| 763 this.settings.deviceFitWindow = WebInspector.settings.createSetting("dev
iceFitWindow", true); | |
| 764 this.settings.emulateMobile = WebInspector.settings.createSetting("emula
teMobile", false); | |
| 765 this.settings.customDevicePresets = WebInspector.settings.createSetting(
"customDevicePresets", []); | |
| 766 | |
| 767 this.settings.emulateTouch = WebInspector.settings.createSetting("emulat
eTouch", false); | |
| 768 | |
| 769 this.settings.overrideGeolocation = WebInspector.settings.createSetting(
"overrideGeolocation", false); | |
| 770 this.settings.geolocationOverride = WebInspector.settings.createSetting(
"geolocationOverride", ""); | |
| 771 | |
| 772 this.settings.overrideDeviceOrientation = WebInspector.settings.createSe
tting("overrideDeviceOrientation", false); | |
| 773 this.settings.deviceOrientationOverride = WebInspector.settings.createSe
tting("deviceOrientationOverride", ""); | |
| 774 | |
| 775 this.settings.overrideCSSMedia = WebInspector.settings.createSetting("ov
errideCSSMedia", false); | |
| 776 this.settings.emulatedCSSMedia = WebInspector.settings.createSetting("em
ulatedCSSMedia", "print"); | |
| 777 | |
| 778 this.settings.networkConditions = WebInspector.settings.createSetting("n
etworkConditions", {throughput: WebInspector.OverridesSupport.NetworkThroughputU
nlimitedValue, latency: 0}); | |
| 779 | 780 |
| 780 if (this._applyInitialOverridesOnTargetAdded) { | 781 if (this._applyInitialOverridesOnTargetAdded) { |
| 781 delete this._applyInitialOverridesOnTargetAdded; | 782 delete this._applyInitialOverridesOnTargetAdded; |
| 782 this.applyInitialOverrides(); | 783 this.applyInitialOverrides(); |
| 783 } | 784 } |
| 784 }, | 785 }, |
| 785 | 786 |
| 786 swapDimensions: function() | 787 swapDimensions: function() |
| 787 { | 788 { |
| 788 var width = WebInspector.overridesSupport.settings.deviceWidth.get(); | 789 var width = WebInspector.overridesSupport.settings.deviceWidth.get(); |
| 789 var height = WebInspector.overridesSupport.settings.deviceHeight.get(); | 790 var height = WebInspector.overridesSupport.settings.deviceHeight.get(); |
| 790 WebInspector.overridesSupport.settings.deviceWidth.set(height); | 791 WebInspector.overridesSupport.settings.deviceWidth.set(height); |
| 791 WebInspector.overridesSupport.settings.deviceHeight.set(width); | 792 WebInspector.overridesSupport.settings.deviceHeight.set(width); |
| 792 }, | 793 }, |
| 793 | 794 |
| 794 /** | 795 /** |
| 795 * @param {!WebInspector.Target} target | 796 * @param {!WebInspector.Target} target |
| 796 */ | 797 */ |
| 797 targetRemoved: function(target) | 798 targetRemoved: function(target) |
| 798 { | 799 { |
| 799 // FIXME: adapt this to multiple targets. | 800 // FIXME: adapt this to multiple targets. |
| 801 if (target === this._target) |
| 802 target.resourceTreeModel.removeEventListener(WebInspector.ResourceTr
eeModel.EventTypes.MainFrameNavigated, this._onMainFrameNavigated, this); |
| 800 }, | 803 }, |
| 801 | 804 |
| 802 /** | 805 /** |
| 803 * @return {boolean} | 806 * @return {boolean} |
| 804 */ | 807 */ |
| 805 hasTouchInputs: function() | 808 hasTouchInputs: function() |
| 806 { | 809 { |
| 807 return !!this._target && this._target.hasTouchInputs; | 810 return !!this._target && this._target.hasTouchInputs; |
| 808 }, | 811 }, |
| 809 | 812 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 822 }, | 825 }, |
| 823 | 826 |
| 824 __proto__: WebInspector.Object.prototype | 827 __proto__: WebInspector.Object.prototype |
| 825 } | 828 } |
| 826 | 829 |
| 827 | 830 |
| 828 /** | 831 /** |
| 829 * @type {!WebInspector.OverridesSupport} | 832 * @type {!WebInspector.OverridesSupport} |
| 830 */ | 833 */ |
| 831 WebInspector.overridesSupport; | 834 WebInspector.overridesSupport; |
| OLD | NEW |