Add ExtendedWebContentsObserver

This commit is contained in:
Cheng Zhao 2018-02-22 15:57:03 +09:00
parent a3124e8873
commit a25b49a127
4 changed files with 25 additions and 4 deletions

View file

@ -134,6 +134,7 @@ void BrowserWindow::Init(v8::Isolate* isolate,
web_contents_.Reset(isolate, web_contents.ToV8());
api_web_contents_ = web_contents.get();
Observe(web_contents->web_contents());
api_web_contents_->AddObserver(this);
// Keep a copy of the options for later use.
mate::Dictionary(isolate, web_contents->GetWrapper()).Set(
@ -175,6 +176,8 @@ BrowserWindow::~BrowserWindow() {
if (!window_->IsClosed())
window_->CloseContents(nullptr);
api_web_contents_->RemoveObserver(this);
// Destroy the native window in next tick because the native code might be
// iterating all windows.
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, window_.release());
@ -222,6 +225,9 @@ bool BrowserWindow::OnMessageReceived(const IPC::Message& message,
return handled;
}
void BrowserWindow::OnRendererResponsive() {
}
void BrowserWindow::WillCloseWindow(bool* prevent_default) {
*prevent_default = Emit("close");
}