forked from uazo/cromite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdd-autoplay-site-setting.patch
343 lines (325 loc) · 17.5 KB
/
Add-autoplay-site-setting.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
From: uazo <[email protected]>
Date: Sat, 7 Nov 2020 21:59:18 +0000
Subject: Add autoplay site setting
Original License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html
License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
Require: Content-settings-infrastructure.patch
---
.../res/drawable-hdpi/settings_autoplay.png | Bin 0 -> 456 bytes
.../res/drawable-mdpi/settings_autoplay.png | Bin 0 -> 296 bytes
.../res/drawable-xhdpi/settings_autoplay.png | Bin 0 -> 551 bytes
.../res/drawable-xxhdpi/settings_autoplay.png | Bin 0 -> 792 bytes
.../drawable-xxxhdpi/settings_autoplay.png | Bin 0 -> 1064 bytes
.../impl/BromiteAutoplayContentSetting.java | 93 ++++++++++++++++++
.../bromite_content_settings/autoplay.grdp | 21 ++++
.../bromite_content_settings/autoplay.inc | 12 +++
.../core/browser/content_settings_registry.cc | 2 +-
.../core/html/media/autoplay_policy.cc | 14 +++
.../core/html/media/autoplay_policy.h | 4 +
11 files changed, 145 insertions(+), 1 deletion(-)
create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-hdpi/settings_autoplay.png
create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-mdpi/settings_autoplay.png
create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-xhdpi/settings_autoplay.png
create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-xxhdpi/settings_autoplay.png
create mode 100644 components/browser_ui/site_settings/android/java/res/drawable-xxxhdpi/settings_autoplay.png
create mode 100644 components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteAutoplayContentSetting.java
create mode 100644 components/browser_ui/strings/bromite_content_settings/autoplay.grdp
create mode 100644 components/content_settings/core/browser/bromite_content_settings/autoplay.inc
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 100644
index 0000000000000000000000000000000000000000..a8a9265f14cd8445ad1f55845099e60dc3c4edf1
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-mdpi/settings_autoplay.png b/components/browser_ui/site_settings/android/java/res/drawable-mdpi/settings_autoplay.png
new file mode 100644
index 0000000000000000000000000000000000000000..49fa10d44f4007532d0d03d15fdcb1a715857e96
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-xhdpi/settings_autoplay.png b/components/browser_ui/site_settings/android/java/res/drawable-xhdpi/settings_autoplay.png
new file mode 100644
index 0000000000000000000000000000000000000000..5a4128a5e02949de754f9cab2635824eda8c539c
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-xxhdpi/settings_autoplay.png b/components/browser_ui/site_settings/android/java/res/drawable-xxhdpi/settings_autoplay.png
new file mode 100644
index 0000000000000000000000000000000000000000..7fceb8c2b546970a3720e8ab225799aa03895b7f
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-xxxhdpi/settings_autoplay.png b/components/browser_ui/site_settings/android/java/res/drawable-xxxhdpi/settings_autoplay.png
new file mode 100644
index 0000000000000000000000000000000000000000..92a315bb00ac1f4dc675e894bf4af3ba7c68bf39
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/src/org/chromium/components/browser_ui/site_settings/impl/BromiteAutoplayContentSetting.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteAutoplayContentSetting.java
new file mode 100644
--- /dev/null
+++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/impl/BromiteAutoplayContentSetting.java
@@ -0,0 +1,93 @@
+/*
+ This file is part of Bromite.
+
+ Bromite is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Bromite is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bromite. If not, see <https://www.gnu.org/licenses/>.
+*/
+
+package org.chromium.components.browser_ui.site_settings.impl;
+
+import org.chromium.components.browser_ui.site_settings.R;
+
+import org.chromium.components.browser_ui.site_settings.BromiteCustomContentSetting;
+import org.chromium.components.browser_ui.site_settings.ContentSettingsResources;
+import org.chromium.components.browser_ui.site_settings.SiteSettingsCategory;
+import org.chromium.components.content_settings.ContentSettingValues;
+import org.chromium.components.content_settings.ContentSettingsType;
+import org.chromium.content_public.browser.BrowserContextHandle;
+
+import androidx.annotation.Nullable;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import java.util.ArrayList;
+
+public class BromiteAutoplayContentSetting extends BromiteCustomContentSetting {
+ public BromiteAutoplayContentSetting() {
+ super(/*contentSettingsType*/ ContentSettingsType.AUTOPLAY,
+ /*defaultEnabledValue*/ ContentSettingValues.ALLOW,
+ /*defaultDisabledValue*/ ContentSettingValues.BLOCK,
+ /*allowException*/ true,
+ /*preferenceKey*/ "autoplay",
+ /*profilePrefKey*/ "autoplay");
+ }
+
+ @Override
+ public ContentSettingsResources.ResourceItem getResourceItem() {
+ return new ContentSettingsResources.ResourceItem(
+ /*icon*/ R.drawable.settings_autoplay,
+ /*title*/ R.string.autoplay_permission_title,
+ /*defaultEnabledValue*/ getDefaultEnabledValue(),
+ /*defaultDisabledValue*/ getDefaultDisabledValue(),
+ /*enabledSummary*/ R.string.website_settings_category_autoplay_enabled,
+ /*disabledSummary*/ R.string.website_settings_category_autoplay_disabled,
+ /*summaryOverrideForScreenReader*/ 0);
+ }
+
+ @Override
+ public int getCategorySummary(@Nullable @ContentSettingValues int value) {
+ switch (value) {
+ case ContentSettingValues.ALLOW:
+ return R.string.website_settings_category_autoplay_enabled;
+ case ContentSettingValues.BLOCK:
+ return R.string.website_settings_category_autoplay_disabled;
+ default:
+ return 0;
+ }
+ }
+
+ @Override
+ public int getCategoryDescription() {
+ return R.string.website_settings_add_site_description_autoplay;
+ }
+
+ @Override
+ public boolean requiresTriStateContentSetting() {
+ return false;
+ }
+
+ @Override
+ public boolean showOnlyDescriptions() {
+ return true;
+ }
+
+ @Override
+ public int getAddExceptionDialogMessage() {
+ return R.string.website_settings_category_autoplay_enabled;
+ }
+
+ @Override
+ public @Nullable Boolean considerException(SiteSettingsCategory category, @ContentSettingValues int value) {
+ return value != ContentSettingValues.BLOCK;
+ }
+}
diff --git a/components/browser_ui/strings/bromite_content_settings/autoplay.grdp b/components/browser_ui/strings/bromite_content_settings/autoplay.grdp
new file mode 100644
--- /dev/null
+++ b/components/browser_ui/strings/bromite_content_settings/autoplay.grdp
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<grit-part>
+ <message name="IDS_AUTOPLAY_PERMISSION_TITLE" desc='Title for the Autoplay settings screen [CHAR-LIMIT=32]' formatter_data="android_java">
+ Autoplay
+ </message>
+ <message name="IDS_WEBSITE_SETTINGS_ADD_SITE_DESCRIPTION_AUTOPLAY" desc="The description for the allow autoplay of muted videos for website dialog." formatter_data="android_java">
+ Allow autoplay for a specific site.
+ </message>
+ <message name="IDS_WEBSITE_SETTINGS_CATEGORY_AUTOPLAY_ENABLED" desc="Summary text explaining that sites are allowed to compile JavaScript in JIT mode." formatter_data="android_java">
+ Allow sites to automatically play muted videos
+ </message>
+ <message name="IDS_WEBSITE_SETTINGS_CATEGORY_AUTOPLAY_DISABLED" desc="Summary text explaining that sites are running JavaScript in JITless mode." formatter_data="android_java">
+ Autoplay disabled
+ </message>
+ <message name="IDS_SETTINGS_SITE_SETTINGS_AUTOPLAY_ALLOWED_EXCEPTIONS" desc="Label for the allowed exceptions site list of the autoplay setting.">
+ Allowed to autoplay
+ </message>
+ <message name="IDS_SETTINGS_SITE_SETTINGS_AUTOPLAY_BLOCKED_EXCEPTIONS" desc="Label for the blocked exceptions site list of the autoplay setting.">
+ Not allowed to autoplay
+ </message>
+</grit-part>
diff --git a/components/content_settings/core/browser/bromite_content_settings/autoplay.inc b/components/content_settings/core/browser/bromite_content_settings/autoplay.inc
new file mode 100644
--- /dev/null
+++ b/components/content_settings/core/browser/bromite_content_settings/autoplay.inc
@@ -0,0 +1,12 @@
+ content_settings::WebsiteSettingsRegistry::GetInstance()
+ ->GetMutable(ContentSettingsType::AUTOPLAY)
+ ->set_show_into_info_page()
+ .set_desktop_ui()
+ .set_is_renderer_content_setting()
+ .set_title_ui(IDS_AUTOPLAY_PERMISSION_TITLE)
+ .set_description_ui(IDS_WEBSITE_SETTINGS_ADD_SITE_DESCRIPTION_AUTOPLAY)
+ .set_allowed_ui(IDS_WEBSITE_SETTINGS_CATEGORY_AUTOPLAY_ENABLED)
+ .set_blocked_ui(IDS_WEBSITE_SETTINGS_CATEGORY_AUTOPLAY_DISABLED)
+ .set_allowed_exceptions_ui(IDS_SETTINGS_SITE_SETTINGS_AUTOPLAY_ALLOWED_EXCEPTIONS)
+ .set_blocked_exceptions_ui(IDS_SETTINGS_SITE_SETTINGS_AUTOPLAY_BLOCKED_EXCEPTIONS)
+ .set_mid_sentence_ui(IDS_AUTOPLAY_PERMISSION_TITLE);
diff --git a/components/content_settings/core/browser/content_settings_registry.cc b/components/content_settings/core/browser/content_settings_registry.cc
--- a/components/content_settings/core/browser/content_settings_registry.cc
+++ b/components/content_settings/core/browser/content_settings_registry.cc
@@ -255,7 +255,7 @@ void ContentSettingsRegistry::Init() {
ContentSettingsInfo::INHERIT_IN_INCOGNITO,
ContentSettingsInfo::EXCEPTIONS_ON_SECURE_ORIGINS_ONLY);
- Register(ContentSettingsType::AUTOPLAY, "autoplay", CONTENT_SETTING_ALLOW,
+ Register(ContentSettingsType::AUTOPLAY, "autoplay", CONTENT_SETTING_BLOCK,
WebsiteSettingsInfo::UNSYNCABLE, /*allowlisted_primary_schemes=*/{},
/*valid_settings=*/{CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK},
WebsiteSettingsInfo::TOP_ORIGIN_ONLY_SCOPE,
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
@@ -8,6 +8,7 @@
#include "third_party/blink/public/mojom/autoplay/autoplay.mojom-blink.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy.mojom-blink.h"
#include "third_party/blink/public/mojom/webpreferences/web_preferences.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"
@@ -330,6 +331,8 @@ void AutoplayPolicy::TryUnlockingUserGesture() {
}
bool AutoplayPolicy::IsGestureNeededForPlayback() const {
+ if (!IsAutoplayAllowedPerSettings())
+ return true;
if (!IsLockedPendingUserGesture())
return false;
@@ -428,6 +431,17 @@ 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->AllowContentSetting(
+ ContentSettingsType::AUTOPLAY, /*default_value*/ false);
+ }
+ 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
@@ -138,6 +138,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;
--