OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.permissions; | 5 package org.chromium.chrome.browser.permissions; |
6 | 6 |
7 import org.chromium.base.annotations.CalledByNative; | 7 import org.chromium.base.annotations.CalledByNative; |
8 import org.chromium.chrome.browser.ResourceId; | 8 import org.chromium.chrome.browser.ResourceId; |
9 import org.chromium.chrome.browser.tab.Tab; | 9 import org.chromium.chrome.browser.tab.Tab; |
10 | 10 |
11 /** | 11 /** |
12 * Delegate class for modal permission dialogs. Contains all of the data display
ed in a prompt, | 12 * Delegate class for modal permission dialogs. Contains all of the data display
ed in a prompt, |
13 * including the button strings, message text, link text, the icon, and whether
or not to display | 13 * including the button strings, message text, link text, the icon, and whether
or not to display |
14 * a persistence toggle. | 14 * a persistence toggle. |
15 * | 15 * |
16 * This class is also the interface to the native-side permissions code. When th
e user responds to | 16 * This class is also the interface to the native-side permissions code. When th
e user responds to |
17 * the permission dialog, the decision is conveyed across the JNI so that the na
tive code can | 17 * the permission dialog, the decision is conveyed across the JNI so that the na
tive code can |
18 * respond appropriately. | 18 * respond appropriately. |
19 */ | 19 */ |
20 public class PermissionDialogDelegate { | 20 public class PermissionDialogDelegate { |
21 /** The native-side counterpart of this class */ | 21 /** The native-side counterpart of this class */ |
22 private long mNativeDelegatePtr; | 22 private long mNativeDelegatePtr; |
23 | 23 |
| 24 /** The controller for this class */ |
| 25 private PermissionDialogController mDialogController; |
| 26 |
24 /** The tab for which to create the dialog. */ | 27 /** The tab for which to create the dialog. */ |
25 private Tab mTab; | 28 private Tab mTab; |
26 | 29 |
27 /** The icon to display in the dialog. */ | 30 /** The icon to display in the dialog. */ |
28 private int mDrawableId; | 31 private int mDrawableId; |
29 | 32 |
30 /** Text shown in the dialog. */ | 33 /** Text shown in the dialog. */ |
31 private String mMessageText; | 34 private String mMessageText; |
32 | 35 |
33 /** Text shown on the link, e.g. "Learn more". */ | 36 /** Text shown on the link, e.g. "Learn more". */ |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 assert mNativeDelegatePtr != 0; | 99 assert mNativeDelegatePtr != 0; |
97 nativeDestroy(mNativeDelegatePtr); | 100 nativeDestroy(mNativeDelegatePtr); |
98 mNativeDelegatePtr = 0; | 101 mNativeDelegatePtr = 0; |
99 } | 102 } |
100 | 103 |
101 public void onLinkClicked() { | 104 public void onLinkClicked() { |
102 assert mNativeDelegatePtr != 0; | 105 assert mNativeDelegatePtr != 0; |
103 nativeLinkClicked(mNativeDelegatePtr); | 106 nativeLinkClicked(mNativeDelegatePtr); |
104 } | 107 } |
105 | 108 |
| 109 public void setDialogController(PermissionDialogController controller) { |
| 110 mDialogController = controller; |
| 111 } |
| 112 |
| 113 /** |
| 114 * Called from C++ by |nativeDelegatePtr| to destroy the dialog. |
| 115 */ |
| 116 @CalledByNative |
| 117 private void dismissFromNative() { |
| 118 mDialogController.dismissFromNative(this); |
| 119 } |
| 120 |
106 /** | 121 /** |
107 * Called from C++ by |nativeDelegatePtr| to instantiate this class. | 122 * Called from C++ by |nativeDelegatePtr| to instantiate this class. |
108 * | 123 * |
109 * @param nativeDelegatePtr The native counterpart that this object owns
. | 124 * @param nativeDelegatePtr The native counterpart that this object owns
. |
110 * @param tab The tab to create the dialog for. | 125 * @param tab The tab to create the dialog for. |
111 * @param contentSettingsTypes The content settings types requested by this
dialog. | 126 * @param contentSettingsTypes The content settings types requested by this
dialog. |
112 * @param iconResourceId The id of the icon to display in the dialog. | 127 * @param iconResourceId The id of the icon to display in the dialog. |
113 * @param message The message to display in the dialog. | 128 * @param message The message to display in the dialog. |
114 * @param linkText The text to display in the link (if any). | 129 * @param linkText The text to display in the link (if any). |
115 * @param primaryTextButton The text to display on the primary button. | 130 * @param primaryTextButton The text to display on the primary button. |
(...skipping 25 matching lines...) Expand all Loading... |
141 mSecondaryButtonText = secondaryButtonText; | 156 mSecondaryButtonText = secondaryButtonText; |
142 mShowPersistenceToggle = showPersistenceToggle; | 157 mShowPersistenceToggle = showPersistenceToggle; |
143 } | 158 } |
144 | 159 |
145 private native void nativeAccept(long nativePermissionDialogDelegate, boolea
n persist); | 160 private native void nativeAccept(long nativePermissionDialogDelegate, boolea
n persist); |
146 private native void nativeCancel(long nativePermissionDialogDelegate, boolea
n persist); | 161 private native void nativeCancel(long nativePermissionDialogDelegate, boolea
n persist); |
147 private native void nativeDismissed(long nativePermissionDialogDelegate); | 162 private native void nativeDismissed(long nativePermissionDialogDelegate); |
148 private native void nativeLinkClicked(long nativePermissionDialogDelegate); | 163 private native void nativeLinkClicked(long nativePermissionDialogDelegate); |
149 private native void nativeDestroy(long nativePermissionDialogDelegate); | 164 private native void nativeDestroy(long nativePermissionDialogDelegate); |
150 } | 165 } |
OLD | NEW |