OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chrome.browser.infobar; |
| 6 |
| 7 import org.chromium.base.annotations.CalledByNative; |
| 8 import org.chromium.chrome.R; |
| 9 import org.chromium.chrome.browser.ResourceId; |
| 10 import org.chromium.ui.base.WindowAndroid; |
| 11 |
| 12 /** |
| 13 * An infobar for showing several permission requests which can be allowed or bl
ocked. |
| 14 */ |
| 15 public class GroupedPermissionInfoBar extends ConfirmInfoBar { |
| 16 private final int[] mPermissionIcons; |
| 17 private final String[] mPermissionText; |
| 18 |
| 19 GroupedPermissionInfoBar(String message, String buttonOk, String buttonCance
l, |
| 20 int[] permissionIcons, String[] permissionText) { |
| 21 super(0, null, message, null, buttonOk, buttonCancel); |
| 22 mPermissionIcons = permissionIcons; |
| 23 mPermissionText = permissionText; |
| 24 } |
| 25 |
| 26 @Override |
| 27 public void createContent(InfoBarLayout layout) { |
| 28 super.createContent(layout); |
| 29 InfoBarControlLayout control = layout.addControlLayout(); |
| 30 |
| 31 for (int i = 0; i < mPermissionIcons.length; i++) { |
| 32 control.addIcon(ResourceId.mapToDrawableId(mPermissionIcons[i]), mPe
rmissionText[i], |
| 33 null, R.color.light_normal_color); |
| 34 } |
| 35 } |
| 36 |
| 37 /** |
| 38 * Create an infobar for a given set of permission requests. |
| 39 * |
| 40 * @param message Message to display at the top of the infobar. |
| 41 * @param buttonOk String to display on the 'Allow' button. |
| 42 * @param buttonCancel String to display on the 'Block' button. |
| 43 * @param permissionIcons Enumerated ID (from ResourceMapper) of an icon to
display next to each |
| 44 * permission. |
| 45 * @param permissionText String to display for each permission request. |
| 46 * @param windowAndroid The window which owns the infobar. |
| 47 * @param contentSettings The list of ContentSettingsTypes requested by the
infobar. |
| 48 */ |
| 49 @CalledByNative |
| 50 private static InfoBar create(String message, String buttonOk, String button
Cancel, |
| 51 int[] permissionIcons, String[] permissionText, WindowAndroid window
Android, |
| 52 int[] contentSettings) { |
| 53 GroupedPermissionInfoBar infobar = new GroupedPermissionInfoBar( |
| 54 message, buttonOk, buttonCancel, permissionIcons, permissionText
); |
| 55 infobar.setContentSettings(windowAndroid, contentSettings); |
| 56 return infobar; |
| 57 } |
| 58 } |
OLD | NEW |