mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 697087 - Multiple notifications content permission prompt. r=mfinkle
This commit is contained in:
parent
361d2bc716
commit
b5930981e8
@ -56,8 +56,17 @@ public class DoorHanger {
|
||||
mPopups = new ArrayList<DoorHangerPopup>();
|
||||
}
|
||||
|
||||
public DoorHangerPopup getPopup() {
|
||||
final DoorHangerPopup dhp = new DoorHangerPopup(mContext);
|
||||
public DoorHangerPopup getPopup(String value) {
|
||||
// Check for duplicate popups
|
||||
for (DoorHangerPopup dhp : mPopups) {
|
||||
if (dhp.getValue().equals(value)) {
|
||||
// Replace it
|
||||
dhp = new DoorHangerPopup(mContext, value);
|
||||
return dhp;
|
||||
}
|
||||
}
|
||||
// No known popup like that, make new one
|
||||
final DoorHangerPopup dhp = new DoorHangerPopup(mContext, value);
|
||||
mPopups.add(dhp);
|
||||
return dhp;
|
||||
}
|
||||
|
@ -57,11 +57,14 @@ public class DoorHangerPopup extends PopupWindow {
|
||||
private LayoutParams mLayoutParams;
|
||||
private View popupView;
|
||||
public int mTabId;
|
||||
// value used to identify the notification
|
||||
private String mValue;
|
||||
private final int POPUP_VERTICAL_SIZE = 100;
|
||||
|
||||
public DoorHangerPopup(Context aContext) {
|
||||
public DoorHangerPopup(Context aContext, String aValue) {
|
||||
super(aContext);
|
||||
mContext = aContext;
|
||||
mValue = aValue;
|
||||
|
||||
LayoutInflater inflater =
|
||||
(LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
@ -91,6 +94,10 @@ public class DoorHangerPopup extends PopupWindow {
|
||||
mChoicesLayout.addView(mButton, mLayoutParams);
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
public void setText(String aText) {
|
||||
mTextView.setText(aText);
|
||||
}
|
||||
|
@ -779,6 +779,7 @@ abstract public class GeckoApp
|
||||
|
||||
void handleDoorHanger(JSONObject geckoObject, final int tabId) throws JSONException {
|
||||
final String msg = geckoObject.getString("message");
|
||||
final String value = geckoObject.getString("value");
|
||||
Log.i(LOG_NAME, "DoorHanger received for tab " + tabId
|
||||
+ ", msg:" + msg);
|
||||
final JSONArray buttons = geckoObject.getJSONArray("buttons");
|
||||
@ -786,7 +787,7 @@ abstract public class GeckoApp
|
||||
mMainHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
DoorHangerPopup dhp =
|
||||
mAppContext.mDoorHanger.getPopup();
|
||||
mAppContext.mDoorHanger.getPopup(value);
|
||||
dhp.setTab(tabId);
|
||||
for (int i = 0; i < buttons.length(); i++) {
|
||||
JSONObject jo;
|
||||
|
@ -584,7 +584,7 @@ var NativeWindow = {
|
||||
_callbacks: {},
|
||||
_callbacksId: 0,
|
||||
_promptId: 0,
|
||||
show: function(aMessage, aButtons, aTab) {
|
||||
show: function(aMessage, aValue, aButtons, aTab) {
|
||||
// use the current tab if none is provided
|
||||
let tabID = aTab ? aTab : BrowserApp.selectedTab.id;
|
||||
aButtons.forEach((function(aButton) {
|
||||
@ -600,7 +600,8 @@ var NativeWindow = {
|
||||
message: aMessage,
|
||||
severity: "PRIORITY_WARNING_MEDIUM",
|
||||
buttons: aButtons,
|
||||
tabID: tabID
|
||||
tabID: tabID,
|
||||
value: aValue
|
||||
}
|
||||
};
|
||||
sendMessageToJava(json);
|
||||
@ -1735,7 +1736,7 @@ var XPInstallObserver = {
|
||||
}
|
||||
}];
|
||||
}
|
||||
NativeWindow.doorhanger.show(messageString, buttons);
|
||||
NativeWindow.doorhanger.show(messageString, aTopic, buttons);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +160,9 @@ ContentPermissionPrompt.prototype = {
|
||||
let message = browserBundle.formatStringFromName(entityName + ".wantsTo",
|
||||
[request.uri.host], 1);
|
||||
|
||||
chromeWin.NativeWindow.doorhanger.show(message, buttons, tabID);
|
||||
chromeWin.NativeWindow.doorhanger.show(message,
|
||||
entityName + request.uri.host,
|
||||
buttons, tabID);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user