| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Once we load, hide the plugin | 5 // Once we load, hide the plugin |
| 6 function moduleDidLoad() { | 6 function moduleDidLoad() { |
| 7 common.hideModule(); | 7 common.hideModule(); |
| 8 } | 8 } |
| 9 | 9 |
| 10 // Called by the common.js module. | 10 // Called by the common.js module. |
| 11 // nacl_io/ppapi_simple generates two different types of messages: | 11 // nacl_io/ppapi_simple generates two different types of messages: |
| 12 // - messages from /dev/tty (prefixed with PS_TTY_PREFIX) | 12 // - messages from /dev/tty (prefixed with PS_TTY_PREFIX) |
| 13 // - exit message (prefixed with PS_EXIT_MESSAGE) | 13 // - exit message (prefixed with PS_EXIT_MESSAGE) |
| 14 function handleMessage(message) { | 14 function handleMessage(message) { |
| 15 if (message.data.indexOf("exit:") == 0) { | 15 if (message.data.indexOf("exit:") == 0) { |
| 16 // When we recieve the exit message we post an empty reply back to | 16 // When we receive the exit message we post an empty reply back to |
| 17 // confirm, at which point the module will exit. | 17 // confirm, at which point the module will exit. |
| 18 message.srcElement.postMessage({"exit" : ""}); | 18 message.srcElement.postMessage({"exit" : ""}); |
| 19 } else if (message.data.indexOf("tty:") == 0) { | 19 } else if (message.data.indexOf("tty:") == 0) { |
| 20 common.logMessage(message.data.slice("tty:".length)); | 20 common.logMessage(message.data.slice("tty:".length)); |
| 21 } else { | 21 } else { |
| 22 console.log("Unhandled message: " + message.data); | 22 console.log("Unhandled message: " + message.data); |
| 23 } | 23 } |
| 24 } | 24 } |
| OLD | NEW |