diff --git a/background.html b/background.html index 5480a088f8..7efe63e1bb 100644 --- a/background.html +++ b/background.html @@ -15,7 +15,6 @@
- diff --git a/bower.json b/bower.json index 73fa11b7d7..eede5dc1fc 100644 --- a/bower.json +++ b/bower.json @@ -88,7 +88,8 @@ "backbone", "backbone.localstorage", "qrcode", - "libphonenumber-api" + "libphonenumber-api", + "native-client" ] } } diff --git a/js-deps/nacl-common.js b/components/native-client/nacl-common.js similarity index 100% rename from js-deps/nacl-common.js rename to components/native-client/nacl-common.js diff --git a/index.html b/index.html index 5b6ac612f3..04393f2b77 100644 --- a/index.html +++ b/index.html @@ -124,8 +124,8 @@ - + diff --git a/js/components.js b/js/components.js index 8761347552..ad35445083 100644 --- a/js/components.js +++ b/js/components.js @@ -22969,3 +22969,452 @@ var libphonenumber=function(){var a={},b=i18n.phonenumbers.PhoneNumberUtil.getIn d)};a.PhoneNumberFormat=i18n.phonenumbers.PhoneNumberFormat;a.format=function(a,d){return b.format(a,d)};return a}();goog.exportSymbol("libphonenumber.parse",libphonenumber.parse);goog.exportSymbol("libphonenumber.getCountryCodeForRegion",libphonenumber.getCountryCodeForRegion);goog.exportSymbol("libphonenumber.getRegionCodeForCountryCode",libphonenumber.getRegionCodeForCountryCode);goog.exportSymbol("libphonenumber.getRegionCodeForNumber",libphonenumber.getRegionCodeForNumber); goog.exportSymbol("libphonenumber.isValidNumber",libphonenumber.isValidNumber);goog.exportSymbol("libphonenumber.isValidNumberForRegion",libphonenumber.isValidNumberForRegion);goog.exportSymbol("libphonenumber.PhoneNumberFormat",libphonenumber.PhoneNumberFormat);goog.exportSymbol("libphonenumber.PhoneNumberFormat.E164",libphonenumber.PhoneNumberFormat.E164);goog.exportSymbol("libphonenumber.PhoneNumberFormat.INTERNATIONAL",libphonenumber.PhoneNumberFormat.INTERNATIONAL); goog.exportSymbol("libphonenumber.PhoneNumberFormat.NATIONAL",libphonenumber.PhoneNumberFormat.NATIONAL);goog.exportSymbol("libphonenumber.PhoneNumberFormat.RFC3966",libphonenumber.PhoneNumberFormat.RFC3966);goog.exportSymbol("libphonenumber.format",libphonenumber.format);})(); + +// Copyright (c) 2012 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. + +// Set to true when the Document is loaded IFF "test=true" is in the query +// string. +var isTest = false; + +// Set to true when loading a "Release" NaCl module, false when loading a +// "Debug" NaCl module. +var isRelease = false; + +// Javascript module pattern: +// see http://en.wikipedia.org/wiki/Unobtrusive_JavaScript#Namespaces +// In essence, we define an anonymous function which is immediately called and +// returns a new object. The new object contains only the exported definitions; +// all other definitions in the anonymous function are inaccessible to external +// code. +var common = (function() { + + function isHostToolchain(tool) { + return tool == 'win' || tool == 'linux' || tool == 'mac'; + } + + /** + * Return the mime type for NaCl plugin. + * + * @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc. + * @return {string} The mime-type for the kind of NaCl plugin matching + * the given toolchain. + */ + function mimeTypeForTool(tool) { + // For NaCl modules use application/x-nacl. + var mimetype = 'application/x-nacl'; + if (isHostToolchain(tool)) { + // For non-NaCl PPAPI plugins use the x-ppapi-debug/release + // mime type. + if (isRelease) + mimetype = 'application/x-ppapi-release'; + else + mimetype = 'application/x-ppapi-debug'; + } else if (tool == 'pnacl' && isRelease) { + mimetype = 'application/x-pnacl'; + } + return mimetype; + } + + /** + * Check if the browser supports NaCl plugins. + * + * @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc. + * @return {bool} True if the browser supports the type of NaCl plugin + * produced by the given toolchain. + */ + function browserSupportsNaCl(tool) { + // Assume host toolchains always work with the given browser. + // The below mime-type checking might not work with + // --register-pepper-plugins. + if (isHostToolchain(tool)) { + return true; + } + var mimetype = mimeTypeForTool(tool); + return navigator.mimeTypes[mimetype] !== undefined; + } + + /** + * Inject a script into the DOM, and call a callback when it is loaded. + * + * @param {string} url The url of the script to load. + * @param {Function} onload The callback to call when the script is loaded. + * @param {Function} onerror The callback to call if the script fails to load. + */ + function injectScript(url, onload, onerror) { + var scriptEl = document.createElement('script'); + scriptEl.type = 'text/javascript'; + scriptEl.src = url; + scriptEl.onload = onload; + if (onerror) { + scriptEl.addEventListener('error', onerror, false); + } + document.head.appendChild(scriptEl); + } + + /** + * Run all tests for this example. + * + * @param {Object} moduleEl The module DOM element. + */ + function runTests(moduleEl) { + console.log('runTests()'); + common.tester = new Tester(); + + // All NaCl SDK examples are OK if the example exits cleanly; (i.e. the + // NaCl module returns 0 or calls exit(0)). + // + // Without this exception, the browser_tester thinks that the module + // has crashed. + common.tester.exitCleanlyIsOK(); + + common.tester.addAsyncTest('loaded', function(test) { + test.pass(); + }); + + if (typeof window.addTests !== 'undefined') { + window.addTests(); + } + + common.tester.waitFor(moduleEl); + common.tester.run(); + } + + /** + * Create the Native Client