Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1416)

Unified Diff: native_client_sdk/src/examples/api/vpn_provider/example.js

Issue 1731273002: ppapi: PPB_VpnProvider: Add a simple NaCl SDK example. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@vpn-ppapi
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
+}

Powered by Google App Engine
This is Rietveld 408576698