Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit fbde00f

Browse files
MortimerGorokeianhzo
authored andcommitted
Handle the new autoplay permissions (#2624)
1 parent 7ae9302 commit fbde00f

File tree

4 files changed

+10
-19
lines changed

4 files changed

+10
-19
lines changed

app/src/common/shared/org/mozilla/vrbrowser/browser/PermissionDelegate.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@ public void onContentPermissionRequest(GeckoSession aSession, String aUri, int a
119119
return;
120120
}
121121

122+
if (aType == PERMISSION_AUTOPLAY_AUDIBLE || aType == PERMISSION_AUTOPLAY_INAUDIBLE) {
123+
if (SettingsStore.getInstance(mContext).isAutoplayEnabled()) {
124+
callback.grant();
125+
} else {
126+
callback.reject();
127+
}
128+
return;
129+
}
130+
122131
PermissionWidget.PermissionType type;
123132
if (aType == PERMISSION_DESKTOP_NOTIFICATION) {
124133
type = PermissionWidget.PermissionType.Notification;

app/src/common/shared/org/mozilla/vrbrowser/browser/engine/EngineProvider.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ object EngineProvider {
3535
builder.displayDpiOverride(SettingsStore.getInstance(context).displayDpi)
3636
builder.screenSizeOverride(SettingsStore.getInstance(context).maxWindowWidth,
3737
SettingsStore.getInstance(context).maxWindowHeight)
38-
builder.autoplayDefault(if (SettingsStore.getInstance(context).isAutoplayEnabled) GeckoRuntimeSettings.AUTOPLAY_DEFAULT_ALLOWED else GeckoRuntimeSettings.AUTOPLAY_DEFAULT_BLOCKED)
3938

4039
if (SettingsStore.getInstance(context).transparentBorderWidth > 0) {
4140
builder.useMaxScreenDepth(true)

app/src/common/shared/org/mozilla/vrbrowser/browser/engine/SessionStore.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -284,22 +284,6 @@ public void setRemoteDebugging(final boolean enabled) {
284284
}
285285
}
286286

287-
public void setAutoplayEnabled(final boolean enabled) {
288-
if (mRuntime != null) {
289-
mRuntime.getSettings().setAutoplayDefault(enabled ?
290-
GeckoRuntimeSettings.AUTOPLAY_DEFAULT_ALLOWED :
291-
GeckoRuntimeSettings.AUTOPLAY_DEFAULT_BLOCKED);
292-
}
293-
}
294-
295-
public boolean getAutoplayEnabled() {
296-
if (mRuntime != null) {
297-
return mRuntime.getSettings().getAutoplayDefault() == GeckoRuntimeSettings.AUTOPLAY_DEFAULT_ALLOWED;
298-
}
299-
300-
return false;
301-
}
302-
303287
public void setLocales(List<String> locales) {
304288
if (mRuntime != null) {
305289
mRuntime.getSettings().setLocales(locales.stream().toArray(String[]::new));

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DisplayOptionsView.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private void initialize(Context aContext) {
5959
setMSAAMode(mBinding.msaaRadio.getIdForValue(msaaLevel), false);
6060

6161
mBinding.autoplaySwitch.setOnCheckedChangeListener(mAutoplayListener);
62-
setAutoplay(SessionStore.get().getAutoplayEnabled(), false);
62+
setAutoplay(SettingsStore.getInstance(getContext()).isAutoplayEnabled(), false);
6363

6464
mDefaultHomepageUrl = getContext().getString(R.string.homepage_url);
6565

@@ -232,7 +232,6 @@ private void setAutoplay(boolean value, boolean doApply) {
232232
mBinding.autoplaySwitch.setOnCheckedChangeListener(mAutoplayListener);
233233

234234
if (doApply) {
235-
SessionStore.get().setAutoplayEnabled(value);
236235
SettingsStore.getInstance(getContext()).setAutoplayEnabled(value);
237236
}
238237
}

0 commit comments

Comments
 (0)