OLD | NEW |
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 * @interface | 6 * @interface |
7 */ | 7 */ |
8 WebInspector.View = function() | 8 WebInspector.View = function() |
9 { | 9 { |
10 } | 10 } |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 for (var extension of self.runtime.extensions("view")) { | 296 for (var extension of self.runtime.extensions("view")) { |
297 var descriptor = extension.descriptor(); | 297 var descriptor = extension.descriptor(); |
298 this._views.set(descriptor["id"], new WebInspector.ProvidedView(extensio
n)); | 298 this._views.set(descriptor["id"], new WebInspector.ProvidedView(extensio
n)); |
299 this._locationNameByViewId.set(descriptor["id"], descriptor["location"])
; | 299 this._locationNameByViewId.set(descriptor["id"], descriptor["location"])
; |
300 } | 300 } |
301 } | 301 } |
302 | 302 |
303 WebInspector.ViewManager.prototype = { | 303 WebInspector.ViewManager.prototype = { |
304 /** | 304 /** |
305 * @param {!WebInspector.Widget} widget | 305 * @param {!WebInspector.Widget} widget |
| 306 * @return {!Promise} |
306 */ | 307 */ |
307 revealViewWithWidget: function(widget) | 308 revealViewWithWidget: function(widget) |
308 { | 309 { |
309 var view = widget[WebInspector.View._symbol]; | 310 var view = widget[WebInspector.View._symbol]; |
310 if (view) | 311 if (view) |
311 this.revealView(view); | 312 return this.revealView(view); |
| 313 return Promise.resolve(); |
312 }, | 314 }, |
313 | 315 |
314 /** | 316 /** |
315 * @param {!WebInspector.View} view | 317 * @param {!WebInspector.View} view |
316 * @return {!Promise} | 318 * @return {!Promise} |
317 */ | 319 */ |
318 revealView: function(view) | 320 revealView: function(view) |
319 { | 321 { |
320 var location = /** @type {?WebInspector.ViewManager._Location} */ (view[
WebInspector.ViewManager._Location.symbol]); | 322 var location = /** @type {?WebInspector.ViewManager._Location} */ (view[
WebInspector.ViewManager._Location.symbol]); |
321 if (!location) | 323 if (!location) |
322 return Promise.resolve(); | 324 return Promise.resolve(); |
323 location._reveal(); | 325 location._reveal(); |
324 return location.showView(view); | 326 return location.showView(view); |
325 }, | 327 }, |
326 | 328 |
327 /** | 329 /** |
328 * @param {string} viewId | 330 * @param {string} viewId |
| 331 * @return {?WebInspector.View} |
| 332 */ |
| 333 view: function(viewId) |
| 334 { |
| 335 return this._views.get(viewId); |
| 336 }, |
| 337 |
| 338 /** |
| 339 * @param {string} viewId |
329 * @return {!Promise} | 340 * @return {!Promise} |
330 */ | 341 */ |
331 showView: function(viewId) | 342 showView: function(viewId) |
332 { | 343 { |
333 var view = this._views.get(viewId); | 344 var view = this._views.get(viewId); |
334 if (!view) { | 345 if (!view) { |
335 console.error("Could not find view for id: '" + viewId + "' " + new
Error().stack); | 346 console.error("Could not find view for id: '" + viewId + "' " + new
Error().stack); |
336 return Promise.resolve(); | 347 return Promise.resolve(); |
337 } | 348 } |
338 var locationName = this._locationNameByViewId.get(viewId); | 349 var locationName = this._locationNameByViewId.get(viewId); |
339 if (locationName === "drawer-view") | 350 if (locationName === "drawer-view") |
340 WebInspector.userMetrics.drawerShown(viewId); | 351 WebInspector.userMetrics.drawerShown(viewId); |
341 | 352 |
342 return this._resolveLocation(locationName).then(location => { | 353 return this._resolveLocation(locationName).then(location => { |
343 if (!location) | 354 if (!location) |
344 return; | 355 throw new Error("Could not resolve location for view: " + viewId
); |
345 location._reveal(); | 356 location._reveal(); |
346 return location.showView(view); | 357 return location.showView(view); |
347 }); | 358 }); |
348 }, | 359 }, |
349 | 360 |
350 /** | 361 /** |
351 * @param {string=} location | 362 * @param {string=} location |
352 * @return {!Promise<?WebInspector.ViewManager._Location>} | 363 * @return {!Promise<?WebInspector.ViewManager._Location>} |
353 */ | 364 */ |
354 _resolveLocation: function(location) | 365 _resolveLocation: function(location) |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 this.appendView(view); | 817 this.appendView(view); |
807 }, | 818 }, |
808 | 819 |
809 __proto__: WebInspector.ViewManager._Location.prototype | 820 __proto__: WebInspector.ViewManager._Location.prototype |
810 } | 821 } |
811 | 822 |
812 /** | 823 /** |
813 * @type {!WebInspector.ViewManager} | 824 * @type {!WebInspector.ViewManager} |
814 */ | 825 */ |
815 WebInspector.viewManager; | 826 WebInspector.viewManager; |
OLD | NEW |