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

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

Issue 317153002: [DevTools] Move user agent override to responsive design toolbar. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Optimized pngs Created 6 years, 6 months 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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 "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", 393 "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",
394 "1280x800x1"], 394 "1280x800x1"],
395 ["Samsung Galaxy Tab 7.7, 8.9, 10.1", 395 ["Samsung Galaxy Tab 7.7, 8.9, 10.1",
396 "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", 396 "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",
397 "1280x800x1"], 397 "1280x800x1"],
398 ["Samsung Galaxy Tab", 398 ["Samsung Galaxy Tab",
399 "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", 399 "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",
400 "1024x600x1"], 400 "1024x600x1"],
401 ]; 401 ];
402 402
403 WebInspector.OverridesSupport._userAgents = [
404 ["Android 4.0.2 \u2014 Galaxy Nexus", "Mozilla/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F) AppleWebKit/534.30 (KHTML, like Gecko) Versio n/4.0 Mobile Safari/534.30"],
405 ["Android 2.3 \u2014 Nexus S", "Mozilla/5.0 (Linux; U; Android 2.3.6; en-us; Nexus S Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"],
406 ["BlackBerry \u2014 BB10", "Mozilla/5.0 (BB10; Touch) AppleWebKit/537.1+ (KH TML, like Gecko) Version/10.0.0.1337 Mobile Safari/537.1+"],
407 ["BlackBerry \u2014 PlayBook 2.1", "Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML, like Gecko) Version/7.2.1.0 Safari/536. 2+"],
408 ["BlackBerry \u2014 9900", "Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en- US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.187 Mobile Safari/534. 11+"],
409 ["Chrome 31 \u2014 Mac", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) App leWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"],
410 ["Chrome 31 \u2014 Windows", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.3 6 (KHTML, like Gecko) Chrome/31.0.1650.16 Safari/537.36"],
411 ["Chrome \u2014 Android Tablet", "Mozilla/5.0 (Linux; Android 4.1.2; Nexus 7 Build/JZ054K) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safar i/535.19"],
412 ["Chrome \u2014 Android Mobile", "Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19"],
413 ["Firefox 14 \u2014 Android Mobile", "Mozilla/5.0 (Android; Mobile; rv:14.0) Gecko/14.0 Firefox/14.0"],
414 ["Firefox 14 \u2014 Android Tablet", "Mozilla/5.0 (Android; Tablet; rv:14.0) Gecko/14.0 Firefox/14.0"],
415 ["Firefox 4 \u2014 Mac", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2. 0.1) Gecko/20100101 Firefox/4.0.1"],
416 ["Firefox 4 \u2014 Windows", "Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/2 0100101 Firefox/4.0.1"],
417 ["Firefox 7 \u2014 Mac", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7. 0.1) Gecko/20100101 Firefox/7.0.1"],
418 ["Firefox 7 \u2014 Windows", "Mozilla/5.0 (Windows NT 6.1; Intel Mac OS X 10 .6; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"],
419 ["Internet Explorer 10", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2 ; Trident/6.0)"],
420 ["Internet Explorer 7", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)" ],
421 ["Internet Explorer 8", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)"],
422 ["Internet Explorer 9", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"],
423 ["iPad \u2014 iOS 7", "Mozilla/5.0 (iPad; CPU OS 7_0_2 like Mac OS X) AppleW ebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A501 Safari/9537.53"],
424 ["iPad \u2014 iOS 6", "Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWeb Kit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"],
425 ["iPhone \u2014 iOS 7", "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_2 like Mac O S X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A4449d Safari /9537.53"],
426 ["iPhone \u2014 iOS 6", "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/853 6.25"],
427 ["MeeGo \u2014 Nokia N9", "Mozilla/5.0 (MeeGo; NokiaN9) AppleWebKit/534.13 ( KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13"],
428 ["Opera 18 \u2014 Mac", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) Appl eWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 OPR/18.0.12 84.68"],
429 ["Opera 18 \u2014 Windows", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 OPR/18.0.1284.68"],
430 ["Opera 12 \u2014 Mac", "Opera/9.80 (Macintosh; Intel Mac OS X 10.9.1) Prest o/2.12.388 Version/12.16"],
431 ["Opera 12 \u2014 Windows", "Opera/9.80 (Windows NT 6.1) Presto/2.12.388 Ver sion/12.16"],
432 ["Silk \u2014 Kindle Fire (Desktop view)", "Mozilla/5.0 (Linux; U; en-us; KF THWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true"],
433 ["Silk \u2014 Kindle Fire (Mobile view)", "Mozilla/5.0 (Linux; U; Android 4. 2.2; en-us; KFTHWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Mobile Safari/535.19 Silk-Accelerated=true"],
434 ];
435
403 WebInspector.OverridesSupport.prototype = { 436 WebInspector.OverridesSupport.prototype = {
404 /** 437 /**
405 * @return {boolean} 438 * @return {boolean}
406 */ 439 */
407 responsiveDesignAvailable: function() 440 responsiveDesignAvailable: function()
408 { 441 {
409 return this._responsiveDesignAvailable; 442 return this._responsiveDesignAvailable;
410 }, 443 },
411 444
412 /** 445 /**
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 if (size.height !== this.settings.deviceHeight.get()) 561 if (size.height !== this.settings.deviceHeight.get())
529 this.settings.deviceHeight.set(size.height); 562 this.settings.deviceHeight.set(size.height);
530 }, 563 },
531 564
532 _deviceMetricsChanged: function() 565 _deviceMetricsChanged: function()
533 { 566 {
534 this._showRulersChanged(); 567 this._showRulersChanged();
535 568
536 if (this._deviceMetricsChangedListenerMuted) 569 if (this._deviceMetricsChangedListenerMuted)
537 return; 570 return;
538 var responsiveDesignAvailableAndDisabled = this._responsiveDesignAvailab le && !WebInspector.settings.responsiveDesignMode.get(); 571 var responsiveDesignAvailableAndDisabled = this._responsiveDesignAvailab le && !WebInspector.settings.responsiveDesign.enabled.get();
539 var overrideDeviceResolution = this.settings.overrideDeviceResolution.ge t(); 572 var overrideDeviceResolution = this.settings.overrideDeviceResolution.ge t();
540 if (responsiveDesignAvailableAndDisabled || (!overrideDeviceResolution & & !this.settings.emulateViewport.get())) { 573 if (responsiveDesignAvailableAndDisabled || (!overrideDeviceResolution & & !this.settings.emulateViewport.get())) {
541 PageAgent.clearDeviceMetricsOverride(apiCallback.bind(this)); 574 PageAgent.clearDeviceMetricsOverride(apiCallback.bind(this));
542 if (this._pageResizer) 575 if (this._pageResizer)
543 this._pageResizer.update(0, 0, 0); 576 this._pageResizer.update(0, 0, 0);
544 this.maybeHasActiveOverridesChanged(); 577 this.maybeHasActiveOverridesChanged();
545 return; 578 return;
546 } 579 }
547 580
548 var dipWidth = overrideDeviceResolution ? this.settings.deviceWidth.get( ) : 0; 581 var dipWidth = overrideDeviceResolution ? this.settings.deviceWidth.get( ) : 0;
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 } 957 }
925 } 958 }
926 959
927 if (!selectionRestored) 960 if (!selectionRestored)
928 deviceSelectElement.selectedIndex = devices.length - 1; 961 deviceSelectElement.selectedIndex = devices.length - 1;
929 } 962 }
930 963
931 return deviceSelectElement; 964 return deviceSelectElement;
932 }, 965 },
933 966
967 /**
968 * @param {!Document} document
969 * @return {{select: !Element, input: !Element}}
970 */
971 createUserAgentSelectAndInput: function(document)
972 {
973 var overrideUserAgentSetting = WebInspector.overridesSupport.settings.ov errideUserAgent;
974 var userAgentSetting = WebInspector.overridesSupport.settings.userAgent;
975 var userAgents = WebInspector.OverridesSupport._userAgents.concat([[WebI nspector.UIString("Other"), "Other"]]);
976
977 var userAgentSelectElement = document.createElement("select");
978 for (var i = 0; i < userAgents.length; ++i)
979 userAgentSelectElement.add(new Option(userAgents[i][0], userAgents[i ][1]));
980 userAgentSelectElement.selectedIndex = 0;
981
982 var otherUserAgentElement = document.createElement("input");
983 otherUserAgentElement.type = "text";
984 otherUserAgentElement.value = userAgentSetting.get();
985 otherUserAgentElement.title = userAgentSetting.get();
986
987 settingChanged();
988 userAgentSetting.addChangeListener(settingChanged);
989 userAgentSelectElement.addEventListener("change", userAgentSelected, fal se);
990
991 otherUserAgentElement.addEventListener("dblclick", textDoubleClicked, tr ue);
992 otherUserAgentElement.addEventListener("blur", textChanged, false);
993 otherUserAgentElement.addEventListener("keydown", textKeyDown, false);
994
995 function userAgentSelected()
996 {
997 var value = userAgentSelectElement.options[userAgentSelectElement.se lectedIndex].value;
998 if (value !== "Other") {
999 userAgentSetting.removeChangeListener(settingChanged);
1000 userAgentSetting.set(value);
1001 userAgentSetting.addChangeListener(settingChanged);
1002 otherUserAgentElement.value = value;
1003 otherUserAgentElement.title = value;
1004 otherUserAgentElement.readOnly = true;
1005 } else {
1006 otherUserAgentElement.readOnly = !overrideUserAgentSetting.get() ;
1007 otherUserAgentElement.focus();
1008 }
1009 overrideUserAgentSetting.set(true);
1010 }
1011
1012 function settingChanged()
1013 {
1014 var value = userAgentSetting.get();
1015 var options = userAgentSelectElement.options;
1016 var selectionRestored = false;
1017 for (var i = 0; i < options.length; ++i) {
1018 if (options[i].value === value) {
1019 userAgentSelectElement.selectedIndex = i;
1020 selectionRestored = true;
1021 break;
1022 }
1023 }
1024
1025 otherUserAgentElement.readOnly = !overrideUserAgentSetting.get() || selectionRestored;
1026 if (!selectionRestored)
1027 userAgentSelectElement.selectedIndex = options.length - 1;
1028
1029 if (otherUserAgentElement.value !== value) {
1030 otherUserAgentElement.value = value;
1031 otherUserAgentElement.title = value;
1032 }
1033 }
1034
1035 function textKeyDown(event)
1036 {
1037 if (isEnterKey(event))
1038 textChanged();
1039 }
1040
1041 function textDoubleClicked()
1042 {
1043 userAgentSelectElement.selectedIndex = userAgents.length - 1;
1044 userAgentSelected();
1045 }
1046
1047 function textChanged()
1048 {
1049 if (userAgentSetting.get() !== otherUserAgentElement.value)
1050 userAgentSetting.set(otherUserAgentElement.value);
1051 }
1052
1053 overrideUserAgentSetting.addChangeListener(overrideUserAgentChanged);
1054 function overrideUserAgentChanged()
1055 {
1056 otherUserAgentElement.readOnly = !overrideUserAgentSetting.get() || (userAgentSelectElement.options[userAgentSelectElement.selectedIndex].value !== "Other");
1057 }
1058
1059 return { select: userAgentSelectElement, input: otherUserAgentElement };
1060 },
1061
934 __proto__: WebInspector.Object.prototype 1062 __proto__: WebInspector.Object.prototype
935 } 1063 }
936 1064
937 1065
938 /** 1066 /**
939 * @type {!WebInspector.OverridesSupport} 1067 * @type {!WebInspector.OverridesSupport}
940 */ 1068 */
941 WebInspector.overridesSupport; 1069 WebInspector.overridesSupport;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698