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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 _deviceMetricsChanged: function() | 456 _deviceMetricsChanged: function() |
457 { | 457 { |
458 if (this._deviceMetricsChangedListenerMuted) | 458 if (this._deviceMetricsChangedListenerMuted) |
459 return; | 459 return; |
460 var metrics = WebInspector.OverridesSupport.DeviceMetrics.parseSetting(W
ebInspector.settings.overrideDeviceMetrics.get() ? WebInspector.settings.deviceM
etrics.get() : ""); | 460 var metrics = WebInspector.OverridesSupport.DeviceMetrics.parseSetting(W
ebInspector.settings.overrideDeviceMetrics.get() ? WebInspector.settings.deviceM
etrics.get() : ""); |
461 if (!metrics.isValid()) | 461 if (!metrics.isValid()) |
462 return; | 462 return; |
463 | 463 |
464 var dipWidth = Math.round(metrics.width / metrics.deviceScaleFactor); | 464 var dipWidth = Math.round(metrics.width / metrics.deviceScaleFactor); |
465 var dipHeight = Math.round(metrics.height / metrics.deviceScaleFactor); | 465 var dipHeight = Math.round(metrics.height / metrics.deviceScaleFactor); |
| 466 var metricsOverrideEnabled = !!(dipWidth && dipHeight); |
466 | 467 |
467 // Disable override without checks. | 468 // Disable override without checks. |
468 if (dipWidth && dipHeight && WebInspector.OverridesSupport.isInspectingD
evice()) { | 469 if (metricsOverrideEnabled && WebInspector.OverridesSupport.isInspecting
Device()) { |
469 this._updateDeviceMetricsWarningMessage(WebInspector.UIString("Scree
n emulation on the device is not available.")); | 470 this._updateDeviceMetricsWarningMessage(WebInspector.UIString("Scree
n emulation on the device is not available.")); |
470 return; | 471 return; |
471 } | 472 } |
472 | 473 |
473 PageAgent.setDeviceMetricsOverride(dipWidth, dipHeight, metrics.deviceSc
aleFactor, WebInspector.settings.emulateViewport.get(), WebInspector.settings.de
viceFitWindow.get(), metrics.textAutosizing, metrics.fontScaleFactor(), apiCallb
ack.bind(this)); | 474 PageAgent.setDeviceMetricsOverride(dipWidth, dipHeight, metricsOverrideE
nabled ? metrics.deviceScaleFactor : 0, WebInspector.settings.emulateViewport.ge
t(), WebInspector.settings.deviceFitWindow.get(), metrics.textAutosizing, metric
s.fontScaleFactor(), apiCallback.bind(this)); |
474 this.maybeHasActiveOverridesChanged(); | 475 this.maybeHasActiveOverridesChanged(); |
475 | 476 |
476 /** | 477 /** |
477 * @param {?Protocol.Error} error | 478 * @param {?Protocol.Error} error |
478 * @this {WebInspector.OverridesSupport} | 479 * @this {WebInspector.OverridesSupport} |
479 */ | 480 */ |
480 function apiCallback(error) | 481 function apiCallback(error) |
481 { | 482 { |
482 if (error) { | 483 if (error) { |
483 this._updateDeviceMetricsWarningMessage(WebInspector.UIString("S
creen emulation is not available on this page.")); | 484 this._updateDeviceMetricsWarningMessage(WebInspector.UIString("S
creen emulation is not available on this page.")); |
484 return; | 485 return; |
485 } | 486 } |
486 | 487 |
487 var metricsOverrideEnabled = !!(dipWidth && dipHeight); | |
488 var viewportEnabled = WebInspector.settings.emulateViewport.get(); | 488 var viewportEnabled = WebInspector.settings.emulateViewport.get(); |
489 this._updateDeviceMetricsWarningMessage(this._deviceMetricsOverrideE
nabled !== metricsOverrideEnabled || (metricsOverrideEnabled && this._emulateVie
wportEnabled != viewportEnabled) ? | 489 this._updateDeviceMetricsWarningMessage(this._deviceMetricsOverrideE
nabled !== metricsOverrideEnabled || (metricsOverrideEnabled && this._emulateVie
wportEnabled != viewportEnabled) ? |
490 WebInspector.UIString("You might need to reload the page for pro
per user agent spoofing and viewport rendering.") : ""); | 490 WebInspector.UIString("You might need to reload the page for pro
per user agent spoofing and viewport rendering.") : ""); |
491 this._deviceMetricsOverrideEnabled = metricsOverrideEnabled; | 491 this._deviceMetricsOverrideEnabled = metricsOverrideEnabled; |
492 this._emulateViewportEnabled = viewportEnabled; | 492 this._emulateViewportEnabled = viewportEnabled; |
493 this._deviceMetricsOverrideAppliedForTest(); | 493 this._deviceMetricsOverrideAppliedForTest(); |
494 } | 494 } |
495 }, | 495 }, |
496 | 496 |
497 _deviceMetricsOverrideAppliedForTest: function() | 497 _deviceMetricsOverrideAppliedForTest: function() |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 }, | 595 }, |
596 | 596 |
597 __proto__: WebInspector.Object.prototype | 597 __proto__: WebInspector.Object.prototype |
598 } | 598 } |
599 | 599 |
600 | 600 |
601 /** | 601 /** |
602 * @type {!WebInspector.OverridesSupport} | 602 * @type {!WebInspector.OverridesSupport} |
603 */ | 603 */ |
604 WebInspector.overridesSupport; | 604 WebInspector.overridesSupport; |
OLD | NEW |