Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set default_id and cancel_id correctly on confirm dialogs (backport: 5-0-x) #17578

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions atom/browser/atom_javascript_dialog_manager.cc
Expand Up @@ -52,9 +52,16 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
return;
}

// No default button
int default_id = -1;
int cancel_id = 0;

std::vector<std::string> buttons = {"OK"};
if (dialog_type == JavaScriptDialogType::JAVASCRIPT_DIALOG_TYPE_CONFIRM) {
buttons.push_back("Cancel");
// First button is default, second button is cancel
default_id = 0;
cancel_id = 1;
}

origin_counts_[origin]++;
Expand All @@ -76,8 +83,8 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
}

atom::ShowMessageBox(
window, atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, -1, 0,
atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
window, atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, default_id,
cancel_id, atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
base::UTF16ToUTF8(message_text), "", checkbox, false, gfx::ImageSkia(),
base::Bind(&AtomJavaScriptDialogManager::OnMessageBoxCallback,
base::Unretained(this), base::Passed(std::move(callback)),
Expand Down