Chromium Code Reviews| 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 assert mDialogController == null; | |
|
dominickn
2017/05/24 03:33:38
I don't think this assert is needed.
Timothy Loh
2017/05/24 04:59:33
OK, removed
| |
| 111 mDialogController = controller; | |
| 112 } | |
| 113 | |
| 114 /** | |
| 115 * Called from C++ by |nativeDelegatePtr| to destroy the dialog. | |
| 116 */ | |
| 117 @CalledByNative | |
| 118 private void destroyFromNative() { | |
|
dominickn
2017/05/24 03:33:38
dismissFromNative
Timothy Loh
2017/05/24 04:59:33
Done.
| |
| 119 assert mNativeDelegatePtr != 0; | |
| 120 mNativeDelegatePtr = 0; | |
| 121 mDialogController.destroyFromNative(this); | |
| 122 } | |
| 123 | |
| 106 /** | 124 /** |
| 107 * Called from C++ by |nativeDelegatePtr| to instantiate this class. | 125 * Called from C++ by |nativeDelegatePtr| to instantiate this class. |
| 108 * | 126 * |
| 109 * @param nativeDelegatePtr The native counterpart that this object owns . | 127 * @param nativeDelegatePtr The native counterpart that this object owns . |
| 110 * @param tab The tab to create the dialog for. | 128 * @param tab The tab to create the dialog for. |
| 111 * @param contentSettingsTypes The content settings types requested by this dialog. | 129 * @param contentSettingsTypes The content settings types requested by this dialog. |
| 112 * @param iconResourceId The id of the icon to display in the dialog. | 130 * @param iconResourceId The id of the icon to display in the dialog. |
| 113 * @param message The message to display in the dialog. | 131 * @param message The message to display in the dialog. |
| 114 * @param linkText The text to display in the link (if any). | 132 * @param linkText The text to display in the link (if any). |
| 115 * @param primaryTextButton The text to display on the primary button. | 133 * @param primaryTextButton The text to display on the primary button. |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 141 mSecondaryButtonText = secondaryButtonText; | 159 mSecondaryButtonText = secondaryButtonText; |
| 142 mShowPersistenceToggle = showPersistenceToggle; | 160 mShowPersistenceToggle = showPersistenceToggle; |
| 143 } | 161 } |
| 144 | 162 |
| 145 private native void nativeAccept(long nativePermissionDialogDelegate, boolea n persist); | 163 private native void nativeAccept(long nativePermissionDialogDelegate, boolea n persist); |
| 146 private native void nativeCancel(long nativePermissionDialogDelegate, boolea n persist); | 164 private native void nativeCancel(long nativePermissionDialogDelegate, boolea n persist); |
| 147 private native void nativeDismissed(long nativePermissionDialogDelegate); | 165 private native void nativeDismissed(long nativePermissionDialogDelegate); |
| 148 private native void nativeLinkClicked(long nativePermissionDialogDelegate); | 166 private native void nativeLinkClicked(long nativePermissionDialogDelegate); |
| 149 private native void nativeDestroy(long nativePermissionDialogDelegate); | 167 private native void nativeDestroy(long nativePermissionDialogDelegate); |
| 150 } | 168 } |
| OLD | NEW |