You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/01/29 21:15:56 UTC
[2/4] js commit: [android] Remove plugin code from platform.js
[android] Remove plugin code from platform.js
- Moves window.openDatabase() clobber into a symbols file
- Moves App symbols into the platform.js file
Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/8412ae0b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/8412ae0b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/8412ae0b
Branch: refs/heads/symbolmapping
Commit: 8412ae0bc6f05e62b3bd15560c362022a1f43c85
Parents: 98fd804
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Jan 29 14:35:14 2013 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Jan 29 14:35:14 2013 -0500
----------------------------------------------------------------------
lib/android/platform.js | 38 +-----------
lib/android/plugin/android/app/symbols.js | 24 --------
lib/android/plugin/android/storage/openDatabase.js | 47 +++++++++++++++
lib/android/plugin/android/storage/symbols.js | 25 ++++++++
4 files changed, 74 insertions(+), 60 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/8412ae0b/lib/android/platform.js
----------------------------------------------------------------------
diff --git a/lib/android/platform.js b/lib/android/platform.js
index a1a01ed..0b2c411 100644
--- a/lib/android/platform.js
+++ b/lib/android/platform.js
@@ -28,6 +28,8 @@ module.exports = {
modulemapper = require('cordova/modulemapper');
modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
+ modulemapper.clobbers('cordova/plugin/android/app', 'navigator.app');
+
modulemapper.mapModules(window);
// Inject a listener for the backbutton on the document.
@@ -42,42 +44,6 @@ module.exports = {
cordova.addDocumentEventHandler('menubutton');
cordova.addDocumentEventHandler('searchbutton');
- // Figure out if we need to shim-in localStorage and WebSQL
- // support from the native side.
- var storage = require('cordova/plugin/android/storage');
-
- // First patch WebSQL if necessary
- if (typeof window.openDatabase == 'undefined') {
- // Not defined, create an openDatabase function for all to use!
- window.openDatabase = storage.openDatabase;
- } else {
- // Defined, but some Android devices will throw a SECURITY_ERR -
- // so we wrap the whole thing in a try-catch and shim in our own
- // if the device has Android bug 16175.
- var originalOpenDatabase = window.openDatabase;
- window.openDatabase = function(name, version, desc, size) {
- var db = null;
- try {
- db = originalOpenDatabase(name, version, desc, size);
- }
- catch (ex) {
- if (ex.code === 18) {
- db = null;
- } else {
- throw ex;
- }
- }
-
- if (db === null) {
- return storage.openDatabase(name, version, desc, size);
- }
- else {
- return db;
- }
-
- };
- }
-
// Let native code know we are all done on the JS side.
// Native code will then un-hide the WebView.
channel.join(function() {
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/8412ae0b/lib/android/plugin/android/app/symbols.js
----------------------------------------------------------------------
diff --git a/lib/android/plugin/android/app/symbols.js b/lib/android/plugin/android/app/symbols.js
deleted file mode 100644
index d75c58f..0000000
--- a/lib/android/plugin/android/app/symbols.js
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/android/app', 'navigator.app');
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/8412ae0b/lib/android/plugin/android/storage/openDatabase.js
----------------------------------------------------------------------
diff --git a/lib/android/plugin/android/storage/openDatabase.js b/lib/android/plugin/android/storage/openDatabase.js
new file mode 100644
index 0000000..137cfa1
--- /dev/null
+++ b/lib/android/plugin/android/storage/openDatabase.js
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+
+var modulemapper = require('cordova/modulemapper'),
+ storage = require('cordova/plugin/android/storage');
+
+var originalOpenDatabase = modulemapper.getOriginalSymbol(window, 'openDatabase');
+
+module.exports = function(name, version, desc, size) {
+ // First patch WebSQL if necessary
+ if (!originalOpenDatabase) {
+ // Not defined, create an openDatabase function for all to use!
+ return storage.openDatabase.apply(this, arguments);
+ }
+
+ // Defined, but some Android devices will throw a SECURITY_ERR -
+ // so we wrap the whole thing in a try-catch and shim in our own
+ // if the device has Android bug 16175.
+ try {
+ return originalOpenDatabase(name, version, desc, size);
+ } catch (ex) {
+ if (ex.code !== 18) {
+ throw ex;
+ }
+ }
+ return storage.openDatabase(name, version, desc, size);
+};
+
+
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/8412ae0b/lib/android/plugin/android/storage/symbols.js
----------------------------------------------------------------------
diff --git a/lib/android/plugin/android/storage/symbols.js b/lib/android/plugin/android/storage/symbols.js
new file mode 100644
index 0000000..4c81aab
--- /dev/null
+++ b/lib/android/plugin/android/storage/symbols.js
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.clobbers('cordova/plugins/android/storage/openDatabase', 'openDatabase');
+