OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @extends {WebInspector.VBox} | 7 * @extends {WebInspector.VBox} |
8 */ | 8 */ |
9 WebInspector.SensorsView = function() | 9 WebInspector.SensorsView = function() |
10 { | 10 { |
11 WebInspector.VBox.call(this, true); | 11 WebInspector.VBox.call(this, true); |
12 this.registerRequiredCSS("emulation/sensors.css"); | 12 this.registerRequiredCSS("emulation/sensors.css"); |
13 this.contentElement.classList.add("sensors-view"); | 13 this.contentElement.classList.add("sensors-view"); |
14 | 14 |
15 this._geolocationSetting = WebInspector.settings.createSetting("emulation.ge
olocationOverride", ""); | 15 this._geolocationSetting = WebInspector.settings.createSetting("emulation.ge
olocationOverride", ""); |
16 this._geolocation = WebInspector.Geolocation.parseSetting(this._geolocationS
etting.get()); | 16 this._geolocation = WebInspector.Geolocation.parseSetting(this._geolocationS
etting.get()); |
17 this._geolocationOverrideEnabled = false; | 17 this._geolocationOverrideEnabled = false; |
18 this._createGeolocationSection(this._geolocation); | 18 this._createGeolocationSection(this._geolocation); |
19 | 19 |
20 this.contentElement.createChild("div").classList.add("panel-section-separato
r"); | 20 this.contentElement.createChild("div").classList.add("panel-section-separato
r"); |
21 | 21 |
22 this._deviceOrientationSetting = WebInspector.settings.createSetting("emulat
ion.deviceOrientationOverride", ""); | 22 this._deviceOrientationSetting = WebInspector.settings.createSetting("emulat
ion.deviceOrientationOverride", ""); |
23 this._deviceOrientation = WebInspector.DeviceOrientation.parseSetting(this._
deviceOrientationSetting.get()); | 23 this._deviceOrientation = WebInspector.DeviceOrientation.parseSetting(this._
deviceOrientationSetting.get()); |
24 this._deviceOrientationOverrideEnabled = false; | 24 this._deviceOrientationOverrideEnabled = false; |
25 this._createDeviceOrientationSection(); | 25 this._createDeviceOrientationSection(); |
26 | 26 |
27 this.contentElement.createChild("div").classList.add("panel-section-separato
r"); | 27 this.contentElement.createChild("div").classList.add("panel-section-separato
r"); |
28 | 28 |
29 this._appendTouchControl(); | 29 this._appendTouchControl(); |
30 } | 30 }; |
31 | 31 |
32 WebInspector.SensorsView.prototype = { | 32 WebInspector.SensorsView.prototype = { |
33 /** | 33 /** |
34 * @param {!WebInspector.Geolocation} geolocation | 34 * @param {!WebInspector.Geolocation} geolocation |
35 */ | 35 */ |
36 _createGeolocationSection: function(geolocation) | 36 _createGeolocationSection: function(geolocation) |
37 { | 37 { |
38 var geogroup = this.contentElement.createChild("section", "sensors-group
"); | 38 var geogroup = this.contentElement.createChild("section", "sensors-group
"); |
39 geogroup.createChild("div", "sensors-group-title").textContent = WebInsp
ector.UIString("Geolocation"); | 39 geogroup.createChild("div", "sensors-group-title").textContent = WebInsp
ector.UIString("Geolocation"); |
40 var fields = geogroup.createChild("div", "geo-fields"); | 40 var fields = geogroup.createChild("div", "geo-fields"); |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 select.appendChild(new Option(WebInspector.UIString("Force enabled"), "e
nabled")); | 413 select.appendChild(new Option(WebInspector.UIString("Force enabled"), "e
nabled")); |
414 select.addEventListener("change", applyTouch, false); | 414 select.addEventListener("change", applyTouch, false); |
415 | 415 |
416 function applyTouch() | 416 function applyTouch() |
417 { | 417 { |
418 WebInspector.MultitargetTouchModel.instance().setCustomTouchEnabled(
select.value === "enabled"); | 418 WebInspector.MultitargetTouchModel.instance().setCustomTouchEnabled(
select.value === "enabled"); |
419 } | 419 } |
420 }, | 420 }, |
421 | 421 |
422 __proto__ : WebInspector.VBox.prototype | 422 __proto__ : WebInspector.VBox.prototype |
423 } | 423 }; |
424 | 424 |
425 /** @enum {string} */ | 425 /** @enum {string} */ |
426 WebInspector.SensorsView.DeviceOrientationModificationSource = { | 426 WebInspector.SensorsView.DeviceOrientationModificationSource = { |
427 UserInput: "userInput", | 427 UserInput: "userInput", |
428 UserDrag: "userDrag", | 428 UserDrag: "userDrag", |
429 ResetButton: "resetButton", | 429 ResetButton: "resetButton", |
430 SelectPreset: "selectPreset" | 430 SelectPreset: "selectPreset" |
431 } | 431 }; |
432 | 432 |
433 /** {string} */ | 433 /** {string} */ |
434 WebInspector.SensorsView.NonPresetOptions = { | 434 WebInspector.SensorsView.NonPresetOptions = { |
435 "NoOverride": "noOverride", | 435 "NoOverride": "noOverride", |
436 "Custom": "custom", | 436 "Custom": "custom", |
437 "Unavailable": "unavailable" | 437 "Unavailable": "unavailable" |
438 } | 438 }; |
439 | 439 |
440 /** @type {!Array.<{title: string, value: !Array.<{title: string, location: stri
ng}>}>} */ | 440 /** @type {!Array.<{title: string, value: !Array.<{title: string, location: stri
ng}>}>} */ |
441 WebInspector.SensorsView.PresetLocations = [ | 441 WebInspector.SensorsView.PresetLocations = [ |
442 { | 442 { |
443 title: "Presets", | 443 title: "Presets", |
444 value: [ | 444 value: [ |
445 {title: WebInspector.UIString("Berlin"), location: "[52.520007, 13.4
04954]"}, | 445 {title: WebInspector.UIString("Berlin"), location: "[52.520007, 13.4
04954]"}, |
446 {title: WebInspector.UIString("London"), location: "[51.507351, -0.1
27758]"}, | 446 {title: WebInspector.UIString("London"), location: "[51.507351, -0.1
27758]"}, |
447 {title: WebInspector.UIString("Moscow"), location: "[55.755826, 37.6
17300]"}, | 447 {title: WebInspector.UIString("Moscow"), location: "[55.755826, 37.6
17300]"}, |
448 {title: WebInspector.UIString("Mountain View"), location: "[37.38605
2, -122.083851]"}, | 448 {title: WebInspector.UIString("Mountain View"), location: "[37.38605
2, -122.083851]"}, |
449 {title: WebInspector.UIString("Mumbai"), location: "[19.075984, 72.8
77656]"}, | 449 {title: WebInspector.UIString("Mumbai"), location: "[19.075984, 72.8
77656]"}, |
450 {title: WebInspector.UIString("San Francisco"), location: "[37.77492
9, -122.419416]"}, | 450 {title: WebInspector.UIString("San Francisco"), location: "[37.77492
9, -122.419416]"}, |
451 {title: WebInspector.UIString("Shanghai"), location: "[31.230416, 12
1.473701]"}, | 451 {title: WebInspector.UIString("Shanghai"), location: "[31.230416, 12
1.473701]"}, |
452 {title: WebInspector.UIString("São Paulo"), location: "[-23.550520,
-46.633309]"}, | 452 {title: WebInspector.UIString("São Paulo"), location: "[-23.550520,
-46.633309]"}, |
453 {title: WebInspector.UIString("Tokyo"), location: "[35.689487, 139.6
91706]"}, | 453 {title: WebInspector.UIString("Tokyo"), location: "[35.689487, 139.6
91706]"}, |
454 ] | 454 ] |
455 }, | 455 }, |
456 { | 456 { |
457 title: "Error", | 457 title: "Error", |
458 value: [ | 458 value: [ |
459 {title: WebInspector.UIString("Location unavailable"), location: Web
Inspector.SensorsView.NonPresetOptions.Unavailable} | 459 {title: WebInspector.UIString("Location unavailable"), location: Web
Inspector.SensorsView.NonPresetOptions.Unavailable} |
460 ] | 460 ] |
461 } | 461 } |
462 ] | 462 ]; |
463 | 463 |
464 /** @type {!Array.<{title: string, value: !Array.<{title: string, orientation: !
WebInspector.DeviceOrientation}>}>} */ | 464 /** @type {!Array.<{title: string, value: !Array.<{title: string, orientation: !
WebInspector.DeviceOrientation}>}>} */ |
465 WebInspector.SensorsView.PresetOrientations = [ | 465 WebInspector.SensorsView.PresetOrientations = [ |
466 { | 466 { |
467 title: "Presets", | 467 title: "Presets", |
468 value: [ | 468 value: [ |
469 {title: WebInspector.UIString("Portrait"), orientation: "[0, 90, 0]"
}, | 469 {title: WebInspector.UIString("Portrait"), orientation: "[0, 90, 0]"
}, |
470 {title: WebInspector.UIString("Portrait upside down"), orientation:
"[180, -90, 0]"}, | 470 {title: WebInspector.UIString("Portrait upside down"), orientation:
"[180, -90, 0]"}, |
471 {title: WebInspector.UIString("Landscape left"), orientation: "[0, 9
0, -90]"}, | 471 {title: WebInspector.UIString("Landscape left"), orientation: "[0, 9
0, -90]"}, |
472 {title: WebInspector.UIString("Landscape right"), orientation: "[0,
90, 90]"}, | 472 {title: WebInspector.UIString("Landscape right"), orientation: "[0,
90, 90]"}, |
473 {title: WebInspector.UIString("Display up"), orientation: "[0, 0, 0]
"}, | 473 {title: WebInspector.UIString("Display up"), orientation: "[0, 0, 0]
"}, |
474 {title: WebInspector.UIString("Display down"), orientation: "[0, 180
, 0]"} | 474 {title: WebInspector.UIString("Display down"), orientation: "[0, 180
, 0]"} |
475 ] | 475 ] |
476 } | 476 } |
477 ] | 477 ]; |
478 | 478 |
479 /** | 479 /** |
480 * @return {!WebInspector.SensorsView} | 480 * @return {!WebInspector.SensorsView} |
481 */ | 481 */ |
482 WebInspector.SensorsView.instance = function() | 482 WebInspector.SensorsView.instance = function() |
483 { | 483 { |
484 if (!WebInspector.SensorsView._instanceObject) | 484 if (!WebInspector.SensorsView._instanceObject) |
485 WebInspector.SensorsView._instanceObject = new WebInspector.SensorsView(
); | 485 WebInspector.SensorsView._instanceObject = new WebInspector.SensorsView(
); |
486 return WebInspector.SensorsView._instanceObject; | 486 return WebInspector.SensorsView._instanceObject; |
487 } | 487 }; |
488 | 488 |
489 /** | 489 /** |
490 * @constructor | 490 * @constructor |
491 * @implements {WebInspector.ActionDelegate} | 491 * @implements {WebInspector.ActionDelegate} |
492 */ | 492 */ |
493 WebInspector.SensorsView.ShowActionDelegate = function() | 493 WebInspector.SensorsView.ShowActionDelegate = function() |
494 { | 494 { |
495 } | 495 }; |
496 | 496 |
497 WebInspector.SensorsView.ShowActionDelegate.prototype = { | 497 WebInspector.SensorsView.ShowActionDelegate.prototype = { |
498 /** | 498 /** |
499 * @override | 499 * @override |
500 * @param {!WebInspector.Context} context | 500 * @param {!WebInspector.Context} context |
501 * @param {string} actionId | 501 * @param {string} actionId |
502 * @return {boolean} | 502 * @return {boolean} |
503 */ | 503 */ |
504 handleAction: function(context, actionId) | 504 handleAction: function(context, actionId) |
505 { | 505 { |
506 WebInspector.viewManager.showView("sensors"); | 506 WebInspector.viewManager.showView("sensors"); |
507 return true; | 507 return true; |
508 } | 508 } |
509 } | 509 }; |
510 | 510 |
511 WebInspector.SensorsView.ShiftDragOrientationSpeed = 16; | 511 WebInspector.SensorsView.ShiftDragOrientationSpeed = 16; |
OLD | NEW |