Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
|
Jacob
2013/12/05 22:56:12
2012->2013
| |
| 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 |
| 11 * copyright notice, this list of conditions and the following disclaimer | 11 * copyright notice, this list of conditions and the following disclaimer |
| 12 * in the documentation and/or other materials provided with the | 12 * in the documentation and/or other materials provided with the |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 33 */ | |
| 34 WebInspector.DartDispatcher = function(iframe) | |
| 35 { | |
| 36 this._iframe = iframe; | |
| 37 } | |
| 38 | |
| 39 WebInspector.DartDispatcher.prototype = { | |
| 40 // FIXME this one isn't hooked up on the other side. is it needed? | |
|
Jacob
2013/12/05 22:56:12
remove FIXME. it is out of date
Cutch
2013/12/05 23:09:37
Done.
| |
| 41 observatoryData: function(id, data) | |
| 42 { | |
| 43 window.console.log("XXX payload is:", id, data); | |
|
Jacob
2013/12/05 22:56:12
remove XXX log message.
Cutch
2013/12/05 23:09:37
Done.
| |
| 44 this._iframe.contentWindow.postMessage({ | |
| 45 id: id, | |
| 46 error: null, | |
| 47 data: data, | |
| 48 name: "observatoryData" | |
| 49 }, "*"); | |
| 50 }, | |
| 51 | |
| 52 } | |
| 53 | |
| 54 /** | |
| 55 * @constructor | |
| 33 * @extends {WebInspector.View} | 56 * @extends {WebInspector.View} |
| 34 * @param {string} id | 57 * @param {string} id |
| 35 * @param {string} src | 58 * @param {string} src |
| 36 * @param {string} className | 59 * @param {string} className |
| 37 */ | 60 */ |
| 38 WebInspector.ExtensionView = function(id, src, className) | 61 WebInspector.DartView = function(id, src, className) |
| 39 { | 62 { |
| 40 WebInspector.View.call(this); | 63 WebInspector.View.call(this); |
| 41 this.element.className = "fill"; | 64 this.element.className = "fill"; |
| 42 | 65 |
| 43 this._id = id; | 66 this._id = id; |
| 44 this._iframe = document.createElement("iframe"); | 67 this._iframe = document.createElement("iframe"); |
| 45 this._iframe.addEventListener("load", this._onLoad.bind(this), false); | 68 this._iframe.addEventListener("load", this._onLoad.bind(this), false); |
| 46 this._iframe.src = src; | 69 this._iframe.src = src; |
| 47 this._iframe.className = className; | 70 this._iframe.className = className; |
| 48 this.setDefaultFocusedElement(this._iframe); | 71 this.setDefaultFocusedElement(this._iframe); |
| 49 | 72 |
| 73 window.addEventListener('message', this._onMessage.bind(this), false); | |
| 74 InspectorBackend.registerDartDispatcher(new WebInspector.DartDispatcher(this ._iframe)); | |
| 50 this.element.appendChild(this._iframe); | 75 this.element.appendChild(this._iframe); |
| 51 } | 76 } |
| 52 | 77 |
| 53 WebInspector.ExtensionView.prototype = { | 78 |
| 79 WebInspector.DartView.prototype = { | |
| 54 wasShown: function() | 80 wasShown: function() |
| 55 { | 81 { |
| 82 DartAgent | |
| 83 /* | |
| 56 if (typeof this._frameIndex === "number") | 84 if (typeof this._frameIndex === "number") |
| 57 WebInspector.extensionServer.notifyViewShown(this._id, this._frameIn dex); | 85 // WebInspector.extensionServer.notifyViewShown(this._id, this._fram eIndex); |
| 86 // XXX | |
| 87 */ | |
| 58 }, | 88 }, |
| 59 | 89 |
| 60 willHide: function() | 90 willHide: function() |
| 61 { | 91 { |
| 92 /* | |
| 62 if (typeof this._frameIndex === "number") | 93 if (typeof this._frameIndex === "number") |
| 63 WebInspector.extensionServer.notifyViewHidden(this._id); | 94 // WebInspector.extensionServer.notifyViewHidden(this._id); |
| 95 */ | |
| 96 }, | |
| 97 | |
| 98 _onMessage: function(e) | |
| 99 { | |
| 100 var data = JSON.parse(e.data); | |
| 101 if (e.source == this._iframe.contentWindow && data.method == "observator yQuery") { | |
| 102 var iframeContentWindow = this._iframe.contentWindow; | |
| 103 var id = data.id; | |
| 104 DartAgent.observatoryQuery(id, data.query); | |
| 105 } else { | |
| 106 window.console.log("XXX ignoring spurious event:", e); | |
| 107 } | |
| 64 }, | 108 }, |
| 65 | 109 |
| 66 _onLoad: function() | 110 _onLoad: function() |
| 67 { | 111 { |
| 68 var frames = /** @type {Window} */ (window.frames); | 112 var frames = /** @type {Window} */ (window.frames); |
| 69 this._frameIndex = Array.prototype.indexOf.call(frames, this._iframe.con tentWindow); | 113 this._frameIndex = Array.prototype.indexOf.call(frames, this._iframe.con tentWindow); |
| 114 /* | |
| 70 if (this.isShowing()) | 115 if (this.isShowing()) |
| 71 WebInspector.extensionServer.notifyViewShown(this._id, this._frameIn dex); | 116 // WebInspector.extensionServer.notifyViewShown(this._id, this._fram eIndex); |
| 117 */ | |
| 72 }, | 118 }, |
| 73 | 119 |
| 74 __proto__: WebInspector.View.prototype | 120 __proto__: WebInspector.View.prototype |
| 75 } | |
| 76 | |
| 77 /** | |
| 78 * @constructor | |
| 79 * @extends {WebInspector.View} | |
| 80 * @param {string} id | |
| 81 */ | |
| 82 WebInspector.ExtensionNotifierView = function(id) | |
| 83 { | |
| 84 WebInspector.View.call(this); | |
| 85 | |
| 86 this._id = id; | |
| 87 } | |
| 88 | |
| 89 WebInspector.ExtensionNotifierView.prototype = { | |
| 90 wasShown: function() | |
| 91 { | |
| 92 WebInspector.extensionServer.notifyViewShown(this._id); | |
| 93 }, | |
| 94 | |
| 95 willHide: function() | |
| 96 { | |
| 97 WebInspector.extensionServer.notifyViewHidden(this._id); | |
| 98 }, | |
| 99 | |
| 100 __proto__: WebInspector.View.prototype | |
| 101 } | 121 } |
| OLD | NEW |