Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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