Skip to content

Commit 81cbb6d

Browse files
committed
Bug 1379560 - Part 2 - Add support for custom default permissions in 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
1 parent fd18cbe commit 81cbb6d

File tree

5 files changed

+530
-46
lines changed

5 files changed

+530
-46
lines changed

browser/base/content/pageinfo/permissions.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -475,14 +475,22 @@ gPermURI
475475
aPartId
476476
)
477477
;
478+
let
479+
defaultState
480+
=
481+
SitePermissions
482+
.
483+
getDefault
484+
(
485+
aPartId
486+
)
487+
;
478488
if
479489
(
480490
state
481491
!
482492
=
483-
SitePermissions
484-
.
485-
UNKNOWN
493+
defaultState
486494
)
487495
{
488496
checkbox
@@ -521,15 +529,6 @@ true
521529
"
522530
)
523531
;
524-
state
525-
=
526-
SitePermissions
527-
.
528-
getDefault
529-
(
530-
aPartId
531-
)
532-
;
533532
}
534533
setRadioState
535534
(
@@ -1221,6 +1220,8 @@ id
12211220
var
12221221
permission
12231222
=
1223+
parseInt
1224+
(
12241225
id
12251226
.
12261227
split
@@ -1232,6 +1233,7 @@ split
12321233
[
12331234
1
12341235
]
1236+
)
12351237
;
12361238
SitePermissions
12371239
.

browser/components/preferences/sitePermissions.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,9 +1094,39 @@ state
10941094
SitePermissions
10951095
.
10961096
UNKNOWN
1097+
&
1098+
&
1099+
permission
1100+
.
1101+
capability
1102+
=
1103+
=
1104+
SitePermissions
1105+
.
1106+
PROMPT
1107+
)
1108+
{
1109+
state
1110+
=
1111+
SitePermissions
1112+
.
1113+
PROMPT
1114+
;
1115+
}
1116+
else
1117+
if
1118+
(
1119+
state
1120+
=
1121+
=
1122+
SitePermissions
1123+
.
1124+
UNKNOWN
10971125
)
1126+
{
10981127
continue
10991128
;
1129+
}
11001130
let
11011131
m
11021132
=

browser/locales/en-US/chrome/browser/sitePermissions.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ current
155155
blocked
156156
=
157157
Blocked
158+
state
159+
.
160+
current
161+
.
162+
prompt
163+
=
164+
Always
165+
Ask
158166
#
159167
LOCALIZATION
160168
NOTE

browser/modules/SitePermissions.jsm

Lines changed: 108 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,13 @@ Services
567567
perms
568568
.
569569
DENY_ACTION
570+
PROMPT
571+
:
572+
Services
573+
.
574+
perms
575+
.
576+
PROMPT_ACTION
570577
ALLOW_COOKIES_FOR_SESSION
571578
:
572579
Components
@@ -612,6 +619,21 @@ SitePermissions
612619
SCOPE_PERSISTENT
613620
}
614621
"
622+
_defaultPrefBranch
623+
:
624+
Services
625+
.
626+
prefs
627+
.
628+
getBranch
629+
(
630+
"
631+
permissions
632+
.
633+
default
634+
.
635+
"
636+
)
615637
getAllByURI
616638
(
617639
uri
@@ -966,6 +988,9 @@ return
966988
[
967989
SitePermissions
968990
.
991+
PROMPT
992+
SitePermissions
993+
.
969994
ALLOW
970995
SitePermissions
971996
.
@@ -1005,7 +1030,15 @@ getDefault
10051030
return
10061031
this
10071032
.
1033+
_defaultPrefBranch
1034+
.
1035+
getIntPref
1036+
(
1037+
permissionID
1038+
this
1039+
.
10081040
UNKNOWN
1041+
)
10091042
;
10101043
}
10111044
get
@@ -1016,14 +1049,22 @@ browser
10161049
)
10171050
{
10181051
let
1052+
defaultState
1053+
=
1054+
this
1055+
.
1056+
getDefault
1057+
(
1058+
permissionID
1059+
)
1060+
;
1061+
let
10191062
result
10201063
=
10211064
{
10221065
state
10231066
:
1024-
this
1025-
.
1026-
UNKNOWN
1067+
defaultState
10271068
scope
10281069
:
10291070
this
@@ -1131,10 +1172,12 @@ SCOPE_SESSION
11311172
}
11321173
if
11331174
(
1134-
!
11351175
result
11361176
.
11371177
state
1178+
=
1179+
=
1180+
defaultState
11381181
)
11391182
{
11401183
let
@@ -1198,6 +1241,17 @@ state
11981241
this
11991242
.
12001243
UNKNOWN
1244+
|
1245+
|
1246+
state
1247+
=
1248+
=
1249+
this
1250+
.
1251+
getDefault
1252+
(
1253+
permissionID
1254+
)
12011255
)
12021256
{
12031257
this
@@ -1524,6 +1578,11 @@ this
15241578
.
15251579
UNKNOWN
15261580
:
1581+
case
1582+
this
1583+
.
1584+
PROMPT
1585+
:
15271586
return
15281587
gStringBundle
15291588
.
@@ -1618,6 +1677,25 @@ state
16181677
case
16191678
this
16201679
.
1680+
PROMPT
1681+
:
1682+
return
1683+
gStringBundle
1684+
.
1685+
GetStringFromName
1686+
(
1687+
"
1688+
state
1689+
.
1690+
current
1691+
.
1692+
prompt
1693+
"
1694+
)
1695+
;
1696+
case
1697+
this
1698+
.
16211699
ALLOW
16221700
:
16231701
if
@@ -1742,38 +1820,16 @@ image
17421820
"
17431821
:
17441822
{
1745-
getDefault
1746-
(
1747-
)
1748-
{
1749-
return
1750-
Services
1751-
.
1752-
prefs
1753-
.
1754-
getIntPref
1755-
(
1756-
"
1757-
permissions
1758-
.
1759-
default
1760-
.
1761-
image
1762-
"
1763-
)
1764-
=
1765-
=
1766-
2
1767-
?
1768-
SitePermissions
1769-
.
1770-
BLOCK
1823+
states
17711824
:
1825+
[
17721826
SitePermissions
17731827
.
17741828
ALLOW
1775-
;
1776-
}
1829+
SitePermissions
1830+
.
1831+
BLOCK
1832+
]
17771833
}
17781834
"
17791835
cookie
@@ -1941,6 +1997,16 @@ SitePermissions
19411997
ALLOW
19421998
;
19431999
}
2000+
states
2001+
:
2002+
[
2003+
SitePermissions
2004+
.
2005+
ALLOW
2006+
SitePermissions
2007+
.
2008+
BLOCK
2009+
]
19442010
}
19452011
"
19462012
install
@@ -1976,6 +2042,16 @@ SitePermissions
19762042
ALLOW
19772043
;
19782044
}
2045+
states
2046+
:
2047+
[
2048+
SitePermissions
2049+
.
2050+
ALLOW
2051+
SitePermissions
2052+
.
2053+
BLOCK
2054+
]
19792055
}
19802056
"
19812057
geo

0 commit comments

Comments
 (0)