Revert the removal of an option to block autoplay

This commit is contained in:
Carmelo Messina 2020-11-07 23:03:08 +01:00
parent a3d4ff7371
commit 36e72671b0
2 changed files with 649 additions and 0 deletions

View file

@ -150,4 +150,5 @@ Remove-weblayer-dependency-on-Play-Services.patch
Timezone-customization.patch
Move-some-account-settings-back-to-privacy-settings.patch
Add-a-flag-to-always-view-desktop-site-for-all-websites.patch
Revert-removal-option-to-block-autoplay.patch
Automated-domain-substitution.patch

View file

@ -0,0 +1,648 @@
From: uazo <uazo@users.noreply.github.com>
Date: Sat, 7 Nov 2020 21:59:18 +0000
Subject: Revert the removal of an option to block autoplay
---
.../browser_ui/site_settings/android/BUILD.gn | 10 ++++++++++
.../res/drawable-hdpi/settings_autoplay.png | Bin 0 -> 456 bytes
.../java/res/drawable-hdpi/settings_media.png | Bin 0 -> 196 bytes
.../res/drawable-mdpi/settings_autoplay.png | Bin 0 -> 296 bytes
.../java/res/drawable-mdpi/settings_media.png | Bin 0 -> 144 bytes
.../res/drawable-xhdpi/settings_autoplay.png | Bin 0 -> 551 bytes
.../res/drawable-xhdpi/settings_media.png | Bin 0 -> 227 bytes
.../res/drawable-xxhdpi/settings_autoplay.png | Bin 0 -> 792 bytes
.../res/drawable-xxhdpi/settings_media.png | Bin 0 -> 297 bytes
.../drawable-xxxhdpi/settings_autoplay.png | Bin 0 -> 1064 bytes
.../res/drawable-xxxhdpi/settings_media.png | Bin 0 -> 383 bytes
.../res/xml/single_website_preferences.xml | 2 ++
.../res/xml/site_settings_preferences.xml | 11 +++++++++++
.../ContentSettingsResources.java | 5 +++++
.../site_settings/SingleCategorySettings.java | 6 ++++++
.../site_settings/SingleWebsiteSettings.java | 2 ++
.../site_settings/SiteSettingsCategory.java | 12 +++++++++---
.../WebsitePermissionsFetcher.java | 5 +++++
.../WebsitePreferenceBridge.java | 9 +++++++++
.../android/website_preference_bridge.cc | 18 ++++++++++++++++++
.../strings/android/site_settings.grdp | 12 ++++++++++++
.../core/browser/content_settings_utils.cc | 2 ++
.../core/common/content_settings.cc | 1 +
.../core/common/content_settings.h | 1 +
.../core/common/content_settings.mojom | 1 +
.../common/content_settings_mojom_traits.cc | 1 +
.../common/content_settings_mojom_traits.h | 5 +++++
.../renderer/content_settings_agent_impl.cc | 11 +++++++++++
.../renderer/content_settings_agent_impl.h | 1 +
.../android/page_info_controller_android.cc | 1 +
.../platform/web_content_settings_client.h | 3 +++
.../core/html/media/autoplay_policy.cc | 12 +++++++++++-
.../core/html/media/autoplay_policy.h | 4 ++++
33 files changed, 131 insertions(+), 4 deletions(-)
create mode 100755 components/browser_ui/site_settings/android/java/res/drawable-hdpi/settings_autoplay.png
create mode 100755 components/browser_ui/site_settings/android/java/res/drawable-hdpi/settings_media.png
create mode 100755 components/browser_ui/site_settings/android/java/res/drawable-mdpi/settings_autoplay.png
create mode 100755 components/browser_ui/site_settings/android/java/res/drawable-mdpi/settings_media.png
create mode 100755 components/browser_ui/site_settings/android/java/res/drawable-xhdpi/settings_autoplay.png
create mode 100755 components/browser_ui/site_settings/android/java/res/drawable-xhdpi/settings_media.png
create mode 100755 components/browser_ui/site_settings/android/java/res/drawable-xxhdpi/settings_autoplay.png
create mode 100755 components/browser_ui/site_settings/android/java/res/drawable-xxhdpi/settings_media.png
create mode 100755 components/browser_ui/site_settings/android/java/res/drawable-xxxhdpi/settings_autoplay.png
create mode 100755 components/browser_ui/site_settings/android/java/res/drawable-xxxhdpi/settings_media.png
diff --git a/components/browser_ui/site_settings/android/BUILD.gn b/components/browser_ui/site_settings/android/BUILD.gn
--- a/components/browser_ui/site_settings/android/BUILD.gn
+++ b/components/browser_ui/site_settings/android/BUILD.gn
@@ -189,6 +189,16 @@ android_resources("java_resources") {
"java/res/drawable-xxxhdpi/settings_storage.png",
"java/res/drawable-xxxhdpi/settings_usb.png",
"java/res/drawable-xxxhdpi/web_asset.png",
+ "java/res/drawable-hdpi/settings_autoplay.png",
+ "java/res/drawable-hdpi/settings_media.png",
+ "java/res/drawable-xhdpi/settings_autoplay.png",
+ "java/res/drawable-xhdpi/settings_media.png",
+ "java/res/drawable-xxhdpi/settings_autoplay.png",
+ "java/res/drawable-xxhdpi/settings_media.png",
+ "java/res/drawable-mdpi/settings_autoplay.png",
+ "java/res/drawable-mdpi/settings_media.png",
+ "java/res/drawable-xxxhdpi/settings_autoplay.png",
+ "java/res/drawable-xxxhdpi/settings_media.png",
"java/res/drawable/ic_person_24dp.xml",
"java/res/drawable/settings_bluetooth.xml",
"java/res/layout/add_site_dialog.xml",
diff --git a/components/browser_ui/site_settings/android/java/res/drawable-hdpi/settings_autoplay.png b/components/browser_ui/site_settings/android/java/res/drawable-hdpi/settings_autoplay.png
new file mode 100755
GIT binary patch
literal 456
zcmV;(0XP1MP)<h;3K|Lk000e1NJLTq001Na001Ni1ONa4O9@aD0004xNkl<Zcmd^>
zv2MaJ5QYmZs7m@68Tt%)0T}7#GcJmh4B69}fh}W`x!sUhd4N1chpY%8u@-es;cQTy
zGbWY1VQ**q%l&uuT^{am%=;qbIaI7>hvTfF;<*Ut{eMAbL!QB&HFUzBXR~2P41Zx8
z)>!6-O>RP(9xN_j-$FSZiy-wPUj)-Jl(4<5Et;Mc!<K5}jwP!>dwn%v3G5VXX+fR6
zfpz3x+Y|Y)K6`aNHVw{qdv4}^DAdl0F;g<cu%;M_QeJHg8RVIajV_AK%qV!0vEmv1
z#vVbjZa-Q+lSd;emiMaVzX)Z*+nGY^7d%tYY9KFz2z6mO9x2+}RepX<5}`zKxo)iR
zz{m)~NhMClXs`4GHM$vG2T_S4KzpqpIGl{BX8{q3sfX5s0TlVSK=Ataj-&0{v9#{N
z{;&j_q`#yfB8jBm<%OhAge7edm84b@`b2QRo9WRKN#xNwD<h5zoBL8ri$BDs;tw$`
y{$1Kp0i#npN<C~x1#L&}8>IV|-Tf!x{>CqV{oZM{Igf1s0000<MNUMnLSTY>m&@A#
literal 0
HcmV?d00001
diff --git a/components/browser_ui/site_settings/android/java/res/drawable-hdpi/settings_media.png b/components/browser_ui/site_settings/android/java/res/drawable-hdpi/settings_media.png
new file mode 100755
GIT binary patch
literal 196
zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8K8x2KC^NX4zU=MHi<81S$L=<k{~
zS9xXl^B1m0)6OYf(Y&HDWs&Na3vw+<lY{F{DEqE0%Fda1fa&lf;fQygTZ<-#9VmKj
z)sXP%<AweHg>`<1b9tg-XZ)JnQYL=tvV}~mQQaf~xdSupJvH|JXFV9XkV$dfg>-?u
vn-h2yPqj{9I#J^BGX7y(%C2Q$8%r6}!(y+fKlT0sbQXiBtDnm{r-UW|{=iO$
literal 0
HcmV?d00001
diff --git a/components/browser_ui/site_settings/android/java/res/drawable-mdpi/settings_autoplay.png b/components/browser_ui/site_settings/android/java/res/drawable-mdpi/settings_autoplay.png
new file mode 100755
GIT binary patch
literal 296
zcmV+@0oVSCP)<h;3K|Lk000e1NJLTq000;O000;W1ONa4N`Cco0002*Nkl<Zc-p;F
zu?>ST5R5=Hk+X;yg9#|y{3AI^L4jN_0yR^lp<y0UAY}`bhK9U}6x+c{;s$?XpYHT`
z_WQ8+DiaXc!3Y!8NIOv`U+9>_9hQ%}W9}t45w<H~z#4hQDkf8`VbB=1O|%hcI?jda
zV;k+`LgB0>TQfw*%xg4TCAk}wycg<C;jW}mI*Sz_g!XRC-~-OCu{Db@O*?8?8^Rj&
zS{^N1H6fiLjCAC#fRLNPkP|W*!URjjT!AiQtzvYZ{t%#iA(xXD1Xz-(u@oBGf2}Be
u*BbnAfuj*Re80yVxjo)NA1L&T?!2C$I@?4>V>|Ky0000<MNUMnLSTX*1bI&Y
literal 0
HcmV?d00001
diff --git a/components/browser_ui/site_settings/android/java/res/drawable-mdpi/settings_media.png b/components/browser_ui/site_settings/android/java/res/drawable-mdpi/settings_media.png
new file mode 100755
GIT binary patch
literal 144
zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_+ia8DP<kP60R2|a~l%C7>i{Fh)C
zuztl*CdP5d)Wx2maPjwMQ|pA}h1oy29|>(?Ua0s=-o^O}<BZA~Iy}5B4?bM}P|uRp
rQRg$I&7FgHo=Zlh$Xm;pO~wp5?G52)gySawtzhtU^>bP0l+XkKX{9bg
literal 0
HcmV?d00001
diff --git a/components/browser_ui/site_settings/android/java/res/drawable-xhdpi/settings_autoplay.png b/components/browser_ui/site_settings/android/java/res/drawable-xhdpi/settings_autoplay.png
new file mode 100755
GIT binary patch
literal 551
zcmV+?0@(eDP)<h;3K|Lk000e1NJLTq001xm001xu1ONa4{R=S+0005*Nkl<Zc-rk(
zy>fy;5RRo0wX?Hwh9Zw(#Vgp}9uO@kj!GT?W_XdLp-A4qiidDg@B~=L$xN`2Fo6Ry
zoC`9!!WnNX*>%6WZ+~v@;l6HTnG5Pb03nIUF_Q>F2&iK&{=v0ABR=d&Dwa&+>$CpO
zN8o1rO<Uv$u0HDF9##;Ow3|Q-tE-%+18~W?=HLW7u&HLKOxcVLm1<yTUrsfUGq~xX
zqx<cUyx0DE0A@`^cGeUaIn=iCwjFlbea(GBJf>jQOd%dgDu@oJ0JqvZU3NJ!T~_A+
zw>7k!d)Tk%U1PSM!@i8g3Qx?K@4o3Chv27xSRb|1lL*LZCn{;7NuQNv<q5!Ftw$V!
zc)av3R5$TCJ)+DZDSW^ao>676eW3vl6flwYSMx=l(G+1kL4+N%tlEhfAQy}(nDFWr
zbXw{Z4tCiO1OTTBcDW68nyP>kgahDIfn8VxO;uQ6Yd8Q-71auD*mMx(DnrEqaH<To
z&_)dhyat$p1K?CKh1bGGfX(<C05JbrZN`P>Q#wV`gM2wnZ5*JY22WGzg(js{SktOi
z^lWxu_H1_Y+jaYe^U~wOk$z>$zx3sgE%FC1e02PlFgl8cUvcTd1Q~vNjPEQT-<g7p
p?=l}ClAlmgAAvHTvG;Wo>j%AMEx!+_@2>y=002ovPDHLkV1fY;_gnw~
literal 0
HcmV?d00001
diff --git a/components/browser_ui/site_settings/android/java/res/drawable-xhdpi/settings_media.png b/components/browser_ui/site_settings/android/java/res/drawable-xhdpi/settings_media.png
new file mode 100755
GIT binary patch
literal 227
zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}b0DRh}-6Ar*0NFWB-OGT>o-5W`$0
zVR5|p<$<#jMSNAFZDkA19~}4TP*}X{(9BieH|_QK_h^X`&taMElMEdew%=Xu${%}c
z>hYd@^Bw#2pT>Ooy>u?~gOIrG)xXX5&t`oR6t{SL{^#A14CWa%?Cc%yA267fZ#W<u
zl?>#}|If(uDZ<u)!JjFyp<$hzf<kg=!Ul(RoE~Nl*H47x{<&hR`B$mv&*GFRe{AO^
b&Jbrm_kCI#v(9s%s~J39{an^LB{Ts5x>sAN
literal 0
HcmV?d00001
diff --git a/components/browser_ui/site_settings/android/java/res/drawable-xxhdpi/settings_autoplay.png b/components/browser_ui/site_settings/android/java/res/drawable-xxhdpi/settings_autoplay.png
new file mode 100755
GIT binary patch
literal 792
zcmV+z1LypSP)<h;3K|Lk000e1NJLTq002k;002k`1ONa4|Kxkj0008tNkl<ZcmeHN
zv2Nl_5Kd(&P^2J2k<wEAFOV*wK{6%nd}~AH7AGB@E1m)cC{TL;PY?@4L47q{DkQ2)
zgu;oFPN%!E!Ny}lw9<LD9oFB@H#0js!$l#56r!s*CDlL=Bg|=u6>VsP6)iEx2tCzs
zN?!=Ys;Vvm+R!dxZSbnPR`u*)=$?G~q+QDONj}}54UDQIpq+dnupUkhrgMXd90~(9
z>D-*sHYV1z%eSyr=BeO3;m5&Ge2@<pO;xiip5YmGMb*%ROFljhg4(L5++aL|o)4Xt
z#%NjP*f=bsMdO23efEqzx#k+Py)EC-cdk<X`U-t|-#g6Ixz21IO!tgFux}-M*tcpx
z+bE=rR*I5^H|s7_BE7>~l(<Z;9NA<MwvEhAv<UAec5h`y4E^$WnI||NFX<&hz9~zC
z>oA;)6G#{m)`C=tNtmpB)?rp!gtK?*J1gwU@xCMXrLcRedOG_Aoa>~>!hiCJ<GzU?
zU4g;RFi3>{ojT&^9q|2A6eswfXXRwNew}jUlw`DpvbTS<8sy~{`pMeAwZ6%yL!Xy$
zN2*G=JTQ;lS${M|)Hzo?si<yxhaM+sazIk*Xq?iqof0qI(UJg?P=^+O4kR2zHF)`D
zl|_IA)LCU-!l_0)@}9u|IUq50<g;J&;sK4Ankxn*pe__Vqj<GBGo&d7B%n^2OnV;x
zfh7Y}69W=Zr)o@h8E>K0Up2cT1|*=)t}wk-{0CUjdxjX0fI83Mf&Ybo(3S(znzB<m
z^)SCv%fntq6%#ah*z2DdwY@s>U#@89zg#sfKk^r7!;A&m>sd-zwDXs+niu)Z|Ao(>
z;TfMn@`obY`5%hfKBYBiHdqh(w`25gSn1i))3E8OQ(Krf&Sz(7oX<QX`)FaR!DvC-
z;R|!`ZTxsjnS4B@Ou=|cg8`miBTkKmz^eW)jLCUb2{*+b2?DrQRj0pNXexyiQpitx
WnED%yq_MdG0000<MNUMnLSTZmtagO}
literal 0
HcmV?d00001
diff --git a/components/browser_ui/site_settings/android/java/res/drawable-xxhdpi/settings_media.png b/components/browser_ui/site_settings/android/java/res/drawable-xxhdpi/settings_media.png
new file mode 100755
GIT binary patch
literal 297
zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY0wn)GsXhawK6tt~hE&A8z2wVv$Uva&;S-@t
zw{H}u1ZmDN=DO5+cWZg!^>u%GJESvvoH^$@{kW&2-mUH&Qm5D=;FRVs%X@6U|5n~*
zZ__6k@b-0u=f3z+JJm01l5X&_&5k8A;<ly!I5*{`&V;*vcid}x?=$C^<DB>h@`ejG
zf1G6f$Z`6EO$Y3g91a1QAlwARC8lu|?lvAE{9#EmgOPcI7#kzY1zTeQ2ZoEvAabU<
z19vk6(~0M7OdJaedHHw)1-`Cs*rjn|m#M=wSI4;7ZZcOY);_x0YOr!8_gDM%YZu2o
lsP4ZK`F!gs9iW?Eus#pSh>kCpxdHS$gQu&X%Q~loCIHn%d<p;n
literal 0
HcmV?d00001
diff --git a/components/browser_ui/site_settings/android/java/res/drawable-xxxhdpi/settings_autoplay.png b/components/browser_ui/site_settings/android/java/res/drawable-xxxhdpi/settings_autoplay.png
new file mode 100755
GIT binary patch
literal 1064
zcmV+@1lRkCP)<h;3K|Lk000e1NJLTq003YB003YJ1ONa4NRhv@000B;Nkl<Zc-rk-
zF-Rjp6x}q5UMCS0#3Pl(5mH&l%1Q;{uKI6w6G2RqfI_g2*e8Om;Gwl(ZGDB6<Z@mY
z41!h)DtJW--GhTGoY}a$GqZ^U^QZnZ|INPr^Z%bejuk6btXQ$4Pc|mmBCFCqouNZL
z+*6<WxThXEbVmEE$`&^!KcwMX<5*@*wCR=nknxH(Yhrn8{DYY8r>Mvd@I-#RfhTrA
zML#uC<7*jKp)UCfqsuC_%t(wck71K;$=5J$u~{A)viWQYSLEv(xME8~Gk$Frr{wD&
zI9;0^#@?^uf&63!9@uK4#y8Tm7iz{GPOt-V=gT=S+ekOkUbdWb=Rw%P3EhS2?={j1
znNJh=@$S+WRQC#g>V2o{6{t=Z?|z3LG~wtMZ-y=hF8Pd>n~yV_n@0=J13_GRGrG;6
z!}Wm09<l3XrRL0HmmUXf$+b79b@vCEkE8V|m6_M4a5NCYj5h8ElLt5Mf{yv!1>6J^
zi6*pop5R{>=jCZ_r}{L`gMViY9x2#y;<%R48&%;r*r_TXTLH$uVB1MRu#FdSHKn7?
z`-}(CeD>8zNbpUBfCq&DBPizKc3=Bf2#S%UBhDc1I|)nBzrdE{;{7Yp^VBj!$TQBx
zU|S+zz^3T;B^;-eQx(qzY{qtLVzw3S*uwXXPwGdTn6<_H_N*cX4be2o$8UU5g&+nP
ztP-!%(B(t6s4>q!uz#qm24H<k2=lrzDi~B0_J233?tcwcDq&ZkQ87A!4)}QA%f<zu
zN+mDL=L_s0dX?>oQ*Am<Tmb4+LW?hjMXctzD}w*YO8`)&lA9OoSdl_b7mgzXK%Gi_
z?u=G6wV#{`bvXd)RH8aJPdie9oUbr@1vvofRPqXZWjjJ~o-Oiq9zP`qK%Gi{imxNF
z#ZV>GxMfcqM;3rOm2koVsD>M`&n>zm4?vwt*x~f|!wop&79@E9>Qn-8+GpV^zc}AJ
zFAqSSO71+T*$FqG_g1BxlLw$qrE-qb>xHV|o^zsEc>wBE^0J)HeYgSrw<?XaJOFhn
zHPW0;|APTQNjCuVDP;an+!=-&MJXXSYW_iHekj4JNd|K$X%6Ph52wvfXhcC<e@cl`
zVkxC4tod=0da3dbmbI2u4)v8)uq;{FLQA%=g_7RFmf@vE<BPjPEU%+9qVl@=7aZzW
zOoyYnVlw}dPjsfExn`|pg0EQ(zvwo+)xh{>55wDS3~zX{EoY-``m=49hBUsaw;r=*
z+}2~(e82VBHh+(@{oX!+2n#ThdxByg0maD|^ghF~58(`dil|N~cLlAek3rFLSGLCO
ib6hJ{tXQ#P#rX?0El=KlH_u1_0000<MNUMnLSTX(y!wd%
literal 0
HcmV?d00001
diff --git a/components/browser_ui/site_settings/android/java/res/drawable-xxxhdpi/settings_media.png b/components/browser_ui/site_settings/android/java/res/drawable-xxxhdpi/settings_media.png
new file mode 100755
GIT binary patch
literal 383
zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD0wg^q?%&M7!06`b;uuoF`1ZP?-(d#<w?y$L
zY9>#Fp2!%_zV>{<!i5H(QZ<5>F8`{yVlop4Td;!pv81p=lm1V=ce_mIXYwA8l^tNP
z>}`Hf^4$43KP-RW{%L95Cw%(s-_lic-mUv{@z=@4$A8}35?!Uoc4Ym3lkXX~SnD?*
zefE#@LwjLF0lT3>?C;cH6E4_xFqYZ(WxZ2iv*}+v>$?Kmo*N2#nk62rH`92pAiv=s
z-!%3$`<rVT-tc{5oMqj?_${sZ6W=C=Mb;<SJKibCFR1y#$Z)Tl4d}50`mW3%U&;fC
zh_4JUAcFP~Y9CN=!z)IEDZC(+kw3rw6=Ak|$y=hRV0x<IN(;k%uK!x^YNL-<uIBo%
z?bOP9HyniuR+xvzeLWVvk$>g)vR}U*#(MOYGW`!Ze{Jcr@7w)dK;R4SjE>VwZd4b5
P>}T+F^>bP0l+XkKNl&N6
literal 0
HcmV?d00001
diff --git a/components/browser_ui/site_settings/android/java/res/xml/single_website_preferences.xml b/components/browser_ui/site_settings/android/java/res/xml/single_website_preferences.xml
--- a/components/browser_ui/site_settings/android/java/res/xml/single_website_preferences.xml
+++ b/components/browser_ui/site_settings/android/java/res/xml/single_website_preferences.xml
@@ -69,6 +69,8 @@
android:key="automatic_downloads_permission_list" />
<ListPreference
android:key="protected_media_identifier_permission_list" />
+ <ListPreference
+ android:key="autoplay_permission_list" />
<ListPreference
android:key="sound_permission_list" />
<ListPreference
diff --git a/components/browser_ui/site_settings/android/java/res/xml/site_settings_preferences.xml b/components/browser_ui/site_settings/android/java/res/xml/site_settings_preferences.xml
--- a/components/browser_ui/site_settings/android/java/res/xml/site_settings_preferences.xml
+++ b/components/browser_ui/site_settings/android/java/res/xml/site_settings_preferences.xml
@@ -65,6 +65,17 @@
<org.chromium.components.browser_ui.settings.ChromeBasePreference
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
android:key="protected_content" />
+ <!-- Autoplay -->
+ <org.chromium.components.browser_ui.settings.ChromeBasePreference
+ android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
+ android:key="autoplay" />
+ <!-- Media -->
+ <org.chromium.components.browser_ui.settings.ChromeBasePreference
+ android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
+ android:key="media"
+ android:title="@string/media_permission_title"
+ android:icon="@drawable/settings_media"
+ app:iconTint="@color/default_icon_color" />
<!-- Sound -->
<org.chromium.components.browser_ui.settings.ChromeBasePreference
android:fragment="org.chromium.components.browser_ui.site_settings.SingleCategorySettings"
diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/ContentSettingsResources.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/ContentSettingsResources.java
--- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/ContentSettingsResources.java
+++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/ContentSettingsResources.java
@@ -112,6 +112,11 @@ public class ContentSettingsResources {
R.string.automatic_downloads_permission_title,
R.string.automatic_downloads_permission_title, ContentSettingValues.ASK,
ContentSettingValues.BLOCK, R.string.website_settings_category_ask, 0));
+ localMap.put(ContentSettingsType.AUTOPLAY,
+ new ResourceItem(R.drawable.settings_autoplay, R.string.autoplay_title,
+ R.string.autoplay_title, ContentSettingValues.ALLOW,
+ ContentSettingValues.BLOCK,
+ R.string.website_settings_category_autoplay_allowed, 0));
localMap.put(ContentSettingsType.BACKGROUND_SYNC,
new ResourceItem(R.drawable.permission_background_sync,
R.string.background_sync_permission_title,
diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleCategorySettings.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleCategorySettings.java
--- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleCategorySettings.java
+++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleCategorySettings.java
@@ -637,6 +637,8 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
int resource = 0;
if (mCategory.showSites(SiteSettingsCategory.Type.AUTOMATIC_DOWNLOADS)) {
resource = R.string.website_settings_add_site_description_automatic_downloads;
+ } else if (mCategory.showSites(SiteSettingsCategory.Type.AUTOPLAY)) {
+ resource = R.string.website_settings_add_site_description_autoplay;
} else if (mCategory.showSites(SiteSettingsCategory.Type.BACKGROUND_SYNC)) {
resource = R.string.website_settings_add_site_description_background_sync;
} else if (mCategory.showSites(SiteSettingsCategory.Type.JAVASCRIPT)) {
@@ -754,6 +756,10 @@ public class SingleCategorySettings extends SiteSettingsPreferenceFragment
boolean exception = false;
if (mCategory.showSites(SiteSettingsCategory.Type.SOUND)) {
exception = true;
+ } else if (mCategory.showSites(SiteSettingsCategory.Type.AUTOPLAY)
+ && !WebsitePreferenceBridge.isCategoryEnabled(
+ browserContextHandle, ContentSettingsType.AUTOPLAY)) {
+ exception = true;
} else if (mCategory.showSites(SiteSettingsCategory.Type.JAVASCRIPT)) {
exception = true;
} else if (mCategory.showSites(SiteSettingsCategory.Type.COOKIES)) {
diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java
--- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java
+++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java
@@ -96,6 +96,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
return "sound_permission_list";
case ContentSettingsType.TIMEZONE_OVERRIDE:
return "timezone_override_permission_list";
+ case ContentSettingsType.AUTOPLAY:
+ return "autoplay_permission_list";
default:
return null;
}
diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsCategory.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsCategory.java
--- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsCategory.java
+++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SiteSettingsCategory.java
@@ -42,7 +42,8 @@ public class SiteSettingsCategory {
Type.BACKGROUND_SYNC, Type.BLUETOOTH, Type.BLUETOOTH_SCANNING, Type.CAMERA,
Type.CLIPBOARD, Type.COOKIES, Type.DEVICE_LOCATION, Type.JAVASCRIPT, Type.MICROPHONE,
Type.NFC, Type.NOTIFICATIONS, Type.POPUPS, Type.PROTECTED_MEDIA, Type.SENSORS,
- Type.SOUND, Type.USB, Type.VIRTUAL_REALITY, Type.USE_STORAGE, Type.TIMEZONE_OVERRIDE})
+ Type.SOUND, Type.USB, Type.VIRTUAL_REALITY, Type.USE_STORAGE, Type.TIMEZONE_OVERRIDE,
+ Type.AUTOPLAY})
@Retention(RetentionPolicy.SOURCE)
public @interface Type {
// Values used to address array index - should be enumerated from 0 and can't have gaps.
@@ -70,11 +71,12 @@ public class SiteSettingsCategory {
int BLUETOOTH = 19;
int VIRTUAL_REALITY = 20;
int USE_STORAGE = 21;
- int TIMEZONE_OVERRIDE = 22; // Always last as it should appear in the UI at the bottom.
+ int TIMEZONE_OVERRIDE = 22;
+ int AUTOPLAY = 23; // Always last as it should appear in the UI at the bottom.
/**
* Number of handled categories used for calculating array sizes.
*/
- int NUM_ENTRIES = 23;
+ int NUM_ENTRIES = 24;
}
private final BrowserContextHandle mBrowserContextHandle;
@@ -192,6 +194,8 @@ public class SiteSettingsCategory {
return ContentSettingsType.VR;
case Type.TIMEZONE_OVERRIDE:
return ContentSettingsType.TIMEZONE_OVERRIDE;
+ case Type.AUTOPLAY:
+ return ContentSettingsType.AUTOPLAY;
// case Type.ALL_SITES
// case Type.USE_STORAGE
default:
@@ -265,6 +269,8 @@ public class SiteSettingsCategory {
return "virtual_reality";
case Type.TIMEZONE_OVERRIDE:
return "timezone_override";
+ case Type.AUTOPLAY:
+ return "autoplay";
default:
assert false;
return "";
diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java
--- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java
+++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePermissionsFetcher.java
@@ -125,6 +125,8 @@ public class WebsitePermissionsFetcher {
queue.add(new ExceptionInfoFetcher(ContentSettingsType.BACKGROUND_SYNC));
// Automatic Downloads permission is per-origin.
queue.add(new ExceptionInfoFetcher(ContentSettingsType.AUTOMATIC_DOWNLOADS));
+ // Autoplay permission is per-origin.
+ queue.add(new ExceptionInfoFetcher(ContentSettingsType.AUTOPLAY));
// USB device permission is per-origin and per-embedder.
queue.add(new ChooserExceptionInfoFetcher(ContentSettingsType.USB_GUARD));
// Clipboard info is per-origin.
@@ -230,6 +232,9 @@ public class WebsitePermissionsFetcher {
} else if (category.showSites(SiteSettingsCategory.Type.PROTECTED_MEDIA)) {
// Protected media identifier permission is per-origin and per-embedder.
queue.add(new PermissionInfoFetcher(PermissionInfo.Type.PROTECTED_MEDIA_IDENTIFIER));
+ } else if (category.showSites(SiteSettingsCategory.Type.AUTOPLAY)) {
+ // Autoplay permission is per-origin.
+ queue.add(new ExceptionInfoFetcher(ContentSettingsType.AUTOPLAY));
} else if (category.showSites(SiteSettingsCategory.Type.USB)) {
// USB device permission is per-origin.
queue.add(new ChooserExceptionInfoFetcher(ContentSettingsType.USB_GUARD));
diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java
--- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java
+++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/WebsitePreferenceBridge.java
@@ -368,6 +368,10 @@ public class WebsitePreferenceBridge {
WebsitePreferenceBridgeJni.get().setAutomaticDownloadsEnabled(
browserContextHandle, allow);
break;
+ case ContentSettingsType.AUTOPLAY:
+ WebsitePreferenceBridgeJni.get().setAutoplayEnabled(
+ browserContextHandle, allow);
+ break;
case ContentSettingsType.BACKGROUND_SYNC:
WebsitePreferenceBridgeJni.get().setBackgroundSyncEnabled(
browserContextHandle, allow);
@@ -433,6 +437,9 @@ public class WebsitePreferenceBridge {
case ContentSettingsType.AUTOMATIC_DOWNLOADS:
return WebsitePreferenceBridgeJni.get().getAutomaticDownloadsEnabled(
browserContextHandle);
+ case ContentSettingsType.AUTOPLAY:
+ return WebsitePreferenceBridgeJni.get().getAutoplayEnabled(
+ browserContextHandle);
case ContentSettingsType.BACKGROUND_SYNC:
return WebsitePreferenceBridgeJni.get().getBackgroundSyncEnabled(
browserContextHandle);
@@ -740,5 +747,7 @@ public class WebsitePreferenceBridge {
void setVrEnabled(BrowserContextHandle browserContextHandle, boolean enabled);
String getCustomTimezone(BrowserContextHandle browserContextHandle);
void setCustomTimezone(BrowserContextHandle browserContextHandle, String timezone);
+ boolean getAutoplayEnabled(BrowserContextHandle browserContextHandle);
+ void setAutoplayEnabled(BrowserContextHandle browserContextHandle, boolean enabled);
}
}
diff --git a/components/browser_ui/site_settings/android/website_preference_bridge.cc b/components/browser_ui/site_settings/android/website_preference_bridge.cc
--- a/components/browser_ui/site_settings/android/website_preference_bridge.cc
+++ b/components/browser_ui/site_settings/android/website_preference_bridge.cc
@@ -1443,3 +1443,21 @@ static base::android::ScopedJavaLocalRef<jstring> JNI_WebsitePreferenceBridge_Ge
GetHostContentSettingsMap(jbrowser_context_handle)->GetTimezoneOverrideValue(timezone);
return ConvertUTF8ToJavaString(env, timezone);
}
+
+static jboolean JNI_WebsitePreferenceBridge_GetAutoplayEnabled(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& jbrowser_context_handle) {
+ return GetBooleanForContentSetting(jbrowser_context_handle,
+ ContentSettingsType::AUTOPLAY);
+}
+
+static void JNI_WebsitePreferenceBridge_SetAutoplayEnabled(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& jbrowser_context_handle,
+ jboolean allow) {
+ GetHostContentSettingsMap(jbrowser_context_handle)
+ ->SetDefaultContentSetting(
+ ContentSettingsType::AUTOPLAY,
+ allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK);
+}
+
diff --git a/components/browser_ui/strings/android/site_settings.grdp b/components/browser_ui/strings/android/site_settings.grdp
--- a/components/browser_ui/strings/android/site_settings.grdp
+++ b/components/browser_ui/strings/android/site_settings.grdp
@@ -12,6 +12,18 @@
<message name="IDS_ADS_PERMISSION_TITLE" desc="Title for the ads permission [CHAR-LIMIT=32]">
Ads
</message>
+ <message name="IDS_AUTOPLAY_TITLE" desc='Title for the Autoplay settings screen [CHAR-LIMIT=32]'>
+ Autoplay
+ </message>
+ <message name="IDS_MEDIA_PERMISSION_TITLE" desc="Title of the menu containing the media permissions [CHAR-LIMIT=32]">
+ Media
+ </message>
+ <message name="IDS_WEBSITE_SETTINGS_ADD_SITE_DESCRIPTION_AUTOPLAY" desc="The description for the allow autoplay of muted videos for website dialog.">
+ Allow autoplay of muted videos for a specific site.
+ </message>
+ <message name="IDS_WEBSITE_SETTINGS_CATEGORY_AUTOPLAY_ALLOWED" desc="Summary text explaining that sites are allowed to automatically play muted videos and that it is the recommended setting.">
+ Allow sites to automatically play muted videos (recommended)
+ </message>
<message name="IDS_AR_PERMISSION_TITLE" desc="Title of the permission to use Augmented Reality [CHAR-LIMIT=32]">
Augmented reality
</message>
diff --git a/components/content_settings/core/browser/content_settings_utils.cc b/components/content_settings/core/browser/content_settings_utils.cc
--- a/components/content_settings/core/browser/content_settings_utils.cc
+++ b/components/content_settings/core/browser/content_settings_utils.cc
@@ -143,6 +143,8 @@ void GetRendererContentSettingRules(const HostContentSettingsMap* map,
#endif
map->GetSettingsForOneType(ContentSettingsType::JAVASCRIPT,
ResourceIdentifier(), &(rules->script_rules));
+ map->GetSettingsForOneType(ContentSettingsType::AUTOPLAY,
+ ResourceIdentifier(), &(rules->autoplay_rules));
map->GetSettingsForOneType(ContentSettingsType::POPUPS, ResourceIdentifier(),
&(rules->popup_redirect_rules));
diff --git a/components/content_settings/core/common/content_settings.cc b/components/content_settings/core/common/content_settings.cc
--- a/components/content_settings/core/common/content_settings.cc
+++ b/components/content_settings/core/common/content_settings.cc
@@ -177,6 +177,7 @@ bool RendererContentSettingRules::IsRendererContentSetting(
ContentSettingsType content_type) {
return content_type == ContentSettingsType::IMAGES ||
content_type == ContentSettingsType::JAVASCRIPT ||
+ content_type == ContentSettingsType::AUTOPLAY ||
content_type == ContentSettingsType::CLIENT_HINTS ||
content_type == ContentSettingsType::POPUPS ||
content_type == ContentSettingsType::MIXEDSCRIPT ||
diff --git a/components/content_settings/core/common/content_settings.h b/components/content_settings/core/common/content_settings.h
--- a/components/content_settings/core/common/content_settings.h
+++ b/components/content_settings/core/common/content_settings.h
@@ -76,6 +76,7 @@ struct RendererContentSettingRules {
~RendererContentSettingRules();
ContentSettingsForOneType image_rules;
ContentSettingsForOneType script_rules;
+ ContentSettingsForOneType autoplay_rules;
ContentSettingsForOneType popup_redirect_rules;
ContentSettingsForOneType mixed_content_rules;
ContentSettingsForOneType timezone_override_rules;
diff --git a/components/content_settings/core/common/content_settings.mojom b/components/content_settings/core/common/content_settings.mojom
--- a/components/content_settings/core/common/content_settings.mojom
+++ b/components/content_settings/core/common/content_settings.mojom
@@ -75,6 +75,7 @@ struct ContentSettingPatternSource {
struct RendererContentSettingRules {
array<ContentSettingPatternSource> image_rules;
array<ContentSettingPatternSource> script_rules;
+ array<ContentSettingPatternSource> autoplay_rules;
array<ContentSettingPatternSource> popup_redirect_rules;
array<ContentSettingPatternSource> mixed_content_rules;
array<ContentSettingPatternSource> timezone_override_rules;
diff --git a/components/content_settings/core/common/content_settings_mojom_traits.cc b/components/content_settings/core/common/content_settings_mojom_traits.cc
--- a/components/content_settings/core/common/content_settings_mojom_traits.cc
+++ b/components/content_settings/core/common/content_settings_mojom_traits.cc
@@ -99,6 +99,7 @@ bool StructTraits<content_settings::mojom::RendererContentSettingRulesDataView,
RendererContentSettingRules* out) {
return data.ReadImageRules(&out->image_rules) &&
data.ReadScriptRules(&out->script_rules) &&
+ data.ReadAutoplayRules(&out->autoplay_rules) &&
data.ReadPopupRedirectRules(&out->popup_redirect_rules) &&
data.ReadMixedContentRules(&out->mixed_content_rules) &&
data.ReadTimezoneOverrideRules(&out->timezone_override_rules) &&
diff --git a/components/content_settings/core/common/content_settings_mojom_traits.h b/components/content_settings/core/common/content_settings_mojom_traits.h
--- a/components/content_settings/core/common/content_settings_mojom_traits.h
+++ b/components/content_settings/core/common/content_settings_mojom_traits.h
@@ -134,6 +134,11 @@ struct StructTraits<
return r.script_rules;
}
+ static const std::vector<ContentSettingPatternSource>& autoplay_rules(
+ const RendererContentSettingRules& r) {
+ return r.autoplay_rules;
+ }
+
static const std::vector<ContentSettingPatternSource>& popup_redirect_rules(
const RendererContentSettingRules& r) {
return r.popup_redirect_rules;
diff --git a/components/content_settings/renderer/content_settings_agent_impl.cc b/components/content_settings/renderer/content_settings_agent_impl.cc
--- a/components/content_settings/renderer/content_settings_agent_impl.cc
+++ b/components/content_settings/renderer/content_settings_agent_impl.cc
@@ -425,6 +425,17 @@ bool ContentSettingsAgentImpl::AllowRunningInsecureContent(
return allow;
}
+bool ContentSettingsAgentImpl::AllowAutoplay(bool default_value) {
+ if (!content_setting_rules_)
+ return default_value;
+
+ blink::WebLocalFrame* frame = render_frame()->GetWebFrame();
+ return GetContentSettingFromRules(
+ content_setting_rules_->autoplay_rules, frame,
+ url::Origin(frame->GetDocument().GetSecurityOrigin()).GetURL()) ==
+ CONTENT_SETTING_ALLOW;
+}
+
bool ContentSettingsAgentImpl::AllowPopupsAndRedirects(bool default_value) {
if (!content_setting_rules_)
return default_value;
diff --git a/components/content_settings/renderer/content_settings_agent_impl.h b/components/content_settings/renderer/content_settings_agent_impl.h
--- a/components/content_settings/renderer/content_settings_agent_impl.h
+++ b/components/content_settings/renderer/content_settings_agent_impl.h
@@ -98,6 +98,7 @@ class ContentSettingsAgentImpl
void DidNotAllowScript() override;
bool AllowRunningInsecureContent(bool allowed_per_settings,
const blink::WebURL& url) override;
+ bool AllowAutoplay(bool default_value) override;
bool AllowPopupsAndRedirects(bool default_value) override;
void PassiveInsecureContentFound(const blink::WebURL& resource_url) override;
bool ShouldAutoupgradeMixedContent() override;
diff --git a/components/page_info/android/page_info_controller_android.cc b/components/page_info/android/page_info_controller_android.cc
--- a/components/page_info/android/page_info_controller_android.cc
+++ b/components/page_info/android/page_info_controller_android.cc
@@ -120,6 +120,7 @@ void PageInfoControllerAndroid::SetPermissionInfo(
permissions_to_display.push_back(ContentSettingsType::ADS);
permissions_to_display.push_back(
ContentSettingsType::PROTECTED_MEDIA_IDENTIFIER);
+ permissions_to_display.push_back(ContentSettingsType::AUTOPLAY);
permissions_to_display.push_back(ContentSettingsType::SOUND);
if (base::FeatureList::IsEnabled(features::kWebNfc))
permissions_to_display.push_back(ContentSettingsType::NFC);
diff --git a/third_party/blink/public/platform/web_content_settings_client.h b/third_party/blink/public/platform/web_content_settings_client.h
--- a/third_party/blink/public/platform/web_content_settings_client.h
+++ b/third_party/blink/public/platform/web_content_settings_client.h
@@ -92,6 +92,9 @@ class WebContentSettingsClient {
// interface.
virtual bool AllowMutationEvents(bool default_value) { return default_value; }
+ // Controls whether autoplay is allowed for this frame.
+ virtual bool AllowAutoplay(bool default_value) { return default_value; }
+
virtual bool AllowPopupsAndRedirects(bool default_value) {
return default_value;
}
diff --git a/third_party/blink/renderer/core/html/media/autoplay_policy.cc b/third_party/blink/renderer/core/html/media/autoplay_policy.cc
--- a/third_party/blink/renderer/core/html/media/autoplay_policy.cc
+++ b/third_party/blink/renderer/core/html/media/autoplay_policy.cc
@@ -7,6 +7,7 @@
#include "build/build_config.h"
#include "third_party/blink/public/mojom/autoplay/autoplay.mojom-blink.h"
#include "third_party/blink/public/mojom/feature_policy/feature_policy.mojom-blink.h"
+#include "third_party/blink/public/platform/web_content_settings_client.h"
#include "third_party/blink/public/platform/web_media_player.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/public/web/web_local_frame_client.h"
@@ -311,7 +312,7 @@ bool AutoplayPolicy::IsGestureNeededForPlayback() const {
// We want to allow muted video to autoplay if the element is allowed to
// autoplay muted.
- return !IsEligibleForAutoplayMuted();
+ return !(IsEligibleForAutoplayMuted() && IsAutoplayAllowedPerSettings());
}
String AutoplayPolicy::GetPlayErrorMessage() const {
@@ -380,6 +381,15 @@ void AutoplayPolicy::MaybeSetAutoplayInitiated() {
}
}
+bool AutoplayPolicy::IsAutoplayAllowedPerSettings() const {
+ LocalFrame* frame = element_->GetDocument().GetFrame();
+ if (!frame)
+ return false;
+ if (auto* settings_client = frame->GetContentSettingsClient())
+ return settings_client->AllowAutoplay(true /* default_value */);
+ return true;
+}
+
bool AutoplayPolicy::ShouldAutoplay() {
if (!element_->GetExecutionContext() ||
element_->GetExecutionContext()->IsSandboxed(
diff --git a/third_party/blink/renderer/core/html/media/autoplay_policy.h b/third_party/blink/renderer/core/html/media/autoplay_policy.h
--- a/third_party/blink/renderer/core/html/media/autoplay_policy.h
+++ b/third_party/blink/renderer/core/html/media/autoplay_policy.h
@@ -131,6 +131,10 @@ class CORE_EXPORT AutoplayPolicy final
// should use, if checking to see if an action is allowed.
bool IsLockedPendingUserGesture() const;
+ // Return true if and only if the settings allow autoplay of media on this
+ // frame.
+ bool IsAutoplayAllowedPerSettings() const;
+
bool IsAutoplayingMutedInternal(bool muted) const;
bool IsOrWillBeAutoplayingMutedInternal(bool muted) const;
--
2.17.1