Index: native_client_sdk/src/examples/api/vpn_provider/example.js |
diff --git a/native_client_sdk/src/examples/api/vpn_provider/example.js b/native_client_sdk/src/examples/api/vpn_provider/example.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..fb405b27d0cf6055fa4796c566fdd74025c4b3a9 |
--- /dev/null |
+++ b/native_client_sdk/src/examples/api/vpn_provider/example.js |
@@ -0,0 +1,37 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
binji
2016/02/24 19:23:08
2016, and remove (c)
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// This function is called by common.js when the NaCl module is |
+// loaded. |
+function moduleDidLoad() { |
+ // Once we load, hide the plugin. In this example, we don't display anything |
+ // in the plugin, so it is fine to hide it. |
+ common.hideModule(); |
+ |
+ // After the NaCl module has loaded, common.naclModule is a reference to the |
+ // NaCl module's <embed> element. |
+ // |
+ // postMessage sends a message to it. |
+ // common.naclModule.postMessage('hello'); |
+} |
+ |
+function load_me() { |
binji
2016/02/24 19:23:08
nit: loadMe (and unloadMe below)
|
+ common.naclModule.postMessage('hello'); |
+ |
+ document.getElementById("load").disabled = true; |
+ document.getElementById("unload").disabled = false; |
+} |
+function unload_me() { |
+ common.naclModule.postMessage('bye'); |
+ |
+ document.getElementById("load").disabled = false; |
+ document.getElementById("unload").disabled = true; |
+} |
+ |
+// This function is called by common.js when a message is received from the |
+// NaCl module. |
+function handleMessage(message) { |
+ var logEl = document.getElementById('log'); |
+ logEl.textContent += message.data; |
+} |