OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
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 |
(...skipping 12 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 * @extends {WebInspector.SDKObject} | 33 * @extends {WebInspector.SDKModel} |
34 * @param {!WebInspector.Target} target | 34 * @param {!WebInspector.Target} target |
35 */ | 35 */ |
36 WebInspector.ConsoleModel = function(target) | 36 WebInspector.ConsoleModel = function(target) |
37 { | 37 { |
38 WebInspector.SDKObject.call(this, target); | 38 WebInspector.SDKModel.call(this, WebInspector.ConsoleModel, target); |
39 | 39 |
40 /** @type {!Array.<!WebInspector.ConsoleMessage>} */ | 40 /** @type {!Array.<!WebInspector.ConsoleMessage>} */ |
41 this._messages = []; | 41 this._messages = []; |
42 this.warnings = 0; | 42 this.warnings = 0; |
43 this.errors = 0; | 43 this.errors = 0; |
44 this._consoleAgent = target.consoleAgent(); | 44 this._consoleAgent = target.consoleAgent(); |
45 target.registerConsoleDispatcher(new WebInspector.ConsoleDispatcher(this)); | 45 target.registerConsoleDispatcher(new WebInspector.ConsoleDispatcher(this)); |
46 this._enableAgent(); | 46 this._enableAgent(); |
47 } | 47 } |
48 | 48 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 }, | 123 }, |
124 | 124 |
125 _messagesCleared: function() | 125 _messagesCleared: function() |
126 { | 126 { |
127 this._messages = []; | 127 this._messages = []; |
128 this.errors = 0; | 128 this.errors = 0; |
129 this.warnings = 0; | 129 this.warnings = 0; |
130 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.ConsoleCl
eared); | 130 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.ConsoleCl
eared); |
131 }, | 131 }, |
132 | 132 |
133 __proto__: WebInspector.SDKObject.prototype | 133 __proto__: WebInspector.SDKModel.prototype |
134 } | 134 } |
135 | 135 |
136 /** | 136 /** |
137 * @param {!WebInspector.ExecutionContext} executionContext | 137 * @param {!WebInspector.ExecutionContext} executionContext |
138 * @param {string} text | 138 * @param {string} text |
139 * @param {boolean=} useCommandLineAPI | 139 * @param {boolean=} useCommandLineAPI |
140 */ | 140 */ |
141 WebInspector.ConsoleModel.evaluateCommandInConsole = function(executionContext,
text, useCommandLineAPI) | 141 WebInspector.ConsoleModel.evaluateCommandInConsole = function(executionContext,
text, useCommandLineAPI) |
142 { | 142 { |
143 useCommandLineAPI = !!useCommandLineAPI; | 143 useCommandLineAPI = !!useCommandLineAPI; |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 } | 467 } |
468 | 468 |
469 /** | 469 /** |
470 * @constructor | 470 * @constructor |
471 * @extends {WebInspector.Object} | 471 * @extends {WebInspector.Object} |
472 * @implements {WebInspector.TargetManager.Observer} | 472 * @implements {WebInspector.TargetManager.Observer} |
473 */ | 473 */ |
474 WebInspector.MultitargetConsoleModel = function() | 474 WebInspector.MultitargetConsoleModel = function() |
475 { | 475 { |
476 WebInspector.targetManager.observeTargets(this); | 476 WebInspector.targetManager.observeTargets(this); |
| 477 WebInspector.targetManager.addModelListener(WebInspector.ConsoleModel, WebIn
spector.ConsoleModel.Events.MessageAdded, this._consoleMessageAdded, this); |
| 478 WebInspector.targetManager.addModelListener(WebInspector.ConsoleModel, WebIn
spector.ConsoleModel.Events.CommandEvaluated, this._commandEvaluated, this); |
477 } | 479 } |
478 | 480 |
479 WebInspector.MultitargetConsoleModel.prototype = { | 481 WebInspector.MultitargetConsoleModel.prototype = { |
480 /** | 482 /** |
481 * @param {!WebInspector.Target} target | 483 * @param {!WebInspector.Target} target |
482 */ | 484 */ |
483 targetAdded: function(target) | 485 targetAdded: function(target) |
484 { | 486 { |
485 if (!this._mainTarget) { | 487 if (!this._mainTarget) { |
486 this._mainTarget = target; | 488 this._mainTarget = target; |
487 target.consoleModel.addEventListener(WebInspector.ConsoleModel.Event
s.ConsoleCleared, this._consoleCleared, this); | 489 target.consoleModel.addEventListener(WebInspector.ConsoleModel.Event
s.ConsoleCleared, this._consoleCleared, this); |
488 } | 490 } |
489 target.consoleModel.addEventListener(WebInspector.ConsoleModel.Events.Me
ssageAdded, this._consoleMessageAdded, this); | |
490 target.consoleModel.addEventListener(WebInspector.ConsoleModel.Events.Co
mmandEvaluated, this._commandEvaluated, this); | |
491 }, | 491 }, |
492 | 492 |
493 /** | 493 /** |
494 * @param {!WebInspector.Target} target | 494 * @param {!WebInspector.Target} target |
495 */ | 495 */ |
496 targetRemoved: function(target) | 496 targetRemoved: function(target) |
497 { | 497 { |
498 if (this._mainTarget === target) { | 498 if (this._mainTarget === target) { |
499 delete this._mainTarget; | 499 delete this._mainTarget; |
500 target.consoleModel.removeEventListener(WebInspector.ConsoleModel.Ev
ents.ConsoleCleared, this._consoleCleared, this); | 500 target.consoleModel.removeEventListener(WebInspector.ConsoleModel.Ev
ents.ConsoleCleared, this._consoleCleared, this); |
501 } | 501 } |
502 target.consoleModel.removeEventListener(WebInspector.ConsoleModel.Events
.MessageAdded, this._consoleMessageAdded, this); | |
503 target.consoleModel.removeEventListener(WebInspector.ConsoleModel.Events
.CommandEvaluated, this._commandEvaluated, this); | |
504 }, | 502 }, |
505 | 503 |
506 /** | 504 /** |
507 * @return {!Array.<!WebInspector.ConsoleMessage>} | 505 * @return {!Array.<!WebInspector.ConsoleMessage>} |
508 */ | 506 */ |
509 messages: function() | 507 messages: function() |
510 { | 508 { |
511 var targets = WebInspector.targetManager.targets(); | 509 var targets = WebInspector.targetManager.targets(); |
512 var result = []; | 510 var result = []; |
513 for (var i = 0; i < targets.length; ++i) | 511 for (var i = 0; i < targets.length; ++i) |
(...skipping 22 matching lines...) Expand all Loading... |
536 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.CommandEv
aluated, event.data); | 534 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.CommandEv
aluated, event.data); |
537 }, | 535 }, |
538 | 536 |
539 __proto__: WebInspector.Object.prototype | 537 __proto__: WebInspector.Object.prototype |
540 } | 538 } |
541 | 539 |
542 /** | 540 /** |
543 * @type {!WebInspector.MultitargetConsoleModel} | 541 * @type {!WebInspector.MultitargetConsoleModel} |
544 */ | 542 */ |
545 WebInspector.multitargetConsoleModel; | 543 WebInspector.multitargetConsoleModel; |
OLD | NEW |