Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: Source/devtools/front_end/OverridesSupport.js

Issue 45363004: DevTools: explicitly control support for viewport meta tag so that desktop emulation was possible (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Review comments addressed. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 24 matching lines...) Expand all
35 WebInspector.OverridesSupport = function() 35 WebInspector.OverridesSupport = function()
36 { 36 {
37 this._canForceCompositingMode = null; 37 this._canForceCompositingMode = null;
38 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeMod el.EventTypes.MainFrameNavigated, this.updateCanForceCompositingMode.bind(this, null), this); 38 WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeMod el.EventTypes.MainFrameNavigated, this.updateCanForceCompositingMode.bind(this, null), this);
39 39
40 WebInspector.settings.overrideUserAgent.addChangeListener(this._userAgentCha nged, this); 40 WebInspector.settings.overrideUserAgent.addChangeListener(this._userAgentCha nged, this);
41 WebInspector.settings.userAgent.addChangeListener(this._userAgentChanged, th is); 41 WebInspector.settings.userAgent.addChangeListener(this._userAgentChanged, th is);
42 42
43 WebInspector.settings.overrideDeviceMetrics.addChangeListener(this._deviceMe tricsChanged, this); 43 WebInspector.settings.overrideDeviceMetrics.addChangeListener(this._deviceMe tricsChanged, this);
44 WebInspector.settings.deviceMetrics.addChangeListener(this._deviceMetricsCha nged, this); 44 WebInspector.settings.deviceMetrics.addChangeListener(this._deviceMetricsCha nged, this);
45 WebInspector.settings.emulateViewport.addChangeListener(this._deviceMetricsC hanged, this);
45 WebInspector.settings.deviceFitWindow.addChangeListener(this._deviceMetricsC hanged, this); 46 WebInspector.settings.deviceFitWindow.addChangeListener(this._deviceMetricsC hanged, this);
46 47
47 WebInspector.settings.overrideGeolocation.addChangeListener(this._geolocatio nPositionChanged, this); 48 WebInspector.settings.overrideGeolocation.addChangeListener(this._geolocatio nPositionChanged, this);
48 WebInspector.settings.geolocationOverride.addChangeListener(this._geolocatio nPositionChanged, this); 49 WebInspector.settings.geolocationOverride.addChangeListener(this._geolocatio nPositionChanged, this);
49 50
50 WebInspector.settings.overrideDeviceOrientation.addChangeListener(this._devi ceOrientationChanged, this); 51 WebInspector.settings.overrideDeviceOrientation.addChangeListener(this._devi ceOrientationChanged, this);
51 WebInspector.settings.deviceOrientationOverride.addChangeListener(this._devi ceOrientationChanged, this); 52 WebInspector.settings.deviceOrientationOverride.addChangeListener(this._devi ceOrientationChanged, this);
52 53
53 WebInspector.settings.emulateTouchEvents.addChangeListener(this._emulateTouc hEventsChanged, this); 54 WebInspector.settings.emulateTouchEvents.addChangeListener(this._emulateTouc hEventsChanged, this);
54 55
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 * @param {string} deviceMetrics 403 * @param {string} deviceMetrics
403 * @param {string} userAgent 404 * @param {string} userAgent
404 */ 405 */
405 emulateDevice: function(deviceMetrics, userAgent) 406 emulateDevice: function(deviceMetrics, userAgent)
406 { 407 {
407 WebInspector.settings.deviceMetrics.set(deviceMetrics); 408 WebInspector.settings.deviceMetrics.set(deviceMetrics);
408 WebInspector.settings.userAgent.set(userAgent); 409 WebInspector.settings.userAgent.set(userAgent);
409 WebInspector.settings.overrideDeviceMetrics.set(true); 410 WebInspector.settings.overrideDeviceMetrics.set(true);
410 WebInspector.settings.overrideUserAgent.set(true); 411 WebInspector.settings.overrideUserAgent.set(true);
411 WebInspector.settings.emulateTouchEvents.set(true); 412 WebInspector.settings.emulateTouchEvents.set(true);
413 WebInspector.settings.emulateViewport.set(true);
412 }, 414 },
413 415
414 reset: function() 416 reset: function()
415 { 417 {
416 WebInspector.settings.overrideDeviceMetrics.set(false); 418 WebInspector.settings.overrideDeviceMetrics.set(false);
417 WebInspector.settings.overrideUserAgent.set(false); 419 WebInspector.settings.overrideUserAgent.set(false);
418 WebInspector.settings.emulateTouchEvents.set(false); 420 WebInspector.settings.emulateTouchEvents.set(false);
419 WebInspector.settings.overrideDeviceOrientation.set(false); 421 WebInspector.settings.overrideDeviceOrientation.set(false);
420 WebInspector.settings.overrideGeolocation.set(false); 422 WebInspector.settings.overrideGeolocation.set(false);
421 WebInspector.settings.overrideCSSMedia.set(false); 423 WebInspector.settings.overrideCSSMedia.set(false);
424 WebInspector.settings.emulateViewport.set(false);
422 }, 425 },
423 426
424 applyInitialOverrides: function() 427 applyInitialOverrides: function()
425 { 428 {
426 if (this._anyOverrideIsEnabled()) 429 if (this._anyOverrideIsEnabled())
427 this.updateCanForceCompositingMode(this._updateAllOverrides.bind(thi s)); 430 this.updateCanForceCompositingMode(this._updateAllOverrides.bind(thi s));
428 else 431 else
429 this._updateAllOverrides(); 432 this._updateAllOverrides();
430 }, 433 },
431 434
(...skipping 13 matching lines...) Expand all
445 this.dispatchEventToListeners(WebInspector.OverridesSupport.Events.Overr idesEnabledButImpossibleChanged); 448 this.dispatchEventToListeners(WebInspector.OverridesSupport.Events.Overr idesEnabledButImpossibleChanged);
446 }, 449 },
447 450
448 _deviceMetricsChanged: function() 451 _deviceMetricsChanged: function()
449 { 452 {
450 var metrics = WebInspector.OverridesSupport.DeviceMetrics.parseSetting(W ebInspector.settings.overrideDeviceMetrics.get() && this._canForceCompositingMod e ? WebInspector.settings.deviceMetrics.get() : ""); 453 var metrics = WebInspector.OverridesSupport.DeviceMetrics.parseSetting(W ebInspector.settings.overrideDeviceMetrics.get() && this._canForceCompositingMod e ? WebInspector.settings.deviceMetrics.get() : "");
451 if (metrics.isValid()) { 454 if (metrics.isValid()) {
452 var active = metrics.width > 0 && metrics.height > 0; 455 var active = metrics.width > 0 && metrics.height > 0;
453 var dipWidth = Math.round(metrics.width / metrics.deviceScaleFactor) ; 456 var dipWidth = Math.round(metrics.width / metrics.deviceScaleFactor) ;
454 var dipHeight = Math.round(metrics.height / metrics.deviceScaleFacto r); 457 var dipHeight = Math.round(metrics.height / metrics.deviceScaleFacto r);
455 PageAgent.setDeviceMetricsOverride(dipWidth, dipHeight, metrics.devi ceScaleFactor, WebInspector.settings.deviceFitWindow.get(), metrics.textAutosizi ng, metrics.fontScaleFactor); 458 PageAgent.setDeviceMetricsOverride(dipWidth, dipHeight, metrics.devi ceScaleFactor, WebInspector.settings.emulateViewport.get(), WebInspector.setting s.deviceFitWindow.get(), metrics.textAutosizing, metrics.fontScaleFactor);
456 } 459 }
457 this._revealOverridesTabIfNeeded(); 460 this._revealOverridesTabIfNeeded();
458 this.dispatchEventToListeners(WebInspector.OverridesSupport.Events.Overr idesEnabledButImpossibleChanged); 461 this.dispatchEventToListeners(WebInspector.OverridesSupport.Events.Overr idesEnabledButImpossibleChanged);
459 }, 462 },
460 463
461 _geolocationPositionChanged: function() 464 _geolocationPositionChanged: function()
462 { 465 {
463 if (!WebInspector.settings.overrideGeolocation.get() || !this._canForceC ompositingMode) { 466 if (!WebInspector.settings.overrideGeolocation.get() || !this._canForceC ompositingMode) {
464 PageAgent.clearGeolocationOverride(); 467 PageAgent.clearGeolocationOverride();
465 return; 468 return;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 }, 540 },
538 541
539 __proto__: WebInspector.Object.prototype 542 __proto__: WebInspector.Object.prototype
540 } 543 }
541 544
542 545
543 /** 546 /**
544 * @type {WebInspector.OverridesSupport} 547 * @type {WebInspector.OverridesSupport}
545 */ 548 */
546 WebInspector.overridesSupport; 549 WebInspector.overridesSupport;
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorPageAgent.cpp ('k') | Source/devtools/front_end/OverridesView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698