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 16 matching lines...) Expand all Loading... |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 /** | 31 /** |
32 * @constructor | 32 * @constructor |
33 */ | 33 */ |
34 WebInspector.OverridesSupport = function() | 34 WebInspector.OverridesSupport = function() |
35 { | 35 { |
36 this._overridesActive = WebInspector.settings.enableOverridesOnStartup.get()
; | 36 this._overridesActive = WebInspector.settings.enableOverridesOnStartup.get()
; |
| 37 this._deviceMetricsOverridesActive = false; |
37 this._updateAllOverrides(); | 38 this._updateAllOverrides(); |
38 | 39 |
39 WebInspector.settings.overrideUserAgent.addChangeListener(this._userAgentCha
nged, this); | 40 WebInspector.settings.overrideUserAgent.addChangeListener(this._userAgentCha
nged, this); |
40 WebInspector.settings.userAgent.addChangeListener(this._userAgentChanged, th
is); | 41 WebInspector.settings.userAgent.addChangeListener(this._userAgentChanged, th
is); |
41 | 42 |
42 WebInspector.settings.overrideDeviceMetrics.addChangeListener(this._deviceMe
tricsChanged, this); | 43 WebInspector.settings.overrideDeviceMetrics.addChangeListener(this._deviceMe
tricsChanged, this); |
43 WebInspector.settings.deviceMetrics.addChangeListener(this._deviceMetricsCha
nged, this); | 44 WebInspector.settings.deviceMetrics.addChangeListener(this._deviceMetricsCha
nged, this); |
44 WebInspector.settings.deviceFitWindow.addChangeListener(this._deviceMetricsC
hanged, this); | 45 WebInspector.settings.deviceFitWindow.addChangeListener(this._deviceMetricsC
hanged, this); |
45 | 46 |
46 WebInspector.settings.overrideGeolocation.addChangeListener(this._geolocatio
nPositionChanged, this); | 47 WebInspector.settings.overrideGeolocation.addChangeListener(this._geolocatio
nPositionChanged, this); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 }, | 340 }, |
340 | 341 |
341 _userAgentChanged: function() | 342 _userAgentChanged: function() |
342 { | 343 { |
343 NetworkAgent.setUserAgentOverride(this._overridesActive && WebInspector.
settings.overrideUserAgent.get() ? WebInspector.settings.userAgent.get() : ""); | 344 NetworkAgent.setUserAgentOverride(this._overridesActive && WebInspector.
settings.overrideUserAgent.get() ? WebInspector.settings.userAgent.get() : ""); |
344 }, | 345 }, |
345 | 346 |
346 _deviceMetricsChanged: function() | 347 _deviceMetricsChanged: function() |
347 { | 348 { |
348 var metrics = WebInspector.OverridesSupport.DeviceMetrics.parseSetting(t
his._overridesActive && WebInspector.settings.overrideDeviceMetrics.get() ? WebI
nspector.settings.deviceMetrics.get() : ""); | 349 var metrics = WebInspector.OverridesSupport.DeviceMetrics.parseSetting(t
his._overridesActive && WebInspector.settings.overrideDeviceMetrics.get() ? WebI
nspector.settings.deviceMetrics.get() : ""); |
349 if (metrics.isValid()) | 350 if (metrics.isValid()) { |
| 351 var active = metrics.width > 0 && metrics.height > 0; |
350 PageAgent.setDeviceMetricsOverride(metrics.width, metrics.height, me
trics.fontScaleFactor, WebInspector.settings.deviceFitWindow.get()); | 352 PageAgent.setDeviceMetricsOverride(metrics.width, metrics.height, me
trics.fontScaleFactor, WebInspector.settings.deviceFitWindow.get()); |
| 353 if (active != this._deviceMetricsOverridesActive) { |
| 354 PageAgent.reload(false); |
| 355 this._deviceMetricsOverridesActive = active; |
| 356 } |
| 357 } |
351 }, | 358 }, |
352 | 359 |
353 _geolocationPositionChanged: function() | 360 _geolocationPositionChanged: function() |
354 { | 361 { |
355 if (!this._overridesActive || !WebInspector.settings.overrideGeolocation
.get()) { | 362 if (!this._overridesActive || !WebInspector.settings.overrideGeolocation
.get()) { |
356 PageAgent.clearGeolocationOverride(); | 363 PageAgent.clearGeolocationOverride(); |
357 return; | 364 return; |
358 } | 365 } |
359 var geolocation = WebInspector.OverridesSupport.GeolocationPosition.pars
eSetting(WebInspector.settings.geolocationOverride.get()); | 366 var geolocation = WebInspector.OverridesSupport.GeolocationPosition.pars
eSetting(WebInspector.settings.geolocationOverride.get()); |
360 if (geolocation.error) | 367 if (geolocation.error) |
(...skipping 22 matching lines...) Expand all Loading... |
383 PageAgent.setEmulatedMedia(this._overridesActive && WebInspector.setting
s.overrideCSSMedia.get() ? WebInspector.settings.emulatedCSSMedia.get() : ""); | 390 PageAgent.setEmulatedMedia(this._overridesActive && WebInspector.setting
s.overrideCSSMedia.get() ? WebInspector.settings.emulatedCSSMedia.get() : ""); |
384 WebInspector.cssModel.mediaQueryResultChanged(); | 391 WebInspector.cssModel.mediaQueryResultChanged(); |
385 } | 392 } |
386 } | 393 } |
387 | 394 |
388 | 395 |
389 /** | 396 /** |
390 * @type {WebInspector.OverridesSupport} | 397 * @type {WebInspector.OverridesSupport} |
391 */ | 398 */ |
392 WebInspector.overridesSupport; | 399 WebInspector.overridesSupport; |
OLD | NEW |