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

Side by Side Diff: native_client_sdk/src/examples/common.js

Issue 11823042: Add args to DidCreate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Javascript module pattern: 5 // Javascript module pattern:
6 // see http://en.wikipedia.org/wiki/Unobtrusive_JavaScript#Namespaces 6 // see http://en.wikipedia.org/wiki/Unobtrusive_JavaScript#Namespaces
7 // In essence, we define an anonymous function which is immediately called and 7 // In essence, we define an anonymous function which is immediately called and
8 // returns a new object. The new object contains only the exported definitions; 8 // returns a new object. The new object contains only the exported definitions;
9 // all other definitions in the anonymous function are inaccessible to external 9 // all other definitions in the anonymous function are inaccessible to external
10 // code. 10 // code.
11 var common = (function () { 11 var common = (function () {
12 12
13 /** 13 /**
14 * Create the Native Client <embed> element as a child of the DOM element 14 * Create the Native Client <embed> element as a child of the DOM element
15 * named "listener". 15 * named "listener".
16 * 16 *
17 * @param {string} name The name of the example. 17 * @param {string} name The name of the example.
18 * @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc. 18 * @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc.
19 * @param {string} path Directory name where .nmf file can be found. 19 * @param {string} path Directory name where .nmf file can be found.
20 * @param {number} width The width to create the plugin. 20 * @param {number} width The width to create the plugin.
21 * @param {number} height The height to create the plugin. 21 * @param {number} height The height to create the plugin.
22 * @param {args} optional dictionary of args to send to DidCreateInstance
binji 2013/01/10 19:45:56 nit: @param {Object} args ...
22 */ 23 */
23 function createNaClModule(name, tool, path, width, height) { 24 function createNaClModule(name, tool, path, width, height, args) {
24 var moduleEl = document.createElement('embed'); 25 var moduleEl = document.createElement('embed');
25 moduleEl.setAttribute('name', 'nacl_module'); 26 moduleEl.setAttribute('name', 'nacl_module');
26 moduleEl.setAttribute('id', 'nacl_module'); 27 moduleEl.setAttribute('id', 'nacl_module');
27 moduleEl.setAttribute('width', width); 28 moduleEl.setAttribute('width', width);
28 moduleEl.setAttribute('height',height); 29 moduleEl.setAttribute('height',height);
29 moduleEl.setAttribute('src', path + '/' + name + '.nmf'); 30 moduleEl.setAttribute('src', path + '/' + name + '.nmf');
31
32 // Add any optional arguments
33 if (args) {
34 for (var key in args) {
35 moduleEl.setAttribute(key, args[key])
36 }
37 }
38
30 // For NaCL modules use application/x-nacl. 39 // For NaCL modules use application/x-nacl.
31 var mimetype = 'application/x-nacl'; 40 var mimetype = 'application/x-nacl';
32 var isHost = tool == 'win' || tool == 'linux' || tool == 'mac'; 41 var isHost = tool == 'win' || tool == 'linux' || tool == 'mac';
33 if (isHost) { 42 if (isHost) {
34 // For non-nacl PPAPI plugins use the x-ppapi-debug/release 43 // For non-nacl PPAPI plugins use the x-ppapi-debug/release
35 // mime type. 44 // mime type.
36 if (path.toLowerCase().indexOf('release') != -1) 45 if (path.toLowerCase().indexOf('release') != -1)
37 mimetype = 'application/x-ppapi-release'; 46 mimetype = 'application/x-ppapi-release';
38 else 47 else
39 mimetype = 'application/x-ppapi-debug'; 48 mimetype = 'application/x-ppapi-debug';
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 } else if (typeof window.domContentLoaded !== 'undefined') { 254 } else if (typeof window.domContentLoaded !== 'undefined') {
246 loadFunction = window.domContentLoaded; 255 loadFunction = window.domContentLoaded;
247 } 256 }
248 257
249 if (loadFunction) { 258 if (loadFunction) {
250 loadFunction(body.dataset.name, body.dataset.tc, body.dataset.path, 259 loadFunction(body.dataset.name, body.dataset.tc, body.dataset.path,
251 body.dataset.width, body.dataset.height); 260 body.dataset.width, body.dataset.height);
252 } 261 }
253 } 262 }
254 }); 263 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698