Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 * @fileoverview Injects 'injected' object into the inspectable page. | 6 * @fileoverview Injects 'injected' object into the inspectable page. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Dispatches host calls into the injected function calls. | 10 * Dispatches host calls into the injected function calls. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 | 35 |
| 36 /** | 36 /** |
| 37 * This is called by the InspectorFrontend for serialization. | 37 * This is called by the InspectorFrontend for serialization. |
| 38 * We serialize the call and send it to the client over the IPC | 38 * We serialize the call and send it to the client over the IPC |
| 39 * using dispatchOut bound method. | 39 * using dispatchOut bound method. |
| 40 */ | 40 */ |
| 41 var dispatch = function(method, var_args) { | 41 var dispatch = function(method, var_args) { |
| 42 // Handle all messages with non-primitieve arguments here. | 42 // Handle all messages with non-primitieve arguments here. |
| 43 // TODO(pfeldman): Add more. | |
| 44 if (method == 'inspectedWindowCleared') { | 43 if (method == 'inspectedWindowCleared') { |
| 45 return; | 44 return; |
| 46 } | 45 } |
| 47 var call = JSON.stringify(Array.prototype.slice.call(arguments)); | 46 var args = Array.prototype.slice.call(arguments); |
|
yurys
2009/05/28 16:28:04
you can move this in the 'if' block below
| |
| 47 | |
| 48 // Serialize objects here. | |
| 49 if (method == 'addMessageToConsole') { | |
| 50 // Skip first argument since it is serializable. | |
| 51 for (var i = 1; i < args.length; ++i) { | |
| 52 var type = typeof args[i]; | |
| 53 if (type == 'object') { | |
| 54 args[i] = Object.prototype.toString(args[i]); | |
| 55 } else if (type == 'function') { | |
| 56 args[i] = args[i].toString(); | |
| 57 } | |
| 58 } | |
| 59 } | |
| 60 var call = JSON.stringify(args); | |
| 48 RemoteWebInspector.dispatch(call); | 61 RemoteWebInspector.dispatch(call); |
| 49 }; | 62 }; |
| OLD | NEW |