Commit 5ecc8d42 authored by keishi@chromium.org's avatar keishi@chromium.org

ColorChooserWin::End should act like the dialog has closed

This is only a problem on Windows.

When the page closes itself while the color chooser dialog is open,
ColorChooserDialog::DidCloseDialog was called after the listener has been destroyed.

ColorChooserWin::End() will not actually close the color chooser dialog (because we can't) but act like it did so we can do the necessary cleanup.

BUG=279263
R=jschuh@chromium.org, pkasting@chromium.org

Review URL: https://codereview.chromium.org/23785003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220639 0039d316-1c4b-4281-b951-d872f2087c98
parent f357c041
......@@ -68,13 +68,13 @@ void ColorChooserDialog::ExecuteOpen(const ExecuteOpenParams& params) {
void ColorChooserDialog::DidCloseDialog(bool chose_color,
SkColor color,
RunState run_state) {
if (!listener_)
return;
EndRun(run_state);
CopyCustomColors(custom_colors_, g_custom_colors);
if (chose_color)
listener_->OnColorChosen(color);
listener_->OnColorChooserDialogClosed();
if (listener_) {
if (chose_color)
listener_->OnColorChosen(color);
listener_->OnColorChooserDialogClosed();
}
}
void ColorChooserDialog::CopyCustomColors(COLORREF* src, COLORREF* dst) {
......
......@@ -24,7 +24,7 @@ class ColorChooserWin : public content::ColorChooser,
~ColorChooserWin();
// content::ColorChooser overrides:
virtual void End() OVERRIDE {}
virtual void End() OVERRIDE;
virtual void SetSelectedColor(SkColor color) OVERRIDE {}
// views::ColorChooserListener overrides:
......@@ -66,6 +66,16 @@ ColorChooserWin::~ColorChooserWin() {
DCHECK(!color_chooser_dialog_);
}
void ColorChooserWin::End() {
// The ColorChooserDialog's listener is going away. Ideally we'd
// programmatically close the dialog at this point. Since that's impossible,
// we instead tell the dialog its listener is going away, so that the dialog
// doesn't try to communicate with a destroyed listener later. (We also tell
// the renderer the dialog is closed, since from the renderer's perspective
// it effectively is.)
OnColorChooserDialogClosed();
}
void ColorChooserWin::OnColorChosen(SkColor color) {
if (web_contents_)
web_contents_->DidChooseColorInColorChooser(color);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment