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

Unified Diff: native_client_sdk/src/examples/tutorial/filesystem_passing/example.js

Issue 690403002: [NaCl SDK] Add filesystem passing example. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix verify Created 6 years, 2 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/tutorial/filesystem_passing/example.js
diff --git a/native_client_sdk/src/examples/tutorial/filesystem_passing/example.js b/native_client_sdk/src/examples/tutorial/filesystem_passing/example.js
new file mode 100644
index 0000000000000000000000000000000000000000..3d8b7192e98714e564eeb04bd5f0004db7e19737
--- /dev/null
+++ b/native_client_sdk/src/examples/tutorial/filesystem_passing/example.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function attachListeners() {
+ document.getElementById('choosedir').addEventListener('click', function(e) {
+ chrome.fileSystem.chooseEntry({type: 'openDirectory'}, function(entry) {
+ if (!entry) {
+ // The user cancelled the dialog.
+ return;
+ }
+
+ // Send the filesystem and the directory path to the NaCl module.
+ common.naclModule.postMessage({
+ filesystem: entry.filesystem,
+ fullPath: entry.fullPath
+ });
+ });
+ }, false);
+}
+
+// Called by the common.js module.
+function moduleDidLoad() {
+ // The module is not hidden by default so we can easily see if the plugin
+ // failed to load.
+ common.hideModule();
+
+ // Make sure this example is running as an App. If not, display a warning.
+ if (!chrome.fileSystem) {
+ common.updateStatus('Error: must be run as an App.');
+ return;
+ }
+}
+
+// Called by the common.js module.
+function handleMessage(message_event) {
+ common.logMessage(message_event.data);
+}

Powered by Google App Engine
This is Rietveld 408576698