| Index: chrome/android/java/src/org/chromium/chrome/browser/infobar/PermissionInfoBar.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/PermissionInfoBar.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/PermissionInfoBar.java
|
| index 7db788b773f85b88b058b2cd35ab77d8ad4f9163..806968b72e7f6b003a1977180cafcfac3e723c3a 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/PermissionInfoBar.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/PermissionInfoBar.java
|
| @@ -12,25 +12,29 @@ import org.chromium.chrome.R;
|
| import org.chromium.chrome.browser.ResourceId;
|
| import org.chromium.chrome.browser.permissions.AndroidPermissionRequester;
|
| import org.chromium.chrome.browser.tab.Tab;
|
| -import org.chromium.ui.base.WindowAndroid;
|
|
|
| /**
|
| * An infobar used for prompting the user to grant a web API permission.
|
| - *
|
| */
|
| public class PermissionInfoBar
|
| extends ConfirmInfoBar implements AndroidPermissionRequester.RequestDelegate {
|
|
|
| + /** The tab which this infobar will be displayed upon. */
|
| + protected final Tab mTab;
|
| +
|
| + /** The content settings types corresponding to the permission requested in this infobar. */
|
| + protected int[] mContentSettingsTypes;
|
| +
|
| /** Whether or not to show a toggle for opting out of persisting the decision. */
|
| private boolean mShowPersistenceToggle;
|
|
|
| - private AndroidPermissionRequester mRequester;
|
| -
|
| - protected PermissionInfoBar(int iconDrawableId, Bitmap iconBitmap, String message,
|
| - String linkText, String primaryButtonText, String secondaryButtonText,
|
| - boolean showPersistenceToggle) {
|
| + protected PermissionInfoBar(Tab tab, int[] contentSettingsTypes, int iconDrawableId,
|
| + Bitmap iconBitmap, String message, String linkText, String primaryButtonText,
|
| + String secondaryButtonText, boolean showPersistenceToggle) {
|
| super(iconDrawableId, iconBitmap, message, linkText, primaryButtonText,
|
| secondaryButtonText);
|
| + mTab = tab;
|
| + mContentSettingsTypes = contentSettingsTypes;
|
| mShowPersistenceToggle = showPersistenceToggle;
|
| }
|
|
|
| @@ -48,13 +52,6 @@ public class PermissionInfoBar
|
| }
|
|
|
| @Override
|
| - public void onTabReparented(Tab tab) {
|
| - if (mRequester != null) {
|
| - mRequester.setWindowAndroid(tab.getWindowAndroid());
|
| - }
|
| - }
|
| -
|
| - @Override
|
| public void onAndroidPermissionAccepted() {
|
| onButtonClickedInternal(true);
|
| }
|
| @@ -64,29 +61,16 @@ public class PermissionInfoBar
|
| onCloseButtonClicked();
|
| }
|
|
|
| - /**
|
| - * Specifies the {@link ContentSettingsType}s that are controlled by this InfoBar.
|
| - *
|
| - * @param windowAndroid The WindowAndroid that will be used to check for the necessary
|
| - * permissions.
|
| - * @param contentSettings The list of {@link ContentSettingsType}s whose access is guarded
|
| - * by this InfoBar.
|
| - */
|
| - protected void setContentSettings(WindowAndroid windowAndroid, int[] contentSettings) {
|
| - assert windowAndroid != null
|
| - : "A WindowAndroid must be specified to request access to content settings";
|
| -
|
| - mRequester = new AndroidPermissionRequester(windowAndroid, this, contentSettings);
|
| - }
|
| -
|
| @Override
|
| public void onButtonClicked(final boolean isPrimaryButton) {
|
| - if (!isPrimaryButton || getContext() == null || mRequester.shouldSkipPermissionRequest()) {
|
| + // requestAndroidPermissions will call back into this class to finalize the action if it
|
| + // returns true.
|
| + if (!isPrimaryButton || getContext() == null
|
| + || !AndroidPermissionRequester.requestAndroidPermissions(
|
| + mTab, mContentSettingsTypes.clone(), this)) {
|
| onButtonClickedInternal(isPrimaryButton);
|
| return;
|
| }
|
| -
|
| - mRequester.requestAndroidPermissions();
|
| }
|
|
|
| private void onButtonClickedInternal(boolean isPrimaryButton) {
|
| @@ -108,29 +92,28 @@ public class PermissionInfoBar
|
|
|
| /**
|
| * Creates and begins the process for showing a PermissionInfoBar.
|
| - * @param windowAndroid The owning window for the infobar.
|
| - * @param enumeratedIconId ID corresponding to the icon that will be shown for the infobar.
|
| - * The ID must have been mapped using the ResourceMapper class before
|
| - * passing it to this function.
|
| - * @param iconBitmap Bitmap to use if there is no equivalent Java resource for
|
| - * enumeratedIconId.
|
| - * @param message Message to display to the user indicating what the infobar is for.
|
| - * @param linkText Link text to display in addition to the message.
|
| - * @param buttonOk String to display on the OK button.
|
| - * @param buttonCancel String to display on the Cancel button.
|
| - * @param contentSettings The list of ContentSettingTypes being requested by this infobar.
|
| + * @param tab The owning tab for the infobar.
|
| + * @param enumeratedIconId ID corresponding to the icon that will be shown for the infobar.
|
| + * The ID must have been mapped using the ResourceMapper class
|
| + * before passing it to this function.
|
| + * @param iconBitmap Bitmap to use if there is no equivalent Java resource for
|
| + * enumeratedIconId.
|
| + * @param message Message to tell the user the purpose of the infobar.
|
| + * @param linkText Link text to display in addition to the message.
|
| + * @param buttonOk String to display on the OK button.
|
| + * @param buttonCancel String to display on the Cancel button.
|
| + * @param contentSettingsTypes The list of ContentSettingTypes being requested by this infobar.
|
| * @param showPersistenceToggle Whether or not a toggle to opt-out of persisting a decision
|
| * should be displayed.
|
| */
|
| @CalledByNative
|
| - private static PermissionInfoBar create(WindowAndroid windowAndroid, int enumeratedIconId,
|
| - Bitmap iconBitmap, String message, String linkText, String buttonOk,
|
| - String buttonCancel, int[] contentSettings, boolean showPersistenceToggle) {
|
| + private static PermissionInfoBar create(Tab tab, int enumeratedIconId, Bitmap iconBitmap,
|
| + String message, String linkText, String buttonOk, String buttonCancel,
|
| + int[] contentSettingsTypes, boolean showPersistenceToggle) {
|
| int drawableId = ResourceId.mapToDrawableId(enumeratedIconId);
|
|
|
| - PermissionInfoBar infoBar = new PermissionInfoBar(drawableId, iconBitmap, message, linkText,
|
| - buttonOk, buttonCancel, showPersistenceToggle);
|
| - infoBar.setContentSettings(windowAndroid, contentSettings);
|
| + PermissionInfoBar infoBar = new PermissionInfoBar(tab, contentSettingsTypes, drawableId,
|
| + iconBitmap, message, linkText, buttonOk, buttonCancel, showPersistenceToggle);
|
|
|
| return infoBar;
|
| }
|
|
|