Make OnMessageBoxCallback a method since it is accessing members

This commit is contained in:
Cheng Zhao 2018-03-06 11:35:53 +09:00
Родитель 7516b059fe
Коммит ca42325ade
2 изменённых файлов: 14 добавлений и 17 удалений

Просмотреть файл

@ -64,13 +64,14 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
checkbox_string = "Prevent this app from creating additional dialogs";
}
}
atom::ShowMessageBox(NativeWindow::FromWebContents(web_contents),
atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, -1,
0, atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
base::UTF16ToUTF8(message_text), "", checkbox_string,
false, gfx::ImageSkia(),
base::Bind(&OnMessageBoxCallback, callback, origin,
&origin_counts_));
atom::ShowMessageBox(
NativeWindow::FromWebContents(web_contents),
atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, -1, 0,
atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
base::UTF16ToUTF8(message_text), "", checkbox_string,
false, gfx::ImageSkia(),
base::Bind(&AtomJavaScriptDialogManager::OnMessageBoxCallback,
base::Unretained(this), callback, origin));
}
void AtomJavaScriptDialogManager::RunBeforeUnloadDialog(
@ -87,16 +88,13 @@ void AtomJavaScriptDialogManager::CancelDialogs(
bool reset_state) {
}
// static
void AtomJavaScriptDialogManager::OnMessageBoxCallback(
const DialogClosedCallback& callback,
const std::string& origin,
std::map<std::string, int>* origin_counts_,
int code,
bool checkbox_checked) {
if (checkbox_checked) {
(*origin_counts_)[origin] = kUserWantsNoMoreDialogs;
}
if (checkbox_checked)
origin_counts_[origin] = kUserWantsNoMoreDialogs;
callback.Run(code == 0, base::string16());
}

Просмотреть файл

@ -37,11 +37,10 @@ class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager {
bool reset_state) override;
private:
static void OnMessageBoxCallback(const DialogClosedCallback& callback,
const std::string& origin,
std::map<std::string, int>* origins_,
int code,
bool checkbox_checked);
void OnMessageBoxCallback(const DialogClosedCallback& callback,
const std::string& origin,
int code,
bool checkbox_checked);
api::WebContents* api_web_contents_;
std::map<std::string, int> origin_counts_;