Commit 2d0305e8 authored by dgozman@chromium.org's avatar dgozman@chromium.org

[DevTools] Ability to emulate touch or user agent, even when device emulation is turned off.

BUG=327641
R=pfeldman@chromium.org

Review URL: https://codereview.chromium.org/342443002

git-svn-id: svn://svn.chromium.org/blink/trunk@176330 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent a5115349
......@@ -5,7 +5,7 @@
function onload()
{
testRunner.showWebInspector(JSON.stringify({lastActivePanel:"\"console\"", overrideUserAgent: "true", drawerEditorShown: "false"}));
testRunner.showWebInspector(JSON.stringify({lastActivePanel:"\"console\"", overrideUserAgent: "true", userAgent: "\"some user agent\"", drawerEditorShown: "false"}));
runTest();
}
......
......@@ -412,7 +412,8 @@ WebInspector.ResponsiveDesignView.prototype = {
// Touch and viewport.
this._touchSection = document.createElementWithClass("div", "responsive-design-section");
fieldsetElement = WebInspector.SettingsUI.createSettingFieldset(WebInspector.overridesSupport.settings.emulateDevice);
fieldsetElement.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Touch"), WebInspector.overridesSupport.settings.emulateTouchEvents, true));
if (!WebInspector.overridesSupport.hasTouchInputs())
fieldsetElement.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Touch"), WebInspector.overridesSupport.settings.deviceTouch, true));
var viewportCheckbox = WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Mobile"), WebInspector.overridesSupport.settings.emulateViewport, true);
viewportCheckbox.title = WebInspector.UIString("Enable meta viewport, overlay scrollbars and default 980px body width");
fieldsetElement.appendChild(viewportCheckbox);
......@@ -425,7 +426,7 @@ WebInspector.ResponsiveDesignView.prototype = {
this._networkSection.appendChild(WebInspector.overridesSupport.createNetworkThroughputSelect(document));
this._userAgentSection = document.createElementWithClass("div", "responsive-design-section responsive-design-user-agent-section");
this._userAgentSection.appendChild(WebInspector.SettingsUI.createSettingLabel(WebInspector.UIString("User Agent:"), WebInspector.overridesSupport.settings.userAgent, 25, "200px", WebInspector.overridesSupport.settings.overrideUserAgent, WebInspector.UIString("no override")));
this._userAgentSection.appendChild(WebInspector.SettingsUI.createSettingLabel(WebInspector.UIString("User Agent:"), WebInspector.overridesSupport.settings.deviceUserAgent, 25, "200px", WebInspector.UIString("no override")));
updateNetworkCheckboxTitle();
WebInspector.overridesSupport.settings.networkConditionsDomains.addChangeListener(updateNetworkCheckboxTitle);
......
......@@ -169,11 +169,10 @@ WebInspector.SettingsUI.createSettingInputField = function(label, setting, numer
* @param {!WebInspector.Setting} setting
* @param {number=} maxLength
* @param {string=} width
* @param {!WebInspector.Setting=} toggleSetting
* @param {string=} defaultText
* @return {!Element}
*/
WebInspector.SettingsUI.createSettingLabel = function(label, setting, maxLength, width, toggleSetting, defaultText)
WebInspector.SettingsUI.createSettingLabel = function(label, setting, maxLength, width, defaultText)
{
var p = document.createElement("p");
var labelElement = p.createChild("span");
......@@ -185,14 +184,12 @@ WebInspector.SettingsUI.createSettingLabel = function(label, setting, maxLength,
if (width)
p.style.width = width;
if (toggleSetting)
toggleSetting.addChangeListener(onSettingChange);
setting.addChangeListener(onSettingChange);
onSettingChange();
function onSettingChange()
{
var text = toggleSetting && !toggleSetting.get() ? (defaultText || "") : setting.get();
var text = setting.get() || defaultText;
spanElement.title = text;
if (maxLength && text.length > maxLength)
text = text.substring(0, maxLength - 2) + "...";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment