Back out c51c5db7903f (bug 679194) since I'm backing out the cset that it stacks on top of
authorDaniel Holbert <dholbert@cs.stanford.edu>
Mon, 15 Aug 2011 20:59:11 -0700
changeset 75313 51c50cf19742ffaf2c014f404739c407857f9ba2
parent 75312 c86cbbb7d0bf14ae7af5be3ebb23af50554b98ec
child 75314 37dedb70a68adaf8d74fb2c2e58377ffb89e0449
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
bugs679194
milestone8.0a1
backs outc51c5db7903fd0da25e1143c65a33a19c30cb7e8
Back out c51c5db7903f (bug 679194) since I'm backing out the cset that it stacks on top of
mobile/chrome/content/common-ui.js
mobile/chrome/content/content.js
mobile/chrome/content/injected.js
mobile/components/ContentPermissionPrompt.js
mobile/locales/en-US/chrome/browser.properties
--- a/mobile/chrome/content/common-ui.js
+++ b/mobile/chrome/content/common-ui.js
@@ -206,17 +206,17 @@ var PageActions = {
   },
 
   get _loginManager() {
     delete this._loginManager;
     return this._loginManager = Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
   },
 
   // Permissions we track in Page Actions
-  _permissions: ["popup", "offline-app", "geolocation", "desktop-notification", "openWebappsList", "openWebappsUninstall"],
+  _permissions: ["popup", "offline-app", "geolocation", "desktop-notification"],
 
   _forEachPermissions: function _forEachPermissions(aHost, aCallback) {
     let pm = Services.perms;
     for (let i = 0; i < this._permissions.length; i++) {
       let type = this._permissions[i];
       if (!pm.testPermission(aHost, type))
         continue;
 
@@ -1729,47 +1729,16 @@ var WebappsUI = {
       app.iconURI = icon;
 
     let root = baseURI.resolve("/").toString();
     app.appURI = app.manifest.launch_path ? baseURI.resolve(app.manifest.launch_path) : root.substring(0, root.length - 1);
 
     return app;
   },
 
-  askPermission: function(aMessage, aType, aCallbacks) {
-    let uri = Services.io.newURI(aMessage.json.from, null, null);
-    let perm = Services.perms.testExactPermission(uri, aType);
-    switch(perm) {
-      case Ci.nsIPermissionManager.ALLOW_ACTION:
-        aCallbacks.allow();
-        return;
-      case Ci.nsIPermissionManager.DENY_ACTION:
-        aCallbacks.cancel();
-        return;
-    }
-
-    let prompt = Cc["@mozilla.org/content-permission/prompt;1"].createInstance(Ci.nsIContentPermissionPrompt);
-
-    prompt.prompt({
-      type: aType,
-      uri: uri,
-      window: null,
-      element: aMessage.target,
-
-      cancel: function() {
-        aCallbacks.cancel();
-      },
-
-      allow: function() {
-        Services.perms.add(uri, aType, Ci.nsIPermissionManager.ALLOW_ACTION);
-        aCallbacks.allow();
-      },
-    });
-  },
-
   receiveMessage: function(aMessage) {
     let browser = aMessage.target;
     switch(aMessage.name) {
       case "OpenWebapps:Install":
         WebappsUI._openwebapps = browser;
         WebappsUI.show(WebappsUI.convertManifest(aMessage.json));
         break;
       case "OpenWebapps:GetInstalledBy":
@@ -1778,48 +1747,29 @@ var WebappsUI = {
             { apps: apps, callbackID: aMessage.json.callbackID });
         break;
       case "OpenWebapps:AmInstalled":
         let app = OpenWebapps.amInstalled(aMessage.json.appURI);
         browser.messageManager.sendAsyncMessage("OpenWebapps:AmInstalled:Return",
             { installed: app != null, app: app, callbackID: aMessage.json.callbackID });
         break;
       case "OpenWebapps:MgmtList":
-        this.askPermission(aMessage, "openWebappsList", {
-          cancel: function() {
-            browser.messageManager.sendAsyncMessage("OpenWebapps:MgmtList:Return",
-              { ok: false, callbackID: aMessage.json.callbackID });
-          },
-          
-          allow: function() {
-            let list = OpenWebapps.mgmtList();
-            browser.messageManager.sendAsyncMessage("OpenWebapps:MgmtList:Return",
-              { ok: true, apps: list, callbackID: aMessage.json.callbackID });
-          }
-        });
+        let list = OpenWebapps.mgmtList();
+        browser.messageManager.sendAsyncMessage("OpenWebapps:MgmtList:Return",
+            { ok: true, apps: list, callbackID: aMessage.json.callbackID });
         break;
       case "OpenWebapps:MgmtLaunch":
         let res = OpenWebapps.mgmtLaunch(aMessage.json.origin);
         browser.messageManager.sendAsyncMessage("OpenWebapps:MgmtLaunch:Return",
             { ok: res, callbackID: aMessage.json.callbackID });
         break;
       case "OpenWebapps:MgmtUninstall":
-        this.askPermission(aMessage, "openWebappsUninstall", {
-          cancel: function() {
-            browser.messageManager.sendAsyncMessage("OpenWebapps:MgmtUninstall:Return",
-              { ok: false, callbackID: aMessage.json.callbackID });
-          },
-          
-          allow: function() {
-            let uninstalled = OpenWebapps.mgmtUninstall(aMessage.json.origin);
-            browser.messageManager.sendAsyncMessage("OpenWebapps:MgmtUninstall:Return",
-              { ok: uninstalled, callbackID: aMessage.json.callbackID });
-          }
-        });
-        
+        let uninstalled = OpenWebapps.mgmtUninstall(aMessage.json.origin);
+        browser.messageManager.sendAsyncMessage("OpenWebapps:MgmtUninstall:Return",
+            { ok: uninstalled, callbackID: aMessage.json.callbackID });
         break;
     }
   },
 
   checkBox: function(aEvent) {
     let elem = aEvent.originalTarget;
     let perm = elem.getAttribute("perm");
     if (this._application.capabilities && this._application.capabilities.indexOf(perm) != -1) {
--- a/mobile/chrome/content/content.js
+++ b/mobile/chrome/content/content.js
@@ -1576,37 +1576,37 @@ let OpenWebapps = {
 
     xhr.onerror = function() {
       if (aErrorCallback)
         aErrorCallback({ code: "networkError", message: "Unable to retrieve manifest" });
     }
 
     xhr.send(null);
   },
-
+  
   amInstalled: function(aAppURI, aSuccessCallback, aErrorCallback) {
     sendAsyncMessage("OpenWebapps:AmInstalled", { appURI: aAppURI, callbackID:  OpenWebapps.getCallbackId({ success: aSuccessCallback, error: aErrorCallback }) });
   },
-
+  
   getInstalledBy: function(aStoreURI, aSuccessCallback, aErrorCallback) {
     sendAsyncMessage("OpenWebapps:GetInstalledBy", { storeURI: aStoreURI.href, callbackID:  OpenWebapps.getCallbackId({ success: aSuccessCallback, error: aErrorCallback }) });
   },
-
+  
   mgmtLaunch: function(aOrigin, aSuccessCallback, aErrorCallback) {
     sendAsyncMessage("OpenWebapps:MgmtLaunch", { origin: aOrigin, callbackID:  OpenWebapps.getCallbackId({ success: aSuccessCallback, error: aErrorCallback }) });
   },
-
-  mgmtList: function(aFrom, aSuccessCallback, aErrorCallback) {
-    sendAsyncMessage("OpenWebapps:MgmtList", { from: aFrom.href, callbackID:  OpenWebapps.getCallbackId({ success: aSuccessCallback, error: aErrorCallback }) });
+  
+  mgmtList: function(aSuccessCallback, aErrorCallback) {
+    sendAsyncMessage("OpenWebapps:MgmtList", { callbackID:  OpenWebapps.getCallbackId({ success: aSuccessCallback, error: aErrorCallback }) });
   },
-
-  mgmtUninstall: function(aFrom, aOrigin, aSuccessCallback, aErrorCallback) {
-    sendAsyncMessage("OpenWebapps:MgmtUninstall", { from: aFrom.href, origin: aOrigin, callbackID:  OpenWebapps.getCallbackId({ success: aSuccessCallback, error: aErrorCallback }) });
+  
+  mgmtUninstall: function(aOrigin, aSuccessCallback, aErrorCallback) {
+    sendAsyncMessage("OpenWebapps:MgmtUninstall", { origin: aOrigin, callbackID:  OpenWebapps.getCallbackId({ success: aSuccessCallback, error: aErrorCallback }) });
   },
-
+  
   receiveMessage: function(aMessage) {
     let msg = aMessage.json;
     let callbacks = OpenWebapps.getCallback(msg.callbackID);
     switch(aMessage.name) {
       case "OpenWebapps:InstallAborted" :
         if (callbacks.error)
           callbacks.error({ code: "denied", message: "User denied installation" });
         break;
@@ -1675,22 +1675,22 @@ let OpenWebapps = {
     sandbox.importFunction(function(aStoreURI, aSuccessCallback, aErrorCallback) {
         OpenWebapps.getInstalledBy(aStoreURI, aSuccessCallback, aErrorCallback);
         }, "OpenWebapps_getInstalledBy");
     
     sandbox.importFunction(function(aOrigin, aSuccessCallback, aErrorCallback) {
         OpenWebapps.mgmtLaunch(aOrigin, aSuccessCallback, aErrorCallback);
         }, "OpenWebappsMgmt_launch");
     
-    sandbox.importFunction(function(aFrom, aSuccessCallback, aErrorCallback) {
-        OpenWebapps.mgmtList(aFrom, aSuccessCallback, aErrorCallback);
+    sandbox.importFunction(function(aSuccessCallback, aErrorCallback) {
+        OpenWebapps.mgmtList(aSuccessCallback, aErrorCallback);
         }, "OpenWebappsMgmt_list");
     
-    sandbox.importFunction(function(aFrom, aOrigin, aSuccessCallback, aErrorCallback) {
-        OpenWebapps.mgmtUninstall(aFrom, aOrigin, aSuccessCallback, aErrorCallback);
+    sandbox.importFunction(function(aOrigin, aSuccessCallback, aErrorCallback) {
+        OpenWebapps.mgmtUninstall(aOrigin, aSuccessCallback, aErrorCallback);
         }, "OpenWebappsMgmt_uninstall");
 
     let toInject = OpenWebapps.getInjected();
     Cu.evalInSandbox(toInject, sandbox, "1.8", "chrome://browser/content/injected.js", 1);
   }
 };
 
 OpenWebapps.init();
--- a/mobile/chrome/content/injected.js
+++ b/mobile/chrome/content/injected.js
@@ -51,16 +51,16 @@ if (window && window.navigator) {
   }
   
   window.navigator.mozApps.mgmt = {
     launch: function(aOrigin, aSuccessCallback, aErrorCallback) {
       return OpenWebappsMgmt_launch(aOrigin, aSuccessCallback, aErrorCallback);
     },
     
     list: function(aSuccessCallback, aErrorCallback) {
-      return OpenWebappsMgmt_list(window.location, aSuccessCallback, aErrorCallback);
+      return OpenWebappsMgmt_list(aSuccessCallback, aErrorCallback);
     },
     
     uninstall: function(aOrigin, aSuccessCallback, aErrorCallback) {
-      return OpenWebappsMgmt_uninstall(window.location, aOrigin, aSuccessCallback, aErrorCallback);
+      return OpenWebappsMgmt_uninstall(aOrigin, aSuccessCallback, aErrorCallback);
     }
   }
 }
--- a/mobile/components/ContentPermissionPrompt.js
+++ b/mobile/components/ContentPermissionPrompt.js
@@ -25,18 +25,17 @@ function setPagePermission(type, uri, al
   contentPrefs.setPref(uri, contentPrefName, count);
   if (count == kCountBeforeWeRemember)
     pm.add(uri, type, Ci.nsIPermissionManager.ALLOW_ACTION);
   else if (count == -kCountBeforeWeRemember)
     pm.add(uri, type, Ci.nsIPermissionManager.DENY_ACTION);
 }
 
 const kEntities = { "geolocation": "geolocation", "desktop-notification": "desktopNotification",
-                    "indexedDB": "offlineApps", "indexedDBQuota": "indexedDBQuota",
-                    "openWebappsList": "openWebappsList", "openWebappsUninstall": "openWebappsUninstall"};
+                    "indexedDB": "offlineApps", "indexedDBQuota": "indexedDBQuota" };
 
 function ContentPermissionPrompt() {}
 
 ContentPermissionPrompt.prototype = {
   classID: Components.ID("{C6E8C44D-9F39-4AF7-BCC0-76E38A8310F5}"),
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPermissionPrompt]),
 
--- a/mobile/locales/en-US/chrome/browser.properties
+++ b/mobile/locales/en-US/chrome/browser.properties
@@ -168,24 +168,16 @@ offlineApps.notNow=Not Now
 offlineApps.dontAllow=Don't Allow
 offlineApps.wantsTo=%S wants to store data on your device for offline use.
 
 # IndexedDB Quota increases
 indexedDBQuota.allow=Allow
 indexedDBQuota.dontAllow=Don't Allow
 indexedDBQuota.wantsTo=%S wants to store a lot of data on your device for offline use.
 
-# Open Web Apps management API
-openWebappsUninstall.allow=Allow
-openWebappsUninstall.dontAllow=Don't Allow
-openWebappsUninstall.wantsTo=%S wants to uninstall an application on your device.
-openWebappsList.allow=Allow
-openWebappsList.dontAllow=Don't Allow
-openWebappsList.wantsTo=%S wants to retrieve the list of applications on you device.
-
 # Bookmark List
 bookmarkList.desktop=Desktop Bookmarks
 
 # Closing Tabs
 tabs.closeWarningTitle=Confirm close
 
 # LOCALIZATION NOTE (tabs.closeWarning): Semi-colon list of plural forms.
 # See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
@@ -209,18 +201,16 @@ homepage.custom2=Custom Page
 
 # Page Actions
 pageactions.saveas.pdf=Save As PDF
 pageactions.geolocation=Location
 pageactions.popup=Popups
 pageactions.offline-app=Offline Storage
 pageactions.password=Password
 pageactions.desktop-notification=Web Notifications
-pageactions.openWebappsUninstall=Uninstalling Open Web Apps
-pageactions.openWebappsList=Listing Open Web Apps
 
 # Open Search
 opensearch.searchWith=Search With:
 opensearch.searchFor=Search for "%S"
 
 # Open in Another App
 # LOCALIZATION NOTE: openinapp.specific is the text displayed if there is a single external app
 # %S is the name of the app, like "YouTube" or "Picassa"