Skip to content

Commit

Permalink
Bug 1379560 - Part 2 - Add support for custom default permissions in …
Browse files Browse the repository at this point in the history
…SitePermissions.jsm. r=Paolo

Part 1 added support for changing default permissions via pref. This
patch adds support in the frontend code, which is required to actually
make it work for most permission prompts.

This patch introduces the concept of SitePermissions.PROMPT (which
already exists in the permission manager) to distinguish between
the default UNKNOWN state and the explicit PROMPT state. They both
have the same effect (always asking the user for confirmation).

MozReview-Commit-ID: 2Gg9uwigter

UltraBlame original commit: 99b0d3748cdae722454c26912cccdc2fdbb60e44
  • Loading branch information
marco-c committed Oct 2, 2019
1 parent fd18cbe commit 81cbb6d
Show file tree
Hide file tree
Showing 5 changed files with 530 additions and 46 deletions.
26 changes: 14 additions & 12 deletions browser/base/content/pageinfo/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,14 +475,22 @@ gPermURI
aPartId
)
;
let
defaultState
=
SitePermissions
.
getDefault
(
aPartId
)
;
if
(
state
!
=
SitePermissions
.
UNKNOWN
defaultState
)
{
checkbox
Expand Down Expand Up @@ -521,15 +529,6 @@ true
"
)
;
state
=
SitePermissions
.
getDefault
(
aPartId
)
;
}
setRadioState
(
Expand Down Expand Up @@ -1221,6 +1220,8 @@ id
var
permission
=
parseInt
(
id
.
split
Expand All @@ -1232,6 +1233,7 @@ split
[
1
]
)
;
SitePermissions
.
Expand Down
30 changes: 30 additions & 0 deletions browser/components/preferences/sitePermissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1094,9 +1094,39 @@ state
SitePermissions
.
UNKNOWN
&
&
permission
.
capability
=
=
SitePermissions
.
PROMPT
)
{
state
=
SitePermissions
.
PROMPT
;
}
else
if
(
state
=
=
SitePermissions
.
UNKNOWN
)
{
continue
;
}
let
m
=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ current
blocked
=
Blocked
state
.
current
.
prompt
=
Always
Ask
#
LOCALIZATION
NOTE
Expand Down
140 changes: 108 additions & 32 deletions browser/modules/SitePermissions.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,13 @@ Services
perms
.
DENY_ACTION
PROMPT
:
Services
.
perms
.
PROMPT_ACTION
ALLOW_COOKIES_FOR_SESSION
:
Components
Expand Down Expand Up @@ -612,6 +619,21 @@ SitePermissions
SCOPE_PERSISTENT
}
"
_defaultPrefBranch
:
Services
.
prefs
.
getBranch
(
"
permissions
.
default
.
"
)
getAllByURI
(
uri
Expand Down Expand Up @@ -966,6 +988,9 @@ return
[
SitePermissions
.
PROMPT
SitePermissions
.
ALLOW
SitePermissions
.
Expand Down Expand Up @@ -1005,7 +1030,15 @@ getDefault
return
this
.
_defaultPrefBranch
.
getIntPref
(
permissionID
this
.
UNKNOWN
)
;
}
get
Expand All @@ -1016,14 +1049,22 @@ browser
)
{
let
defaultState
=
this
.
getDefault
(
permissionID
)
;
let
result
=
{
state
:
this
.
UNKNOWN
defaultState
scope
:
this
Expand Down Expand Up @@ -1131,10 +1172,12 @@ SCOPE_SESSION
}
if
(
!
result
.
state
=
=
defaultState
)
{
let
Expand Down Expand Up @@ -1198,6 +1241,17 @@ state
this
.
UNKNOWN
|
|
state
=
=
this
.
getDefault
(
permissionID
)
)
{
this
Expand Down Expand Up @@ -1524,6 +1578,11 @@ this
.
UNKNOWN
:
case
this
.
PROMPT
:
return
gStringBundle
.
Expand Down Expand Up @@ -1618,6 +1677,25 @@ state
case
this
.
PROMPT
:
return
gStringBundle
.
GetStringFromName
(
"
state
.
current
.
prompt
"
)
;
case
this
.
ALLOW
:
if
Expand Down Expand Up @@ -1742,38 +1820,16 @@ image
"
:
{
getDefault
(
)
{
return
Services
.
prefs
.
getIntPref
(
"
permissions
.
default
.
image
"
)
=
=
2
?
SitePermissions
.
BLOCK
states
:
[
SitePermissions
.
ALLOW
;
}
SitePermissions
.
BLOCK
]
}
"
cookie
Expand Down Expand Up @@ -1941,6 +1997,16 @@ SitePermissions
ALLOW
;
}
states
:
[
SitePermissions
.
ALLOW
SitePermissions
.
BLOCK
]
}
"
install
Expand Down Expand Up @@ -1976,6 +2042,16 @@ SitePermissions
ALLOW
;
}
states
:
[
SitePermissions
.
ALLOW
SitePermissions
.
BLOCK
]
}
"
geo
Expand Down
Loading

0 comments on commit 81cbb6d

Please sign in to comment.