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

Handle the new autoplay permissions #2624

Merged
merged 1 commit into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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