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/05/23 22:03:50 UTC

[27/30] git commit: Revert "Support chrome webstore links. Updated to support new app dir structure."

Revert "Support chrome webstore links. Updated to support new app dir structure."

This reverts commit 9f0d462b4b1fd9137765fe8d85e076146daf4abc.


Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/6d9f5c9a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/6d9f5c9a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/6d9f5c9a

Branch: refs/heads/master
Commit: 6d9f5c9af590e228a989ed4457e4dd0f45e9ea98
Parents: 1105393
Author: Braden Shepherdson <br...@gmail.com>
Authored: Fri May 17 12:27:05 2013 -0400
Committer: Braden Shepherdson <br...@gmail.com>
Committed: Fri May 17 12:27:05 2013 -0400

----------------------------------------------------------------------
 www/cdvah_index.html              |    1 -
 www/cdvah_js/CrxDownloader.js     |   31 ----------------
 www/cdvah_js/CrxPackageHandler.js |   60 ++++++++++++++------------------
 3 files changed, 26 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/6d9f5c9a/www/cdvah_index.html
----------------------------------------------------------------------
diff --git a/www/cdvah_index.html b/www/cdvah_index.html
index 77bbd2b..3eaede1 100644
--- a/www/cdvah_index.html
+++ b/www/cdvah_index.html
@@ -13,7 +13,6 @@
         <script type="text/javascript" src="cdvah_js/AppsService.js"></script>
         <script type="text/javascript" src="cdvah_js/AppBundleAlias.js"></script>
         <script type="text/javascript" src="cdvah_js/KnownExtensionDownloader.js"></script>
-        <script type="text/javascript" src="cdvah_js/CrxDownloader.js"></script>
         <script type="text/javascript" src="cdvah_js/CdvhPackageHandler.js"></script>
         <script type="text/javascript" src="cdvah_js/CrxPackageHandler.js"></script>
         <script type="text/javascript" src="cdvah_js/ListCtrl.js"></script>

http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/6d9f5c9a/www/cdvah_js/CrxDownloader.js
----------------------------------------------------------------------
diff --git a/www/cdvah_js/CrxDownloader.js b/www/cdvah_js/CrxDownloader.js
deleted file mode 100644
index 0388a08..0000000
--- a/www/cdvah_js/CrxDownloader.js
+++ /dev/null
@@ -1,31 +0,0 @@
-(function(){
-    "use strict";
-    /* global myApp */
-    myApp.run(["AppsService", "ResourcesLoader", function(AppsService, ResourcesLoader){
-
-        function isChromeWebStoreUri(pattern){
-            var regexUri = /^https:\/\/chrome.google.com\/webstore\/detail\/.*?\/[a-z]{32}((\?|#|\/).*)?$/;
-            var ret = (pattern.search(regexUri) !== -1);
-            return ret;
-        }
-
-        AppsService.registerPatternDownloader({
-            canHandleSourcePattern : isChromeWebStoreUri,
-
-            downloadFromPattern : function (appName, pattern, tempDirectory) {
-                var fileName = tempDirectory + appName + ".crx";
-                var chromeAppIdRegex = /^https:\/\/chrome\.google\.com\/webstore\/detail\/.*?\/([a-z]{32})/;
-                // Two results expected.
-                // 1 - the entire match of the regex
-                // 2 - the match of the capture group i.e. the app id
-                var matches = pattern.match(chromeAppIdRegex);
-                if(!matches || matches.length !== 2){
-                    throw new Error("Invalid url for chrome web store");
-                }
-                var sourceUrl = "https://clients2.google.com/service/update2/crx?response=redirect&x=id%3D" + matches[1] + "%26uc";
-                return ResourcesLoader.downloadFromUrl(sourceUrl, fileName);
-            }
-        }, 500 /* assign a priority */);
-
-    }]);
-})();
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/6d9f5c9a/www/cdvah_js/CrxPackageHandler.js
----------------------------------------------------------------------
diff --git a/www/cdvah_js/CrxPackageHandler.js b/www/cdvah_js/CrxPackageHandler.js
index e4b4e7b..2627fd7 100644
--- a/www/cdvah_js/CrxPackageHandler.js
+++ b/www/cdvah_js/CrxPackageHandler.js
@@ -1,9 +1,7 @@
 (function(){
     "use strict";
     /* global myApp */
-    myApp.run(["AppsService", "ResourcesLoader", "ContextMenuInjectScript", function(AppsService, ResourcesLoader, ContextMenuInjectScript){
-
-        var platformId = cordova.require("cordova/platform").id;
+    myApp.run(["AppsService", "ResourcesLoader", function(AppsService, ResourcesLoader){
 
         function copyFile(startUrl, targetLocation){
             /************ Begin Work around for File system bug ************/
@@ -21,42 +19,36 @@
         }
 
         AppsService.registerPackageHandler("crx", {
-            extractPackageToDirectory : function (appName, fileName, outputDirectory){
-                var dataToAppend = ContextMenuInjectScript.getInjectString(appName);
-                var platformDirectory = outputDirectory + "/" + platformId + "/";
-                var platformWWWDirectory = platformDirectory + "www/";
-                var cordovaFile = platformWWWDirectory + "cordova.js";
-
-                // We need to
-                // 1) Copy over the files required to convert a crx to a normal web app
-                // 2) Modify the cordova.js file
-                return ResourcesLoader.extractZipFile(fileName, platformWWWDirectory)
+            extractPackageToDirectory : function (fileName, outputDirectory){
+                return ResourcesLoader.ensureDirectoryExists(outputDirectory + "/www")
                 .then(function(){
-                    return Q.all([
-                        copyFile("app-bundle:///cordova.js", cordovaFile),
-                        copyFile("app-bundle:///crx_files/config." + platformId + ".xml", platformDirectory + "config.xml"),
-                        copyFile("app-bundle:///crx_files/www/cordova_plugins.json", platformWWWDirectory + "cordova_plugins.json"),
-                        copyFile("app-bundle:///crx_files/www/chromeapp.html", platformWWWDirectory + "chromeapp.html"),
-                        copyFile("app-bundle:///crx_files/www/chromeappstyles.css", platformWWWDirectory + "chromeappstyles.css"),
-                        copyFile("app-bundle:///crx_files/www/chromebgpage.html", platformWWWDirectory + "chromebgpage.html"),
-                        copyFile("app-bundle:///crx_files/www/plugins/chrome/api/app/runtime.js", platformWWWDirectory + "plugins/chrome/api/app/runtime.js"),
-                        copyFile("app-bundle:///crx_files/www/plugins/chrome/api/app/window.js", platformWWWDirectory + "plugins/chrome/api/app/window.js"),
-                        copyFile("app-bundle:///crx_files/www/plugins/chrome/api/bootstrap.js", platformWWWDirectory + "plugins/chrome/api/bootstrap.js"),
-                        copyFile("app-bundle:///crx_files/www/plugins/chrome/api/helpers/stubs.js", platformWWWDirectory + "plugins/chrome/api/helpers/stubs.js"),
-                        copyFile("app-bundle:///crx_files/www/plugins/chrome/api/mobile.js", platformWWWDirectory + "plugins/chrome/api/mobile.js"),
-                        copyFile("app-bundle:///crx_files/www/plugins/chrome/api/runtime.js", platformWWWDirectory + "plugins/chrome/api/runtime.js"),
-                        copyFile("app-bundle:///crx_files/www/plugins/chrome.common/events.js", platformWWWDirectory + "plugins/chrome.common/events.js"),
-                        copyFile("app-bundle:///crx_files/www/plugins/chrome.fileSystem/fileSystem.js", platformWWWDirectory + "plugins/chrome.fileSystem/fileSystem.js"),
-                        copyFile("app-bundle:///crx_files/www/plugins/chrome.i18n/i18n.js", platformWWWDirectory + "plugins/chrome.i18n/i18n.js"),
-                        copyFile("app-bundle:///crx_files/www/plugins/chrome.identity/identity.js", platformWWWDirectory + "plugins/chrome.identity/identity.js"),
-                        copyFile("app-bundle:///crx_files/www/plugins/chrome.socket/socket.js", platformWWWDirectory + "plugins/chrome.socket/socket.js"),
-                        copyFile("app-bundle:///crx_files/www/plugins/chrome.storage/storage.js", platformWWWDirectory + "plugins/chrome.storage/storage.js")
-                    ]);
+                    return ResourcesLoader.extractZipFile(fileName, outputDirectory + "/www");
                 })
                 .then(function(){
-                    return ResourcesLoader.appendFileContents(cordovaFile, dataToAppend);
+                    return Q.all([
+                        copyFile("cdv-app-harness:///direct/cordova.js", outputDirectory + "/www/cordova.js"),
+                        copyFile("cdv-app-harness:///direct/crx_files/config.android.xml", outputDirectory + "/config.android.xml"),
+                        copyFile("cdv-app-harness:///direct/crx_files/config.ios.xml", outputDirectory + "/config.ios.xml"),
+                        copyFile("cdv-app-harness:///direct/crx_files/www/cordova_plugins.json", outputDirectory + "/www/cordova_plugins.json"),
+                        copyFile("cdv-app-harness:///direct/crx_files/www/chromeapp.html", outputDirectory + "/www/chromeapp.html"),
+                        copyFile("cdv-app-harness:///direct/crx_files/www/chromeappstyles.css", outputDirectory + "/www/chromeappstyles.css"),
+                        copyFile("cdv-app-harness:///direct/crx_files/www/chromebgpage.html", outputDirectory + "/www/chromebgpage.html"),
+                        copyFile("cdv-app-harness:///direct/crx_files/www/plugins/chrome/api/app/runtime.js", outputDirectory + "/www/plugins/chrome/api/app/runtime.js"),
+                        copyFile("cdv-app-harness:///direct/crx_files/www/plugins/chrome/api/app/window.js", outputDirectory + "/www/plugins/chrome/api/app/window.js"),
+                        copyFile("cdv-app-harness:///direct/crx_files/www/plugins/chrome/api/bootstrap.js", outputDirectory + "/www/plugins/chrome/api/bootstrap.js"),
+                        copyFile("cdv-app-harness:///direct/crx_files/www/plugins/chrome/api/helpers/stubs.js", outputDirectory + "/www/plugins/chrome/api/helpers/stubs.js"),
+                        copyFile("cdv-app-harness:///direct/crx_files/www/plugins/chrome/api/mobile.js", outputDirectory + "/www/plugins/chrome/api/mobile.js"),
+                        copyFile("cdv-app-harness:///direct/crx_files/www/plugins/chrome/api/runtime.js", outputDirectory + "/www/plugins/chrome/api/runtime.js"),
+                        copyFile("cdv-app-harness:///direct/crx_files/www/plugins/chrome.common/events.js", outputDirectory + "/www/plugins/chrome.common/events.js"),
+                        copyFile("cdv-app-harness:///direct/crx_files/www/plugins/chrome.fileSystem/fileSystem.js", outputDirectory + "/www/plugins/chrome.fileSystem/fileSystem.js"),
+                        copyFile("cdv-app-harness:///direct/crx_files/www/plugins/chrome.i18n/i18n.js", outputDirectory + "/www/plugins/chrome.i18n/i18n.js"),
+                        copyFile("cdv-app-harness:///direct/crx_files/www/plugins/chrome.identity/identity.js", outputDirectory + "/www/plugins/chrome.identity/identity.js"),
+                        copyFile("cdv-app-harness:///direct/crx_files/www/plugins/chrome.socket/socket.js", outputDirectory + "/www/plugins/chrome.socket/socket.js"),
+                        copyFile("cdv-app-harness:///direct/crx_files/www/plugins/chrome.storage/storage.js", outputDirectory + "/www/plugins/chrome.storage/storage.js")
+                    ]);
                 });
             }
         });
+
     }]);
 })();
\ No newline at end of file