|
@@ -0,0 +1,544 @@
|
|
|
+# HG changeset patch
|
|
|
+# User Ehsan Akhgari <ehsan@mozilla.com>
|
|
|
+# Date 1540885735 0
|
|
|
+# Node ID 60129b9fe3f652601b1fdbe0d3bc2786f0ca4105
|
|
|
+# Parent 307d45ba0b837b15c12d1a06e831c173f9bd62a3
|
|
|
+Bug 1502747 - Remove nsIContentPermissionType.access and all of its supporting code r=snorp,baku
|
|
|
+
|
|
|
+This field was originally added for the b2g-only DeviceStorage API,
|
|
|
+and isn't used for anything else right now.
|
|
|
+
|
|
|
+This reverts the remaining parts of bug 1043136 and bug 1043136
|
|
|
+as well as some support code for mobile.
|
|
|
+
|
|
|
+Differential Revision: https://phabricator.services.mozilla.com/D10014
|
|
|
+
|
|
|
+diff --git a/dom/base/nsContentPermissionHelper.cpp b/dom/base/nsContentPermissionHelper.cpp
|
|
|
+--- a/dom/base/nsContentPermissionHelper.cpp
|
|
|
++++ b/dom/base/nsContentPermissionHelper.cpp
|
|
|
+@@ -190,38 +190,31 @@ bool ContentPermissionRequestParent::IsB
|
|
|
+ // It's unsafe to send out any message now.
|
|
|
+ ContentParent* contentParent = static_cast<ContentParent*>(Manager());
|
|
|
+ return !contentParent->IsAlive();
|
|
|
+ }
|
|
|
+
|
|
|
+ NS_IMPL_ISUPPORTS(ContentPermissionType, nsIContentPermissionType)
|
|
|
+
|
|
|
+ ContentPermissionType::ContentPermissionType(
|
|
|
+- const nsACString& aType, const nsACString& aAccess,
|
|
|
++ const nsACString& aType,
|
|
|
+ const nsTArray<nsString>& aOptions) {
|
|
|
+ mType = aType;
|
|
|
+- mAccess = aAccess;
|
|
|
+ mOptions = aOptions;
|
|
|
+ }
|
|
|
+
|
|
|
+ ContentPermissionType::~ContentPermissionType() {}
|
|
|
+
|
|
|
+ NS_IMETHODIMP
|
|
|
+ ContentPermissionType::GetType(nsACString& aType) {
|
|
|
+ aType = mType;
|
|
|
+ return NS_OK;
|
|
|
+ }
|
|
|
+
|
|
|
+ NS_IMETHODIMP
|
|
|
+-ContentPermissionType::GetAccess(nsACString& aAccess) {
|
|
|
+- aAccess = mAccess;
|
|
|
+- return NS_OK;
|
|
|
+-}
|
|
|
+-
|
|
|
+-NS_IMETHODIMP
|
|
|
+ ContentPermissionType::GetOptions(nsIArray** aOptions) {
|
|
|
+ NS_ENSURE_ARG_POINTER(aOptions);
|
|
|
+
|
|
|
+ *aOptions = nullptr;
|
|
|
+
|
|
|
+ nsresult rv;
|
|
|
+ nsCOMPtr<nsIMutableArray> options =
|
|
|
+ do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
|
|
|
+@@ -246,32 +239,30 @@ ContentPermissionType::GetOptions(nsIArr
|
|
|
+
|
|
|
+ // nsContentPermissionUtils
|
|
|
+
|
|
|
+ /* static */ uint32_t nsContentPermissionUtils::ConvertPermissionRequestToArray(
|
|
|
+ nsTArray<PermissionRequest>& aSrcArray, nsIMutableArray* aDesArray) {
|
|
|
+ uint32_t len = aSrcArray.Length();
|
|
|
+ for (uint32_t i = 0; i < len; i++) {
|
|
|
+ RefPtr<ContentPermissionType> cpt = new ContentPermissionType(
|
|
|
+- aSrcArray[i].type(), aSrcArray[i].access(), aSrcArray[i].options());
|
|
|
++ aSrcArray[i].type(), aSrcArray[i].options());
|
|
|
+ aDesArray->AppendElement(cpt);
|
|
|
+ }
|
|
|
+ return len;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* static */ uint32_t nsContentPermissionUtils::ConvertArrayToPermissionRequest(
|
|
|
+ nsIArray* aSrcArray, nsTArray<PermissionRequest>& aDesArray) {
|
|
|
+ uint32_t len = 0;
|
|
|
+ aSrcArray->GetLength(&len);
|
|
|
+ for (uint32_t i = 0; i < len; i++) {
|
|
|
+ nsCOMPtr<nsIContentPermissionType> cpt = do_QueryElementAt(aSrcArray, i);
|
|
|
+ nsAutoCString type;
|
|
|
+- nsAutoCString access;
|
|
|
+ cpt->GetType(type);
|
|
|
+- cpt->GetAccess(access);
|
|
|
+
|
|
|
+ nsCOMPtr<nsIArray> optionArray;
|
|
|
+ cpt->GetOptions(getter_AddRefs(optionArray));
|
|
|
+ uint32_t optionsLength = 0;
|
|
|
+ if (optionArray) {
|
|
|
+ optionArray->GetLength(&optionsLength);
|
|
|
+ }
|
|
|
+ nsTArray<nsString> options;
|
|
|
+@@ -280,17 +271,17 @@ ContentPermissionType::GetOptions(nsIArr
|
|
|
+ do_QueryElementAt(optionArray, j);
|
|
|
+ if (isupportsString) {
|
|
|
+ nsString option;
|
|
|
+ isupportsString->GetData(option);
|
|
|
+ options.AppendElement(option);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+- aDesArray.AppendElement(PermissionRequest(type, access, options));
|
|
|
++ aDesArray.AppendElement(PermissionRequest(type, options));
|
|
|
+ }
|
|
|
+ return len;
|
|
|
+ }
|
|
|
+
|
|
|
+ static std::map<PContentPermissionRequestParent*, TabId>&
|
|
|
+ ContentPermissionRequestParentMap() {
|
|
|
+ MOZ_ASSERT(NS_IsMainThread());
|
|
|
+ static std::map<PContentPermissionRequestParent*, TabId>
|
|
|
+@@ -302,21 +293,21 @@ static std::map<PContentPermissionReques
|
|
|
+ ContentPermissionRequestChildMap() {
|
|
|
+ MOZ_ASSERT(NS_IsMainThread());
|
|
|
+ static std::map<PContentPermissionRequestChild*, TabId>
|
|
|
+ sPermissionRequestChildMap;
|
|
|
+ return sPermissionRequestChildMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* static */ nsresult nsContentPermissionUtils::CreatePermissionArray(
|
|
|
+- const nsACString& aType, const nsACString& aAccess,
|
|
|
++ const nsACString& aType,
|
|
|
+ const nsTArray<nsString>& aOptions, nsIArray** aTypesArray) {
|
|
|
+ nsCOMPtr<nsIMutableArray> types = do_CreateInstance(NS_ARRAY_CONTRACTID);
|
|
|
+ RefPtr<ContentPermissionType> permType =
|
|
|
+- new ContentPermissionType(aType, aAccess, aOptions);
|
|
|
++ new ContentPermissionType(aType, aOptions);
|
|
|
+ types->AppendElement(permType);
|
|
|
+ types.forget(aTypesArray);
|
|
|
+
|
|
|
+ return NS_OK;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* static */ PContentPermissionRequestParent*
|
|
|
+ nsContentPermissionUtils::CreateContentPermissionRequestParent(
|
|
|
+diff --git a/dom/base/nsContentPermissionHelper.h b/dom/base/nsContentPermissionHelper.h
|
|
|
+--- a/dom/base/nsContentPermissionHelper.h
|
|
|
++++ b/dom/base/nsContentPermissionHelper.h
|
|
|
+@@ -41,37 +41,35 @@ class PermissionRequest;
|
|
|
+ class ContentPermissionRequestParent;
|
|
|
+ class PContentPermissionRequestParent;
|
|
|
+
|
|
|
+ class ContentPermissionType : public nsIContentPermissionType {
|
|
|
+ public:
|
|
|
+ NS_DECL_ISUPPORTS
|
|
|
+ NS_DECL_NSICONTENTPERMISSIONTYPE
|
|
|
+
|
|
|
+- ContentPermissionType(const nsACString& aType, const nsACString& aAccess,
|
|
|
++ ContentPermissionType(const nsACString& aType,
|
|
|
+ const nsTArray<nsString>& aOptions);
|
|
|
+
|
|
|
+ protected:
|
|
|
+ virtual ~ContentPermissionType();
|
|
|
+
|
|
|
+ nsCString mType;
|
|
|
+- nsCString mAccess;
|
|
|
+ nsTArray<nsString> mOptions;
|
|
|
+ };
|
|
|
+
|
|
|
+ class nsContentPermissionUtils {
|
|
|
+ public:
|
|
|
+ static uint32_t ConvertPermissionRequestToArray(
|
|
|
+ nsTArray<PermissionRequest>& aSrcArray, nsIMutableArray* aDesArray);
|
|
|
+
|
|
|
+ static uint32_t ConvertArrayToPermissionRequest(
|
|
|
+ nsIArray* aSrcArray, nsTArray<PermissionRequest>& aDesArray);
|
|
|
+
|
|
|
+ static nsresult CreatePermissionArray(const nsACString& aType,
|
|
|
+- const nsACString& aAccess,
|
|
|
+ const nsTArray<nsString>& aOptions,
|
|
|
+ nsIArray** aTypesArray);
|
|
|
+
|
|
|
+ static PContentPermissionRequestParent* CreateContentPermissionRequestParent(
|
|
|
+ const nsTArray<PermissionRequest>& aRequests, Element* aElement,
|
|
|
+ const IPC::Principal& aPrincipal, const bool aIsHandlingUserInput,
|
|
|
+ const TabId& aTabId);
|
|
|
+
|
|
|
+diff --git a/dom/geolocation/nsGeolocation.cpp b/dom/geolocation/nsGeolocation.cpp
|
|
|
+--- a/dom/geolocation/nsGeolocation.cpp
|
|
|
++++ b/dom/geolocation/nsGeolocation.cpp
|
|
|
+@@ -334,17 +334,17 @@ nsGeolocationRequest::GetPrincipal(nsIPr
|
|
|
+
|
|
|
+ return NS_OK;
|
|
|
+ }
|
|
|
+
|
|
|
+ NS_IMETHODIMP
|
|
|
+ nsGeolocationRequest::GetTypes(nsIArray** aTypes) {
|
|
|
+ nsTArray<nsString> emptyOptions;
|
|
|
+ return nsContentPermissionUtils::CreatePermissionArray(
|
|
|
+- NS_LITERAL_CSTRING("geolocation"), NS_LITERAL_CSTRING("unused"),
|
|
|
++ NS_LITERAL_CSTRING("geolocation"),
|
|
|
+ emptyOptions, aTypes);
|
|
|
+ }
|
|
|
+
|
|
|
+ NS_IMETHODIMP
|
|
|
+ nsGeolocationRequest::GetWindow(mozIDOMWindow** aRequestingWindow) {
|
|
|
+ NS_ENSURE_ARG_POINTER(aRequestingWindow);
|
|
|
+
|
|
|
+ nsCOMPtr<nsPIDOMWindowInner> window = do_QueryReferent(mLocator->GetOwner());
|
|
|
+diff --git a/dom/interfaces/base/nsIContentPermissionPrompt.idl b/dom/interfaces/base/nsIContentPermissionPrompt.idl
|
|
|
+--- a/dom/interfaces/base/nsIContentPermissionPrompt.idl
|
|
|
++++ b/dom/interfaces/base/nsIContentPermissionPrompt.idl
|
|
|
+@@ -16,22 +16,16 @@ interface nsIArray;
|
|
|
+ interface nsIContentPermissionType : nsISupports {
|
|
|
+ /**
|
|
|
+ * The type of the permission request, such as
|
|
|
+ * "geolocation".
|
|
|
+ */
|
|
|
+ readonly attribute ACString type;
|
|
|
+
|
|
|
+ /**
|
|
|
+- * The access of the permission request, such as
|
|
|
+- * "read".
|
|
|
+- */
|
|
|
+- readonly attribute ACString access;
|
|
|
+-
|
|
|
+- /**
|
|
|
+ * The array of available options.
|
|
|
+ */
|
|
|
+ readonly attribute nsIArray options; // ["choice1", "choice2"]
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Interface provides the callback type.
|
|
|
+ */
|
|
|
+diff --git a/dom/ipc/PContentPermission.ipdlh b/dom/ipc/PContentPermission.ipdlh
|
|
|
+--- a/dom/ipc/PContentPermission.ipdlh
|
|
|
++++ b/dom/ipc/PContentPermission.ipdlh
|
|
|
+@@ -2,17 +2,16 @@
|
|
|
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
+
|
|
|
+ namespace mozilla {
|
|
|
+ namespace dom {
|
|
|
+
|
|
|
+ struct PermissionRequest {
|
|
|
+ nsCString type;
|
|
|
+- nsCString access;
|
|
|
+ nsString[] options;
|
|
|
+ };
|
|
|
+
|
|
|
+ struct PermissionChoice {
|
|
|
+ nsCString type;
|
|
|
+ nsString choice;
|
|
|
+ };
|
|
|
+
|
|
|
+diff --git a/dom/midi/MIDIPermissionRequest.cpp b/dom/midi/MIDIPermissionRequest.cpp
|
|
|
+--- a/dom/midi/MIDIPermissionRequest.cpp
|
|
|
++++ b/dom/midi/MIDIPermissionRequest.cpp
|
|
|
+@@ -59,17 +59,17 @@ MIDIPermissionRequest::GetRequester(
|
|
|
+ NS_IMETHODIMP
|
|
|
+ MIDIPermissionRequest::GetTypes(nsIArray** aTypes) {
|
|
|
+ NS_ENSURE_ARG_POINTER(aTypes);
|
|
|
+ nsTArray<nsString> options;
|
|
|
+ if (mNeedsSysex) {
|
|
|
+ options.AppendElement(NS_LITERAL_STRING("sysex"));
|
|
|
+ }
|
|
|
+ return nsContentPermissionUtils::CreatePermissionArray(
|
|
|
+- NS_LITERAL_CSTRING("midi"), NS_LITERAL_CSTRING("unused"), options,
|
|
|
++ NS_LITERAL_CSTRING("midi"), options,
|
|
|
+ aTypes);
|
|
|
+ }
|
|
|
+
|
|
|
+ NS_IMETHODIMP
|
|
|
+ MIDIPermissionRequest::GetPrincipal(nsIPrincipal** aRequestingPrincipal) {
|
|
|
+ NS_ENSURE_ARG_POINTER(aRequestingPrincipal);
|
|
|
+ NS_IF_ADDREF(*aRequestingPrincipal = mPrincipal);
|
|
|
+ return NS_OK;
|
|
|
+diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.cpp
|
|
|
+--- a/dom/notification/Notification.cpp
|
|
|
++++ b/dom/notification/Notification.cpp
|
|
|
+@@ -583,17 +583,17 @@ nsresult NotificationPermissionRequest::
|
|
|
+ mPromise->MaybeResolve(mPermission);
|
|
|
+ return rv;
|
|
|
+ }
|
|
|
+
|
|
|
+ NS_IMETHODIMP
|
|
|
+ NotificationPermissionRequest::GetTypes(nsIArray** aTypes) {
|
|
|
+ nsTArray<nsString> emptyOptions;
|
|
|
+ return nsContentPermissionUtils::CreatePermissionArray(
|
|
|
+- NS_LITERAL_CSTRING("desktop-notification"), NS_LITERAL_CSTRING("unused"),
|
|
|
++ NS_LITERAL_CSTRING("desktop-notification"),
|
|
|
+ emptyOptions, aTypes);
|
|
|
+ }
|
|
|
+
|
|
|
+ NS_IMPL_ISUPPORTS(NotificationTelemetryService, nsIObserver)
|
|
|
+
|
|
|
+ NotificationTelemetryService::NotificationTelemetryService()
|
|
|
+ : mDNDRecorded(false) {}
|
|
|
+
|
|
|
+diff --git a/dom/push/Push.js b/dom/push/Push.js
|
|
|
+--- a/dom/push/Push.js
|
|
|
++++ b/dom/push/Push.js
|
|
|
+@@ -175,17 +175,16 @@ Push.prototype = {
|
|
|
+ } catch (e) {}
|
|
|
+ return permission;
|
|
|
+ },
|
|
|
+
|
|
|
+ _requestPermission: function(allowCallback, cancelCallback) {
|
|
|
+ // Create an array with a single nsIContentPermissionType element.
|
|
|
+ let type = {
|
|
|
+ type: "desktop-notification",
|
|
|
+- access: null,
|
|
|
+ options: [],
|
|
|
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPermissionType]),
|
|
|
+ };
|
|
|
+ let typeArray = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
|
|
|
+ typeArray.appendElement(type);
|
|
|
+
|
|
|
+ // create a nsIContentPermissionRequest
|
|
|
+ let request = {
|
|
|
+diff --git a/dom/quota/StorageManager.cpp b/dom/quota/StorageManager.cpp
|
|
|
+--- a/dom/quota/StorageManager.cpp
|
|
|
++++ b/dom/quota/StorageManager.cpp
|
|
|
+@@ -730,17 +730,17 @@ PersistentStoragePermissionRequest::GetR
|
|
|
+
|
|
|
+ NS_IMETHODIMP
|
|
|
+ PersistentStoragePermissionRequest::GetTypes(nsIArray** aTypes) {
|
|
|
+ MOZ_ASSERT(aTypes);
|
|
|
+
|
|
|
+ nsTArray<nsString> emptyOptions;
|
|
|
+
|
|
|
+ return nsContentPermissionUtils::CreatePermissionArray(
|
|
|
+- NS_LITERAL_CSTRING("persistent-storage"), NS_LITERAL_CSTRING("unused"),
|
|
|
++ NS_LITERAL_CSTRING("persistent-storage"),
|
|
|
+ emptyOptions, aTypes);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*******************************************************************************
|
|
|
+ * StorageManager
|
|
|
+ ******************************************************************************/
|
|
|
+
|
|
|
+ StorageManager::StorageManager(nsIGlobalObject* aGlobal) : mOwner(aGlobal) {
|
|
|
+diff --git a/mobile/android/components/ContentPermissionPrompt.js b/mobile/android/components/ContentPermissionPrompt.js
|
|
|
+--- a/mobile/android/components/ContentPermissionPrompt.js
|
|
|
++++ b/mobile/android/components/ContentPermissionPrompt.js
|
|
|
+@@ -12,42 +12,36 @@ ChromeUtils.defineModuleGetter(this, "Do
|
|
|
+ "resource://gre/modules/Prompt.jsm");
|
|
|
+
|
|
|
+ const kEntities = {
|
|
|
+ "contacts": "contacts",
|
|
|
+ "desktop-notification": "desktopNotification2",
|
|
|
+ "geolocation": "geolocation",
|
|
|
+ };
|
|
|
+
|
|
|
+-// For these types, prompt for permission if action is unknown.
|
|
|
+-const PROMPT_FOR_UNKNOWN = [
|
|
|
+- "desktop-notification",
|
|
|
+- "geolocation",
|
|
|
+-];
|
|
|
+-
|
|
|
+ function ContentPermissionPrompt() {}
|
|
|
+
|
|
|
+ ContentPermissionPrompt.prototype = {
|
|
|
+ classID: Components.ID("{C6E8C44D-9F39-4AF7-BCC0-76E38A8310F5}"),
|
|
|
+
|
|
|
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPermissionPrompt]),
|
|
|
+
|
|
|
+- handleExistingPermission: function handleExistingPermission(request, type, denyUnknown, callback) {
|
|
|
++ handleExistingPermission: function handleExistingPermission(request, type, isApp, callback) {
|
|
|
+ let result = Services.perms.testExactPermissionFromPrincipal(request.principal, type);
|
|
|
+ if (result == Ci.nsIPermissionManager.ALLOW_ACTION) {
|
|
|
+ callback(/* allow */ true);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (result == Ci.nsIPermissionManager.DENY_ACTION) {
|
|
|
+ callback(/* allow */ false);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+- if (denyUnknown && result == Ci.nsIPermissionManager.UNKNOWN_ACTION) {
|
|
|
++ if (isApp && result == Ci.nsIPermissionManager.UNKNOWN_ACTION) {
|
|
|
+ callback(/* allow */ false);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ },
|
|
|
+
|
|
|
+ getChromeWindow: function getChromeWindow(aWindow) {
|
|
|
+@@ -92,45 +86,42 @@ ContentPermissionPrompt.prototype = {
|
|
|
+ (granted ? request.allow : request.cancel)();
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ request.allow();
|
|
|
+ };
|
|
|
+
|
|
|
+ // Returns true if the request was handled
|
|
|
+- let access = (perm.access && perm.access !== "unused") ?
|
|
|
+- (perm.type + "-" + perm.access) : perm.type;
|
|
|
+- if (this.handleExistingPermission(request, access,
|
|
|
+- /* denyUnknown */ isApp || !PROMPT_FOR_UNKNOWN.includes(perm.type), callback)) {
|
|
|
++ if (this.handleExistingPermission(request, perm.type, isApp, callback)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ let browserBundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
|
|
|
+ let entityName = kEntities[perm.type];
|
|
|
+
|
|
|
+ let buttons = [{
|
|
|
+ label: browserBundle.GetStringFromName(entityName + ".dontAllow"),
|
|
|
+ callback: function(aChecked) {
|
|
|
+ // If the user checked "Don't ask again" or this is a desktopNotification, make a permanent exception
|
|
|
+ if (aChecked || entityName == "desktopNotification2")
|
|
|
+- Services.perms.addFromPrincipal(request.principal, access, Ci.nsIPermissionManager.DENY_ACTION);
|
|
|
++ Services.perms.addFromPrincipal(request.principal, perm.type, Ci.nsIPermissionManager.DENY_ACTION);
|
|
|
+
|
|
|
+ callback(/* allow */ false);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: browserBundle.GetStringFromName(entityName + ".allow"),
|
|
|
+ callback: function(aChecked) {
|
|
|
+ // If the user checked "Don't ask again" or this is a desktopNotification, make a permanent exception
|
|
|
+ if (aChecked || entityName == "desktopNotification2") {
|
|
|
+- Services.perms.addFromPrincipal(request.principal, access, Ci.nsIPermissionManager.ALLOW_ACTION);
|
|
|
++ Services.perms.addFromPrincipal(request.principal, perm.type, Ci.nsIPermissionManager.ALLOW_ACTION);
|
|
|
+ } else if (isApp) {
|
|
|
+ // Otherwise allow the permission for the current session if the request comes from an app
|
|
|
+- Services.perms.addFromPrincipal(request.principal, access, Ci.nsIPermissionManager.ALLOW_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION);
|
|
|
++ Services.perms.addFromPrincipal(request.principal, perm.type, Ci.nsIPermissionManager.ALLOW_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION);
|
|
|
+ }
|
|
|
+
|
|
|
+ callback(/* allow */ true);
|
|
|
+ },
|
|
|
+ positive: true
|
|
|
+ }];
|
|
|
+
|
|
|
+ let chromeWin = this.getChromeForRequest(request);
|
|
|
+diff --git a/mobile/android/components/geckoview/GeckoViewPermission.js b/mobile/android/components/geckoview/GeckoViewPermission.js
|
|
|
+--- a/mobile/android/components/geckoview/GeckoViewPermission.js
|
|
|
++++ b/mobile/android/components/geckoview/GeckoViewPermission.js
|
|
|
+@@ -181,17 +181,16 @@ GeckoViewPermission.prototype = {
|
|
|
+
|
|
|
+ let perm = types.queryElementAt(0, Ci.nsIContentPermissionType);
|
|
|
+ let dispatcher = GeckoViewUtils.getDispatcherForWindow(
|
|
|
+ aRequest.window ? aRequest.window : aRequest.element.ownerGlobal);
|
|
|
+ dispatcher.sendRequestForResult({
|
|
|
+ type: "GeckoView:ContentPermission",
|
|
|
+ uri: aRequest.principal.URI.displaySpec,
|
|
|
+ perm: perm.type,
|
|
|
+- access: perm.access !== "unused" ? perm.access : null,
|
|
|
+ }).then(granted => {
|
|
|
+ if (!granted) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // Ask for app permission after asking for content permission.
|
|
|
+ if (perm.type === "geolocation") {
|
|
|
+ return this.getAppPermissions(dispatcher, [PERM_ACCESS_FINE_LOCATION]);
|
|
|
+ }
|
|
|
+diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/util/Callbacks.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/util/Callbacks.kt
|
|
|
+--- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/util/Callbacks.kt
|
|
|
++++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/util/Callbacks.kt
|
|
|
+@@ -49,17 +49,17 @@ class Callbacks private constructor() {
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ interface PermissionDelegate : GeckoSession.PermissionDelegate {
|
|
|
+ override fun onAndroidPermissionsRequest(session: GeckoSession, permissions: Array<out String>, callback: GeckoSession.PermissionDelegate.Callback) {
|
|
|
+ callback.reject()
|
|
|
+ }
|
|
|
+
|
|
|
+- override fun onContentPermissionRequest(session: GeckoSession, uri: String, type: Int, access: String, callback: GeckoSession.PermissionDelegate.Callback) {
|
|
|
++ override fun onContentPermissionRequest(session: GeckoSession, uri: String, type: Int, callback: GeckoSession.PermissionDelegate.Callback) {
|
|
|
+ callback.reject()
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onMediaPermissionRequest(session: GeckoSession, uri: String, video: Array<out GeckoSession.PermissionDelegate.MediaSource>, audio: Array<out GeckoSession.PermissionDelegate.MediaSource>, callback: GeckoSession.PermissionDelegate.MediaCallback) {
|
|
|
+ callback.reject()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
|
|
|
+--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
|
|
|
++++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
|
|
|
+@@ -285,18 +285,17 @@ public class GeckoSession extends LayerS
|
|
|
+ type = PermissionDelegate.PERMISSION_GEOLOCATION;
|
|
|
+ } else if ("desktop_notification".equals(typeString)) {
|
|
|
+ type = PermissionDelegate.PERMISSION_DESKTOP_NOTIFICATION;
|
|
|
+ } else {
|
|
|
+ throw new IllegalArgumentException("Unknown permission request: " + typeString);
|
|
|
+ }
|
|
|
+ delegate.onContentPermissionRequest(
|
|
|
+ GeckoSession.this, message.getString("uri"),
|
|
|
+- type, message.getString("access"),
|
|
|
+- new PermissionCallback(typeString, callback));
|
|
|
++ type, new PermissionCallback(typeString, callback));
|
|
|
+ } else if ("GeckoView:MediaPermission".equals(event)) {
|
|
|
+ GeckoBundle[] videoBundles = message.getBundleArray("video");
|
|
|
+ GeckoBundle[] audioBundles = message.getBundleArray("audio");
|
|
|
+ PermissionDelegate.MediaSource[] videos = null;
|
|
|
+ PermissionDelegate.MediaSource[] audios = null;
|
|
|
+
|
|
|
+ if (videoBundles != null) {
|
|
|
+ videos = new PermissionDelegate.MediaSource[videoBundles.length];
|
|
|
+@@ -2096,21 +2095,20 @@ public class GeckoSession extends LayerS
|
|
|
+ /**
|
|
|
+ * Request content permission.
|
|
|
+ *
|
|
|
+ * @param session GeckoSession instance requesting the permission.
|
|
|
+ * @param uri The URI of the content requesting the permission.
|
|
|
+ * @param type The type of the requested permission; possible values are,
|
|
|
+ * PERMISSION_GEOLOCATION
|
|
|
+ * PERMISSION_DESKTOP_NOTIFICATION
|
|
|
+- * @param access Not used.
|
|
|
+ * @param callback Callback interface.
|
|
|
+ */
|
|
|
+- void onContentPermissionRequest(GeckoSession session, String uri, int type,
|
|
|
+- String access, Callback callback);
|
|
|
++ void onContentPermissionRequest(GeckoSession session, String uri,
|
|
|
++ int type, Callback callback);
|
|
|
+
|
|
|
+ class MediaSource {
|
|
|
+ /**
|
|
|
+ * The media source is a camera.
|
|
|
+ */
|
|
|
+ public static final int SOURCE_CAMERA = 0;
|
|
|
+
|
|
|
+ /**
|
|
|
+diff --git a/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java b/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java
|
|
|
+--- a/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java
|
|
|
++++ b/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java
|
|
|
+@@ -258,18 +258,17 @@ public class GeckoViewActivity extends A
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ mCallback = callback;
|
|
|
+ requestPermissions(permissions, androidPermissionRequestCode);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onContentPermissionRequest(final GeckoSession session, final String uri,
|
|
|
+- final int type, final String access,
|
|
|
+- final Callback callback) {
|
|
|
++ final int type, final Callback callback) {
|
|
|
+ final int resId;
|
|
|
+ if (PERMISSION_GEOLOCATION == type) {
|
|
|
+ resId = R.string.request_geolocation;
|
|
|
+ } else if (PERMISSION_DESKTOP_NOTIFICATION == type) {
|
|
|
+ resId = R.string.request_notification;
|
|
|
+ } else {
|
|
|
+ Log.w(LOGTAG, "Unknown permission: " + type);
|
|
|
+ callback.reject();
|