Chromium Code Reviews| 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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 415 "Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/5 25.10 (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2", | 415 "Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/5 25.10 (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2", |
| 416 "1280x800x1"], | 416 "1280x800x1"], |
| 417 ["Samsung Galaxy Tab 7.7, 8.9, 10.1", | 417 ["Samsung Galaxy Tab 7.7, 8.9, 10.1", |
| 418 "Mozilla/5.0 (Linux; U; Android 2.2; en-us; SCH-I800 Build/FROYO) AppleWebK it/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1", | 418 "Mozilla/5.0 (Linux; U; Android 2.2; en-us; SCH-I800 Build/FROYO) AppleWebK it/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1", |
| 419 "1280x800x1"], | 419 "1280x800x1"], |
| 420 ["Samsung Galaxy Tab", | 420 ["Samsung Galaxy Tab", |
| 421 "Mozilla/5.0 (Linux; U; Android 2.2; en-us; SCH-I800 Build/FROYO) AppleWebK it/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1", | 421 "Mozilla/5.0 (Linux; U; Android 2.2; en-us; SCH-I800 Build/FROYO) AppleWebK it/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1", |
| 422 "1024x600x1"], | 422 "1024x600x1"], |
| 423 ]; | 423 ]; |
| 424 | 424 |
| 425 WebInspector.OverridesSupport._desktops = [ | 425 WebInspector.OverridesSupport._desktops = [ |
|
pfeldman
2014/06/18 16:15:41
_notebooks?
dgozman
2014/06/18 16:25:41
Done.
| |
| 426 ["Chromebook Pixel", | 426 ["Chromebook Pixel", |
|
pfeldman
2014/06/18 16:15:40
We should not list particular models here, I'd rat
| |
| 427 "Mozilla/5.0 (X11; CrOS x86_64 3912.23.0) AppleWebKit/537.36 (KHTML, like G ecko) Chrome/27.0.1453.46 Safari/537.36", | 427 "Mozilla/5.0 (X11; CrOS x86_64 3912.23.0) AppleWebKit/537.36 (KHTML, like G ecko) Chrome/27.0.1453.46 Safari/537.36", |
| 428 "1280x950x2x1x0"], | 428 "1280x950x2x1x0"], |
| 429 ["Apple MacBook Pro", | 429 ["Apple MacBook Pro", |
| 430 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.46 Safari/537.36", | 430 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.46 Safari/537.36", |
| 431 "1280x800x1x0x0"], | 431 "1280x800x1x0x0"], |
| 432 ["Apple MacBook Pro Retina", | 432 ["Apple MacBook Pro Retina", |
| 433 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.46 Safari/537.36", | 433 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.46 Safari/537.36", |
| 434 "1440x900x2x0x0"], | 434 "1440x900x2x0x0"], |
| 435 ["Apple MacBook Air", | 435 ["Apple MacBook Air", |
| 436 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.46 Safari/537.36", | 436 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.46 Safari/537.36", |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 851 }, | 851 }, |
| 852 | 852 |
| 853 /** | 853 /** |
| 854 * @return {string} | 854 * @return {string} |
| 855 */ | 855 */ |
| 856 warningMessage: function() | 856 warningMessage: function() |
| 857 { | 857 { |
| 858 return this._deviceMetricsWarningMessage || this._userAgentWarningMessag e || ""; | 858 return this._deviceMetricsWarningMessage || this._userAgentWarningMessag e || ""; |
| 859 }, | 859 }, |
| 860 | 860 |
| 861 clearWarningMessage: function() | |
| 862 { | |
| 863 this._deviceMetricsWarningMessage = ""; | |
| 864 this._userAgentWarningMessage = ""; | |
| 865 this.dispatchEventToListeners(WebInspector.OverridesSupport.Events.Overr idesWarningUpdated); | |
| 866 }, | |
| 867 | |
| 861 /** | 868 /** |
| 862 * @param {!WebInspector.Target} target | 869 * @param {!WebInspector.Target} target |
| 863 */ | 870 */ |
| 864 targetAdded: function(target) | 871 targetAdded: function(target) |
| 865 { | 872 { |
| 866 // FIXME: adapt this to multiple targets. | 873 // FIXME: adapt this to multiple targets. |
| 867 if (this._target) | 874 if (this._target) |
| 868 return; | 875 return; |
| 869 this._target = target; | 876 this._target = target; |
| 870 | 877 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 984 | 991 |
| 985 /** | 992 /** |
| 986 * @param {!Document} document | 993 * @param {!Document} document |
| 987 * @return {!Element} | 994 * @return {!Element} |
| 988 */ | 995 */ |
| 989 createDeviceSelect: function(document) | 996 createDeviceSelect: function(document) |
| 990 { | 997 { |
| 991 var deviceSelectElement = document.createElement("select"); | 998 var deviceSelectElement = document.createElement("select"); |
| 992 deviceSelectElement.disabled = WebInspector.overridesSupport.isInspectin gDevice(); | 999 deviceSelectElement.disabled = WebInspector.overridesSupport.isInspectin gDevice(); |
| 993 | 1000 |
| 994 var devices = WebInspector.OverridesSupport._phones.concat(WebInspector. OverridesSupport._tablets).concat(WebInspector.OverridesSupport._desktops); | 1001 var selectDeviceOption = new Option(WebInspector.UIString("<Select model >"), WebInspector.UIString("<Select model>")); |
| 995 devices.sort(); | 1002 selectDeviceOption.device = new WebInspector.OverridesSupport.Device("", ""); |
| 1003 deviceSelectElement.add(selectDeviceOption); | |
| 996 | 1004 |
| 997 var selectDevice = [WebInspector.UIString("<Select model>"), "", ""]; | 1005 addGroup(WebInspector.UIString("Phones"), WebInspector.OverridesSupport. _phones); |
|
pfeldman
2014/06/18 16:15:40
Responsive design assumes that we should not disti
dgozman
2014/06/18 16:25:41
Done.
| |
| 998 devices = devices.concat([selectDevice]); | 1006 addGroup(WebInspector.UIString("Tablets"), WebInspector.OverridesSupport ._tablets); |
| 999 for (var i = 0; i < devices.length; ++i) { | 1007 addGroup(WebInspector.UIString("Desktops"), WebInspector.OverridesSuppor t._desktops); |
| 1000 var device = devices[i]; | 1008 |
| 1001 var option = new Option(device[0], device[0]); | 1009 /** |
| 1002 option.device = new WebInspector.OverridesSupport.Device(device[2], device[1]); | 1010 * @param {string} name |
| 1003 deviceSelectElement.add(option); | 1011 * @param {!Array.<!Array.<string>>} devices |
| 1012 */ | |
| 1013 function addGroup(name, devices) | |
| 1014 { | |
| 1015 devices = devices.slice(); | |
| 1016 devices.sort(); | |
| 1017 var groupElement = deviceSelectElement.createChild("optgroup"); | |
| 1018 groupElement.label = name; | |
| 1019 for (var i = 0; i < devices.length; ++i) { | |
| 1020 var device = devices[i]; | |
| 1021 var option = new Option(device[0], device[0]); | |
| 1022 option.device = new WebInspector.OverridesSupport.Device(device[ 2], device[1]); | |
| 1023 groupElement.appendChild(option); | |
| 1024 } | |
| 1004 } | 1025 } |
| 1005 | 1026 |
| 1006 deviceSelectElement.addEventListener("change", deviceSelected, false); | 1027 deviceSelectElement.addEventListener("change", deviceSelected, false); |
| 1007 | 1028 |
| 1008 var emulatedSettingChangedMuted = false; | 1029 var emulatedSettingChangedMuted = false; |
| 1009 WebInspector.overridesSupport.settings.deviceWidth.addChangeListener(emu latedSettingChanged); | 1030 WebInspector.overridesSupport.settings.deviceWidth.addChangeListener(emu latedSettingChanged); |
| 1010 WebInspector.overridesSupport.settings.deviceHeight.addChangeListener(em ulatedSettingChanged); | 1031 WebInspector.overridesSupport.settings.deviceHeight.addChangeListener(em ulatedSettingChanged); |
| 1011 WebInspector.overridesSupport.settings.deviceScaleFactor.addChangeListen er(emulatedSettingChanged); | 1032 WebInspector.overridesSupport.settings.deviceScaleFactor.addChangeListen er(emulatedSettingChanged); |
| 1012 WebInspector.overridesSupport.settings.deviceTextAutosizing.addChangeLis tener(emulatedSettingChanged); | 1033 WebInspector.overridesSupport.settings.deviceTextAutosizing.addChangeLis tener(emulatedSettingChanged); |
| 1013 WebInspector.overridesSupport.settings.emulateViewport.addChangeListener (emulatedSettingChanged); | 1034 WebInspector.overridesSupport.settings.emulateViewport.addChangeListener (emulatedSettingChanged); |
| 1014 WebInspector.overridesSupport.settings.emulateTouch.addChangeListener(em ulatedSettingChanged); | 1035 WebInspector.overridesSupport.settings.emulateTouch.addChangeListener(em ulatedSettingChanged); |
| 1015 WebInspector.overridesSupport.settings.userAgent.addChangeListener(emula tedSettingChanged); | 1036 WebInspector.overridesSupport.settings.userAgent.addChangeListener(emula tedSettingChanged); |
| 1016 emulatedSettingChanged(); | 1037 emulatedSettingChanged(); |
| 1017 | 1038 |
| 1018 function deviceSelected() | 1039 function deviceSelected() |
| 1019 { | 1040 { |
| 1020 if (deviceSelectElement.selectedIndex === devices.length - 1) | 1041 if (deviceSelectElement.selectedIndex === 0) |
| 1021 return; | 1042 return; |
| 1022 | 1043 |
| 1023 var option = deviceSelectElement.options[deviceSelectElement.selecte dIndex]; | 1044 var option = deviceSelectElement.options[deviceSelectElement.selecte dIndex]; |
| 1024 emulatedSettingChangedMuted = true; | 1045 emulatedSettingChangedMuted = true; |
| 1025 WebInspector.overridesSupport.emulateDevice(option.device); | 1046 WebInspector.overridesSupport.emulateDevice(option.device); |
| 1026 emulatedSettingChangedMuted = false; | 1047 emulatedSettingChangedMuted = false; |
| 1027 } | 1048 } |
| 1028 | 1049 |
| 1029 function emulatedSettingChanged() | 1050 function emulatedSettingChanged() |
| 1030 { | 1051 { |
| 1031 if (emulatedSettingChangedMuted) | 1052 if (emulatedSettingChangedMuted) |
| 1032 return; | 1053 return; |
| 1033 | 1054 |
| 1034 var index = devices.length - 1; | 1055 var index = 0; |
| 1035 for (var i = 0; i < devices.length; ++i) { | 1056 for (var i = 1; i < deviceSelectElement.options.length; ++i) { |
| 1036 var option = deviceSelectElement.options[i]; | 1057 var option = deviceSelectElement.options[i]; |
| 1037 if (WebInspector.overridesSupport.isEmulatingDevice(option.devic e)) { | 1058 if (WebInspector.overridesSupport.isEmulatingDevice(option.devic e)) { |
| 1038 index = i; | 1059 index = i; |
| 1039 break; | 1060 break; |
| 1040 } | 1061 } |
| 1041 } | 1062 } |
| 1042 deviceSelectElement.selectedIndex = index; | 1063 deviceSelectElement.selectedIndex = index; |
| 1043 } | 1064 } |
| 1044 | 1065 |
| 1045 return deviceSelectElement; | 1066 return deviceSelectElement; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1094 }, | 1115 }, |
| 1095 | 1116 |
| 1096 __proto__: WebInspector.Object.prototype | 1117 __proto__: WebInspector.Object.prototype |
| 1097 } | 1118 } |
| 1098 | 1119 |
| 1099 | 1120 |
| 1100 /** | 1121 /** |
| 1101 * @type {!WebInspector.OverridesSupport} | 1122 * @type {!WebInspector.OverridesSupport} |
| 1102 */ | 1123 */ |
| 1103 WebInspector.overridesSupport; | 1124 WebInspector.overridesSupport; |
| OLD | NEW |