OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 | |
5 /* eslint-disable indent */ | 4 /* eslint-disable indent */ |
6 (function(window) { | 5 (function(window) { |
7 | 6 |
8 // DevToolsAPI ---------------------------------------------------------------- | 7 // DevToolsAPI ---------------------------------------------------------------
- |
9 | 8 |
10 /** | 9 /** |
11 * @constructor | 10 * @unrestricted |
12 */ | 11 */ |
13 function DevToolsAPIImpl() | 12 var DevToolsAPIImpl = class { |
14 { | 13 constructor() { |
15 /** | 14 /** |
16 * @type {number} | 15 * @type {number} |
17 */ | 16 */ |
18 this._lastCallId = 0; | 17 this._lastCallId = 0; |
19 | 18 |
20 /** | 19 /** |
21 * @type {!Object.<number, function(?Object)>} | 20 * @type {!Object.<number, function(?Object)>} |
22 */ | 21 */ |
23 this._callbacks = {}; | 22 this._callbacks = {}; |
24 } | 23 } |
25 | 24 |
26 DevToolsAPIImpl.prototype = { | |
27 /** | 25 /** |
28 * @param {number} id | 26 * @param {number} id |
29 * @param {?Object} arg | 27 * @param {?Object} arg |
30 */ | 28 */ |
31 embedderMessageAck: function(id, arg) | 29 embedderMessageAck(id, arg) { |
32 { | 30 var callback = this._callbacks[id]; |
33 var callback = this._callbacks[id]; | 31 delete this._callbacks[id]; |
34 delete this._callbacks[id]; | 32 if (callback) |
35 if (callback) | 33 callback(arg); |
36 callback(arg); | 34 } |
37 }, | |
38 | 35 |
39 /** | 36 /** |
40 * @param {string} method | 37 * @param {string} method |
41 * @param {!Array.<*>} args | 38 * @param {!Array.<*>} args |
42 * @param {?function(?Object)} callback | 39 * @param {?function(?Object)} callback |
43 */ | 40 */ |
44 sendMessageToEmbedder: function(method, args, callback) | 41 sendMessageToEmbedder(method, args, callback) { |
45 { | 42 var callId = ++this._lastCallId; |
46 var callId = ++this._lastCallId; | 43 if (callback) |
47 if (callback) | 44 this._callbacks[callId] = callback; |
48 this._callbacks[callId] = callback; | 45 var message = {'id': callId, 'method': method}; |
49 var message = { "id": callId, "method": method }; | 46 if (args.length) |
50 if (args.length) | 47 message.params = args; |
51 message.params = args; | 48 DevToolsHost.sendMessageToEmbedder(JSON.stringify(message)); |
52 DevToolsHost.sendMessageToEmbedder(JSON.stringify(message)); | 49 } |
53 }, | |
54 | 50 |
55 /** | 51 /** |
56 * @param {string} method | 52 * @param {string} method |
57 * @param {!Array<*>} args | 53 * @param {!Array<*>} args |
58 */ | 54 */ |
59 _dispatchOnInspectorFrontendAPI: function(method, args) | 55 _dispatchOnInspectorFrontendAPI(method, args) { |
60 { | 56 const inspectorFrontendAPI = /** @type {!Object<string, function()>} */ (w
indow['InspectorFrontendAPI']); |
61 const inspectorFrontendAPI = /** @type {!Object<string, function()>} */
(window["InspectorFrontendAPI"]); | 57 inspectorFrontendAPI[method].apply(inspectorFrontendAPI, args); |
62 inspectorFrontendAPI[method].apply(inspectorFrontendAPI, args); | 58 } |
63 }, | |
64 | 59 |
65 // API methods below this line -------------------------------------------- | 60 // API methods below this line -------------------------------------------- |
66 | 61 |
67 /** | 62 /** |
68 * @param {!Array.<!ExtensionDescriptor>} extensions | 63 * @param {!Array.<!ExtensionDescriptor>} extensions |
69 */ | 64 */ |
70 addExtensions: function(extensions) | 65 addExtensions(extensions) { |
71 { | 66 // Support for legacy front-ends (<M41). |
72 // Support for legacy front-ends (<M41). | 67 if (window['WebInspector']['addExtensions']) |
73 if (window["WebInspector"]["addExtensions"]) | 68 window['WebInspector']['addExtensions'](extensions); |
74 window["WebInspector"]["addExtensions"](extensions); | 69 else |
75 else | 70 this._dispatchOnInspectorFrontendAPI('addExtensions', [extensions]); |
76 this._dispatchOnInspectorFrontendAPI("addExtensions", [extensions]); | 71 } |
77 }, | |
78 | 72 |
79 /** | 73 /** |
80 * @param {string} url | 74 * @param {string} url |
81 */ | 75 */ |
82 appendedToURL: function(url) | 76 appendedToURL(url) { |
83 { | 77 this._dispatchOnInspectorFrontendAPI('appendedToURL', [url]); |
84 this._dispatchOnInspectorFrontendAPI("appendedToURL", [url]); | 78 } |
85 }, | |
86 | 79 |
87 /** | 80 /** |
88 * @param {string} url | 81 * @param {string} url |
89 */ | 82 */ |
90 canceledSaveURL: function(url) | 83 canceledSaveURL(url) { |
91 { | 84 this._dispatchOnInspectorFrontendAPI('canceledSaveURL', [url]); |
92 this._dispatchOnInspectorFrontendAPI("canceledSaveURL", [url]); | 85 } |
93 }, | 86 |
94 | 87 contextMenuCleared() { |
95 contextMenuCleared: function() | 88 this._dispatchOnInspectorFrontendAPI('contextMenuCleared', []); |
96 { | 89 } |
97 this._dispatchOnInspectorFrontendAPI("contextMenuCleared", []); | |
98 }, | |
99 | 90 |
100 /** | 91 /** |
101 * @param {string} id | 92 * @param {string} id |
102 */ | 93 */ |
103 contextMenuItemSelected: function(id) | 94 contextMenuItemSelected(id) { |
104 { | 95 this._dispatchOnInspectorFrontendAPI('contextMenuItemSelected', [id]); |
105 this._dispatchOnInspectorFrontendAPI("contextMenuItemSelected", [id]); | 96 } |
106 }, | |
107 | 97 |
108 /** | 98 /** |
109 * @param {number} count | 99 * @param {number} count |
110 */ | 100 */ |
111 deviceCountUpdated: function(count) | 101 deviceCountUpdated(count) { |
112 { | 102 this._dispatchOnInspectorFrontendAPI('deviceCountUpdated', [count]); |
113 this._dispatchOnInspectorFrontendAPI("deviceCountUpdated", [count]); | 103 } |
114 }, | |
115 | 104 |
116 /** | 105 /** |
117 * @param {boolean} discoverUsbDevices | 106 * @param {boolean} discoverUsbDevices |
118 * @param {boolean} portForwardingEnabled | 107 * @param {boolean} portForwardingEnabled |
119 * @param {!Adb.PortForwardingConfig} portForwardingConfig | 108 * @param {!Adb.PortForwardingConfig} portForwardingConfig |
120 */ | 109 */ |
121 devicesDiscoveryConfigChanged: function(discoverUsbDevices, portForwardingEn
abled, portForwardingConfig) | 110 devicesDiscoveryConfigChanged(discoverUsbDevices, portForwardingEnabled, por
tForwardingConfig) { |
122 { | 111 this._dispatchOnInspectorFrontendAPI( |
123 this._dispatchOnInspectorFrontendAPI("devicesDiscoveryConfigChanged", [d
iscoverUsbDevices, portForwardingEnabled, portForwardingConfig]); | 112 'devicesDiscoveryConfigChanged', [discoverUsbDevices, portForwardingEn
abled, portForwardingConfig]); |
124 }, | 113 } |
125 | 114 |
126 /** | 115 /** |
127 * @param {!Adb.PortForwardingStatus} status | 116 * @param {!Adb.PortForwardingStatus} status |
128 */ | 117 */ |
129 devicesPortForwardingStatusChanged: function(status) | 118 devicesPortForwardingStatusChanged(status) { |
130 { | 119 this._dispatchOnInspectorFrontendAPI('devicesPortForwardingStatusChanged',
[status]); |
131 this._dispatchOnInspectorFrontendAPI("devicesPortForwardingStatusChanged
", [status]); | 120 } |
132 }, | |
133 | 121 |
134 /** | 122 /** |
135 * @param {!Array.<!Adb.Device>} devices | 123 * @param {!Array.<!Adb.Device>} devices |
136 */ | 124 */ |
137 devicesUpdated: function(devices) | 125 devicesUpdated(devices) { |
138 { | 126 this._dispatchOnInspectorFrontendAPI('devicesUpdated', [devices]); |
139 this._dispatchOnInspectorFrontendAPI("devicesUpdated", [devices]); | 127 } |
140 }, | |
141 | 128 |
142 /** | 129 /** |
143 * @param {string} message | 130 * @param {string} message |
144 */ | 131 */ |
145 dispatchMessage: function(message) | 132 dispatchMessage(message) { |
146 { | 133 this._dispatchOnInspectorFrontendAPI('dispatchMessage', [message]); |
147 this._dispatchOnInspectorFrontendAPI("dispatchMessage", [message]); | 134 } |
148 }, | |
149 | 135 |
150 /** | 136 /** |
151 * @param {string} messageChunk | 137 * @param {string} messageChunk |
152 * @param {number} messageSize | 138 * @param {number} messageSize |
153 */ | 139 */ |
154 dispatchMessageChunk: function(messageChunk, messageSize) | 140 dispatchMessageChunk(messageChunk, messageSize) { |
155 { | 141 this._dispatchOnInspectorFrontendAPI('dispatchMessageChunk', [messageChunk
, messageSize]); |
156 this._dispatchOnInspectorFrontendAPI("dispatchMessageChunk", [messageChu
nk, messageSize]); | 142 } |
157 }, | 143 |
158 | 144 enterInspectElementMode() { |
159 enterInspectElementMode: function() | 145 this._dispatchOnInspectorFrontendAPI('enterInspectElementMode', []); |
160 { | 146 } |
161 this._dispatchOnInspectorFrontendAPI("enterInspectElementMode", []); | |
162 }, | |
163 | 147 |
164 /** | 148 /** |
165 * @param {number} callId | 149 * @param {number} callId |
166 * @param {string} script | 150 * @param {string} script |
167 */ | 151 */ |
168 evaluateForTestInFrontend: function(callId, script) | 152 evaluateForTestInFrontend(callId, script) { |
169 { | 153 this._dispatchOnInspectorFrontendAPI('evaluateForTestInFrontend', [callId,
script]); |
170 this._dispatchOnInspectorFrontendAPI("evaluateForTestInFrontend", [callI
d, script]); | 154 } |
171 }, | |
172 | 155 |
173 /** | 156 /** |
174 * @param {!Array.<!{fileSystemName: string, rootURL: string, fileSystemPath
: string}>} fileSystems | 157 * @param {!Array.<!{fileSystemName: string, rootURL: string, fileSystemPath
: string}>} fileSystems |
175 */ | 158 */ |
176 fileSystemsLoaded: function(fileSystems) | 159 fileSystemsLoaded(fileSystems) { |
177 { | 160 this._dispatchOnInspectorFrontendAPI('fileSystemsLoaded', [fileSystems]); |
178 this._dispatchOnInspectorFrontendAPI("fileSystemsLoaded", [fileSystems])
; | 161 } |
179 }, | 162 |
180 | 163 /** |
181 /** | 164 * @param {string} fileSystemPath |
182 * @param {string} fileSystemPath | 165 */ |
183 */ | 166 fileSystemRemoved(fileSystemPath) { |
184 fileSystemRemoved: function(fileSystemPath) | 167 this._dispatchOnInspectorFrontendAPI('fileSystemRemoved', [fileSystemPath]
); |
185 { | 168 } |
186 this._dispatchOnInspectorFrontendAPI("fileSystemRemoved", [fileSystemPat
h]); | |
187 }, | |
188 | 169 |
189 /** | 170 /** |
190 * @param {!{fileSystemName: string, rootURL: string, fileSystemPath: string
}} fileSystem | 171 * @param {!{fileSystemName: string, rootURL: string, fileSystemPath: string
}} fileSystem |
191 */ | 172 */ |
192 fileSystemAdded: function(fileSystem) | 173 fileSystemAdded(fileSystem) { |
193 { | 174 this._dispatchOnInspectorFrontendAPI('fileSystemAdded', ['', fileSystem]); |
194 this._dispatchOnInspectorFrontendAPI("fileSystemAdded", ["", fileSystem]
); | 175 } |
195 }, | |
196 | 176 |
197 /** | 177 /** |
198 * @param {!Array<string>} changedPaths | 178 * @param {!Array<string>} changedPaths |
199 */ | 179 */ |
200 fileSystemFilesChanged: function(changedPaths) | 180 fileSystemFilesChanged(changedPaths) { |
201 { | 181 this._dispatchOnInspectorFrontendAPI('fileSystemFilesChanged', [changedPat
hs]); |
202 this._dispatchOnInspectorFrontendAPI("fileSystemFilesChanged", [changedP
aths]); | 182 } |
203 }, | |
204 | 183 |
205 /** | 184 /** |
206 * @param {number} requestId | 185 * @param {number} requestId |
207 * @param {string} fileSystemPath | 186 * @param {string} fileSystemPath |
208 * @param {number} totalWork | 187 * @param {number} totalWork |
209 */ | 188 */ |
210 indexingTotalWorkCalculated: function(requestId, fileSystemPath, totalWork) | 189 indexingTotalWorkCalculated(requestId, fileSystemPath, totalWork) { |
211 { | 190 this._dispatchOnInspectorFrontendAPI('indexingTotalWorkCalculated', [reque
stId, fileSystemPath, totalWork]); |
212 this._dispatchOnInspectorFrontendAPI("indexingTotalWorkCalculated", [req
uestId, fileSystemPath, totalWork]); | 191 } |
213 }, | |
214 | 192 |
215 /** | 193 /** |
216 * @param {number} requestId | 194 * @param {number} requestId |
217 * @param {string} fileSystemPath | 195 * @param {string} fileSystemPath |
218 * @param {number} worked | 196 * @param {number} worked |
219 */ | 197 */ |
220 indexingWorked: function(requestId, fileSystemPath, worked) | 198 indexingWorked(requestId, fileSystemPath, worked) { |
221 { | 199 this._dispatchOnInspectorFrontendAPI('indexingWorked', [requestId, fileSys
temPath, worked]); |
222 this._dispatchOnInspectorFrontendAPI("indexingWorked", [requestId, fileS
ystemPath, worked]); | 200 } |
223 }, | |
224 | 201 |
225 /** | 202 /** |
226 * @param {number} requestId | 203 * @param {number} requestId |
227 * @param {string} fileSystemPath | 204 * @param {string} fileSystemPath |
228 */ | 205 */ |
229 indexingDone: function(requestId, fileSystemPath) | 206 indexingDone(requestId, fileSystemPath) { |
230 { | 207 this._dispatchOnInspectorFrontendAPI('indexingDone', [requestId, fileSyste
mPath]); |
231 this._dispatchOnInspectorFrontendAPI("indexingDone", [requestId, fileSys
temPath]); | 208 } |
232 }, | |
233 | 209 |
234 /** | 210 /** |
235 * @param {{type: string, key: string, code: string, keyCode: number, modifi
ers: number}} event | 211 * @param {{type: string, key: string, code: string, keyCode: number, modifi
ers: number}} event |
236 */ | 212 */ |
237 keyEventUnhandled: function(event) | 213 keyEventUnhandled(event) { |
238 { | 214 event.keyIdentifier = keyCodeToKeyIdentifier(event.keyCode); |
239 event.keyIdentifier = keyCodeToKeyIdentifier(event.keyCode); | 215 this._dispatchOnInspectorFrontendAPI('keyEventUnhandled', [event]); |
240 this._dispatchOnInspectorFrontendAPI("keyEventUnhandled", [event]); | 216 } |
241 }, | |
242 | 217 |
243 /** | 218 /** |
244 * @param {boolean} hard | 219 * @param {boolean} hard |
245 */ | 220 */ |
246 reloadInspectedPage: function(hard) | 221 reloadInspectedPage(hard) { |
247 { | 222 this._dispatchOnInspectorFrontendAPI('reloadInspectedPage', [hard]); |
248 this._dispatchOnInspectorFrontendAPI("reloadInspectedPage", [hard]); | 223 } |
249 }, | |
250 | 224 |
251 /** | 225 /** |
252 * @param {string} url | 226 * @param {string} url |
253 * @param {number} lineNumber | 227 * @param {number} lineNumber |
254 * @param {number} columnNumber | 228 * @param {number} columnNumber |
255 */ | 229 */ |
256 revealSourceLine: function(url, lineNumber, columnNumber) | 230 revealSourceLine(url, lineNumber, columnNumber) { |
257 { | 231 this._dispatchOnInspectorFrontendAPI('revealSourceLine', [url, lineNumber,
columnNumber]); |
258 this._dispatchOnInspectorFrontendAPI("revealSourceLine", [url, lineNumbe
r, columnNumber]); | 232 } |
259 }, | |
260 | 233 |
261 /** | 234 /** |
262 * @param {string} url | 235 * @param {string} url |
263 */ | 236 */ |
264 savedURL: function(url) | 237 savedURL(url) { |
265 { | 238 this._dispatchOnInspectorFrontendAPI('savedURL', [url]); |
266 this._dispatchOnInspectorFrontendAPI("savedURL", [url]); | 239 } |
267 }, | |
268 | 240 |
269 /** | 241 /** |
270 * @param {number} requestId | 242 * @param {number} requestId |
271 * @param {string} fileSystemPath | 243 * @param {string} fileSystemPath |
272 * @param {!Array.<string>} files | 244 * @param {!Array.<string>} files |
273 */ | 245 */ |
274 searchCompleted: function(requestId, fileSystemPath, files) | 246 searchCompleted(requestId, fileSystemPath, files) { |
275 { | 247 this._dispatchOnInspectorFrontendAPI('searchCompleted', [requestId, fileSy
stemPath, files]); |
276 this._dispatchOnInspectorFrontendAPI("searchCompleted", [requestId, file
SystemPath, files]); | 248 } |
277 }, | |
278 | 249 |
279 /** | 250 /** |
280 * @param {string} tabId | 251 * @param {string} tabId |
281 */ | 252 */ |
282 setInspectedTabId: function(tabId) | 253 setInspectedTabId(tabId) { |
283 { | 254 // Support for legacy front-ends (<M41). |
284 // Support for legacy front-ends (<M41). | 255 if (window['WebInspector']['setInspectedTabId']) |
285 if (window["WebInspector"]["setInspectedTabId"]) | 256 window['WebInspector']['setInspectedTabId'](tabId); |
286 window["WebInspector"]["setInspectedTabId"](tabId); | 257 else |
287 else | 258 this._dispatchOnInspectorFrontendAPI('setInspectedTabId', [tabId]); |
288 this._dispatchOnInspectorFrontendAPI("setInspectedTabId", [tabId]); | 259 } |
289 }, | |
290 | 260 |
291 /** | 261 /** |
292 * @param {boolean} useSoftMenu | 262 * @param {boolean} useSoftMenu |
293 */ | 263 */ |
294 setUseSoftMenu: function(useSoftMenu) | 264 setUseSoftMenu(useSoftMenu) { |
295 { | 265 this._dispatchOnInspectorFrontendAPI('setUseSoftMenu', [useSoftMenu]); |
296 this._dispatchOnInspectorFrontendAPI("setUseSoftMenu", [useSoftMenu]); | 266 } |
297 }, | |
298 | 267 |
299 /** | 268 /** |
300 * @param {string} panelName | 269 * @param {string} panelName |
301 */ | 270 */ |
302 showPanel: function(panelName) | 271 showPanel(panelName) { |
303 { | 272 this._dispatchOnInspectorFrontendAPI('showPanel', [panelName]); |
304 this._dispatchOnInspectorFrontendAPI("showPanel", [panelName]); | 273 } |
305 }, | |
306 | 274 |
307 /** | 275 /** |
308 * @param {number} id | 276 * @param {number} id |
309 * @param {string} chunk | 277 * @param {string} chunk |
310 * @param {boolean} encoded | 278 * @param {boolean} encoded |
311 */ | 279 */ |
312 streamWrite: function(id, chunk, encoded) | 280 streamWrite(id, chunk, encoded) { |
313 { | 281 this._dispatchOnInspectorFrontendAPI('streamWrite', [id, encoded ? this._d
ecodeBase64(chunk) : chunk]); |
314 this._dispatchOnInspectorFrontendAPI("streamWrite", [id, encoded ? this.
_decodeBase64(chunk) : chunk]); | 282 } |
315 }, | |
316 | 283 |
317 /** | 284 /** |
318 * @param {string} chunk | 285 * @param {string} chunk |
319 * @return {string} | 286 * @return {string} |
320 */ | 287 */ |
321 _decodeBase64: function(chunk) | 288 _decodeBase64(chunk) { |
322 { | 289 var request = new XMLHttpRequest(); |
323 var request = new XMLHttpRequest(); | 290 request.open('GET', 'data:text/plain;base64,' + chunk, false); |
324 request.open("GET", "data:text/plain;base64," + chunk, false); | 291 request.send(null); |
325 request.send(null); | 292 if (request.status === 200) { |
326 if (request.status === 200) { | 293 return request.responseText; |
327 return request.responseText; | 294 } else { |
328 } else { | 295 console.error('Error while decoding chunk in streamWrite'); |
329 console.error("Error while decoding chunk in streamWrite"); | 296 return ''; |
330 return ""; | 297 } |
331 } | 298 } |
332 } | 299 }; |
333 }; | 300 |
334 | 301 var DevToolsAPI = new DevToolsAPIImpl(); |
335 var DevToolsAPI = new DevToolsAPIImpl(); | 302 window.DevToolsAPI = DevToolsAPI; |
336 window.DevToolsAPI = DevToolsAPI; | 303 |
337 | 304 // InspectorFrontendHostImpl -------------------------------------------------
- |
338 // InspectorFrontendHostImpl -------------------------------------------------- | 305 |
339 | 306 /** |
340 /** | 307 * @implements {InspectorFrontendHostAPI} |
341 * @constructor | 308 * @unrestricted |
342 * @implements {InspectorFrontendHostAPI} | 309 */ |
343 */ | 310 var InspectorFrontendHostImpl = class { |
344 function InspectorFrontendHostImpl() | |
345 { | |
346 } | |
347 | |
348 InspectorFrontendHostImpl.prototype = { | |
349 /** | 311 /** |
350 * @override | 312 * @override |
351 * @return {string} | 313 * @return {string} |
352 */ | 314 */ |
353 getSelectionBackgroundColor: function() | 315 getSelectionBackgroundColor() { |
354 { | 316 return DevToolsHost.getSelectionBackgroundColor(); |
355 return DevToolsHost.getSelectionBackgroundColor(); | 317 } |
356 }, | |
357 | 318 |
358 /** | 319 /** |
359 * @override | 320 * @override |
360 * @return {string} | 321 * @return {string} |
361 */ | 322 */ |
362 getSelectionForegroundColor: function() | 323 getSelectionForegroundColor() { |
363 { | 324 return DevToolsHost.getSelectionForegroundColor(); |
364 return DevToolsHost.getSelectionForegroundColor(); | 325 } |
365 }, | |
366 | 326 |
367 /** | 327 /** |
368 * @override | 328 * @override |
369 * @return {string} | 329 * @return {string} |
370 */ | 330 */ |
371 platform: function() | 331 platform() { |
372 { | 332 return DevToolsHost.platform(); |
373 return DevToolsHost.platform(); | 333 } |
374 }, | 334 |
375 | 335 /** |
376 /** | 336 * @override |
377 * @override | 337 */ |
378 */ | 338 loadCompleted() { |
379 loadCompleted: function() | 339 DevToolsAPI.sendMessageToEmbedder('loadCompleted', [], null); |
380 { | 340 } |
381 DevToolsAPI.sendMessageToEmbedder("loadCompleted", [], null); | 341 |
382 }, | 342 /** |
383 | 343 * @override |
384 /** | 344 */ |
385 * @override | 345 bringToFront() { |
386 */ | 346 DevToolsAPI.sendMessageToEmbedder('bringToFront', [], null); |
387 bringToFront: function() | 347 } |
388 { | 348 |
389 DevToolsAPI.sendMessageToEmbedder("bringToFront", [], null); | 349 /** |
390 }, | 350 * @override |
391 | 351 */ |
392 /** | 352 closeWindow() { |
393 * @override | 353 DevToolsAPI.sendMessageToEmbedder('closeWindow', [], null); |
394 */ | 354 } |
395 closeWindow: function() | |
396 { | |
397 DevToolsAPI.sendMessageToEmbedder("closeWindow", [], null); | |
398 }, | |
399 | 355 |
400 /** | 356 /** |
401 * @override | 357 * @override |
402 * @param {boolean} isDocked | 358 * @param {boolean} isDocked |
403 * @param {function()} callback | 359 * @param {function()} callback |
404 */ | 360 */ |
405 setIsDocked: function(isDocked, callback) | 361 setIsDocked(isDocked, callback) { |
406 { | 362 DevToolsAPI.sendMessageToEmbedder('setIsDocked', [isDocked], callback); |
407 DevToolsAPI.sendMessageToEmbedder("setIsDocked", [isDocked], callback); | 363 } |
408 }, | |
409 | 364 |
410 /** | 365 /** |
411 * Requests inspected page to be placed atop of the inspector frontend with
specified bounds. | 366 * Requests inspected page to be placed atop of the inspector frontend with
specified bounds. |
412 * @override | 367 * @override |
413 * @param {{x: number, y: number, width: number, height: number}} bounds | 368 * @param {{x: number, y: number, width: number, height: number}} bounds |
414 */ | 369 */ |
415 setInspectedPageBounds: function(bounds) | 370 setInspectedPageBounds(bounds) { |
416 { | 371 DevToolsAPI.sendMessageToEmbedder('setInspectedPageBounds', [bounds], null
); |
417 DevToolsAPI.sendMessageToEmbedder("setInspectedPageBounds", [bounds], nu
ll); | 372 } |
418 }, | 373 |
419 | 374 /** |
420 /** | 375 * @override |
421 * @override | 376 */ |
422 */ | 377 inspectElementCompleted() { |
423 inspectElementCompleted: function() | 378 DevToolsAPI.sendMessageToEmbedder('inspectElementCompleted', [], null); |
424 { | 379 } |
425 DevToolsAPI.sendMessageToEmbedder("inspectElementCompleted", [], null); | 380 |
426 }, | 381 /** |
427 | 382 * @override |
428 /** | |
429 * @override | |
430 * @param {string} url | 383 * @param {string} url |
431 * @param {string} headers | 384 * @param {string} headers |
432 * @param {number} streamId | 385 * @param {number} streamId |
433 * @param {function(!InspectorFrontendHostAPI.LoadNetworkResourceResult)} ca
llback | 386 * @param {function(!InspectorFrontendHostAPI.LoadNetworkResourceResult)} ca
llback |
434 */ | 387 */ |
435 loadNetworkResource: function(url, headers, streamId, callback) | 388 loadNetworkResource(url, headers, streamId, callback) { |
436 { | 389 DevToolsAPI.sendMessageToEmbedder( |
437 DevToolsAPI.sendMessageToEmbedder("loadNetworkResource", [url, headers,
streamId], /** @type {function(?Object)} */ (callback)); | 390 'loadNetworkResource', [url, headers, streamId], /** @type {function(?
Object)} */ (callback)); |
438 }, | 391 } |
439 | 392 |
440 /** | 393 /** |
441 * @override | 394 * @override |
442 * @param {function(!Object<string, string>)} callback | 395 * @param {function(!Object<string, string>)} callback |
443 */ | 396 */ |
444 getPreferences: function(callback) | 397 getPreferences(callback) { |
445 { | 398 DevToolsAPI.sendMessageToEmbedder('getPreferences', [], /** @type {functio
n(?Object)} */ (callback)); |
446 DevToolsAPI.sendMessageToEmbedder("getPreferences", [], /** @type {funct
ion(?Object)} */ (callback)); | 399 } |
447 }, | |
448 | 400 |
449 /** | 401 /** |
450 * @override | 402 * @override |
451 * @param {string} name | 403 * @param {string} name |
452 * @param {string} value | 404 * @param {string} value |
453 */ | 405 */ |
454 setPreference: function(name, value) | 406 setPreference(name, value) { |
455 { | 407 DevToolsAPI.sendMessageToEmbedder('setPreference', [name, value], null); |
456 DevToolsAPI.sendMessageToEmbedder("setPreference", [name, value], null); | 408 } |
457 }, | |
458 | 409 |
459 /** | 410 /** |
460 * @override | 411 * @override |
461 * @param {string} name | 412 * @param {string} name |
462 */ | 413 */ |
463 removePreference: function(name) | 414 removePreference(name) { |
464 { | 415 DevToolsAPI.sendMessageToEmbedder('removePreference', [name], null); |
465 DevToolsAPI.sendMessageToEmbedder("removePreference", [name], null); | 416 } |
466 }, | |
467 | 417 |
468 /** | 418 /** |
469 * @override | 419 * @override |
470 */ | 420 */ |
471 clearPreferences: function() | 421 clearPreferences() { |
472 { | 422 DevToolsAPI.sendMessageToEmbedder('clearPreferences', [], null); |
473 DevToolsAPI.sendMessageToEmbedder("clearPreferences", [], null); | 423 } |
474 }, | |
475 | 424 |
476 /** | 425 /** |
477 * @override | 426 * @override |
478 * @param {string} origin | 427 * @param {string} origin |
479 * @param {string} script | 428 * @param {string} script |
480 */ | 429 */ |
481 setInjectedScriptForOrigin: function(origin, script) | 430 setInjectedScriptForOrigin(origin, script) { |
482 { | 431 DevToolsHost.setInjectedScriptForOrigin(origin, script); |
483 DevToolsHost.setInjectedScriptForOrigin(origin, script); | 432 } |
484 }, | |
485 | 433 |
486 /** | 434 /** |
487 * @override | 435 * @override |
488 * @param {string} url | 436 * @param {string} url |
489 */ | 437 */ |
490 inspectedURLChanged: function(url) | 438 inspectedURLChanged(url) { |
491 { | 439 DevToolsAPI.sendMessageToEmbedder('inspectedURLChanged', [url], null); |
492 DevToolsAPI.sendMessageToEmbedder("inspectedURLChanged", [url], null); | 440 } |
493 }, | |
494 | 441 |
495 /** | 442 /** |
496 * @override | 443 * @override |
497 * @param {string} text | 444 * @param {string} text |
498 */ | 445 */ |
499 copyText: function(text) | 446 copyText(text) { |
500 { | 447 DevToolsHost.copyText(text); |
501 DevToolsHost.copyText(text); | 448 } |
502 }, | |
503 | 449 |
504 /** | 450 /** |
505 * @override | 451 * @override |
506 * @param {string} url | 452 * @param {string} url |
507 */ | 453 */ |
508 openInNewTab: function(url) | 454 openInNewTab(url) { |
509 { | 455 DevToolsAPI.sendMessageToEmbedder('openInNewTab', [url], null); |
510 DevToolsAPI.sendMessageToEmbedder("openInNewTab", [url], null); | 456 } |
511 }, | |
512 | 457 |
513 /** | 458 /** |
514 * @override | 459 * @override |
515 * @param {string} url | 460 * @param {string} url |
516 * @param {string} content | 461 * @param {string} content |
517 * @param {boolean} forceSaveAs | 462 * @param {boolean} forceSaveAs |
518 */ | 463 */ |
519 save: function(url, content, forceSaveAs) | 464 save(url, content, forceSaveAs) { |
520 { | 465 DevToolsAPI.sendMessageToEmbedder('save', [url, content, forceSaveAs], nul
l); |
521 DevToolsAPI.sendMessageToEmbedder("save", [url, content, forceSaveAs], n
ull); | 466 } |
522 }, | |
523 | 467 |
524 /** | 468 /** |
525 * @override | 469 * @override |
526 * @param {string} url | 470 * @param {string} url |
527 * @param {string} content | 471 * @param {string} content |
528 */ | 472 */ |
529 append: function(url, content) | 473 append(url, content) { |
530 { | 474 DevToolsAPI.sendMessageToEmbedder('append', [url, content], null); |
531 DevToolsAPI.sendMessageToEmbedder("append", [url, content], null); | 475 } |
532 }, | |
533 | 476 |
534 /** | 477 /** |
535 * @override | 478 * @override |
536 * @param {string} message | 479 * @param {string} message |
537 */ | 480 */ |
538 sendMessageToBackend: function(message) | 481 sendMessageToBackend(message) { |
539 { | 482 DevToolsAPI.sendMessageToEmbedder('dispatchProtocolMessage', [message], nu
ll); |
540 DevToolsAPI.sendMessageToEmbedder("dispatchProtocolMessage", [message],
null); | 483 } |
541 }, | |
542 | 484 |
543 /** | 485 /** |
544 * @override | 486 * @override |
545 * @param {string} actionName | 487 * @param {string} actionName |
546 * @param {number} actionCode | 488 * @param {number} actionCode |
547 * @param {number} bucketSize | 489 * @param {number} bucketSize |
548 */ | 490 */ |
549 recordEnumeratedHistogram: function(actionName, actionCode, bucketSize) | 491 recordEnumeratedHistogram(actionName, actionCode, bucketSize) { |
550 { | 492 // Support for M49 frontend. |
551 // Support for M49 frontend. | 493 if (actionName === 'DevTools.DrawerShown') |
552 if (actionName === "DevTools.DrawerShown") | 494 return; |
553 return; | 495 DevToolsAPI.sendMessageToEmbedder('recordEnumeratedHistogram', [actionName
, actionCode, bucketSize], null); |
554 DevToolsAPI.sendMessageToEmbedder("recordEnumeratedHistogram", [actionNa
me, actionCode, bucketSize], null); | 496 } |
555 }, | |
556 | 497 |
557 /** | 498 /** |
558 * @override | 499 * @override |
559 */ | 500 */ |
560 requestFileSystems: function() | 501 requestFileSystems() { |
561 { | 502 DevToolsAPI.sendMessageToEmbedder('requestFileSystems', [], null); |
562 DevToolsAPI.sendMessageToEmbedder("requestFileSystems", [], null); | 503 } |
563 }, | |
564 | 504 |
565 /** | 505 /** |
566 * @override | 506 * @override |
567 * @param {string=} fileSystemPath | 507 * @param {string=} fileSystemPath |
568 */ | 508 */ |
569 addFileSystem: function(fileSystemPath) | 509 addFileSystem(fileSystemPath) { |
570 { | 510 DevToolsAPI.sendMessageToEmbedder('addFileSystem', [fileSystemPath || ''],
null); |
571 DevToolsAPI.sendMessageToEmbedder("addFileSystem", [fileSystemPath || ""
], null); | 511 } |
572 }, | |
573 | 512 |
574 /** | 513 /** |
575 * @override | 514 * @override |
576 * @param {string} fileSystemPath | 515 * @param {string} fileSystemPath |
577 */ | 516 */ |
578 removeFileSystem: function(fileSystemPath) | 517 removeFileSystem(fileSystemPath) { |
579 { | 518 DevToolsAPI.sendMessageToEmbedder('removeFileSystem', [fileSystemPath], nu
ll); |
580 DevToolsAPI.sendMessageToEmbedder("removeFileSystem", [fileSystemPath],
null); | 519 } |
581 }, | |
582 | 520 |
583 /** | 521 /** |
584 * @override | 522 * @override |
585 * @param {string} fileSystemId | 523 * @param {string} fileSystemId |
586 * @param {string} registeredName | 524 * @param {string} registeredName |
587 * @return {?DOMFileSystem} | 525 * @return {?DOMFileSystem} |
588 */ | 526 */ |
589 isolatedFileSystem: function(fileSystemId, registeredName) | 527 isolatedFileSystem(fileSystemId, registeredName) { |
590 { | 528 return DevToolsHost.isolatedFileSystem(fileSystemId, registeredName); |
591 return DevToolsHost.isolatedFileSystem(fileSystemId, registeredName); | 529 } |
592 }, | |
593 | 530 |
594 /** | 531 /** |
595 * @override | 532 * @override |
596 * @param {!FileSystem} fileSystem | 533 * @param {!FileSystem} fileSystem |
597 */ | 534 */ |
598 upgradeDraggedFileSystemPermissions: function(fileSystem) | 535 upgradeDraggedFileSystemPermissions(fileSystem) { |
599 { | 536 DevToolsHost.upgradeDraggedFileSystemPermissions(fileSystem); |
600 DevToolsHost.upgradeDraggedFileSystemPermissions(fileSystem); | 537 } |
601 }, | |
602 | 538 |
603 /** | 539 /** |
604 * @override | 540 * @override |
605 * @param {number} requestId | 541 * @param {number} requestId |
606 * @param {string} fileSystemPath | 542 * @param {string} fileSystemPath |
607 */ | 543 */ |
608 indexPath: function(requestId, fileSystemPath) | 544 indexPath(requestId, fileSystemPath) { |
609 { | 545 DevToolsAPI.sendMessageToEmbedder('indexPath', [requestId, fileSystemPath]
, null); |
610 DevToolsAPI.sendMessageToEmbedder("indexPath", [requestId, fileSystemPat
h], null); | 546 } |
611 }, | |
612 | 547 |
613 /** | 548 /** |
614 * @override | 549 * @override |
615 * @param {number} requestId | 550 * @param {number} requestId |
616 */ | 551 */ |
617 stopIndexing: function(requestId) | 552 stopIndexing(requestId) { |
618 { | 553 DevToolsAPI.sendMessageToEmbedder('stopIndexing', [requestId], null); |
619 DevToolsAPI.sendMessageToEmbedder("stopIndexing", [requestId], null); | 554 } |
620 }, | |
621 | 555 |
622 /** | 556 /** |
623 * @override | 557 * @override |
624 * @param {number} requestId | 558 * @param {number} requestId |
625 * @param {string} fileSystemPath | 559 * @param {string} fileSystemPath |
626 * @param {string} query | 560 * @param {string} query |
627 */ | 561 */ |
628 searchInPath: function(requestId, fileSystemPath, query) | 562 searchInPath(requestId, fileSystemPath, query) { |
629 { | 563 DevToolsAPI.sendMessageToEmbedder('searchInPath', [requestId, fileSystemPa
th, query], null); |
630 DevToolsAPI.sendMessageToEmbedder("searchInPath", [requestId, fileSystem
Path, query], null); | 564 } |
631 }, | |
632 | 565 |
633 /** | 566 /** |
634 * @override | 567 * @override |
635 * @return {number} | 568 * @return {number} |
636 */ | 569 */ |
637 zoomFactor: function() | 570 zoomFactor() { |
638 { | 571 return DevToolsHost.zoomFactor(); |
639 return DevToolsHost.zoomFactor(); | 572 } |
640 }, | |
641 | 573 |
642 /** | 574 /** |
643 * @override | 575 * @override |
644 */ | 576 */ |
645 zoomIn: function() | 577 zoomIn() { |
646 { | 578 DevToolsAPI.sendMessageToEmbedder('zoomIn', [], null); |
647 DevToolsAPI.sendMessageToEmbedder("zoomIn", [], null); | 579 } |
648 }, | |
649 | 580 |
650 /** | 581 /** |
651 * @override | 582 * @override |
652 */ | 583 */ |
653 zoomOut: function() | 584 zoomOut() { |
654 { | 585 DevToolsAPI.sendMessageToEmbedder('zoomOut', [], null); |
655 DevToolsAPI.sendMessageToEmbedder("zoomOut", [], null); | 586 } |
656 }, | |
657 | 587 |
658 /** | 588 /** |
659 * @override | 589 * @override |
660 */ | 590 */ |
661 resetZoom: function() | 591 resetZoom() { |
662 { | 592 DevToolsAPI.sendMessageToEmbedder('resetZoom', [], null); |
663 DevToolsAPI.sendMessageToEmbedder("resetZoom", [], null); | 593 } |
664 }, | |
665 | 594 |
666 /** | 595 /** |
667 * @override | 596 * @override |
668 * @param {string} shortcuts | 597 * @param {string} shortcuts |
669 */ | 598 */ |
670 setWhitelistedShortcuts: function(shortcuts) | 599 setWhitelistedShortcuts(shortcuts) { |
671 { | 600 DevToolsAPI.sendMessageToEmbedder('setWhitelistedShortcuts', [shortcuts],
null); |
672 DevToolsAPI.sendMessageToEmbedder("setWhitelistedShortcuts", [shortcuts]
, null); | 601 } |
673 }, | |
674 | 602 |
675 /** | 603 /** |
676 * @param {!Array<string>} certChain | 604 * @param {!Array<string>} certChain |
677 */ | 605 */ |
678 showCertificateViewer: function(certChain) | 606 showCertificateViewer(certChain) { |
679 { | 607 DevToolsAPI.sendMessageToEmbedder('showCertificateViewer', [JSON.stringify
(certChain)], null); |
680 DevToolsAPI.sendMessageToEmbedder("showCertificateViewer", [JSON.stringi
fy(certChain)], null); | 608 } |
681 }, | |
682 | 609 |
683 /** | 610 /** |
684 * @override | 611 * @override |
685 * @return {boolean} | 612 * @return {boolean} |
686 */ | 613 */ |
687 isUnderTest: function() | 614 isUnderTest() { |
688 { | 615 return DevToolsHost.isUnderTest(); |
689 return DevToolsHost.isUnderTest(); | 616 } |
690 }, | |
691 | 617 |
692 /** | 618 /** |
693 * @override | 619 * @override |
694 * @param {function()} callback | 620 * @param {function()} callback |
695 */ | 621 */ |
696 reattach: function(callback) | 622 reattach(callback) { |
697 { | 623 DevToolsAPI.sendMessageToEmbedder('reattach', [], callback); |
698 DevToolsAPI.sendMessageToEmbedder("reattach", [], callback); | 624 } |
699 }, | |
700 | 625 |
701 /** | 626 /** |
702 * @override | 627 * @override |
703 */ | 628 */ |
704 readyForTest: function() | 629 readyForTest() { |
705 { | 630 DevToolsAPI.sendMessageToEmbedder('readyForTest', [], null); |
706 DevToolsAPI.sendMessageToEmbedder("readyForTest", [], null); | 631 } |
707 }, | |
708 | 632 |
709 /** | 633 /** |
710 * @override | 634 * @override |
711 * @param {boolean} discoverUsbDevices | 635 * @param {boolean} discoverUsbDevices |
712 * @param {boolean} portForwardingEnabled | 636 * @param {boolean} portForwardingEnabled |
713 * @param {!Adb.PortForwardingConfig} portForwardingConfig | 637 * @param {!Adb.PortForwardingConfig} portForwardingConfig |
714 */ | 638 */ |
715 setDevicesDiscoveryConfig: function(discoverUsbDevices, portForwardingEnable
d, portForwardingConfig) | 639 setDevicesDiscoveryConfig(discoverUsbDevices, portForwardingEnabled, portFor
wardingConfig) { |
716 { | 640 DevToolsAPI.sendMessageToEmbedder( |
717 DevToolsAPI.sendMessageToEmbedder("setDevicesDiscoveryConfig", [discover
UsbDevices, portForwardingEnabled, JSON.stringify(portForwardingConfig)], null); | 641 'setDevicesDiscoveryConfig', |
718 }, | 642 [discoverUsbDevices, portForwardingEnabled, JSON.stringify(portForward
ingConfig)], null); |
| 643 } |
719 | 644 |
720 /** | 645 /** |
721 * @override | 646 * @override |
722 * @param {boolean} enabled | 647 * @param {boolean} enabled |
723 */ | 648 */ |
724 setDevicesUpdatesEnabled: function(enabled) | 649 setDevicesUpdatesEnabled(enabled) { |
725 { | 650 DevToolsAPI.sendMessageToEmbedder('setDevicesUpdatesEnabled', [enabled], n
ull); |
726 DevToolsAPI.sendMessageToEmbedder("setDevicesUpdatesEnabled", [enabled],
null); | 651 } |
727 }, | |
728 | 652 |
729 /** | 653 /** |
730 * @override | 654 * @override |
731 * @param {string} pageId | 655 * @param {string} pageId |
732 * @param {string} action | 656 * @param {string} action |
733 */ | 657 */ |
734 performActionOnRemotePage: function(pageId, action) | 658 performActionOnRemotePage(pageId, action) { |
735 { | 659 DevToolsAPI.sendMessageToEmbedder('performActionOnRemotePage', [pageId, ac
tion], null); |
736 DevToolsAPI.sendMessageToEmbedder("performActionOnRemotePage", [pageId,
action], null); | 660 } |
737 }, | |
738 | 661 |
739 /** | 662 /** |
740 * @override | 663 * @override |
741 * @param {string} browserId | 664 * @param {string} browserId |
742 * @param {string} url | 665 * @param {string} url |
743 */ | 666 */ |
744 openRemotePage: function(browserId, url) | 667 openRemotePage(browserId, url) { |
745 { | 668 DevToolsAPI.sendMessageToEmbedder('openRemotePage', [browserId, url], null
); |
746 DevToolsAPI.sendMessageToEmbedder("openRemotePage", [browserId, url], nu
ll); | 669 } |
747 }, | |
748 | 670 |
749 /** | 671 /** |
750 * @override | 672 * @override |
751 * @param {number} x | 673 * @param {number} x |
752 * @param {number} y | 674 * @param {number} y |
753 * @param {!Array.<!InspectorFrontendHostAPI.ContextMenuDescriptor>} items | 675 * @param {!Array.<!InspectorFrontendHostAPI.ContextMenuDescriptor>} items |
754 * @param {!Document} document | 676 * @param {!Document} document |
755 */ | 677 */ |
756 showContextMenuAtPoint: function(x, y, items, document) | 678 showContextMenuAtPoint(x, y, items, document) { |
757 { | 679 DevToolsHost.showContextMenuAtPoint(x, y, items, document); |
758 DevToolsHost.showContextMenuAtPoint(x, y, items, document); | 680 } |
759 }, | |
760 | 681 |
761 /** | 682 /** |
762 * @override | 683 * @override |
763 * @return {boolean} | 684 * @return {boolean} |
764 */ | 685 */ |
765 isHostedMode: function() | 686 isHostedMode() { |
766 { | 687 return DevToolsHost.isHostedMode(); |
767 return DevToolsHost.isHostedMode(); | 688 } |
768 }, | |
769 | 689 |
770 // Backward-compatible methods below this line -----------------------------
--------------- | 690 // Backward-compatible methods below this line -----------------------------
--------------- |
771 | 691 |
772 /** | 692 /** |
773 * Support for legacy front-ends (<M50). | 693 * Support for legacy front-ends (<M50). |
774 * @param {string} message | 694 * @param {string} message |
775 */ | 695 */ |
776 sendFrontendAPINotification: function(message) | 696 sendFrontendAPINotification(message) { |
777 { | 697 } |
778 }, | |
779 | 698 |
780 /** | 699 /** |
781 * Support for legacy front-ends (<M41). | 700 * Support for legacy front-ends (<M41). |
782 * @return {string} | 701 * @return {string} |
783 */ | 702 */ |
784 port: function() | 703 port() { |
785 { | 704 return 'unknown'; |
786 return "unknown"; | 705 } |
787 }, | |
788 | 706 |
789 /** | 707 /** |
790 * Support for legacy front-ends (<M38). | 708 * Support for legacy front-ends (<M38). |
791 * @param {number} zoomFactor | 709 * @param {number} zoomFactor |
792 */ | 710 */ |
793 setZoomFactor: function(zoomFactor) | 711 setZoomFactor(zoomFactor) { |
794 { | 712 } |
795 }, | |
796 | 713 |
797 /** | 714 /** |
798 * Support for legacy front-ends (<M34). | 715 * Support for legacy front-ends (<M34). |
799 */ | 716 */ |
800 sendMessageToEmbedder: function() | 717 sendMessageToEmbedder() { |
801 { | 718 } |
802 }, | |
803 | 719 |
804 /** | 720 /** |
805 * Support for legacy front-ends (<M34). | 721 * Support for legacy front-ends (<M34). |
806 * @param {string} dockSide | 722 * @param {string} dockSide |
807 */ | 723 */ |
808 requestSetDockSide: function(dockSide) | 724 requestSetDockSide(dockSide) { |
809 { | 725 DevToolsAPI.sendMessageToEmbedder('setIsDocked', [dockSide !== 'undocked']
, null); |
810 DevToolsAPI.sendMessageToEmbedder("setIsDocked", [dockSide !== "undocked
"], null); | 726 } |
811 }, | |
812 | 727 |
813 /** | 728 /** |
814 * Support for legacy front-ends (<M34). | 729 * Support for legacy front-ends (<M34). |
815 * @return {boolean} | 730 * @return {boolean} |
816 */ | 731 */ |
817 supportsFileSystems: function() | 732 supportsFileSystems() { |
818 { | 733 return true; |
819 return true; | 734 } |
820 }, | |
821 | 735 |
822 /** | 736 /** |
823 * Support for legacy front-ends (<M28). | 737 * Support for legacy front-ends (<M28). |
824 * @return {boolean} | 738 * @return {boolean} |
825 */ | 739 */ |
826 canInspectWorkers: function() | 740 canInspectWorkers() { |
827 { | 741 return true; |
828 return true; | 742 } |
829 }, | |
830 | 743 |
831 /** | 744 /** |
832 * Support for legacy front-ends (<M28). | 745 * Support for legacy front-ends (<M28). |
833 * @return {boolean} | 746 * @return {boolean} |
834 */ | 747 */ |
835 canSaveAs: function() | 748 canSaveAs() { |
836 { | 749 return true; |
837 return true; | 750 } |
838 }, | |
839 | 751 |
840 /** | 752 /** |
841 * Support for legacy front-ends (<M28). | 753 * Support for legacy front-ends (<M28). |
842 * @return {boolean} | 754 * @return {boolean} |
843 */ | 755 */ |
844 canSave: function() | 756 canSave() { |
845 { | 757 return true; |
846 return true; | 758 } |
847 }, | 759 |
848 | 760 /** |
849 /** | 761 * Support for legacy front-ends (<M28). |
850 * Support for legacy front-ends (<M28). | 762 */ |
851 */ | 763 loaded() { |
852 loaded: function() | 764 } |
853 { | |
854 }, | |
855 | 765 |
856 /** | 766 /** |
857 * Support for legacy front-ends (<M28). | 767 * Support for legacy front-ends (<M28). |
858 * @return {string} | 768 * @return {string} |
859 */ | 769 */ |
860 hiddenPanels: function() | 770 hiddenPanels() { |
861 { | 771 return ''; |
862 return ""; | 772 } |
863 }, | |
864 | 773 |
865 /** | 774 /** |
866 * Support for legacy front-ends (<M28). | 775 * Support for legacy front-ends (<M28). |
867 * @return {string} | 776 * @return {string} |
868 */ | 777 */ |
869 localizedStringsURL: function() | 778 localizedStringsURL() { |
870 { | 779 return ''; |
871 return ""; | 780 } |
872 }, | |
873 | 781 |
874 /** | 782 /** |
875 * Support for legacy front-ends (<M28). | 783 * Support for legacy front-ends (<M28). |
876 * @param {string} url | 784 * @param {string} url |
877 */ | 785 */ |
878 close: function(url) | 786 close(url) { |
879 { | 787 } |
880 }, | |
881 | 788 |
882 /** | 789 /** |
883 * Support for legacy front-ends (<M44). | 790 * Support for legacy front-ends (<M44). |
884 * @param {number} actionCode | 791 * @param {number} actionCode |
885 */ | 792 */ |
886 recordActionTaken: function(actionCode) | 793 recordActionTaken(actionCode) { |
887 { | 794 this.recordEnumeratedHistogram('DevTools.ActionTaken', actionCode, 100); |
888 this.recordEnumeratedHistogram("DevTools.ActionTaken", actionCode, 100); | 795 } |
889 }, | |
890 | 796 |
891 /** | 797 /** |
892 * Support for legacy front-ends (<M44). | 798 * Support for legacy front-ends (<M44). |
893 * @param {number} panelCode | 799 * @param {number} panelCode |
894 */ | 800 */ |
895 recordPanelShown: function(panelCode) | 801 recordPanelShown(panelCode) { |
896 { | 802 this.recordEnumeratedHistogram('DevTools.PanelShown', panelCode, 20); |
897 this.recordEnumeratedHistogram("DevTools.PanelShown", panelCode, 20); | 803 } |
898 } | 804 }; |
899 }; | 805 |
900 | 806 window.InspectorFrontendHost = new InspectorFrontendHostImpl(); |
901 window.InspectorFrontendHost = new InspectorFrontendHostImpl(); | 807 |
902 | 808 // DevToolsApp --------------------------------------------------------------- |
903 // DevToolsApp --------------------------------------------------------------- | 809 |
904 | 810 function installObjectObserve() { |
905 function installObjectObserve() | |
906 { | |
907 /** @type {!Array<string>} */ | 811 /** @type {!Array<string>} */ |
908 var properties = [ | 812 var properties = [ |
909 "advancedSearchConfig", "auditsPanelSplitViewState", "auditsSidebarWidth
", "blockedURLs", "breakpoints", "cacheDisabled", "colorFormat", "consoleHistory
", | 813 'advancedSearchConfig', |
910 "consoleTimestampsEnabled", "cpuProfilerView", "cssSourceMapsEnabled", "
currentDockState", "customColorPalette", "customDevicePresets", "customEmulatedD
eviceList", | 814 'auditsPanelSplitViewState', |
911 "customFormatters", "customUserAgent", "databaseTableViewVisibleColumns"
, "dataGrid-cookiesTable", "dataGrid-DOMStorageItemsView", "debuggerSidebarHidde
n", "disableDataSaverInfobar", | 815 'auditsSidebarWidth', |
912 "disablePausedStateOverlay", "domBreakpoints", "domWordWrap", "elementsP
anelSplitViewState", "elementsSidebarWidth", "emulation.deviceHeight", "emulatio
n.deviceModeValue", | 816 'blockedURLs', |
913 "emulation.deviceOrientationOverride", "emulation.deviceScale", "emulati
on.deviceScaleFactor", "emulation.deviceUA", "emulation.deviceWidth", "emulation
.geolocationOverride", | 817 'breakpoints', |
914 "emulation.showDeviceMode", "emulation.showRulers", "enableAsyncStackTra
ces", "eventListenerBreakpoints", "fileMappingEntries", "fileSystemMapping", "Fi
leSystemViewSidebarWidth", | 818 'cacheDisabled', |
915 "fileSystemViewSplitViewState", "filterBar-consoleView", "filterBar-netw
orkPanel", "filterBar-promisePane", "filterBar-timelinePanel", "frameViewerHideC
hromeWindow", | 819 'colorFormat', |
916 "heapSnapshotRetainersViewSize", "heapSnapshotSplitViewState", "hideColl
ectedPromises", "hideNetworkMessages", "highlightNodeOnHoverInOverlay", "highRes
olutionCpuProfiling", | 820 'consoleHistory', |
917 "inlineVariableValues", "Inspector.drawerSplitView", "Inspector.drawerSp
litViewState", "InspectorView.panelOrder", "InspectorView.screencastSplitView", | 821 'consoleTimestampsEnabled', |
918 "InspectorView.screencastSplitViewState", "InspectorView.splitView", "In
spectorView.splitViewState", "javaScriptDisabled", "jsSourceMapsEnabled", "lastA
ctivePanel", "lastDockState", | 822 'cpuProfilerView', |
919 "lastSelectedSourcesSidebarPaneTab", "lastSnippetEvaluationIndex", "laye
rDetailsSplitView", "layerDetailsSplitViewState", "layersPanelSplitViewState", "
layersShowInternalLayers", | 823 'cssSourceMapsEnabled', |
920 "layersSidebarWidth", "messageLevelFilters", "messageURLFilters", "monit
oringXHREnabled", "navigatorGroupByFolder", "navigatorHidden", "networkColorCode
ResourceTypes", | 824 'currentDockState', |
921 "networkConditions", "networkConditionsCustomProfiles", "networkHideData
URL", "networkLogColumnsVisibility", "networkLogLargeRows", "networkLogShowOverv
iew", | 825 'customColorPalette', |
922 "networkPanelSplitViewState", "networkRecordFilmStripSetting", "networkR
esourceTypeFilters", "networkShowPrimaryLoadWaterfall", "networkSidebarWidth", "
openLinkHandler", | 826 'customDevicePresets', |
923 "pauseOnCaughtException", "pauseOnExceptionEnabled", "preserveConsoleLog
", "prettyPrintInfobarDisabled", "previouslyViewedFiles", "profilesPanelSplitVie
wState", | 827 'customEmulatedDeviceList', |
924 "profilesSidebarWidth", "promiseStatusFilters", "recordAllocationStacks"
, "requestHeaderFilterSetting", "request-info-formData-category-expanded", | 828 'customFormatters', |
925 "request-info-general-category-expanded", "request-info-queryString-cate
gory-expanded", "request-info-requestHeaders-category-expanded", | 829 'customUserAgent', |
926 "request-info-requestPayload-category-expanded", "request-info-responseH
eaders-category-expanded", "resources", "resourcesLastSelectedItem", "resourcesP
anelSplitViewState", | 830 'databaseTableViewVisibleColumns', |
927 "resourcesSidebarWidth", "resourceViewTab", "savedURLs", "screencastEnab
led", "scriptsPanelNavigatorSidebarWidth", "searchInContentScripts", "selectedAu
ditCategories", | 831 'dataGrid-cookiesTable', |
928 "selectedColorPalette", "selectedProfileType", "shortcutPanelSwitch", "s
howAdvancedHeapSnapshotProperties", "showEventListenersForAncestors", "showFrame
owkrListeners", | 832 'dataGrid-DOMStorageItemsView', |
929 "showHeaSnapshotObjectsHiddenProperties", "showInheritedComputedStylePro
perties", "showMediaQueryInspector", "showNativeFunctionsInJSProfile", "showUASh
adowDOM", | 833 'debuggerSidebarHidden', |
930 "showWhitespacesInEditor", "sidebarPosition", "skipContentScripts", "ski
pStackFramesPattern", "sourceMapInfobarDisabled", "sourcesPanelDebuggerSidebarSp
litViewState", | 834 'disableDataSaverInfobar', |
931 "sourcesPanelNavigatorSplitViewState", "sourcesPanelSplitSidebarRatio",
"sourcesPanelSplitViewState", "sourcesSidebarWidth", "standardEmulatedDeviceList
", | 835 'disablePausedStateOverlay', |
932 "StylesPaneSplitRatio", "stylesPaneSplitViewState", "textEditorAutocompl
etion", "textEditorAutoDetectIndent", "textEditorBracketMatching", "textEditorIn
dent", | 836 'domBreakpoints', |
933 "timelineCaptureFilmStrip", "timelineCaptureLayersAndPictures", "timelin
eCaptureMemory", "timelineCaptureNetwork", "timeline-details", "timelineEnableJS
Sampling", | 837 'domWordWrap', |
934 "timelineOverviewMode", "timelinePanelDetailsSplitViewState", "timelineP
anelRecorsSplitViewState", "timelinePanelTimelineStackSplitViewState", "timeline
Perspective", | 838 'elementsPanelSplitViewState', |
935 "timeline-split", "timelineTreeGroupBy", "timeline-view", "timelineViewM
ode", "uiTheme", "watchExpressions", "WebInspector.Drawer.lastSelectedView", "We
bInspector.Drawer.showOnLoad", | 839 'elementsSidebarWidth', |
936 "workspaceExcludedFolders", "workspaceFolderExcludePattern", "workspaceI
nfobarDisabled", "workspaceMappingInfobarDisabled", "xhrBreakpoints"]; | 840 'emulation.deviceHeight', |
| 841 'emulation.deviceModeValue', |
| 842 'emulation.deviceOrientationOverride', |
| 843 'emulation.deviceScale', |
| 844 'emulation.deviceScaleFactor', |
| 845 'emulation.deviceUA', |
| 846 'emulation.deviceWidth', |
| 847 'emulation.geolocationOverride', |
| 848 'emulation.showDeviceMode', |
| 849 'emulation.showRulers', |
| 850 'enableAsyncStackTraces', |
| 851 'eventListenerBreakpoints', |
| 852 'fileMappingEntries', |
| 853 'fileSystemMapping', |
| 854 'FileSystemViewSidebarWidth', |
| 855 'fileSystemViewSplitViewState', |
| 856 'filterBar-consoleView', |
| 857 'filterBar-networkPanel', |
| 858 'filterBar-promisePane', |
| 859 'filterBar-timelinePanel', |
| 860 'frameViewerHideChromeWindow', |
| 861 'heapSnapshotRetainersViewSize', |
| 862 'heapSnapshotSplitViewState', |
| 863 'hideCollectedPromises', |
| 864 'hideNetworkMessages', |
| 865 'highlightNodeOnHoverInOverlay', |
| 866 'highResolutionCpuProfiling', |
| 867 'inlineVariableValues', |
| 868 'Inspector.drawerSplitView', |
| 869 'Inspector.drawerSplitViewState', |
| 870 'InspectorView.panelOrder', |
| 871 'InspectorView.screencastSplitView', |
| 872 'InspectorView.screencastSplitViewState', |
| 873 'InspectorView.splitView', |
| 874 'InspectorView.splitViewState', |
| 875 'javaScriptDisabled', |
| 876 'jsSourceMapsEnabled', |
| 877 'lastActivePanel', |
| 878 'lastDockState', |
| 879 'lastSelectedSourcesSidebarPaneTab', |
| 880 'lastSnippetEvaluationIndex', |
| 881 'layerDetailsSplitView', |
| 882 'layerDetailsSplitViewState', |
| 883 'layersPanelSplitViewState', |
| 884 'layersShowInternalLayers', |
| 885 'layersSidebarWidth', |
| 886 'messageLevelFilters', |
| 887 'messageURLFilters', |
| 888 'monitoringXHREnabled', |
| 889 'navigatorGroupByFolder', |
| 890 'navigatorHidden', |
| 891 'networkColorCodeResourceTypes', |
| 892 'networkConditions', |
| 893 'networkConditionsCustomProfiles', |
| 894 'networkHideDataURL', |
| 895 'networkLogColumnsVisibility', |
| 896 'networkLogLargeRows', |
| 897 'networkLogShowOverview', |
| 898 'networkPanelSplitViewState', |
| 899 'networkRecordFilmStripSetting', |
| 900 'networkResourceTypeFilters', |
| 901 'networkShowPrimaryLoadWaterfall', |
| 902 'networkSidebarWidth', |
| 903 'openLinkHandler', |
| 904 'pauseOnCaughtException', |
| 905 'pauseOnExceptionEnabled', |
| 906 'preserveConsoleLog', |
| 907 'prettyPrintInfobarDisabled', |
| 908 'previouslyViewedFiles', |
| 909 'profilesPanelSplitViewState', |
| 910 'profilesSidebarWidth', |
| 911 'promiseStatusFilters', |
| 912 'recordAllocationStacks', |
| 913 'requestHeaderFilterSetting', |
| 914 'request-info-formData-category-expanded', |
| 915 'request-info-general-category-expanded', |
| 916 'request-info-queryString-category-expanded', |
| 917 'request-info-requestHeaders-category-expanded', |
| 918 'request-info-requestPayload-category-expanded', |
| 919 'request-info-responseHeaders-category-expanded', |
| 920 'resources', |
| 921 'resourcesLastSelectedItem', |
| 922 'resourcesPanelSplitViewState', |
| 923 'resourcesSidebarWidth', |
| 924 'resourceViewTab', |
| 925 'savedURLs', |
| 926 'screencastEnabled', |
| 927 'scriptsPanelNavigatorSidebarWidth', |
| 928 'searchInContentScripts', |
| 929 'selectedAuditCategories', |
| 930 'selectedColorPalette', |
| 931 'selectedProfileType', |
| 932 'shortcutPanelSwitch', |
| 933 'showAdvancedHeapSnapshotProperties', |
| 934 'showEventListenersForAncestors', |
| 935 'showFrameowkrListeners', |
| 936 'showHeaSnapshotObjectsHiddenProperties', |
| 937 'showInheritedComputedStyleProperties', |
| 938 'showMediaQueryInspector', |
| 939 'showNativeFunctionsInJSProfile', |
| 940 'showUAShadowDOM', |
| 941 'showWhitespacesInEditor', |
| 942 'sidebarPosition', |
| 943 'skipContentScripts', |
| 944 'skipStackFramesPattern', |
| 945 'sourceMapInfobarDisabled', |
| 946 'sourcesPanelDebuggerSidebarSplitViewState', |
| 947 'sourcesPanelNavigatorSplitViewState', |
| 948 'sourcesPanelSplitSidebarRatio', |
| 949 'sourcesPanelSplitViewState', |
| 950 'sourcesSidebarWidth', |
| 951 'standardEmulatedDeviceList', |
| 952 'StylesPaneSplitRatio', |
| 953 'stylesPaneSplitViewState', |
| 954 'textEditorAutocompletion', |
| 955 'textEditorAutoDetectIndent', |
| 956 'textEditorBracketMatching', |
| 957 'textEditorIndent', |
| 958 'timelineCaptureFilmStrip', |
| 959 'timelineCaptureLayersAndPictures', |
| 960 'timelineCaptureMemory', |
| 961 'timelineCaptureNetwork', |
| 962 'timeline-details', |
| 963 'timelineEnableJSSampling', |
| 964 'timelineOverviewMode', |
| 965 'timelinePanelDetailsSplitViewState', |
| 966 'timelinePanelRecorsSplitViewState', |
| 967 'timelinePanelTimelineStackSplitViewState', |
| 968 'timelinePerspective', |
| 969 'timeline-split', |
| 970 'timelineTreeGroupBy', |
| 971 'timeline-view', |
| 972 'timelineViewMode', |
| 973 'uiTheme', |
| 974 'watchExpressions', |
| 975 'WebInspector.Drawer.lastSelectedView', |
| 976 'WebInspector.Drawer.showOnLoad', |
| 977 'workspaceExcludedFolders', |
| 978 'workspaceFolderExcludePattern', |
| 979 'workspaceInfobarDisabled', |
| 980 'workspaceMappingInfobarDisabled', |
| 981 'xhrBreakpoints' |
| 982 ]; |
937 | 983 |
938 /** | 984 /** |
939 * @this {!{_storage: Object, _name: string}} | 985 * @this {!{_storage: Object, _name: string}} |
940 */ | 986 */ |
941 function settingRemove() | 987 function settingRemove() { |
942 { | 988 this._storage[this._name] = undefined; |
943 this._storage[this._name] = undefined; | |
944 } | 989 } |
945 | 990 |
946 /** | 991 /** |
947 * @param {!Object} object | 992 * @param {!Object} object |
948 * @param {function(!Array<!{name: string}>)} observer | 993 * @param {function(!Array<!{name: string}>)} observer |
949 */ | 994 */ |
950 function objectObserve(object, observer) | 995 function objectObserve(object, observer) { |
951 { | 996 if (window['WebInspector']) { |
952 if (window["WebInspector"]) { | 997 var settingPrototype = /** @type {!Object} */ (window['WebInspector']['S
etting']['prototype']); |
953 var settingPrototype = /** @type {!Object} */ (window["WebInspector"
]["Setting"]["prototype"]); | 998 if (typeof settingPrototype['remove'] === 'function') |
954 if (typeof settingPrototype["remove"] === "function") | 999 settingPrototype['remove'] = settingRemove; |
955 settingPrototype["remove"] = settingRemove; | 1000 } |
| 1001 /** @type {!Set<string>} */ |
| 1002 var changedProperties = new Set(); |
| 1003 var scheduled = false; |
| 1004 |
| 1005 function scheduleObserver() { |
| 1006 if (scheduled) |
| 1007 return; |
| 1008 scheduled = true; |
| 1009 setImmediate(callObserver); |
| 1010 } |
| 1011 |
| 1012 function callObserver() { |
| 1013 scheduled = false; |
| 1014 var changes = /** @type {!Array<!{name: string}>} */ ([]); |
| 1015 changedProperties.forEach(function(name) { |
| 1016 changes.push({name: name}); |
| 1017 }); |
| 1018 changedProperties.clear(); |
| 1019 observer.call(null, changes); |
| 1020 } |
| 1021 |
| 1022 /** @type {!Map<string, *>} */ |
| 1023 var storage = new Map(); |
| 1024 |
| 1025 /** |
| 1026 * @param {string} property |
| 1027 */ |
| 1028 function defineProperty(property) { |
| 1029 if (property in object) { |
| 1030 storage.set(property, object[property]); |
| 1031 delete object[property]; |
956 } | 1032 } |
957 /** @type {!Set<string>} */ | 1033 |
958 var changedProperties = new Set(); | 1034 Object.defineProperty(object, property, { |
959 var scheduled = false; | 1035 /** |
960 | 1036 * @return {*} |
961 function scheduleObserver() | 1037 */ |
962 { | 1038 get: function() { |
963 if (scheduled) | 1039 return storage.get(property); |
964 return; | 1040 }, |
965 scheduled = true; | 1041 |
966 setImmediate(callObserver); | 1042 /** |
967 } | 1043 * @param {*} value |
968 | 1044 */ |
969 function callObserver() | 1045 set: function(value) { |
970 { | 1046 storage.set(property, value); |
971 scheduled = false; | 1047 changedProperties.add(property); |
972 var changes = /** @type {!Array<!{name: string}>} */ ([]); | 1048 scheduleObserver(); |
973 changedProperties.forEach(function(name) { changes.push({name: name}
); }); | 1049 } |
974 changedProperties.clear(); | 1050 }); |
975 observer.call(null, changes); | 1051 } |
976 } | 1052 |
977 | 1053 for (var i = 0; i < properties.length; ++i) |
978 /** @type {!Map<string, *>} */ | 1054 defineProperty(properties[i]); |
979 var storage = new Map(); | |
980 | |
981 /** | |
982 * @param {string} property | |
983 */ | |
984 function defineProperty(property) | |
985 { | |
986 if (property in object) { | |
987 storage.set(property, object[property]); | |
988 delete object[property]; | |
989 } | |
990 | |
991 Object.defineProperty(object, property, { | |
992 /** | |
993 * @return {*} | |
994 */ | |
995 get: function() | |
996 { | |
997 return storage.get(property); | |
998 }, | |
999 | |
1000 /** | |
1001 * @param {*} value | |
1002 */ | |
1003 set: function(value) | |
1004 { | |
1005 storage.set(property, value); | |
1006 changedProperties.add(property); | |
1007 scheduleObserver(); | |
1008 } | |
1009 }); | |
1010 } | |
1011 | |
1012 for (var i = 0; i < properties.length; ++i) | |
1013 defineProperty(properties[i]); | |
1014 } | 1055 } |
1015 | 1056 |
1016 window.Object.observe = objectObserve; | 1057 window.Object.observe = objectObserve; |
1017 } | 1058 } |
1018 | 1059 |
1019 /** @type {!Map<number, string>} */ | 1060 /** @type {!Map<number, string>} */ |
1020 var staticKeyIdentifiers = new Map([ | 1061 var staticKeyIdentifiers = new Map([ |
1021 [0x12, "Alt"], | 1062 [0x12, 'Alt'], |
1022 [0x11, "Control"], | 1063 [0x11, 'Control'], |
1023 [0x10, "Shift"], | 1064 [0x10, 'Shift'], |
1024 [0x14, "CapsLock"], | 1065 [0x14, 'CapsLock'], |
1025 [0x5b, "Win"], | 1066 [0x5b, 'Win'], |
1026 [0x5c, "Win"], | 1067 [0x5c, 'Win'], |
1027 [0x0c, "Clear"], | 1068 [0x0c, 'Clear'], |
1028 [0x28, "Down"], | 1069 [0x28, 'Down'], |
1029 [0x23, "End"], | 1070 [0x23, 'End'], |
1030 [0x0a, "Enter"], | 1071 [0x0a, 'Enter'], |
1031 [0x0d, "Enter"], | 1072 [0x0d, 'Enter'], |
1032 [0x2b, "Execute"], | 1073 [0x2b, 'Execute'], |
1033 [0x70, "F1"], | 1074 [0x70, 'F1'], |
1034 [0x71, "F2"], | 1075 [0x71, 'F2'], |
1035 [0x72, "F3"], | 1076 [0x72, 'F3'], |
1036 [0x73, "F4"], | 1077 [0x73, 'F4'], |
1037 [0x74, "F5"], | 1078 [0x74, 'F5'], |
1038 [0x75, "F6"], | 1079 [0x75, 'F6'], |
1039 [0x76, "F7"], | 1080 [0x76, 'F7'], |
1040 [0x77, "F8"], | 1081 [0x77, 'F8'], |
1041 [0x78, "F9"], | 1082 [0x78, 'F9'], |
1042 [0x79, "F10"], | 1083 [0x79, 'F10'], |
1043 [0x7a, "F11"], | 1084 [0x7a, 'F11'], |
1044 [0x7b, "F12"], | 1085 [0x7b, 'F12'], |
1045 [0x7c, "F13"], | 1086 [0x7c, 'F13'], |
1046 [0x7d, "F14"], | 1087 [0x7d, 'F14'], |
1047 [0x7e, "F15"], | 1088 [0x7e, 'F15'], |
1048 [0x7f, "F16"], | 1089 [0x7f, 'F16'], |
1049 [0x80, "F17"], | 1090 [0x80, 'F17'], |
1050 [0x81, "F18"], | 1091 [0x81, 'F18'], |
1051 [0x82, "F19"], | 1092 [0x82, 'F19'], |
1052 [0x83, "F20"], | 1093 [0x83, 'F20'], |
1053 [0x84, "F21"], | 1094 [0x84, 'F21'], |
1054 [0x85, "F22"], | 1095 [0x85, 'F22'], |
1055 [0x86, "F23"], | 1096 [0x86, 'F23'], |
1056 [0x87, "F24"], | 1097 [0x87, 'F24'], |
1057 [0x2f, "Help"], | 1098 [0x2f, 'Help'], |
1058 [0x24, "Home"], | 1099 [0x24, 'Home'], |
1059 [0x2d, "Insert"], | 1100 [0x2d, 'Insert'], |
1060 [0x25, "Left"], | 1101 [0x25, 'Left'], |
1061 [0x22, "PageDown"], | 1102 [0x22, 'PageDown'], |
1062 [0x21, "PageUp"], | 1103 [0x21, 'PageUp'], |
1063 [0x13, "Pause"], | 1104 [0x13, 'Pause'], |
1064 [0x2c, "PrintScreen"], | 1105 [0x2c, 'PrintScreen'], |
1065 [0x27, "Right"], | 1106 [0x27, 'Right'], |
1066 [0x91, "Scroll"], | 1107 [0x91, 'Scroll'], |
1067 [0x29, "Select"], | 1108 [0x29, 'Select'], |
1068 [0x26, "Up"], | 1109 [0x26, 'Up'], |
1069 [0x2e, "U+007F"], // Standard says that DEL becomes U+007F. | 1110 [0x2e, 'U+007F'], // Standard says that DEL becomes U+007F. |
1070 [0xb0, "MediaNextTrack"], | 1111 [0xb0, 'MediaNextTrack'], |
1071 [0xb1, "MediaPreviousTrack"], | 1112 [0xb1, 'MediaPreviousTrack'], |
1072 [0xb2, "MediaStop"], | 1113 [0xb2, 'MediaStop'], |
1073 [0xb3, "MediaPlayPause"], | 1114 [0xb3, 'MediaPlayPause'], |
1074 [0xad, "VolumeMute"], | 1115 [0xad, 'VolumeMute'], |
1075 [0xae, "VolumeDown"], | 1116 [0xae, 'VolumeDown'], |
1076 [0xaf, "VolumeUp"], | 1117 [0xaf, 'VolumeUp'], |
1077 ]); | 1118 ]); |
1078 | 1119 |
1079 /** | 1120 /** |
1080 * @param {number} keyCode | 1121 * @param {number} keyCode |
1081 * @return {string} | 1122 * @return {string} |
1082 */ | 1123 */ |
1083 function keyCodeToKeyIdentifier(keyCode) | 1124 function keyCodeToKeyIdentifier(keyCode) { |
1084 { | |
1085 var result = staticKeyIdentifiers.get(keyCode); | 1125 var result = staticKeyIdentifiers.get(keyCode); |
1086 if (result !== undefined) | 1126 if (result !== undefined) |
1087 return result; | 1127 return result; |
1088 result = "U+"; | 1128 result = 'U+'; |
1089 var hexString = keyCode.toString(16).toUpperCase(); | 1129 var hexString = keyCode.toString(16).toUpperCase(); |
1090 for (var i = hexString.length; i < 4; ++i) | 1130 for (var i = hexString.length; i < 4; ++i) |
1091 result += "0"; | 1131 result += '0'; |
1092 result += hexString; | 1132 result += hexString; |
1093 return result; | 1133 return result; |
1094 } | 1134 } |
1095 | 1135 |
1096 function installBackwardsCompatibility() | 1136 function installBackwardsCompatibility() { |
1097 { | 1137 if (window.location.search.indexOf('remoteFrontend') === -1) |
1098 if (window.location.search.indexOf("remoteFrontend") === -1) | 1138 return; |
1099 return; | |
1100 | 1139 |
1101 // Support for legacy (<M53) frontends. | 1140 // Support for legacy (<M53) frontends. |
1102 if (!window.KeyboardEvent.prototype.hasOwnProperty("keyIdentifier")) { | 1141 if (!window.KeyboardEvent.prototype.hasOwnProperty('keyIdentifier')) { |
1103 Object.defineProperty(window.KeyboardEvent.prototype, "keyIdentifier", { | 1142 Object.defineProperty(window.KeyboardEvent.prototype, 'keyIdentifier', { |
1104 /** | 1143 /** |
1105 * @return {string} | 1144 * @return {string} |
1106 * @this {KeyboardEvent} | 1145 * @this {KeyboardEvent} |
1107 */ | 1146 */ |
1108 get: function() | 1147 get: function() { |
1109 { | 1148 return keyCodeToKeyIdentifier(this.keyCode); |
1110 return keyCodeToKeyIdentifier(this.keyCode); | 1149 } |
1111 } | 1150 }); |
1112 }); | |
1113 } | 1151 } |
1114 | 1152 |
1115 // Support for legacy (<M50) frontends. | 1153 // Support for legacy (<M50) frontends. |
1116 installObjectObserve(); | 1154 installObjectObserve(); |
1117 | 1155 |
1118 /** | 1156 /** |
1119 * @param {string} property | 1157 * @param {string} property |
1120 * @return {!CSSValue|null} | 1158 * @return {!CSSValue|null} |
1121 * @this {CSSStyleDeclaration} | 1159 * @this {CSSStyleDeclaration} |
1122 */ | 1160 */ |
1123 function getValue(property) | 1161 function getValue(property) { |
1124 { | 1162 // Note that |property| comes from another context, so we can't use === he
re. |
1125 // Note that |property| comes from another context, so we can't use ===
here. | 1163 // eslint-disable-next-line eqeqeq |
1126 // eslint-disable-next-line eqeqeq | 1164 if (property == 'padding-left') { |
1127 if (property == "padding-left") { | 1165 return /** @type {!CSSValue} */ ({ |
1128 return /** @type {!CSSValue} */ ({ | 1166 /** |
1129 /** | 1167 * @return {number} |
1130 * @return {number} | 1168 * @this {!{__paddingLeft: number}} |
1131 * @this {!{__paddingLeft: number}} | 1169 */ |
1132 */ | 1170 getFloatValue: function() { |
1133 getFloatValue: function() { return this.__paddingLeft; }, | 1171 return this.__paddingLeft; |
1134 __paddingLeft: parseFloat(this.paddingLeft) | 1172 }, |
1135 }); | 1173 __paddingLeft: parseFloat(this.paddingLeft) |
1136 } | 1174 }); |
1137 throw new Error("getPropertyCSSValue is undefined"); | 1175 } |
| 1176 throw new Error('getPropertyCSSValue is undefined'); |
1138 } | 1177 } |
1139 | 1178 |
1140 // Support for legacy (<M41) frontends. | 1179 // Support for legacy (<M41) frontends. |
1141 window.CSSStyleDeclaration.prototype.getPropertyCSSValue = getValue; | 1180 window.CSSStyleDeclaration.prototype.getPropertyCSSValue = getValue; |
1142 | 1181 |
1143 function CSSPrimitiveValue() | 1182 function CSSPrimitiveValue() { |
1144 { | |
1145 } | 1183 } |
1146 CSSPrimitiveValue.CSS_PX = 5; | 1184 CSSPrimitiveValue.CSS_PX = 5; |
1147 window.CSSPrimitiveValue = CSSPrimitiveValue; | 1185 window.CSSPrimitiveValue = CSSPrimitiveValue; |
1148 | 1186 |
1149 // Support for legacy (<M44) frontends. | 1187 // Support for legacy (<M44) frontends. |
1150 var styleElement = window.document.createElement("style"); | 1188 var styleElement = window.document.createElement('style'); |
1151 styleElement.type = "text/css"; | 1189 styleElement.type = 'text/css'; |
1152 styleElement.textContent = "html /deep/ * { min-width: 0; min-height: 0; }"; | 1190 styleElement.textContent = 'html /deep/ * { min-width: 0; min-height: 0; }'; |
1153 | 1191 |
1154 // Support for quirky border-image behavior (<M51), see: | 1192 // Support for quirky border-image behavior (<M51), see: |
1155 // https://bugs.chromium.org/p/chromium/issues/detail?id=559258 | 1193 // https://bugs.chromium.org/p/chromium/issues/detail?id=559258 |
1156 styleElement.textContent += "\nhtml /deep/ .cm-breakpoint .CodeMirror-linenu
mber { border-style: solid !important; }"; | 1194 styleElement.textContent += |
1157 styleElement.textContent += "\nhtml /deep/ .cm-breakpoint.cm-breakpoint-cond
itional .CodeMirror-linenumber { border-style: solid !important; }"; | 1195 '\nhtml /deep/ .cm-breakpoint .CodeMirror-linenumber { border-style: sol
id !important; }'; |
| 1196 styleElement.textContent += |
| 1197 '\nhtml /deep/ .cm-breakpoint.cm-breakpoint-conditional .CodeMirror-line
number { border-style: solid !important; }'; |
1158 window.document.head.appendChild(styleElement); | 1198 window.document.head.appendChild(styleElement); |
1159 | 1199 |
1160 // Support for legacy (<M49) frontends. | 1200 // Support for legacy (<M49) frontends. |
1161 Event.prototype.deepPath = undefined; | 1201 Event.prototype.deepPath = undefined; |
1162 | 1202 |
1163 // Support for legacy (<53) frontends. | 1203 // Support for legacy (<53) frontends. |
1164 window.FileError = /** @type {!function (new: FileError) : ?} */ ({ | 1204 window.FileError = /** @type {!function (new: FileError) : ?} */ ({ |
1165 NOT_FOUND_ERR: DOMException.NOT_FOUND_ERR, | 1205 NOT_FOUND_ERR: DOMException.NOT_FOUND_ERR, |
1166 ABORT_ERR: DOMException.ABORT_ERR, | 1206 ABORT_ERR: DOMException.ABORT_ERR, |
1167 INVALID_MODIFICATION_ERR: DOMException.INVALID_MODIFICATION_ERR, | 1207 INVALID_MODIFICATION_ERR: DOMException.INVALID_MODIFICATION_ERR, |
1168 NOT_READABLE_ERR: 0 // No matching DOMException, so code will be 0. | 1208 NOT_READABLE_ERR: 0 // No matching DOMException, so code will be 0. |
1169 }); | 1209 }); |
1170 } | 1210 } |
1171 | 1211 |
1172 function windowLoaded() | 1212 function windowLoaded() { |
1173 { | 1213 window.removeEventListener('DOMContentLoaded', windowLoaded, false); |
1174 window.removeEventListener("DOMContentLoaded", windowLoaded, false); | |
1175 installBackwardsCompatibility(); | 1214 installBackwardsCompatibility(); |
1176 } | 1215 } |
1177 | 1216 |
1178 if (window.document.head && (window.document.readyState === "complete" || window
.document.readyState === "interactive")) | 1217 if (window.document.head && |
| 1218 (window.document.readyState === 'complete' || window.document.readyState =
== 'interactive')) |
1179 installBackwardsCompatibility(); | 1219 installBackwardsCompatibility(); |
1180 else | 1220 else |
1181 window.addEventListener("DOMContentLoaded", windowLoaded, false); | 1221 window.addEventListener('DOMContentLoaded', windowLoaded, false); |
1182 | 1222 |
1183 /** @type {(!function(string, boolean=):boolean)|undefined} */ | 1223 /** @type {(!function(string, boolean=):boolean)|undefined} */ |
1184 DOMTokenList.prototype.__originalDOMTokenListToggle; | 1224 DOMTokenList.prototype.__originalDOMTokenListToggle; |
1185 | 1225 |
1186 if (!DOMTokenList.prototype.__originalDOMTokenListToggle) { | 1226 if (!DOMTokenList.prototype.__originalDOMTokenListToggle) { |
1187 DOMTokenList.prototype.__originalDOMTokenListToggle = DOMTokenList.prototype
.toggle; | 1227 DOMTokenList.prototype.__originalDOMTokenListToggle = DOMTokenList.prototype
.toggle; |
1188 /** | 1228 /** |
1189 * @param {string} token | 1229 * @param {string} token |
1190 * @param {boolean=} force | 1230 * @param {boolean=} force |
1191 * @return {boolean} | 1231 * @return {boolean} |
1192 */ | 1232 */ |
1193 DOMTokenList.prototype.toggle = function(token, force) | 1233 DOMTokenList.prototype.toggle = function(token, force) { |
1194 { | 1234 if (arguments.length === 1) |
1195 if (arguments.length === 1) | 1235 force = !this.contains(token); |
1196 force = !this.contains(token); | 1236 return this.__originalDOMTokenListToggle(token, !!force); |
1197 return this.__originalDOMTokenListToggle(token, !!force); | |
1198 }; | 1237 }; |
1199 } | 1238 } |
1200 | 1239 |
1201 })(window); | 1240 })(window); |
OLD | NEW |