Skip to content

Commit 8655e90

Browse files
committed
onSavePassword dialog can leak when WebViewClassic is destroyed.
The AlertDialog creates in onSavePassword method leaks if WebViewClassic is destroyed when the dialog is shown. Change-Id: I81f20e1dd138467a6413766c0a081b389b334ae0
1 parent 7fecf5f commit 8655e90

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

core/java/android/webkit/WebViewClassic.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,10 @@ protected void measureContent() {
686686
// It's used to dismiss the dialog in destroy if not done before.
687687
private AlertDialog mListBoxDialog = null;
688688

689+
// Reference to the save password dialog so it can be dimissed in
690+
// destroy if not done before.
691+
private AlertDialog mSavePasswordDialog = null;
692+
689693
static final String LOGTAG = "webview";
690694

691695
private ZoomManager mZoomManager;
@@ -1811,7 +1815,7 @@ public void setOverScrollMode(int mode) {
18111815
neverRemember.getData().putString("password", password);
18121816
neverRemember.obj = resumeMsg;
18131817

1814-
new AlertDialog.Builder(mContext)
1818+
mSavePasswordDialog = new AlertDialog.Builder(mContext)
18151819
.setTitle(com.android.internal.R.string.save_password_label)
18161820
.setMessage(com.android.internal.R.string.save_password_message)
18171821
.setPositiveButton(com.android.internal.R.string.save_password_notnow,
@@ -1822,6 +1826,7 @@ public void onClick(DialogInterface dialog, int which) {
18221826
resumeMsg.sendToTarget();
18231827
mResumeMsg = null;
18241828
}
1829+
mSavePasswordDialog = null;
18251830
}
18261831
})
18271832
.setNeutralButton(com.android.internal.R.string.save_password_remember,
@@ -1832,6 +1837,7 @@ public void onClick(DialogInterface dialog, int which) {
18321837
remember.sendToTarget();
18331838
mResumeMsg = null;
18341839
}
1840+
mSavePasswordDialog = null;
18351841
}
18361842
})
18371843
.setNegativeButton(com.android.internal.R.string.save_password_never,
@@ -1842,6 +1848,7 @@ public void onClick(DialogInterface dialog, int which) {
18421848
neverRemember.sendToTarget();
18431849
mResumeMsg = null;
18441850
}
1851+
mSavePasswordDialog = null;
18451852
}
18461853
})
18471854
.setOnCancelListener(new OnCancelListener() {
@@ -1851,6 +1858,7 @@ public void onCancel(DialogInterface dialog) {
18511858
resumeMsg.sendToTarget();
18521859
mResumeMsg = null;
18531860
}
1861+
mSavePasswordDialog = null;
18541862
}
18551863
}).show();
18561864
// Return true so that WebViewCore will pause while the dialog is
@@ -2090,6 +2098,10 @@ private void destroyJava() {
20902098
mListBoxDialog.dismiss();
20912099
mListBoxDialog = null;
20922100
}
2101+
if (mSavePasswordDialog != null) {
2102+
mSavePasswordDialog.dismiss();
2103+
mSavePasswordDialog = null;
2104+
}
20932105
if (mWebViewCore != null) {
20942106
// Tell WebViewCore to destroy itself
20952107
synchronized (this) {

0 commit comments

Comments
 (0)