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._notebooks = [ |
426 ["Chromebook Pixel", | 426 ["Notebook with touch", |
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 "", |
428 "1280x950x2x1x0"], | 428 "1280x950x1x1x0"], |
429 ["Apple MacBook Pro", | 429 ["Notebook with HiDPI screen", |
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 "", |
| 431 "1440x900x2x0x0"], |
| 432 ["Generic notebook", |
| 433 "", |
431 "1280x800x1x0x0"], | 434 "1280x800x1x0x0"], |
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", | |
434 "1440x900x2x0x0"], | |
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", | |
437 "1366x768x1x0x0"], | |
438 ]; | 435 ]; |
439 | 436 |
440 WebInspector.OverridesSupport._networkThroughputUnlimitedValue = -1; | 437 WebInspector.OverridesSupport._networkThroughputUnlimitedValue = -1; |
441 WebInspector.OverridesSupport._networkThroughputPresets = [ | 438 WebInspector.OverridesSupport._networkThroughputPresets = [ |
442 ["Offline", 0], | 439 ["Offline", 0], |
443 ["5 Kbps", 5 * 1024 / 8], | 440 ["5 Kbps", 5 * 1024 / 8], |
444 ["10 Kbps (GSM)", 10 * 1024 / 8], | 441 ["10 Kbps (GSM)", 10 * 1024 / 8], |
445 ["20 Kbps", 20 * 1024 / 8], | 442 ["20 Kbps", 20 * 1024 / 8], |
446 ["40 Kbps (GPRS)", 40 * 1024 / 8], | 443 ["40 Kbps (GPRS)", 40 * 1024 / 8], |
447 ["80 Kbps", 80 * 1024 / 8], | 444 ["80 Kbps", 80 * 1024 / 8], |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 }, | 848 }, |
852 | 849 |
853 /** | 850 /** |
854 * @return {string} | 851 * @return {string} |
855 */ | 852 */ |
856 warningMessage: function() | 853 warningMessage: function() |
857 { | 854 { |
858 return this._deviceMetricsWarningMessage || this._userAgentWarningMessag
e || ""; | 855 return this._deviceMetricsWarningMessage || this._userAgentWarningMessag
e || ""; |
859 }, | 856 }, |
860 | 857 |
| 858 clearWarningMessage: function() |
| 859 { |
| 860 this._deviceMetricsWarningMessage = ""; |
| 861 this._userAgentWarningMessage = ""; |
| 862 this.dispatchEventToListeners(WebInspector.OverridesSupport.Events.Overr
idesWarningUpdated); |
| 863 }, |
| 864 |
861 /** | 865 /** |
862 * @param {!WebInspector.Target} target | 866 * @param {!WebInspector.Target} target |
863 */ | 867 */ |
864 targetAdded: function(target) | 868 targetAdded: function(target) |
865 { | 869 { |
866 // FIXME: adapt this to multiple targets. | 870 // FIXME: adapt this to multiple targets. |
867 if (this._target) | 871 if (this._target) |
868 return; | 872 return; |
869 this._target = target; | 873 this._target = target; |
870 | 874 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 | 988 |
985 /** | 989 /** |
986 * @param {!Document} document | 990 * @param {!Document} document |
987 * @return {!Element} | 991 * @return {!Element} |
988 */ | 992 */ |
989 createDeviceSelect: function(document) | 993 createDeviceSelect: function(document) |
990 { | 994 { |
991 var deviceSelectElement = document.createElement("select"); | 995 var deviceSelectElement = document.createElement("select"); |
992 deviceSelectElement.disabled = WebInspector.overridesSupport.isInspectin
gDevice(); | 996 deviceSelectElement.disabled = WebInspector.overridesSupport.isInspectin
gDevice(); |
993 | 997 |
994 var devices = WebInspector.OverridesSupport._phones.concat(WebInspector.
OverridesSupport._tablets).concat(WebInspector.OverridesSupport._desktops); | 998 var selectDeviceOption = new Option(WebInspector.UIString("<Select model
>"), WebInspector.UIString("<Select model>")); |
995 devices.sort(); | 999 selectDeviceOption.device = new WebInspector.OverridesSupport.Device("",
""); |
| 1000 deviceSelectElement.add(selectDeviceOption); |
996 | 1001 |
997 var selectDevice = [WebInspector.UIString("<Select model>"), "", ""]; | 1002 addGroup(WebInspector.UIString("Devices"), WebInspector.OverridesSupport
._phones.concat(WebInspector.OverridesSupport._tablets)); |
998 devices = devices.concat([selectDevice]); | 1003 addGroup(WebInspector.UIString("Notebooks"), WebInspector.OverridesSuppo
rt._notebooks); |
999 for (var i = 0; i < devices.length; ++i) { | 1004 |
1000 var device = devices[i]; | 1005 /** |
1001 var option = new Option(device[0], device[0]); | 1006 * @param {string} name |
1002 option.device = new WebInspector.OverridesSupport.Device(device[2],
device[1]); | 1007 * @param {!Array.<!Array.<string>>} devices |
1003 deviceSelectElement.add(option); | 1008 */ |
| 1009 function addGroup(name, devices) |
| 1010 { |
| 1011 devices = devices.slice(); |
| 1012 devices.sort(); |
| 1013 var groupElement = deviceSelectElement.createChild("optgroup"); |
| 1014 groupElement.label = name; |
| 1015 for (var i = 0; i < devices.length; ++i) { |
| 1016 var device = devices[i]; |
| 1017 var option = new Option(device[0], device[0]); |
| 1018 option.device = new WebInspector.OverridesSupport.Device(device[
2], device[1]); |
| 1019 groupElement.appendChild(option); |
| 1020 } |
1004 } | 1021 } |
1005 | 1022 |
1006 deviceSelectElement.addEventListener("change", deviceSelected, false); | 1023 deviceSelectElement.addEventListener("change", deviceSelected, false); |
1007 | 1024 |
1008 var emulatedSettingChangedMuted = false; | 1025 var emulatedSettingChangedMuted = false; |
1009 WebInspector.overridesSupport.settings.deviceWidth.addChangeListener(emu
latedSettingChanged); | 1026 WebInspector.overridesSupport.settings.deviceWidth.addChangeListener(emu
latedSettingChanged); |
1010 WebInspector.overridesSupport.settings.deviceHeight.addChangeListener(em
ulatedSettingChanged); | 1027 WebInspector.overridesSupport.settings.deviceHeight.addChangeListener(em
ulatedSettingChanged); |
1011 WebInspector.overridesSupport.settings.deviceScaleFactor.addChangeListen
er(emulatedSettingChanged); | 1028 WebInspector.overridesSupport.settings.deviceScaleFactor.addChangeListen
er(emulatedSettingChanged); |
1012 WebInspector.overridesSupport.settings.deviceTextAutosizing.addChangeLis
tener(emulatedSettingChanged); | 1029 WebInspector.overridesSupport.settings.deviceTextAutosizing.addChangeLis
tener(emulatedSettingChanged); |
1013 WebInspector.overridesSupport.settings.emulateViewport.addChangeListener
(emulatedSettingChanged); | 1030 WebInspector.overridesSupport.settings.emulateViewport.addChangeListener
(emulatedSettingChanged); |
1014 WebInspector.overridesSupport.settings.emulateTouch.addChangeListener(em
ulatedSettingChanged); | 1031 WebInspector.overridesSupport.settings.emulateTouch.addChangeListener(em
ulatedSettingChanged); |
1015 WebInspector.overridesSupport.settings.userAgent.addChangeListener(emula
tedSettingChanged); | 1032 WebInspector.overridesSupport.settings.userAgent.addChangeListener(emula
tedSettingChanged); |
1016 emulatedSettingChanged(); | 1033 emulatedSettingChanged(); |
1017 | 1034 |
1018 function deviceSelected() | 1035 function deviceSelected() |
1019 { | 1036 { |
1020 if (deviceSelectElement.selectedIndex === devices.length - 1) | 1037 if (deviceSelectElement.selectedIndex === 0) |
1021 return; | 1038 return; |
1022 | 1039 |
1023 var option = deviceSelectElement.options[deviceSelectElement.selecte
dIndex]; | 1040 var option = deviceSelectElement.options[deviceSelectElement.selecte
dIndex]; |
1024 emulatedSettingChangedMuted = true; | 1041 emulatedSettingChangedMuted = true; |
1025 WebInspector.overridesSupport.emulateDevice(option.device); | 1042 WebInspector.overridesSupport.emulateDevice(option.device); |
1026 emulatedSettingChangedMuted = false; | 1043 emulatedSettingChangedMuted = false; |
1027 } | 1044 } |
1028 | 1045 |
1029 function emulatedSettingChanged() | 1046 function emulatedSettingChanged() |
1030 { | 1047 { |
1031 if (emulatedSettingChangedMuted) | 1048 if (emulatedSettingChangedMuted) |
1032 return; | 1049 return; |
1033 | 1050 |
1034 var index = devices.length - 1; | 1051 var index = 0; |
1035 for (var i = 0; i < devices.length; ++i) { | 1052 for (var i = 1; i < deviceSelectElement.options.length; ++i) { |
1036 var option = deviceSelectElement.options[i]; | 1053 var option = deviceSelectElement.options[i]; |
1037 if (WebInspector.overridesSupport.isEmulatingDevice(option.devic
e)) { | 1054 if (WebInspector.overridesSupport.isEmulatingDevice(option.devic
e)) { |
1038 index = i; | 1055 index = i; |
1039 break; | 1056 break; |
1040 } | 1057 } |
1041 } | 1058 } |
1042 deviceSelectElement.selectedIndex = index; | 1059 deviceSelectElement.selectedIndex = index; |
1043 } | 1060 } |
1044 | 1061 |
1045 return deviceSelectElement; | 1062 return deviceSelectElement; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1094 }, | 1111 }, |
1095 | 1112 |
1096 __proto__: WebInspector.Object.prototype | 1113 __proto__: WebInspector.Object.prototype |
1097 } | 1114 } |
1098 | 1115 |
1099 | 1116 |
1100 /** | 1117 /** |
1101 * @type {!WebInspector.OverridesSupport} | 1118 * @type {!WebInspector.OverridesSupport} |
1102 */ | 1119 */ |
1103 WebInspector.overridesSupport; | 1120 WebInspector.overridesSupport; |
OLD | NEW |