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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ehsan Akhgari 2018-10-30 07:48:55 +00:00
Родитель 11d5b2d27f
Коммит 54b2e44577
16 изменённых файлов: 16 добавлений и 62 удалений

Просмотреть файл

@ -211,11 +211,9 @@ ContentPermissionRequestParent::IsBeingDestroyed()
NS_IMPL_ISUPPORTS(ContentPermissionType, nsIContentPermissionType)
ContentPermissionType::ContentPermissionType(const nsACString& aType,
const nsACString& aAccess,
const nsTArray<nsString>& aOptions)
{
mType = aType;
mAccess = aAccess;
mOptions = aOptions;
}
@ -230,13 +228,6 @@ ContentPermissionType::GetType(nsACString& aType)
return NS_OK;
}
NS_IMETHODIMP
ContentPermissionType::GetAccess(nsACString& aAccess)
{
aAccess = mAccess;
return NS_OK;
}
NS_IMETHODIMP
ContentPermissionType::GetOptions(nsIArray** aOptions)
{
@ -276,7 +267,6 @@ nsContentPermissionUtils::ConvertPermissionRequestToArray(nsTArray<PermissionReq
for (uint32_t i = 0; i < len; i++) {
RefPtr<ContentPermissionType> cpt =
new ContentPermissionType(aSrcArray[i].type(),
aSrcArray[i].access(),
aSrcArray[i].options());
aDesArray->AppendElement(cpt);
}
@ -292,9 +282,7 @@ nsContentPermissionUtils::ConvertArrayToPermissionRequest(nsIArray* aSrcArray,
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));
@ -312,7 +300,7 @@ nsContentPermissionUtils::ConvertArrayToPermissionRequest(nsIArray* aSrcArray,
}
}
aDesArray.AppendElement(PermissionRequest(type, access, options));
aDesArray.AppendElement(PermissionRequest(type, options));
}
return len;
}
@ -335,14 +323,12 @@ ContentPermissionRequestChildMap()
/* static */ nsresult
nsContentPermissionUtils::CreatePermissionArray(const nsACString& aType,
const nsACString& aAccess,
const nsTArray<nsString>& aOptions,
nsIArray** aTypesArray)
{
nsCOMPtr<nsIMutableArray> types = do_CreateInstance(NS_ARRAY_CONTRACTID);
RefPtr<ContentPermissionType> permType = new ContentPermissionType(aType,
aAccess,
aOptions);
aOptions);
types->AppendElement(permType);
types.forget(aTypesArray);

Просмотреть файл

@ -48,14 +48,12 @@ public:
NS_DECL_NSICONTENTPERMISSIONTYPE
ContentPermissionType(const nsACString& aType,
const nsACString& aAccess,
const nsTArray<nsString>& aOptions);
protected:
virtual ~ContentPermissionType();
nsCString mType;
nsCString mAccess;
nsTArray<nsString> mOptions;
};
@ -72,7 +70,6 @@ public:
static nsresult
CreatePermissionArray(const nsACString& aType,
const nsACString& aAccess,
const nsTArray<nsString>& aOptions,
nsIArray** aTypesArray);

Просмотреть файл

@ -303,7 +303,6 @@ nsGeolocationRequest::GetTypes(nsIArray** aTypes)
{
nsTArray<nsString> emptyOptions;
return nsContentPermissionUtils::CreatePermissionArray(NS_LITERAL_CSTRING("geolocation"),
NS_LITERAL_CSTRING("unused"),
emptyOptions,
aTypes);
}

Просмотреть файл

@ -56,7 +56,6 @@ AutoplayPermissionRequest::GetTypes(nsIArray** aTypes)
nsTArray<nsString> emptyOptions;
return dom::nsContentPermissionUtils::CreatePermissionArray(
NS_LITERAL_CSTRING("autoplay-media"),
NS_LITERAL_CSTRING("unused"),
emptyOptions,
aTypes);
}

Просмотреть файл

@ -21,12 +21,6 @@ interface nsIContentPermissionType : nsISupports {
*/
readonly attribute ACString type;
/**
* The access of the permission request, such as
* "read".
*/
readonly attribute ACString access;
/**
* The array of available options.
*/

Просмотреть файл

@ -7,7 +7,6 @@ namespace dom {
struct PermissionRequest {
nsCString type;
nsCString access;
nsString[] options;
};

Просмотреть файл

@ -69,7 +69,6 @@ MIDIPermissionRequest::GetTypes(nsIArray** aTypes)
options.AppendElement(NS_LITERAL_STRING("sysex"));
}
return nsContentPermissionUtils::CreatePermissionArray(NS_LITERAL_CSTRING("midi"),
NS_LITERAL_CSTRING("unused"),
options,
aTypes);
}

Просмотреть файл

@ -680,7 +680,6 @@ NotificationPermissionRequest::GetTypes(nsIArray** aTypes)
{
nsTArray<nsString> emptyOptions;
return nsContentPermissionUtils::CreatePermissionArray(NS_LITERAL_CSTRING("desktop-notification"),
NS_LITERAL_CSTRING("unused"),
emptyOptions,
aTypes);
}

Просмотреть файл

@ -180,7 +180,6 @@ Push.prototype = {
// Create an array with a single nsIContentPermissionType element.
let type = {
type: "desktop-notification",
access: null,
options: [],
QueryInterface: ChromeUtils.generateQI([Ci.nsIContentPermissionType]),
};

Просмотреть файл

@ -814,7 +814,6 @@ PersistentStoragePermissionRequest::GetTypes(nsIArray** aTypes)
return nsContentPermissionUtils::CreatePermissionArray(
NS_LITERAL_CSTRING("persistent-storage"),
NS_LITERAL_CSTRING("unused"),
emptyOptions,
aTypes);
}

Просмотреть файл

@ -17,12 +17,6 @@ const kEntities = {
"geolocation": "geolocation",
};
// For these types, prompt for permission if action is unknown.
const PROMPT_FOR_UNKNOWN = [
"desktop-notification",
"geolocation",
];
function ContentPermissionPrompt() {}
ContentPermissionPrompt.prototype = {
@ -30,7 +24,7 @@ ContentPermissionPrompt.prototype = {
QueryInterface: ChromeUtils.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);
@ -42,7 +36,7 @@ ContentPermissionPrompt.prototype = {
return true;
}
if (denyUnknown && result == Ci.nsIPermissionManager.UNKNOWN_ACTION) {
if (isApp && result == Ci.nsIPermissionManager.UNKNOWN_ACTION) {
callback(/* allow */ false);
return true;
}
@ -92,10 +86,7 @@ ContentPermissionPrompt.prototype = {
};
// 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;
}
@ -107,7 +98,7 @@ ContentPermissionPrompt.prototype = {
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);
},
@ -117,10 +108,10 @@ ContentPermissionPrompt.prototype = {
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);

Просмотреть файл

@ -205,7 +205,6 @@ GeckoViewPermission.prototype = {
type: "GeckoView:ContentPermission",
uri: aRequest.principal.URI.displaySpec,
perm: perm.type,
access: perm.access !== "unused" ? perm.access : null,
}).then(granted => {
if (!granted) {
return false;

Просмотреть файл

@ -127,11 +127,10 @@ class PermissionDelegateTest : BaseSessionTest() {
mainSession.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
// Ensure the content permission is asked first, before the Android permission.
@AssertCalled(count = 1, order = [1])
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) {
assertThat("URI should match", uri, endsWith(HELLO_HTML_PATH))
assertThat("Type should match", type,
equalTo(GeckoSession.PermissionDelegate.PERMISSION_GEOLOCATION))
assertThat("Access should be null", access, nullValue())
callback.grant()
}
@ -159,7 +158,7 @@ class PermissionDelegateTest : BaseSessionTest() {
mainSession.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
@AssertCalled(count = 1)
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()
}
@ -182,11 +181,10 @@ class PermissionDelegateTest : BaseSessionTest() {
mainSession.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
@AssertCalled(count = 1)
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) {
assertThat("URI should match", uri, endsWith(HELLO_HTML_PATH))
assertThat("Type should match", type,
equalTo(GeckoSession.PermissionDelegate.PERMISSION_DESKTOP_NOTIFICATION))
assertThat("Access should be null", access, nullValue())
callback.grant()
}
})
@ -204,7 +202,7 @@ class PermissionDelegateTest : BaseSessionTest() {
mainSession.delegateDuringNextWait(object : Callbacks.PermissionDelegate {
@AssertCalled(count = 1)
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()
}
})

Просмотреть файл

@ -75,7 +75,7 @@ class Callbacks private constructor() {
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()
}

Просмотреть файл

@ -521,8 +521,7 @@ public class GeckoSession extends LayerSession
}
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");
@ -3317,12 +3316,10 @@ public class GeckoSession extends LayerSession
* PERMISSION_GEOLOCATION
* PERMISSION_DESKTOP_NOTIFICATION
* PERMISSION_AUTOPLAY_MEDIA
* @param access Not used.
* @param callback Callback interface.
*/
void onContentPermissionRequest(GeckoSession session, String uri,
@Permission int type,
String access, Callback callback);
@Permission int type, Callback callback);
class MediaSource {
@IntDef({SOURCE_CAMERA, SOURCE_SCREEN, SOURCE_APPLICATION,

Просмотреть файл

@ -545,8 +545,7 @@ public class GeckoViewActivity extends AppCompatActivity {
@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;