diff --git a/app/src/common/shared/org/mozilla/vrbrowser/browser/PermissionDelegate.java b/app/src/common/shared/org/mozilla/vrbrowser/browser/PermissionDelegate.java index 30f994abb..d0ee6f5a3 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/browser/PermissionDelegate.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/browser/PermissionDelegate.java @@ -20,6 +20,7 @@ import org.mozilla.vrbrowser.db.SitePermission; import org.mozilla.vrbrowser.ui.viewmodel.SitePermissionViewModel; import org.mozilla.vrbrowser.ui.widgets.WidgetManagerDelegate; +import org.mozilla.vrbrowser.ui.widgets.WindowWidget; import org.mozilla.vrbrowser.ui.widgets.dialogs.PermissionWidget; import org.mozilla.vrbrowser.utils.SystemUtils; import org.mozilla.vrbrowser.utils.UrlUtils; @@ -286,11 +287,20 @@ public void setPermissionAllowed(String uri, @SitePermission.Category int catego mSitePermissionModel.deleteSite(site); } else { if (site == null) { - site = new SitePermission(uri, false, SitePermission.SITE_PERMISSION_WEBXR); + site = new SitePermission(uri, false, category); mSitePermissions.add(site); } site.allowed = false; mSitePermissionModel.insertSite(site); } + + // Reload URIs with the same domain + for (WindowWidget window: mWidgetManager.getWindows().getCurrentWindows()) { + Session session = window.getSession(); + if (uri.equalsIgnoreCase(UrlUtils.getHost(session.getCurrentUri()))) { + session.reload(GeckoSession.LOAD_FLAGS_BYPASS_CACHE); + } + } + } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java index 60ebcc59b..18e5f1bd7 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/NavigationURLBar.java @@ -404,7 +404,6 @@ public void setClickable(boolean clickable) { mAudio.playSound(AudioEngine.Sound.CLICK); } - view.requestFocusFromTouch(); if (mDelegate != null) { mDelegate.onWebXRButtonClicked(); } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java index ec4ca9613..a61c3941c 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/NavigationBarWidget.java @@ -16,7 +16,6 @@ import android.util.Pair; import android.view.LayoutInflater; import android.view.View; -import android.webkit.URLUtil; import android.widget.EditText; import androidx.annotation.NonNull; @@ -37,7 +36,6 @@ import org.mozilla.vrbrowser.browser.SessionChangeListener; import org.mozilla.vrbrowser.browser.SettingsStore; import org.mozilla.vrbrowser.browser.engine.Session; -import org.mozilla.vrbrowser.browser.engine.SessionState; import org.mozilla.vrbrowser.browser.engine.SessionStore; import org.mozilla.vrbrowser.databinding.NavigationBarBinding; import org.mozilla.vrbrowser.db.SitePermission; @@ -918,7 +916,7 @@ public void onPopUpButtonClicked() { @Override public void onWebXRButtonClicked() { - showQuickPermission(mBinding.navigationBarNavigation.urlBar.getWebxRButton(), + toggleQuickPermission(mBinding.navigationBarNavigation.urlBar.getWebxRButton(), SitePermission.SITE_PERMISSION_WEBXR, mViewModel.getIsWebXRBlocked().getValue().get()); } @@ -1151,6 +1149,9 @@ private void showNotification(int notificationId, @NotificationPosition int posi public void hideAllNotifications() { NotificationManager.hideAll(); + if (mQuickPermissionWidget != null && mQuickPermissionWidget.isVisible()) { + mQuickPermissionWidget.hide(KEEP_WIDGET); + } } private void hideNotification(int notificationId) { @@ -1163,11 +1164,16 @@ private void hideNotification(int notificationId) { } }; - private void showQuickPermission(UIButton target, @SitePermission.Category int aCategory, boolean aBlocked) { + private void toggleQuickPermission(UIButton target, @SitePermission.Category int aCategory, boolean aBlocked) { if (mQuickPermissionWidget == null) { mQuickPermissionWidget = new QuickPermissionWidget(getContext()); } + if (mQuickPermissionWidget.isVisible() && mQuickPermissionWidget.getCategory() == aCategory) { + mQuickPermissionWidget.hide(KEEP_WIDGET); + return; + } + String uri = UrlUtils.getHost(mAttachedWindow.getSession().getCurrentUri()); mQuickPermissionWidget.setData(uri, aCategory, aBlocked); mQuickPermissionWidget.setDelegate(new QuickPermissionWidget.Delegate() { @@ -1175,14 +1181,12 @@ private void showQuickPermission(UIButton target, @SitePermission.Category int a public void onBlock() { SessionStore.get().setPermissionAllowed(uri, aCategory, false); mQuickPermissionWidget.onDismiss(); - mAttachedWindow.getSession().reload(); } @Override public void onAllow() { SessionStore.get().setPermissionAllowed(uri, aCategory, true); mQuickPermissionWidget.onDismiss(); - mAttachedWindow.getSession().reload(); } }); mQuickPermissionWidget.getPlacement().parentHandle = getHandle(); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/QuickPermissionWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/QuickPermissionWidget.java index 7f79d119d..977edd826 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/QuickPermissionWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/QuickPermissionWidget.java @@ -64,6 +64,10 @@ public void updateUI() { mBinding.executePendingBindings(); } + public @SitePermission.Category int getCategory() { + return mCategory; + } + @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig);