cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [24/24] js commit: [android] Remove plugin code from platform.js
Date Tue, 12 Feb 2013 19:32:41 GMT
Updated Branches:
  refs/heads/master 377be7a5e -> 543a5783c


[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/d7836c15
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/d7836c15
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/d7836c15

Branch: refs/heads/master
Commit: d7836c158669a3e0a7b9adf934ab4ee8be95e0e9
Parents: 3fb8835
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Tue Jan 29 14:35:14 2013 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Tue Feb 12 14:24:33 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/d7836c15/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/d7836c15/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/d7836c15/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/d7836c15/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..c575207
--- /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/plugin/android/storage/openDatabase', 'openDatabase');
+


Mime
View raw message