From d2c853240de6f8c94f789fa5eb390478812cd863 Mon Sep 17 00:00:00 2001 From: Wes Johnston Date: Mon, 25 Aug 2014 12:55:18 -0700 Subject: [PATCH] Bug 1046885 - Disable installing webapps in guest mode profiles. r=myk --- mobile/android/base/BrowserApp.java | 3 +++ mobile/android/locales/en-US/chrome/webapp.properties | 2 ++ mobile/android/modules/WebappManager.jsm | 10 ++++++++++ 3 files changed, 15 insertions(+) diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java index c07cb1ad70f1..0009bc784840 100644 --- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -2517,6 +2517,9 @@ public class BrowserApp extends GeckoApp final boolean inGuestMode = GeckoProfile.get(this).inGuestMode(); share.setVisible(!inGuestMode); share.setEnabled(StringUtils.isShareableUrl(url) && !inGuestMode); + MenuUtils.safeSetEnabled(aMenu, R.id.apps, !inGuestMode); + MenuUtils.safeSetEnabled(aMenu, R.id.addons, !inGuestMode); + MenuUtils.safeSetEnabled(aMenu, R.id.downloads, !inGuestMode); // NOTE: Use MenuUtils.safeSetEnabled because some actions might // be on the BrowserToolbar context menu diff --git a/mobile/android/locales/en-US/chrome/webapp.properties b/mobile/android/locales/en-US/chrome/webapp.properties index 8b06a978d058..5a38c03ac6cd 100644 --- a/mobile/android/locales/en-US/chrome/webapp.properties +++ b/mobile/android/locales/en-US/chrome/webapp.properties @@ -55,3 +55,5 @@ retrievalFailedTitle=#1 update failed;#1 updates failed # %1$S is a comma-separated list of apps for which retrieval failed. # example: Failed to retrieve updates for Foo, Bar, Baz retrievalFailedMessage=Failed to retrieve update for %1$S;Failed to retrieve updates for %1$S + +webappsDisabledInGuest=Installing apps is disabled in guest sessions diff --git a/mobile/android/modules/WebappManager.jsm b/mobile/android/modules/WebappManager.jsm index 273a5af5b413..31adf263fab2 100644 --- a/mobile/android/modules/WebappManager.jsm +++ b/mobile/android/modules/WebappManager.jsm @@ -89,6 +89,12 @@ this.WebappManager = { }, _installApk: function(aMessage, aMessageManager) { return Task.spawn((function*() { + if (this.inGuestSession()) { + aMessage.error = Strings.GetStringFromName("webappsDisabledInGuest"), + aMessageManager.sendAsyncMessage("Webapps:Install:Return:KO", aMessage); + return; + } + let filePath; try { @@ -251,6 +257,10 @@ this.WebappManager = { }), + inGuestSession: function() { + return Services.wm.getMostRecentWindow("navigator:browser").BrowserApp.isGuest; + }, + autoInstall: function(aData) { debug("autoInstall " + aData.manifestURL);