OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 30 matching lines...) Expand all Loading... |
41 | 41 |
42 this._tabbedPane = new WebInspector.TabbedPane(); | 42 this._tabbedPane = new WebInspector.TabbedPane(); |
43 this._tabbedPane.shrinkableTabs = false; | 43 this._tabbedPane.shrinkableTabs = false; |
44 this._tabbedPane.verticalTabLayout = true; | 44 this._tabbedPane.verticalTabLayout = true; |
45 | 45 |
46 if (!WebInspector.overridesSupport.isInspectingDevice()) { | 46 if (!WebInspector.overridesSupport.isInspectingDevice()) { |
47 if (!WebInspector.overridesSupport.responsiveDesignAvailable()) | 47 if (!WebInspector.overridesSupport.responsiveDesignAvailable()) |
48 new WebInspector.OverridesView.DeviceTab().appendAsTab(this._tabbedP
ane); | 48 new WebInspector.OverridesView.DeviceTab().appendAsTab(this._tabbedP
ane); |
49 new WebInspector.OverridesView.ViewportTab().appendAsTab(this._tabbedPan
e); | 49 new WebInspector.OverridesView.ViewportTab().appendAsTab(this._tabbedPan
e); |
50 } | 50 } |
51 new WebInspector.OverridesView.UserAgentTab().appendAsTab(this._tabbedPane); | 51 if (!WebInspector.overridesSupport.responsiveDesignAvailable()) |
| 52 new WebInspector.OverridesView.UserAgentTab().appendAsTab(this._tabbedPa
ne); |
52 new WebInspector.OverridesView.SensorsTab().appendAsTab(this._tabbedPane); | 53 new WebInspector.OverridesView.SensorsTab().appendAsTab(this._tabbedPane); |
53 | 54 |
54 this._lastSelectedTabSetting = WebInspector.settings.createSetting("lastSele
ctedEmulateTab", "device"); | 55 this._lastSelectedTabSetting = WebInspector.settings.createSetting("lastSele
ctedEmulateTab", "device"); |
55 this._tabbedPane.selectTab(this._lastSelectedTabSetting.get()); | 56 this._tabbedPane.selectTab(this._lastSelectedTabSetting.get()); |
56 this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSele
cted, this._tabSelected, this); | 57 this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSele
cted, this._tabSelected, this); |
57 this._tabbedPane.show(this.element); | 58 this._tabbedPane.show(this.element); |
58 | 59 |
59 this._warningFooter = this.element.createChild("div", "overrides-footer"); | 60 this._warningFooter = this.element.createChild("div", "overrides-footer"); |
60 this._overridesWarningUpdated(); | 61 this._overridesWarningUpdated(); |
61 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.OverridesWarningUpdated, this._overridesWarningUpdated, this); | 62 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport
.Events.OverridesWarningUpdated, this._overridesWarningUpdated, this); |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 */ | 346 */ |
346 WebInspector.OverridesView.UserAgentTab = function() | 347 WebInspector.OverridesView.UserAgentTab = function() |
347 { | 348 { |
348 WebInspector.OverridesView.Tab.call(this, "user-agent", WebInspector.UIStrin
g("User Agent"), [WebInspector.overridesSupport.settings.overrideUserAgent]); | 349 WebInspector.OverridesView.Tab.call(this, "user-agent", WebInspector.UIStrin
g("User Agent"), [WebInspector.overridesSupport.settings.overrideUserAgent]); |
349 this.element.classList.add("overrides-user-agent"); | 350 this.element.classList.add("overrides-user-agent"); |
350 var checkbox = this._createSettingCheckbox(WebInspector.UIString("Spoof user
agent"), WebInspector.overridesSupport.settings.overrideUserAgent); | 351 var checkbox = this._createSettingCheckbox(WebInspector.UIString("Spoof user
agent"), WebInspector.overridesSupport.settings.overrideUserAgent); |
351 this.element.appendChild(checkbox); | 352 this.element.appendChild(checkbox); |
352 this.element.appendChild(this._createUserAgentSelectRowElement()); | 353 this.element.appendChild(this._createUserAgentSelectRowElement()); |
353 } | 354 } |
354 | 355 |
355 WebInspector.OverridesView.UserAgentTab._userAgents = [ | |
356 ["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"], | |
357 ["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"], | |
358 ["BlackBerry \u2014 BB10", "Mozilla/5.0 (BB10; Touch) AppleWebKit/537.1+ (KH
TML, like Gecko) Version/10.0.0.1337 Mobile Safari/537.1+"], | |
359 ["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+"], | |
360 ["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+"], | |
361 ["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"], | |
362 ["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"], | |
363 ["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"], | |
364 ["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"], | |
365 ["Firefox 14 \u2014 Android Mobile", "Mozilla/5.0 (Android; Mobile; rv:14.0)
Gecko/14.0 Firefox/14.0"], | |
366 ["Firefox 14 \u2014 Android Tablet", "Mozilla/5.0 (Android; Tablet; rv:14.0)
Gecko/14.0 Firefox/14.0"], | |
367 ["Firefox 4 \u2014 Mac", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.
0.1) Gecko/20100101 Firefox/4.0.1"], | |
368 ["Firefox 4 \u2014 Windows", "Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/2
0100101 Firefox/4.0.1"], | |
369 ["Firefox 7 \u2014 Mac", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.
0.1) Gecko/20100101 Firefox/7.0.1"], | |
370 ["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"], | |
371 ["Internet Explorer 10", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2
; Trident/6.0)"], | |
372 ["Internet Explorer 7", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"
], | |
373 ["Internet Explorer 8", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0;
Trident/4.0)"], | |
374 ["Internet Explorer 9", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1;
Trident/5.0)"], | |
375 ["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"], | |
376 ["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"], | |
377 ["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"], | |
378 ["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"], | |
379 ["MeeGo \u2014 Nokia N9", "Mozilla/5.0 (MeeGo; NokiaN9) AppleWebKit/534.13 (
KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13"], | |
380 ["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"], | |
381 ["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"], | |
382 ["Opera 12 \u2014 Mac", "Opera/9.80 (Macintosh; Intel Mac OS X 10.9.1) Prest
o/2.12.388 Version/12.16"], | |
383 ["Opera 12 \u2014 Windows", "Opera/9.80 (Windows NT 6.1) Presto/2.12.388 Ver
sion/12.16"], | |
384 ["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"], | |
385 ["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"], | |
386 ]; | |
387 | |
388 WebInspector.OverridesView.UserAgentTab.prototype = { | 356 WebInspector.OverridesView.UserAgentTab.prototype = { |
389 /** | 357 /** |
390 * @return {!Element} | 358 * @return {!Element} |
391 */ | 359 */ |
392 _createUserAgentSelectRowElement: function() | 360 _createUserAgentSelectRowElement: function() |
393 { | 361 { |
394 var userAgent = WebInspector.overridesSupport.settings.userAgent.get(); | |
395 var userAgents = WebInspector.OverridesView.UserAgentTab._userAgents.con
cat([[WebInspector.UIString("Other"), "Other"]]); | |
396 | |
397 var fieldsetElement = WebInspector.SettingsUI.createSettingFieldset(WebI
nspector.overridesSupport.settings.overrideUserAgent); | 362 var fieldsetElement = WebInspector.SettingsUI.createSettingFieldset(WebI
nspector.overridesSupport.settings.overrideUserAgent); |
398 | 363 var userAgentSelectAndInput = WebInspector.overridesSupport.createUserAg
entSelectAndInput(document); |
399 this._selectElement = fieldsetElement.createChild("select"); | 364 fieldsetElement.appendChild(userAgentSelectAndInput.select); |
400 fieldsetElement.createChild("br"); | 365 fieldsetElement.createChild("br"); |
401 this._otherUserAgentElement = fieldsetElement.createChild("input"); | 366 fieldsetElement.appendChild(userAgentSelectAndInput.input); |
402 this._otherUserAgentElement.type = "text"; | |
403 this._otherUserAgentElement.value = userAgent; | |
404 this._otherUserAgentElement.title = userAgent; | |
405 | |
406 var selectionRestored = false; | |
407 for (var i = 0; i < userAgents.length; ++i) { | |
408 var agent = userAgents[i]; | |
409 var option = new Option(agent[0], agent[1]); | |
410 this._selectElement.add(option); | |
411 if (userAgent === agent[1]) { | |
412 this._selectElement.selectedIndex = i; | |
413 selectionRestored = true; | |
414 } | |
415 } | |
416 | |
417 if (!selectionRestored) { | |
418 if (!userAgent) | |
419 this._selectElement.selectedIndex = 0; | |
420 else | |
421 this._selectElement.selectedIndex = userAgents.length - 1; | |
422 } | |
423 | |
424 this._selectElement.addEventListener("change", this._userAgentChanged.bi
nd(this, true), false); | |
425 WebInspector.overridesSupport.settings.userAgent.addChangeListener(this.
_userAgentSettingChanged, this); | |
426 | |
427 fieldsetElement.addEventListener("dblclick", textDoubleClicked.bind(this
), false); | |
428 this._otherUserAgentElement.addEventListener("blur", textChanged.bind(th
is), false); | |
429 | |
430 /** | |
431 * @this {WebInspector.OverridesView.UserAgentTab} | |
432 */ | |
433 function textDoubleClicked() | |
434 { | |
435 this._selectElement.selectedIndex = userAgents.length - 1; | |
436 this._userAgentChanged(); | |
437 } | |
438 | |
439 /** | |
440 * @this {WebInspector.OverridesView.UserAgentTab} | |
441 */ | |
442 function textChanged() | |
443 { | |
444 if (WebInspector.overridesSupport.settings.userAgent.get() !== this.
_otherUserAgentElement.value) | |
445 WebInspector.overridesSupport.settings.userAgent.set(this._other
UserAgentElement.value); | |
446 } | |
447 | |
448 return fieldsetElement; | 367 return fieldsetElement; |
449 }, | 368 }, |
450 | 369 |
451 /** | |
452 * @param {boolean=} isUserGesture | |
453 */ | |
454 _userAgentChanged: function(isUserGesture) | |
455 { | |
456 var value = this._selectElement.options[this._selectElement.selectedInde
x].value; | |
457 if (value !== "Other") { | |
458 WebInspector.overridesSupport.settings.userAgent.set(value); | |
459 this._otherUserAgentElement.value = value; | |
460 this._otherUserAgentElement.title = value; | |
461 this._otherUserAgentElement.disabled = true; | |
462 } else { | |
463 this._otherUserAgentElement.disabled = false; | |
464 this._otherUserAgentElement.focus(); | |
465 } | |
466 }, | |
467 | |
468 _userAgentSettingChanged: function() | |
469 { | |
470 var value = WebInspector.overridesSupport.settings.userAgent.get(); | |
471 var options = this._selectElement.options; | |
472 var foundMatch = false; | |
473 for (var i = 0; i < options.length; ++i) { | |
474 if (options[i].value === value) { | |
475 if (this._selectElement.selectedIndex !== i) | |
476 this._selectElement.selectedIndex = i; | |
477 foundMatch = true; | |
478 break; | |
479 } | |
480 } | |
481 | |
482 this._otherUserAgentElement.disabled = foundMatch; | |
483 if (!foundMatch) | |
484 this._selectElement.selectedIndex = options.length - 1; | |
485 | |
486 if (this._otherUserAgentElement.value !== value) { | |
487 this._otherUserAgentElement.value = value; | |
488 this._otherUserAgentElement.title = value; | |
489 } | |
490 }, | |
491 | |
492 __proto__: WebInspector.OverridesView.Tab.prototype | 370 __proto__: WebInspector.OverridesView.Tab.prototype |
493 } | 371 } |
494 | 372 |
495 | 373 |
496 /** | 374 /** |
497 * @constructor | 375 * @constructor |
498 * @extends {WebInspector.OverridesView.Tab} | 376 * @extends {WebInspector.OverridesView.Tab} |
499 */ | 377 */ |
500 WebInspector.OverridesView.SensorsTab = function() | 378 WebInspector.OverridesView.SensorsTab = function() |
501 { | 379 { |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 | 641 |
764 __proto__ : WebInspector.OverridesView.Tab.prototype | 642 __proto__ : WebInspector.OverridesView.Tab.prototype |
765 } | 643 } |
766 | 644 |
767 /** @enum {string} */ | 645 /** @enum {string} */ |
768 WebInspector.OverridesView.SensorsTab.DeviceOrientationModificationSource = { | 646 WebInspector.OverridesView.SensorsTab.DeviceOrientationModificationSource = { |
769 UserInput: "userInput", | 647 UserInput: "userInput", |
770 UserDrag: "userDrag", | 648 UserDrag: "userDrag", |
771 ResetButton: "resetButton" | 649 ResetButton: "resetButton" |
772 } | 650 } |
OLD | NEW |