diff --git a/android/java/org/chromium/chrome/browser/tabbed_mode/BraveTabbedRootUiCoordinator.java b/android/java/org/chromium/chrome/browser/tabbed_mode/BraveTabbedRootUiCoordinator.java index 71c0b30a9676..4f830eba2c30 100644 --- a/android/java/org/chromium/chrome/browser/tabbed_mode/BraveTabbedRootUiCoordinator.java +++ b/android/java/org/chromium/chrome/browser/tabbed_mode/BraveTabbedRootUiCoordinator.java @@ -6,9 +6,11 @@ package org.chromium.chrome.browser.tabbed_mode; import static org.chromium.chrome.browser.lifecycle.ActivityLifecycleDispatcher.ActivityState.RESUMED_WITH_NATIVE; +import static org.chromium.chrome.browser.util.PictureInPictureUtils.deviceSupportedPictureInPictureMode; +import static org.chromium.chrome.browser.util.PictureInPictureUtils.hasPictureInPicturePermissionEnabled; +import static org.chromium.chrome.browser.util.PictureInPictureUtils.launchPictureInPictureSettings; import android.app.PictureInPictureParams; -import android.content.pm.PackageManager; import android.os.Bundle; import android.view.Gravity; import android.view.View; @@ -211,11 +213,16 @@ public void onFullscreenClick() { @Override public void onPictureInPictureClick() { - if (!mActivity.getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)) { + if (!deviceSupportedPictureInPictureMode(mActivity)) { Toast.makeText(mActivity, R.string.picture_in_picture_not_supported, Toast.LENGTH_LONG).show(); return; } + if (!hasPictureInPicturePermissionEnabled(mActivity)) { + launchPictureInPictureSettings(mActivity); + return; + } + final Tab currentTab = mTabModelSelectorSupplier.get().getCurrentTab(); //noinspection ConstantValue if (TabUtils.isYouTubeVideo(currentTab) && mActivity instanceof BraveActivity braveActivity) {