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

Commit

Permalink
Handle the new autoplay permissions (#2624)
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro authored and keianhzo committed Jan 14, 2020
1 parent 7ae9302 commit fbde00f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ public void onContentPermissionRequest(GeckoSession aSession, String aUri, int a
return;
}

if (aType == PERMISSION_AUTOPLAY_AUDIBLE || aType == PERMISSION_AUTOPLAY_INAUDIBLE) {
if (SettingsStore.getInstance(mContext).isAutoplayEnabled()) {
callback.grant();
} else {
callback.reject();
}
return;
}

PermissionWidget.PermissionType type;
if (aType == PERMISSION_DESKTOP_NOTIFICATION) {
type = PermissionWidget.PermissionType.Notification;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ object EngineProvider {
builder.displayDpiOverride(SettingsStore.getInstance(context).displayDpi)
builder.screenSizeOverride(SettingsStore.getInstance(context).maxWindowWidth,
SettingsStore.getInstance(context).maxWindowHeight)
builder.autoplayDefault(if (SettingsStore.getInstance(context).isAutoplayEnabled) GeckoRuntimeSettings.AUTOPLAY_DEFAULT_ALLOWED else GeckoRuntimeSettings.AUTOPLAY_DEFAULT_BLOCKED)

if (SettingsStore.getInstance(context).transparentBorderWidth > 0) {
builder.useMaxScreenDepth(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,22 +284,6 @@ public void setRemoteDebugging(final boolean enabled) {
}
}

public void setAutoplayEnabled(final boolean enabled) {
if (mRuntime != null) {
mRuntime.getSettings().setAutoplayDefault(enabled ?
GeckoRuntimeSettings.AUTOPLAY_DEFAULT_ALLOWED :
GeckoRuntimeSettings.AUTOPLAY_DEFAULT_BLOCKED);
}
}

public boolean getAutoplayEnabled() {
if (mRuntime != null) {
return mRuntime.getSettings().getAutoplayDefault() == GeckoRuntimeSettings.AUTOPLAY_DEFAULT_ALLOWED;
}

return false;
}

public void setLocales(List<String> locales) {
if (mRuntime != null) {
mRuntime.getSettings().setLocales(locales.stream().toArray(String[]::new));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private void initialize(Context aContext) {
setMSAAMode(mBinding.msaaRadio.getIdForValue(msaaLevel), false);

mBinding.autoplaySwitch.setOnCheckedChangeListener(mAutoplayListener);
setAutoplay(SessionStore.get().getAutoplayEnabled(), false);
setAutoplay(SettingsStore.getInstance(getContext()).isAutoplayEnabled(), false);

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

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

if (doApply) {
SessionStore.get().setAutoplayEnabled(value);
SettingsStore.getInstance(getContext()).setAutoplayEnabled(value);
}
}
Expand Down

0 comments on commit fbde00f

Please sign in to comment.