refactor: WebContents::From returns pointer (#24605)

This commit is contained in:
Jeremy Rose 2020-07-16 16:16:05 -07:00 committed by GitHub
parent 14bbc07f1e
commit 45551f6bf2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 48 additions and 63 deletions

View file

@ -27,9 +27,7 @@ constexpr int kUserWantsNoMoreDialogs = -1;
} // namespace
ElectronJavaScriptDialogManager::ElectronJavaScriptDialogManager(
api::WebContents* api_web_contents)
: api_web_contents_(api_web_contents) {}
ElectronJavaScriptDialogManager::ElectronJavaScriptDialogManager() {}
ElectronJavaScriptDialogManager::~ElectronJavaScriptDialogManager() = default;
void ElectronJavaScriptDialogManager::RunJavaScriptDialog(
@ -115,9 +113,11 @@ void ElectronJavaScriptDialogManager::RunBeforeUnloadDialog(
content::RenderFrameHost* rfh,
bool is_reload,
DialogClosedCallback callback) {
bool default_prevented = api_web_contents_->Emit("will-prevent-unload");
std::move(callback).Run(default_prevented, base::string16());
return;
auto* api_web_contents = api::WebContents::From(web_contents);
if (api_web_contents) {
bool default_prevented = api_web_contents->Emit("will-prevent-unload");
std::move(callback).Run(default_prevented, base::string16());
}
}
void ElectronJavaScriptDialogManager::CancelDialogs(