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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/emulation/Geolocation.js

Issue 2137773002: [DevTools] Replace the target type with capabilities (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 * @param {number} latitude 7 * @param {number} latitude
8 * @param {number} longitude 8 * @param {number} longitude
9 * @param {boolean} error 9 * @param {boolean} error
10 */ 10 */
11 WebInspector.Geolocation = function(latitude, longitude, error) 11 WebInspector.Geolocation = function(latitude, longitude, error)
12 { 12 {
13 this.latitude = latitude; 13 this.latitude = latitude;
14 this.longitude = longitude; 14 this.longitude = longitude;
15 this.error = error; 15 this.error = error;
16 } 16 }
17 17
18 WebInspector.Geolocation.prototype = { 18 WebInspector.Geolocation.prototype = {
19 /** 19 /**
20 * @return {string} 20 * @return {string}
21 */ 21 */
22 toSetting: function() 22 toSetting: function()
23 { 23 {
24 return (typeof this.latitude === "number" && typeof this.longitude === " number" && typeof this.error === "string") ? this.latitude + "@" + this.longitud e + ":" + this.error : ""; 24 return (typeof this.latitude === "number" && typeof this.longitude === " number" && typeof this.error === "string") ? this.latitude + "@" + this.longitud e + ":" + this.error : "";
25 }, 25 },
26 26
27 apply: function() 27 apply: function()
28 { 28 {
29 for (var target of WebInspector.targetManager.targets(WebInspector.Targe t.Type.Page)) { 29 for (var target of WebInspector.targetManager.targets(WebInspector.Targe t.Capability.Browser)) {
30 if (this.error) 30 if (this.error)
31 target.emulationAgent().setGeolocationOverride(); 31 target.emulationAgent().setGeolocationOverride();
32 else 32 else
33 target.emulationAgent().setGeolocationOverride(this.latitude, th is.longitude, WebInspector.Geolocation.DefaultMockAccuracy); 33 target.emulationAgent().setGeolocationOverride(this.latitude, th is.longitude, WebInspector.Geolocation.DefaultMockAccuracy);
34 } 34 }
35 }, 35 },
36 36
37 clear: function() 37 clear: function()
38 { 38 {
39 for (var target of WebInspector.targetManager.targets(WebInspector.Targe t.Type.Page)) 39 for (var target of WebInspector.targetManager.targets(WebInspector.Targe t.Capability.Browser))
40 target.emulationAgent().clearGeolocationOverride(); 40 target.emulationAgent().clearGeolocationOverride();
41 } 41 }
42 } 42 }
43 43
44 /** 44 /**
45 * @return {!WebInspector.Geolocation} 45 * @return {!WebInspector.Geolocation}
46 */ 46 */
47 WebInspector.Geolocation.parseSetting = function(value) 47 WebInspector.Geolocation.parseSetting = function(value)
48 { 48 {
49 if (value) { 49 if (value) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 * @param {string} value 93 * @param {string} value
94 * @return {boolean} 94 * @return {boolean}
95 */ 95 */
96 WebInspector.Geolocation.longitudeValidator = function(value) 96 WebInspector.Geolocation.longitudeValidator = function(value)
97 { 97 {
98 var numValue = parseFloat(value); 98 var numValue = parseFloat(value);
99 return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value) && numValue >= -180 & & numValue <= 180; 99 return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value) && numValue >= -180 & & numValue <= 180;
100 } 100 }
101 101
102 WebInspector.Geolocation.DefaultMockAccuracy = 150; 102 WebInspector.Geolocation.DefaultMockAccuracy = 150;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698